Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: pde toolbox
Posted:
Apr 22, 2013 6:13 PM


Alan_Weiss <aweiss@mathworks.com> wrote in message <kj1cvc$fop$1@newscl01ah.mathworks.com>... > On 3/25/2013 2:41 PM, Sashankh Rao wrote: > > "Sashankh Rao" wrote in message > > <kiq3me$m50$1@newscl01ah.mathworks.com>... > >> "Bill Greene" wrote in message > >> <ki2os3$gna$1@newscl01ah.mathworks.com>... > >> > "Sashankh Rao" wrote in message > >> <ki291f$56f$1@newscl01ah.mathworks.com>... > >> > > > I then mesh it: [p,e,t] = initmesh(g); > >> > > Then I create my boundary matrix using [Q,G,H,R] = pdebound(p2,e2); > >> > > I then assemble other matrices using [K,M,F] = assema(p,t,c,a,f); > >> > > Finally I solve the problem using u = assempde(K,M,F,Q,G,H,R); > >> > > > Ah, I see that the documentation page I pointed you to doesn't > >> > show you what to do with the pdebound function once you've created > >> it > >> > sorry. > >> > > That function is actually called by the PDE Toolbox routines > >> not by you. > >> > If you don't want to do anything fancy, but simply want a solution, > >> do this: > >> > > b=@pdebound; % the "pdebound" function can have any name > >> > % also define p,e,t,c,a,f > >> > u=assempde(b,p,e,t,c,a,f); > >> > > Regards, > >> > > Bill > >> > >  > >> > > As per the link below the size of the Q matrix in the boundary > >> file is (N^2 ne) which for a onedimensional system is (1 ne), where > >> ne is the number of edges in the mesh. > > > > > >> http://www.mathworks.com/help/pde/ug/boundaryconditionsforscalarpde.html > >> > > > > However the size for the K and M matrices is (Np Np) where Np > >> is the number of nodes in the matrix. > >> > > > > So I see that the K matrix and Q matrix are not of the same > >> dimensions and hence the error. I am not able to figure out how to > >> fix this problem. Any help will be appreciated very much. > >> > > > > Thank you. > >> > > > > "Bill Greene" wrote in message > >> <khfgev$sgb$1@newscl01ah.mathworks.com>... > >> > > > Hi, > >> > > > > > > "Sashankh Rao" wrote in message > >> <khdu9o$j3c$1@newscl01ah.mathworks.com>... > >> > > > > Using the Matlab pde toolbox I obtain a solution to the > >> Poisson equation for a given geometry using dirichlet boundary > >> conditions. First, I want to determine the gradient at all the > >> boundary nodes. Is this possible using the toolbox? Second, I want to > >> use these gradient values as an input boundary condition for the same > >> boundary to solve a different equation (same geometry). Is this > >> possible to do using the toolbox? Thanks. > >> > > > > > > Yes, this is definitely possible. I'll try to point you > >> in the right direction. > >> > > > > > > The function pdegrad can be used to calculate the > >> gradient of the solution at the > >> > > > element centroids. > >> > > > > >> http://www.mathworks.com/help/pde/ug/pdegrad.html?searchHighlight=pdegrad > >> > > > Then the function pdeprtni can be used to interpolate these > >> centroid values back > >> > > > to the nodes. > >> > > > http://www.mathworks.com/help/pde/ug/pdeprtni.html > >> > > > > > > Using these gradient values in the boundary conditions > >> will require you to write your > >> > > > own boundary condition function, referred to as a "boundary > >> file" in the PDE > >> > > > Toolbox documentation. > >> > > > http://www.mathworks.com/help/pde/ug/pdebound.html > >> > > > > > > This documentation page has some examples of how to write > >> such a function. > >> > > > > >> http://www.mathworks.com/help/pde/ug/boundaryconditionsforscalarpde.html > >> > > > > > > Bill > >> > >> Hi Bill, > >> > >> I have another question related to the above thread. > >> I am trying to impose the Neumann condition at nodes on the boundary. > >> To do this I need to pass additional information to pdebound as shown > >> below. > >> > >> function [qmatrix,gmatrix,hmatrix,rmatrix] = > >> pdebound2(p,e,u,time,u2bn,loc) > >> > >> where u2bn and loc are the additional data. However, I get the > >> following error in trying to do so: > >> > >> Input argument "u2bn" is undefined. > >> Error in ==> pdebound2 at 13 > >> > >> Looks like pdebound will not accept additional data. I am using > >> b = @pdebound; > >> > >> to assemble my boundary matrix. > >> > >> Thanks for taking time to help me. Really appreciate it. > >> > >> Sashankh > > > > Hi Bill, > > > > I think I figured this out. I declared my additional data as global > > variables. Thanks. > > > > Sashankh > > I'm glad that global variables work for you. But there are other ways of > passing parameters that are less rigid. See, for example, > http://www.mathworks.com/help/optim/ug/passingextraparameters.html#bskkr4z > > Alan Weiss > MATLAB mathematical toolbox documentation
Hi Alan,
I just saw your message. Thanks for the tip. I have another question for you and Bill.
I have got my program to run correctly. However, I seem to require a highly refined mesh to arrive at the desired accuracy. Now I am looking to optimize it. Is it possible to use quadratic finite elements (triangular) in the pde toolbox instead of the linear elements (triangular) which it uses by default?
Thanks for your help, Sashankh



