pdebound function form only Dirichlet boundary conditions
3 views (last 30 days)
Show older comments
Hello,
I wrote a boundary condidion file but somehow it doesnt work later on in the "assempde" command. Maybe I did a mistake mit the boundary condition matrixes. I only have Dirichlet boundary conditions, so I wrote zeros in the q and g matrixes for the Neumann conditions, but I am not sure if this is the right way. The geometry matrixes gd, sf and ns did I export form the pdetool GUI. I have a elliptic skalar pde. I hope someone can help me, because the description is not so clear at the help sites.
if true
% dl = decsg(dl, sf, ns)
[p,e,t] = inimesh(dl)
[qmatrix,gmatrix,hmatrix,rmatrix] = pdebound(p,e)
b = @pdebound
u = assempde(b,p,e,t,1,0,10)
end
And here my funktion file.
if true
function [qmatrix,gmatrix,hmatrix,rmatrix] = pdebound(p,e)
ne = size(e,2) % number of edges
qmatrix = zeros(1,ne);
gmatrix = qmatrix;
hmatrix = zeros(1,2*ne);
rmatrix = hmatrix;
regler = 6;
for k = 1:ne
x1 = p(1,e(1,k)); % x at first point in segment
x2 = p(1,e(2,k)); % x at second point in segment
xm = (x1 + x2)/2; % x at segment midpoint
y1 = p(2,e(1,k)); % y at first point in segment
y2 = p(2,e(2,k)); % y at second point in segment
ym = (y1 + y2)/2; % y at segment midpoint
switch e(5,k)
case {1,2,3,4} % rectangle boundaries
hmatrix(k) = 1;
hmatrix(k+ne) = 1;
rmatrix(k) = regler*(x1-y1);
rmatrix(k+ne) = regler*(x2-y2);
otherwise % same as case {5,6,7,8}, circle boundaries
qmatrix(k) = 0;
gmatrix(k) = 0;
end
end
end
I get always this erros. So I thought it is maybe the fault of my function file like I suggested above?
if true
Error using pdebound
Too many input arguments.
Error in pdeefxpd (line 10)
[q,g,h,r]=feval(bl,p,e,u,time);
Error in pdeexpd (line 40)
[q,g,h,r]=pdeefxpd(p,e,u,time,bl);
Error in assemb (line 95)
[q,g,h,r]=pdeexpd(p,e,bl);
Error in assempde (line 185)
[Q,G,H,R]=assemb(b,p,e);
end
0 Comments
Answers (1)
Alan Weiss
on 3 Aug 2015
I wonder if you simply need to change the signature of your function to
function [qmatrix,gmatrix,hmatrix,rmatrix] = pdebound(p,e,u,time)
Also, I wonder why you have the pdebound line here:
[p,e,t] = initmesh(dl); % you originally had inimesh, not initmesh
[qmatrix,gmatrix,hmatrix,rmatrix] = pdebound(p,e) % remove this line
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
0 Comments
See Also
Categories
Find more on Boundary Conditions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!