2
$\begingroup$

I have used TetGenTetrahedralize to generated a cubic mesh.

I want that the edge size of the triangle to be 0.2, how can realized this?

And What does the word "pq1.414a1" mean? inst1 = TetGenTetrahedralize[ inst, "pq1.414a1"]

Needs["TetGenLink`"];
Needs["ComputationalGeometry`"];

long = 15;
broad = 15;
height = 15;

inst = TetGenCreate[];

pts = {{0, 0, 0}, {long, 0, 0}, {long, broad, 0}, {0, broad, 0}, {0, 
    0, height}, {long, 0, height}, {long, broad, height}, {0, broad, 
    height}};
facets = {{{1, 2, 3, 4}}, {{5, 6, 7, 8}}, {{1, 5, 6, 2}}, {{2, 6, 7, 
     3}}, {{3, 7, 8, 4}}, {{4, 8, 5, 1}}};

TetGenSetPoints[inst, pts];
TetGenSetFacets[inst, facets];

inst1 = TetGenTetrahedralize[ inst, "pq1.414a1"]
elemPts = TetGenGetPoints[inst1];
elemFaces = TetGenGetFaces[inst1];

Graphics3D[GraphicsComplex[elemPts, Polygon[elemFaces]]]
$\endgroup$

1 Answer 1

1
$\begingroup$

If I understand you correctly, you would like to generate a mesh from a Cuboid. The meaning of the string is documented in V10 on the TetGenTetrahedralize ref page (also here in the details section.)

The string option a1 tells TetGen to generate a mesh with has tetrahedra that are no larger than a volume of 1. (Unfortunatly there is a bug in TetGen 1.4.3 that does not always respect that request.) So to get an edge length you'd have to convert that into what that would mean as a volume for a tetrahedron. As a very rough estimate we use

Volume[Tetrahedron[{{0, 0, 0}, {0, 0, 0.2}, {0, 0.2, 0}, {0.2, 0, 
    0}}]]
0.00133333

The with

TetGenSetPoints[inst, pts];
TetGenSetFacets[inst, facets];

inst1 = TetGenTetrahedralize[inst, "pq1.414a0.0013"]
elemPts = TetGenGetPoints[inst1];
elemFaces = TetGenGetFaces[inst1];

Graphics3D[GraphicsComplex[elemPts, Polygon[elemFaces]]]

Here is a different way to get to that result:

R1 = DiscretizeGraphics[Cuboid[{0, 0, 0}, {long, broad, height}]]
mr = TriangulateMesh[R1, MaxCellMeasure -> {"Length" -> 0.2}];

The we use

MeshCellCount[mr, 3]
Mean[PropertyValue[{mr, 1}, MeshCellMeasure]]
4898432
0.201541

So we have about 5M tets and the edge length is about 0.2

$\endgroup$
2
  • $\begingroup$ @ user21,The question is how can I get the mesh points coordinates and the element connectivities ... $\endgroup$
    – YuYong
    Jul 21, 2014 at 11:18
  • $\begingroup$ @YuYong, I think that's a followup question, perhaps it's better if you ask a new question. $\endgroup$
    – user21
    Jul 21, 2014 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.