Meshing a volume into tetrahedrons

5 visualizaciones (últimos 30 días)
Ansgar Neuenhofer
Ansgar Neuenhofer el 2 de Ag. de 2023
Respondida: Tushar el 22 de Ag. de 2023
I am trying to mesh a simple volume (into tetrahedrons. I obtained the 3D geometry by extruding a 2-D geometry. From what I understand I can only mesh a volume by first writing an stl-file, then importing it into MATLAB and then meshing the volume. But how do I export my 3-D geometry to an stl-file?
I somehow managed successfully to mesh the brick without the hole using the function Delaunay, triangulation and stl-write.
Below is some code.
Thank you so much for any help you could offer
Ansgar
%exterior boundary
x = [-4 4 4 -4];
y = [-4 -4 4 4];
%interior boundary
x1 = [0 -2 0 2];
y1 = [-2 0 2 0];
R1 = [2;4;x';y'];
R2 = [2;4;x1';y1'];
gm =[R1 R2];
sf = 'R1-R2';
ns = char('R1','R2')'
ns = 2×2 char array
'RR' '12'
g = decsg(gm,sf,ns)
g = 7×8
2 2 2 2 2 2 2 2 4 4 0 -2 0 2 -4 -4 4 -4 -2 0 2 0 -4 4 -4 4 -2 0 2 0 -4 -4 4 4 0 2 0 -2 4 -4 1 1 1 1 1 1 0 1 0 0 0 0 0 0 1 0
model = createpde;
g1=geometryFromEdges(model,g)
g1 =
AnalyticGeometry with properties: NumCells: 0 NumFaces: 1 NumEdges: 8 NumVertices: 8 Vertices: [8×2 double]
%meshing the area works fine
mesh=generateMesh(model,'GeometricOrder','linear','Hmax',1,'Hmin',.3)
mesh =
FEMesh with properties: Nodes: [2×88 double] Elements: [3×132 double] MaxElementSize: 1 MinElementSize: 0.3000 MeshGradation: 1.5000 GeometricOrder: 'linear'
pdeplot(model)
g2=extrude(g1,1)
g2 =
DiscreteGeometry with properties: NumCells: 1 NumFaces: 10 NumEdges: 24 NumVertices: 16 Vertices: [16×3 double]
figure
pdegplot(g2,'FaceLabels','on','facealpha',.2)
%***********************
%where do I go from here
%***********************
%stlwrite, delaunay ??????

Respuestas (1)

Tushar
Tushar el 22 de Ag. de 2023
Hi Ansgar,
I understand that you are looking for meshing the volume into tetrahedrons. But tetrahedron triangulation is not supported by 'stlwrite'. However, you can follow the steps below to get started:
  • Extract the vertices from the 3D model, using the Vertices property of 'DiscreteGeometry' object:
X_=g2.Vertices(:,1);
Y_=g2.Vertices(:,2);
  • Use the 'delaunayTriangulation' object to create a 2-D or 3-D 'Delaunay triangulation' from the set of vertices as follows:
DT=delaunayTriangulation([X_,Y_]);
  • Explore the 'ConnectivityList' Property of the object DT.
  • (optional step) Using the connectivity list as stated above, create a 'triangulation' object:
tri=triangulation(DT.ConnectivityList,X_,Y_);
  • Finally, using the 'stlwrite' function, output this geometry into an STL file:
stlwrite(tri,"output.stl");

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by