how to create a cylinder with minimal nodes and elements?

2 次查看(过去 30 天)
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 个评论
yonatan s
yonatan s 2017-6-13
well there isn't much to see, since setting up the geometry is the first step when using the pde toolbox.
KSSV
KSSV 2017-6-13
Why don't you post your code which generates your cylinder?

请先登录,再进行评论。

回答(1 个)

Ravi Kumar
Ravi Kumar 2017-6-13
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 个评论
Ravi Kumar
Ravi Kumar 2017-6-14
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Geometry and Mesh 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by