How can I customise the mesh generated with PDE toolbox?
Show older comments
Dear all,
I am solving the 3D heat equation using the PDE toolbox. I am simulating an homogeneous brick wall. My geometry is a prism with a rectangular base.
model = createpde;
[xg, yg, zg] = meshgrid(0:0.25:3,0:0.025:0.3,0:0.25:2);
xg = xg(:);
yg = yg(:);
zg = zg(:);
shp = alphaShape(xg,yg,zg,1);
[elements,nodes] = boundaryFacets(shp);
elements = elements';
nodes = nodes';
geometry = geometryFromMesh(model,nodes, elements);
Then I generate the mesh using generateMesh
mesh = generateMesh(model,'Hmax',0.1);
At this point I am aware that I can use the name value pair 'Hmax',Value to decrease the maximum size of the element and therefore obtain a finer mesh, but I would like to be able to refine the mesh "locally".
For example I would like to have a very fine mesh in the Y direction and a coarser mesh in the X and Z dimensions. Is there a way to do this?
Is there a way that allows me to control the number of elements in each direction? i.e. Can I set a grid os 100 elements in the Y direction and 10 elements in the X and Z dimensions?
Thanks!
4 Comments
Damian Sheehy
on 21 Jul 2016
Edited: Damian Sheehy
on 21 Jul 2016
The PDE Toolbox does not provide local mesh controls in the current release. However, if this feature was supported it would be difficult for a mesh generator to produce the mesh you are looking for with well-shaped elements. You can use the mesh that the alphaShape produces as follows, however it's a linear mesh:
model = createpde;
[xg, yg, zg] = meshgrid(0:0.25:3,0:0.09:0.3,0:0.25:2);
xg = xg(:);
yg = yg(:);
zg = zg(:);
shp = alphaShape(xg,yg,zg,1);
[elements,nodes] = alphaTriangulation(shp);
elements = elements';
nodes = nodes';
geometryFromMesh(model,nodes, elements);
Alejandro Arrizabalaga
on 29 Nov 2017
I have a similar problem. I have a 3D geometry which is a disk of radius R (in XY) and length L (in Z). I want to use a prism mesh that has fine 2D triangles on the 2D circular XY-section, but only a coarse rectangular mesh in the Z direction. In this way I divide the disk in layers of "thinner disks". How can I do this using the PDE toolbox? I know I could generate this geometry from COMSOL, but unfortunately I do not have access to it. It would be very nice if Matlab implements this as an option.
Paul Safier
on 18 Mar 2020
Have there been any Matlab version updates that would make it possible to select Hmax different for the x, y and z directions of a 3D mesh?
ADSW121365
on 12 Jun 2020
Best approach would probably be to use CAD and an external mesh generator (e.g GMSH, Tetgen for some free examples), plus geometryfrommesh. GMSH is my preference and supports tonnes of methods for mesh customisation and includes optimisation libraries to ensure there are no/few ill-formed tets in the mesh.
Answers (0)
Categories
Find more on Heat Transfer 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!