ToBoundaryMesh
ToBoundaryMesh[r]
generates a boundary ElementMesh object from the boundary of a region r.
ToBoundaryMesh[r,{{x_{min},x_{max}},…}]
generates a boundary ElementMesh object from the boundary of a region r restricted to the bounding box .
ToBoundaryMesh[rules]
generates a boundary ElementMesh object from a set of rules specifying coordinates and boundary elements.
ToBoundaryMesh[emesh]
generates a new boundary ElementMesh object from an existing ElementMesh, MeshRegion, or BoundaryMeshRegion.
Details and Options
 ToBoundaryMesh[r] generates a boundary ElementMesh object that approximates the boundary of the possibly symbolic region r. In a boundary ElementMesh, the "MeshElements" are set to Automatic and can be computed by using ToElementMesh.
 The specification for regions includes objects described by geometric regions and ImplicitRegion.
 The region r should be a constant region for which ConstantRegionQ gives True.
 In ToBoundaryMesh[rules], the following rules should be given in this order:

"Coordinates">{c_{1},c_{2},…} required to specify the coordinates to be c_{1}, c_{2}, … "BoundaryElements">{b_{1},…} required to specify the boundary elements in the mesh to be b_{1}, … "PointElements">{p_{1},…} optionally specify the point elements in the mesh to be p_{1}, …  For a 1D boundary element mesh, "BoundaryElements" are PointElement.
 For a 2D boundary element mesh, "BoundaryElements" are LineElement.
 For a 3D boundary element mesh, "BoundaryElements" can be TriangleElement and QuadElement.
 ToBoundaryMesh[emesh] may be used to modify an ElementMesh object emesh in various ways, including extracting the boundary and adding markers.
 ToBoundaryMesh has the following options:

AccuracyGoal Infinity digits of accuracy sought "BoundaryGroupingThreshold" Automatic control the grouping of boundaries by normal direction "BoundaryMarkerFunction" None function to compute markers for boundary elements "BoundaryMeshGenerator" Automatic function to generate boundary ElementMesh "CheckIntersections" Automatic control testing for intersecting boundaries "DeleteDuplicateCoordinates" True delete duplicate coordinates "IncludePoints" {} points to be included and considered part of the boundary "MaxBoundaryCellMeasure" Automatic control the size of boundary elements MaxCellMeasure Automatic control the size of mesh elements "MeshOrder" Automatic order of the element mesh "MessageHead" Automatic symbol for messages "PointMarkerFunction" None function to compute markers for point elements PrecisionGoal Automatic digits of precision sought "RegionHoles" Automatic specify region holes  With MaxCellMeasure>m, the measure of the cells created in the region dimension d will be at most m. The measure for the d1dimensional boundary representation cells will by default be chosen to be compatible with good quality ddimensional cells with measure m. Limits for specific dimensions may be specified by using MaxCellMeasure>{"Volume">v,"Area">a,"Length">l}.
 With AccuracyGoal>a and PrecisionGoal>p, an attempt will be made to keep the maximum distance between the region r or the discretized region dreg and any point in RegionSymmetricDifference[r,dreg] to less than , where is the length of the diagonal of the bounding box.
 ToBoundaryMesh[bmesh,opts] or ToBoundaryMesh[emesh,opts] may be used to modify a boundary ElementMesh object bmesh or extract the boundary from a full ElementMesh object emesh in various ways by specifying any one of the options to ToBoundaryMesh.
 If ToBoundaryMesh cannot generate an ElementMesh, then $Failed is returned.
 Invoking ToBoundaryMesh on an EmptyRegion will return an EmptyRegion.
 Options given to ToBoundaryMesh can be given to NDSolve by specifying "MeshOptions". »
 Setting options for ToBoundaryMesh from NDSolve and related functions is explained in NDSolve Finite Element Options.
