TriangleSetRegions[expr,pts,index,attrs]
sets the regions in a Triangle expression.
TriangleSetRegions
TriangleSetRegions[expr,pts,index,attrs]
sets the regions in a Triangle expression.
Details and Options
- To use TriangleSetRegions, you first need to load it using Needs["TriangleLink`"].
- TriangleSetRegions allows you to set different regions in Triangle instances.
Examples
Basic Examples (1)
To use TriangleLink, it must first be loaded:
Needs["TriangleLink`"]Start by specifying the coordinates and displaying them:
pts = {{0., 0.}, {3., 0.}, {3., 3.}, {0., 3.}, {1., 1.}, {2., 1.}, {2., 2.}, {1., 2.}}Graphics[{Red, PointSize[0.02], Point[pts]}]Then create the input instance and set the points:
inst = TriangleCreate[]TriangleSetPoints[inst, pts]Next, the list of segments is created:
segments = {{1, 2}, {2, 3}, {3, 4}, {4, 1}, {5, 6}, {6, 7}, {7, 8}, {8, 5}}Graphics[{ Opacity[0.25], GraphicsComplex[pts, Line[segments]]}]Set the segments in the input instance of Triangle:
TriangleSetSegments[inst, segments]This sets up variables that specify a point within a material domain, as well as a region attribute and a region constraint:
materialDomains = {{0.5, 1.25}, {1.5, 1.25}};
materialDomainsRegionAttribute = {1., 2.};
materialDomainsRegionConstraint = {0.1, 0.01};The material variables are set in the Triangle instance:
TriangleSetRegions[inst, materialDomains, materialDomainsRegionAttribute, materialDomainsRegionConstraint];Retrieve the region values in a Triangle instance:
TriangleGetRegions[inst]This carries out the triangulation, returning a new Triangle instance:
outInst = TriangleTriangulate[ inst, "pqaA"]This extracts the points and elements from the triangulation:
coords = TriangleGetPoints[outInst];
meshElements = TriangleGetElements[outInst];With the following support function, you can visualize the triangles:
TriangleWireframe[i_] := Line[ Flatten[ i[[All, #]]& /@ {{1, 2}, {2, 3}, {3, 1}}, 1]]Graphics[GraphicsComplex[coords, TriangleWireframe[meshElements]]]All elements are now attributed:
Union[TriangleGetElementAttributes[outInst]]