how to create a cylinder with minimal nodes and elements?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
hello,
im trying to create a solid cylinder to use in the pde toolbox, with radius and height of size 1.
i tried it in several ways with functions like multicylinder,cylinder and meshgrid, but the amount of nodes and elements is too big, of about 40,000-50,000, which causes my model to run very slow.
edit - i added some of the codes i tried:
gm=multicylinder (1,1);
model.Geometry=gm;
generateMesh(model);
----
[th,r,h]=meshgrid(linspace(0,2*pi,30),[0,1],[0,1]);
[x,y,z] = pol2cart(th,r,h);
shp = alphaShape(x(:),y(:),z(:),2.5);
% plot(shp);
% applying the geometry to the model
[elements,nodes] = boundaryFacets(shp);
nodes = nodes';
elements = elements';
geometryFromMesh(model,nodes,elements);
% pdegplot(model,'FaceLabels','on','FaceAlpha',1);
% Generate the mesh
generateMesh(model);
---
[x,y,z]=cylinder;
shp = alphaShape(x(:),y(:),z(:));
% plot(shp);
% applying the geometry to the model
[elements,nodes] = boundaryFacets(shp);
nodes = nodes';
elements = elements';
geometryFromMesh(model,nodes,elements);
pdegplot(model,'FaceLabels','on','FaceAlpha',1);
% Generate the mesh
generateMesh(model);
is there a better way? thank you
3 comentarios
Respuestas (1)
Ravi Kumar
el 13 de Jun. de 2017
You can use 'Hmax' parameter to set the target maximum element size, as explained in this documentation page for generateMesh.
For example,
model = createpde;
gm=multicylinder (1,1);
model.Geometry=gm;
generateMesh(model,'Hmax',0.2);
gives a coarse mesh with less than 3000 elements. Note that the discretization error would increase as you coarsen the mesh, particularly for geometries with curved faces/edges.
2 comentarios
Ravi Kumar
el 14 de Jun. de 2017
I did not suggest you should use the mesh I provided. I gave an example and link to documentation, using which you can obtain desired mesh. You need to try and find the right set of parameters that you can specify in generateMesh function call.
Ver también
Categorías
Más información sobre Geometry and Mesh en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!