TetGenSetTetrahedraVolumes[expr,volumes]
constrains tetrahedra volumes for refinement.
TetGenSetTetrahedraVolumes
TetGenSetTetrahedraVolumes[expr,volumes]
constrains tetrahedra volumes for refinement.
Details and Options
- To use TetGenSetTetrahedraVolumes, you first need to load it using Needs["TetGenLink`"].
- TetGenSetTetrahedraVolumes constrains the tetrahedra volume in a refinement of a TetGen instance.
Examples
Basic Examples (1)
To use TetGenLink, it must first be loaded:
Needs["TetGenLink`"]You start by specifying the coordinates and displaying them:
pts = {{0., 0., 0.}, {1., 0., 0.}, {1., 1., 0.}, {0., 1., 0.}, {0., 0., 1.}, {1., 0., 1.}, {1., 1., 1.}, {0., 1., 1.}};Graphics3D[{Red, PointSize[0.02], Point[pts]}]Then you create the input instance and set the points:
inInst = TetGenCreate[]TetGenSetPoints[inInst, pts]Next, the list of facets is created:
facets = {{{1, 2, 3, 4}}, {{5, 6, 7, 8}}, {{1, 2, 6, 5}}, {{2, 3, 7, 6}}, {{3, 4, 8, 7}}, {{4, 1, 5, 8}}};Graphics3D[{ Opacity[0.25], GraphicsComplex[pts, Polygon /@ facets[[All, 1]]]}]Set the facets in the input instance of TetGen:
TetGenSetFacets[inInst, facets]Tetrahedralize the input with an area constraint:
outInst = TetGenTetrahedralize[inInst, "pqa0.01"]To extract the faces and visualize them, you use TetGenGetFaces:
pts = TetGenGetPoints[outInst];
faces = TetGenGetFaces[outInst];Graphics3D[{Opacity[0.75], GraphicsComplex[pts, Polygon[ faces]]}, Boxed -> False]To compute the volume of each of the tetrahedra of the object, you write a support function first:
TetrahedraVolume = Compile[{{coords, _Real, 2}, {elements, _Integer, 1}},
Block[{p},
p = coords[[elements]];
1 / 6 * Abs[Det[p[[ {1, 2, 3}]] - p[[{2, 3, 4}]]]]
]
, RuntimeAttributes -> {Listable}, RuntimeOptions -> "Speed"
];The volume of each tetrahedron can then be computed in the following manner:
coords = TetGenGetPoints[outInst];
meshElements = TetGenGetElements[outInst];
Short[vol = TetrahedraVolume[coords, meshElements]]The total volume can then be computed:
Total[vol]To refine some tetrahedra, choose a selection of coordinates. For example, all coordinates where the
component is larger than 0.7:
selection = Flatten[Position[coords, _ ? (#[[1]] ≥ 0.7&), {1}, Heads -> False]]The refinement elements are then found:
refine = Flatten[Position[meshElements, _ ? (MemberQ[#, Alternatives@@selection]&), {1}, Heads -> False]]The tetrahedra that should keep their volume during refinement are the complement of all tetrahedra and the tetrahedra selected for refinement:
fixed = Complement[Range[Length[meshElements]], refine];Each tetrahedron that is to be refined gets a new volume assigned. Those tetrahedra that should remain unchanged are assigned a
:
vol[[refine]] = vol[[refine]] / 8;
vol[[fixed]] = -1.;Set a TetGen instance with the new tetrahedra volumes:
TetGenSetTetrahedraVolumes[outInst, vol]By specifying the string "r", the TetGen instance is refined. The string "a" implies that volume constraints are to be fulfilled:
outInst2 = TetGenTetrahedralize[outInst, "ra"]To extract the refined faces and visualize them, you use TetGenGetFaces:
pts2 = TetGenGetPoints[outInst2];
faces2 = TetGenGetFaces[outInst2];Graphics3D[{Opacity[0.75], GraphicsComplex[pts2, Polygon[ faces2]]}, Boxed -> False]Tech Notes
Related Guides
Text
Wolfram Research (2012), TetGenSetTetrahedraVolumes, Wolfram Language function, https://reference.wolfram.com/language/TetGenLink/ref/TetGenSetTetrahedraVolumes.html.
CMS
Wolfram Language. 2012. "TetGenSetTetrahedraVolumes." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/TetGenLink/ref/TetGenSetTetrahedraVolumes.html.
APA
Wolfram Language. (2012). TetGenSetTetrahedraVolumes. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/TetGenLink/ref/TetGenSetTetrahedraVolumes.html
BibTeX
@misc{reference.wolfram_2026_tetgensettetrahedravolumes, author="Wolfram Research", title="{TetGenSetTetrahedraVolumes}", year="2012", howpublished="\url{https://reference.wolfram.com/language/TetGenLink/ref/TetGenSetTetrahedraVolumes.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_tetgensettetrahedravolumes, organization={Wolfram Research}, title={TetGenSetTetrahedraVolumes}, year={2012}, url={https://reference.wolfram.com/language/TetGenLink/ref/TetGenSetTetrahedraVolumes.html}, note=[Accessed: 15-June-2026]}