How can I customise the mesh generated with PDE toolbox?

6 views (last 30 days)
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
Paul Safier
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
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.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!