Specifying diffusion coefficient, PDE toolbox
3 次查看(过去 30 天)
显示 更早的评论
I currently solve elliptic PDE with Matlab as follows
pdem = createpde(1);
c=1;
a=0;
f=1;
geometryFromEdges(pdem,@squareg);
[p,e,t]=initmesh(@squareg,'hmax',0.2);
assempde(pdem,p,e,t,c,a,f);
I would like to allow for a variable diffusioncoefficient 'c'. I noticed that if I pass a function instead of a constant as 'c', I am given two arguments, call them A and B, of size 2x177, 4x312. By trying out, I found that the output should have length 312, but I don't know what the output should represent for assempde to work properly. The entries of B are indices, not spatial coordinates. I guess these indices refer to spatial coordinates that are contained in A, but I still don't know what output exactly assempde wants.
I would just want to specify a function 'c' that takes an array of size Nx2 and returns either Nx1 or Nx2x2 arrays. Is this possible?
I am using MATLAB 2015a.
0 个评论
回答(1 个)
Alan Weiss
2016-4-13
Since you have R2015a, you will probably be happiest using the latest workflow. For a 2-D problem, the easiest way to write diffusion coefficients is probably the string form, though you can also use the functional form, too. For an example using both types of coefficients, see this example.
Also, instead of using initmesh, you should probably try using generateMesh, and forgoing the use of the [p,e,t] matrices.
Alan Weiss MATLAB mathematical toolbox documentation
2 个评论
Alan Weiss
2016-4-13
Sorry, I misspoke when I said "latest." Nevertheless, follow the links I gave (which are to R2015a documentation), and see if they make sense to you. Or use the built-in doc command to explore the relevant documentation for your MATLAB version.
Alan Weiss
MATLAB mathematical toolbox documentation
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geometry and Mesh 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!