Examples
open allclose allBasic Examples (4)
Create a boundary element mesh of a Disk:
Convert the boundary element mesh to a full mesh:
Create a boundary mesh of a union of a Disk and a Rectangle:
Create a boundary mesh by explicitly specifying the boundary elements:
Create a full element mesh from the boundary mesh and visualize the resulting element mesh:
Scope (15)
Generate a boundary mesh of a Disk:
Convert an ImplicitRegion with an explicit bounding box:
Convert a GraphicsComplex to a boundary element mesh:
Convert a TransformedRegion to a boundary element mesh:
Convert a 3D Ball to a boundary element mesh:
Convert a 3D GraphicsComplex to a boundary element mesh:
Convert a 3D TransformedRegion to a boundary element mesh:
Create a boundary element mesh from four coordinates and one boundary element:
For a set of points, ToBoundaryMesh will return the convex hull:
1D Point Element Boundary Meshes (2)
2D Line Element Boundary Meshes (1)
Boundary Markers (1)
Boundary markers are useful to specify NeumannValue on a region boundary and are explained further in the section Markers in the Element Mesh Generation.
Create a rectangle with boundary element markers and one additional node inside the domain:
Point Markers (1)
Point markers are useful to specify DirichletCondition on a region boundary and are explained further in the section Markers in the Element Mesh Generation.
Create a rectangle with a boundary element and point elements with markers and one additional node inside the domain:
Visualize the point elements in the boundary mesh with node numbers in blue and markers in red:
Options (27)
"AccuracyGoal" (1)
"BoundaryGroupingThreashold" (7)
ToBoundaryMesh automatically attributes markers to groups of contiguous boundary segments by comparing the boundary normal vectors.
Create a boundary mesh from the numerical region:
Inspect the boundary element markers present:
Visualize the contiguous boundaries:
Visualize the boundaries with element marker 2 or 4:
Inspect the point element markers present:
Use the element markers for specifying boundary conditions in NDSolveValue:
DirichletCondition extracts the point element markers, while NeumannValue and PeriodicBoundaryCondition extract boundary element markers.
Point element markers (red) are deduced from boundary markers (blue). If the node's connected boundary element markers are the same, then the node will have the same marker. On corners, the connected boundary markers typically differ, and an arbitrary choice of the available markers is made:
To control the behavior of which marker gets assigned to a corner node, a "PointMarkerFunction" can be specified. In the following case, all nodes on the left get a 2 as a marker, and on the right get a 4. The remaining markers are deduced from the boundary segment markers:
Switch off the automatic boundary grouping:
The only boundary element marker is the default of 0:
The automatic boundary grouping chooses boundary segments to be contiguous by computing the normals of the boundary segments and then computing the dot product of the neighboring segments. When the dot product is above a threshold , the neighboring segments are considered contiguous.
Create a coarse boundary mesh where boundary elements are grouped if the threshold :
Inspect the union of the boundary element markers:
Create a coarse boundary mesh where boundary elements are grouped if the threshold :
Inspect the union of the boundary element markers:
Construct a 1D boundary mesh with an internal boundary:
The boundary elements include the internal boundary at 1.0 (index 2):
In 1D, the boundary normal for an interior boundary is taken to be 0:
Inspect the union of boundary element markers:
Create a boundary element mesh in 3D from a discretized graphic:
Generate a list of colors for the many boundary groups:
Visualize only the boundaries with element marker 1:
Inspect the boundaries with a different element marker:
The automatic boundary grouping can be useful even for complicated geometries with a large number of groups. Import a gear as an element mesh:
Visualize the boundary mesh and the contiguous boundary groups:
"BoundaryMarkerFunction" (1)
Boundary markers are useful to specify NeumannValue on a region boundary and are explained further in the section Markers in the Element Mesh Generation.
Here is a function that computes integer markers for edges, depending on the coordinates of the edge elements:
Visualize the boundary mesh and the boundary markers:
Inspect the boundary elements:
If "PointElementMarkers" are also computed, those are accessible as the second argument in the function given to "BoundaryMarkerFunction".
"BoundaryMeshGenerator" (8)
The "Continuation" method uses a curve continuation method that can in many cases resolve corners, cusps, and sharp changes quite well:
The "RegionPlot" method is based on improving output from RegionPlot and can sometimes be faster:
The "RegionPlot" method has suboptions to improve the quality of the boundary mesh:
Pass a method option to the BoundaryDiscretizeRegion boundary mesh generator:
Pass a method option to the BoundaryDiscretizeRegion boundary mesh generator to finetune the discretization algorithm:
Visualize the boundary mesh as a mesh region:
The "OpenCascade" boundary mesh generator is well suited for 2D or 3D BooleanRegion expressions consisting of Graphics or Graphics3D primitives.
Use "OpenCascade" as a boundary mesh generator:
Generate colors for the boundary markers:
Visualize the boundary element mesh with highlighted boundary markers:
Options for the "OpenCascade" boundary mesh generator are:
More information about boundary mesh generation options can be found in the section on surface meshes in the OpenCascadeLink tutorial.
Use the "OpenCascade" boundary mesh generator for a union of a Disk and a Rectangle:
The "OpenCascade" boundary mesh generator cannot distinguish between internal boundaries and region holes:
When the full mesh is generated, the entire region will mesh meshed:
Manually specify a region hole by setting "RegionHoles":
The full mesh now respects the region hole and the material boundary:
For complicated geometries, one can use the default boundary mesh generator, since in that case no internal boundaries are generated:
You can now extract the region holes of that boundary mesh:
The found region holes can be used in conjunction with the "OpenCascade" boundary mesh generator:
In case internal boundaries are present, specifying boundary conditions, like DirichletCondition or NeumannValue, with the position predicate True will apply them at these internal boundaries; a more refined boundary predicate should be used to specify specific parts of the boundary.
Replace the internal boundary mesh generator with a custom mesh generator:
"DeleteDuplicateCoordinates" (2)
"IncludePoints" (1)
Specify some additional points to be included in the boundary mesh:
Include the points in the boundary mesh:
Visualize the boundary mesh with the included points:
These additional points are considered to be part of the boundary, but need not be on the actual boundary. Note that with "IncludePoints" you cannot add additional points on the boundary that has been specified by the implicit region. In other words, all "IncludePoints" instances must be strictly within the boundary region.
Create the full mesh from the numerical region:
Points added with "IncludePoints" will be addressable with DirichletCondition. Additionally, if the predicate in DirichletCondition is True, then the boundary condition will take effect at the include points.
"MaxBoundaryCellMeasure" (2)
"MaxCellMeasure" (2)
With MaxCellMeasure>m, a cell size is chosen and a boundary cell size is set to be appropriate for goodquality cells in the embedding dimension:
A specific length can be specified using MaxCellMeasure>{"Length">len}:
A helper function to compute the length of the boundary segments:
"MeshOrder" (1)
ToBoundaryMesh by default generates a firstorder boundary mesh:
Integrate over the boundary mesh and assess the accuracy of the integration:
To obtain a secondorder boundary mesh, the option "MeshOrder" may be used:
Integrate over the boundary mesh and assess the accuracy of the integration:
More information about the "MeshOrder" option can be found in this section of the Element Mesh Generation tutorial and this section of the Element Mesh Generation tutorial.
"PointMarkerFunction" (1)
Point markers are useful to specify DirichletCondition on a region boundary and are explained further in the section Markers in the Element Mesh Generation.
Here is a function that computes integer markers for point elements, depending on the coordinates of the edge nodes:
Applications (1)
Generate a boundary mesh of two nested halfannuli with . Each annulus represents a different subdomain. The first subdomain has an inner radius of and an outer radius of , and the second subdomain has an inner radius of and an outer radius of .
First, create a series of three halfdisks, then a union of the three subregions is generated and finally, to create the two annuli, the first halfdisk is taken as a hole.
Define the inner and outer radius of the first annulus:
Define the outer radius of the second annulus:
Create the halfdisks using Circle:
When a union of halfdisks is created, the left boundary will automatically be deleted from the union. So to bound the region again, a line segment is created and joined to the union of halfdisks. To cut a hole out of the first halfdisk, you can just bound the union from to and from to in the direction, leaving aside the first halfdisk.
Generate a union of the halfdisks and the lines:
Properties & Relations (1)
Pass options for ToBoundaryMesh to NDSolve to solve a stationary PDE:
Possible Issues (6)
If the input symbolic region is unbounded, a default bounding box from is assumed in each space direction:
By specifying an explicit bounding box, the default can be overridden:
Sometime boundary features may not be resolved well:
Setting the size of the boundary elements and increasing the sample points may help:
Alternatively, the "Continuation" boundary mesh generator may work better:
Specifying "IncludePoints" that lie on the boundary of the specified region can create boundary meshes that cannot be converted to full meshes:
The specified "IncludePoints" need to be inside the region:
The amount by which the "IncludePoints" need to be inside the region depends on accuracy of the curvature of the mesh.
The arguments to ToBoundaryMesh are specified as rules and need to be given in the correct order: "Coordinates", "BoundaryElements" and optionally "PointElements":
Specify the arguments in the correct order:
The automatic boundary marker assignment depends on a threshold that determines if two connected boundary elements are assigned the same boundary marker or not. Consider the following boundary mesh:
Visualize the mesh with boundary markers in blue and point node numbers in red:
Note that the edges between nodes 5 and 1 and 1 and 2 have both been attributed the boundary marker 1. The option "BoundaryGroupingThreshold" can be used to change the threshold:
A second alternative is to specify the boundary markers during input:
Text
Wolfram Research (2014), ToBoundaryMesh, Wolfram Language function, https://reference.wolfram.com/language/FEMDocumentation/ref/ToBoundaryMesh.html (updated 2024).
CMS
Wolfram Language. 2014. "ToBoundaryMesh." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/FEMDocumentation/ref/ToBoundaryMesh.html.
APA
Wolfram Language. (2014). ToBoundaryMesh. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/FEMDocumentation/ref/ToBoundaryMesh.html