NDSolve`FEM`
NDSolve`FEM`

ToBoundaryMesh

ToBoundaryMesh[r]

generates a boundary ElementMesh object from the boundary of a region r.

ToBoundaryMesh[r,{{xmin,xmax},}]

generates a boundary ElementMesh object from the boundary of a region r restricted to the bounding box [x_(min),x_(max)]x....

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"->{c1,c2,}required to specify the coordinates to be c1, c2,
    "BoundaryElements"->{b1,}required to specify the boundary elements in the mesh to be b1,
    "PointElements"->{p1,}optionally specify the point elements in the mesh to be p1,
  • 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:
  • AccuracyGoalInfinitydigits of accuracy sought
    "BoundaryGroupingThreshold"Automaticcontrol the grouping of boundaries by normal direction
    "BoundaryMarkerFunction" Nonefunction to compute markers for boundary elements
    "BoundaryMeshGenerator" Automaticfunction to generate boundary ElementMesh
    "CheckIntersections"Automaticcontrol testing for intersecting boundaries
    "DeleteDuplicateCoordinates" Truedelete duplicate coordinates
    "IncludePoints" {}points to be included and considered part of the boundary
    "MaxBoundaryCellMeasure" Automaticcontrol the size of boundary elements
    MaxCellMeasureAutomaticcontrol the size of mesh elements
    "MeshOrder" Automaticorder of the element mesh
    "MessageHead"Automaticsymbol for messages
    "PointMarkerFunction" Nonefunction to compute markers for point elements
    PrecisionGoalAutomaticdigits of precision sought
    "RegionHoles" Automaticspecify 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 d-1-dimensional boundary representation cells will by default be chosen to be compatible with good quality d-dimensional 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 all

Basic Examples  (4)

Load the package:

Create a boundary element mesh of a Disk:

Visualize the boundary mesh:

Convert the boundary element mesh to a full mesh:

Create a boundary mesh of a union of a Disk and a Rectangle:

Visualize the boundary mesh:

Create a boundary mesh by explicitly specifying the boundary elements:

Visualize the boundary mesh:

Create a full element mesh from the boundary mesh and visualize the resulting element mesh:

Get a discretized boundary representation for a cylinder:

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)

Create a point element boundary mesh:

Create a 1D boundary mesh from an implicit region:

2D Line Element Boundary Meshes  (1)

Create a line element boundary mesh with an additional node inside the domain:

2D Higher-Order Boundary Element Meshes  (1)

Create a second-order boundary element mesh:

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:

Create the boundary mesh:

Visualize the boundary mesh and the markers:

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:

Create the boundary mesh:

Visualize the point elements in the boundary mesh with node numbers in blue and markers in red:

Options  (27)

"AccuracyGoal"  (1)

Ensure that the discretized boundary representation is close to the boundary:

A helper function to compute the centroid of the boundary segments:

The largest deviation from the true disk is at the centers of the segments:

With a larger accuracy goal, the error is reduced by using more points:

"BoundaryGroupingThreashold"  (7)

ToBoundaryMesh automatically attributes markers to groups of contiguous boundary segments by comparing the boundary normal vectors.

Create a numerical region:

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:

Visualize the point markers:

Use the element markers for specifying boundary conditions in NDSolveValue:

DirichletCondition extracts the point element markers, while NeumannValue and PeriodicBoundaryCondition extract boundary element markers.

Visualize the solution:

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:

Specify a region:

Pass a method option to the BoundaryDiscretizeRegion boundary mesh generator to fine-tune 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.

Specify a region:

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:

Visualize the boundary mesh:

The "OpenCascade" boundary mesh generator cannot distinguish between internal boundaries and region holes:

Visualize the boundary mesh:

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:

Specify options for a custom mesh generator:

"DeleteDuplicateCoordinates"  (2)

Generally, it is not advisable to have meshes with duplicate coordinates, since the mesh generation process becomes unpredictable. By default, duplicate coordinates are deleted:

When duplicate coordinates are deleted, the incidents of the elements my be re-indexed:

"IncludePoints"  (1)

Create a numerical region:

Inspect the boundary mesh:

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)

With "MaxBoundaryCellMeasure"->m, a boundary cell size is chosen:

Specify a boundary cell size and a cell size:

"MaxCellMeasure"  (2)

With MaxCellMeasure->m, a cell size is chosen and a boundary cell size is set to be appropriate for good-quality 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:

This gives the maximum lengths of the segments:

Create a full mesh from the boundary mesh:

"MeshOrder"  (1)

ToBoundaryMesh by default generates a first-order boundary mesh:

Inspect the mesh order:

Integrate over the boundary mesh and assess the accuracy of the integration:

To obtain a second-order boundary mesh, the option "MeshOrder" may be used:

Inspect the mesh order:

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:

Inspect the boundary elements:

"RegionHoles"  (1)

Create a boundary mesh with an internal region:

Create a full mesh from the boundary mesh:

Create a boundary mesh with an internal region and a region hole specification:

Investigate the region hole in the boundary mesh:

Create a full mesh from the boundary mesh:

Applications  (1)

Generate a boundary mesh of two nested half-annuli 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 half-disks, then a union of the three subregions is generated and finally, to create the two annuli, the first half-disk 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 half-disks using Circle:

When a union of half-disks 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 half-disks. To cut a hole out of the first half-disk, you can just bound the union from to and from to in the direction, leaving aside the first half-disk.

Create two line segments:

Generate a union of the half-disks and the lines:

Generate a boundary mesh restricted to :

Visualize the boundary mesh wireframe:

Properties & Relations  (1)

Pass options for ToBoundaryMesh to NDSolve to solve a stationary PDE:

Visualize the mesh used for the computation:

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:

Wolfram Research (2014), ToBoundaryMesh, Wolfram Language function, https://reference.wolfram.com/language/FEMDocumentation/ref/ToBoundaryMesh.html (updated 2024).

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

BibTeX

@misc{reference.wolfram_2024_toboundarymesh, author="Wolfram Research", title="{ToBoundaryMesh}", year="2024", howpublished="\url{https://reference.wolfram.com/language/FEMDocumentation/ref/ToBoundaryMesh.html}", note=[Accessed: 21-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_toboundarymesh, organization={Wolfram Research}, title={ToBoundaryMesh}, year={2024}, url={https://reference.wolfram.com/language/FEMDocumentation/ref/ToBoundaryMesh.html}, note=[Accessed: 21-December-2024 ]}