how to create a cylinder with minimal nodes and elements?

1 visualización (últimos 30 días)
yonatan s
yonatan s el 12 de Jun. de 2017
Comentada: Ravi Kumar el 14 de Jun. de 2017
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
yonatan s
yonatan s el 13 de Jun. de 2017
well there isn't much to see, since setting up the geometry is the first step when using the pde toolbox.
KSSV
KSSV el 13 de Jun. de 2017
Why don't you post your code which generates your cylinder?

Iniciar sesión para comentar.

Respuestas (1)

Ravi Kumar
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
yonatan s
yonatan s el 13 de Jun. de 2017
thank you, but this mesh is too coarse for me
Ravi Kumar
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.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by