how to create a cylinder with minimal nodes and elements?

1 view (last 30 days)
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 Comments
yonatan s
yonatan s on 13 Jun 2017
well there isn't much to see, since setting up the geometry is the first step when using the pde toolbox.
KSSV
KSSV on 13 Jun 2017
Why don't you post your code which generates your cylinder?

Sign in to comment.

Answers (1)

Ravi Kumar
Ravi Kumar on 13 Jun 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 Comments
Ravi Kumar
Ravi Kumar on 14 Jun 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.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!