ToElementMesh
ToElementMesh[r]
generates an ElementMesh object from a region r.
ToElementMesh[r,{{xmin,xmax},…}]
generates an ElementMesh object from a region r restricted to the bounding box .
ToElementMesh[rules]
generates an ElementMesh object from a set of rules specifying coordinates and elements.
ToElementMesh[emesh]
generates a new ElementMesh object from an existing ElementMesh, MeshRegion, or BoundaryMeshRegion.
Details and Options
- ToElementMesh[r] generates an ElementMesh object that approximates a possibly symbolic region r.
- The specification for regions r includes objects described by geometric regions and ImplicitRegion.
- The region r should be a constant region for which ConstantRegionQ gives True.
- To generate an approximation to the region r, ToElementMesh first calls ToBoundaryMesh.
- In ToElementMesh[rules], the following rules should be given in this order:
-
"Coordinates"->{c1,c2,…} required to specify the coordinates to be c1, c2, … "MeshElements"->{e1,…} required to specify the elements in the mesh to be e1, … "BoundaryElements"->{b1,…} optionally 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 element mesh, "MeshElements" are LineElement. "BoundaryElements" and "PointElements" are, if specified, PointElement.
- For a 2D element mesh, "MeshElements" can be TriangleElement and QuadElement. "BoundaryElements", if specified, are LineElement, and "PointElements" are PointElement.
- For a 3D element mesh, "MeshElements" can be TetrahedronElement or HexahedronElement. "BoundaryElements", if specified, are TriangleElement and QuadElement, and "PointElements" are PointElement.
- ToElementMesh has the same options as ToBoundaryMesh, with the following additions:
-
"CheckQuality" Automatic compute a quality assessment "ElementMeshGenerator" Automatic function to generate an ElementMesh object from a boundary ElementMesh object "ImproveBoundaryPosition" Automatic improve the position of the boundary nodes "MeshElementBlocks" 1 number of blocks of mesh elements "MeshElementConstraint" Automatic additional constraints for mesh elements "MeshElementType" Automatic element type used to mesh input "MeshOrder" Automatic order of the element mesh MeshQualityGoal Automatic specify a mesh element quality goal MeshRefinementFunction Automatic control element refinement in 2D and 3D "NodeReordering" Automatic reorder nodes to generate minimal bandwidth matrices "SteinerPoints" Automatic control the insertion of Steiner points "RegionMarker" None specify region markers - ToElementMesh[emesh,opts] may be used to modify an ElementMesh object emesh in various ways by specifying any of the options for ToElementMesh.
- If ToElementMesh cannot generate an ElementMesh, then $Failed is returned.
- Invoking ToElementMesh on an EmptyRegion will return an EmptyRegion.
- Options given to ToElementMesh can be given to NDSolve by specifying "MeshOptions". »
- Setting options for ToElementMesh from NDSolve and related functions is explained in NDSolve Finite Element Options.
Examples
open allclose allBasic Examples (4)Summary of the most common use cases

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-btfg05
Generate an element mesh for a disk:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-w7pxg

Visualize the element mesh wireframe:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-5jg3pt

Generate an element mesh for the union of a disk and a rectangle:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-2ou2vk


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-ji2kjl

Specify an unbounded region with a bounding box:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-2eppju


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-2ouu4a

Specify the elements of an element mesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-x5k0lv


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-e0b8zi

Scope (29)Survey of the scope of standard use cases
Generate a mesh in the region between two circles:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-m7p2t4

Generate a mesh in the region between two circles using a BooleanRegion:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-lwdm3i

Convert an ImplicitRegion with an explicit bounding box:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-2kh7pb

Convert an ImplicitRegion computed from a RegionDistance with an explicit bounding box:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-sm3dtq

Convert a GraphicsComplex to an element mesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-g4smlq

Convert a TransformedRegion to an element mesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-xtaym7

Convert a 3D Ball to an element mesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-1c5elf


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-g3jilb

Convert a 3D GraphicsComplex to an element mesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-4w1oa0

Create a mesh from a 3D ImplicitRegion:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-n4ihq3

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-nrhzsj


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-si39ck

Create a mesh from a 3D BooleanRegion:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-u9d32p


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-nax62y


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-jde8m9

Convert a 3D TransformedRegion to an element mesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-vggjx4

Create an element mesh from four coordinates and two elements:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-2j136o


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-s54ezt

For a set of points, ToElementMesh will return a Delaunay triangulation:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-tgvxme

1D Line Element Meshes (3)

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-w8k11y


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-nqrt8z

Create a 1D ElementMesh with region holes from an ImplicitRegion:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-7s4yuq


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-jb5xd3

Create an ElementMeshRegionProduct from a 1D ElementMesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-myc2sk

2D Triangle Element Meshes (2)
Create a triangle element mesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-qypolg


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-jj66em

Create an ElementMeshRegionProduct from a 2D ElementMesh and a 1D ElementMesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-xu6338

2D Quad Element Meshes (2)

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-hjamqt

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-2hxsp2


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-5lagaz


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-z21o4g

Visualize the node numbers in red and the element numbers in blue:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-6cqk5v

2D Mixed-Element Type Meshes (1)
2D Higher-Order Element Meshes (1)
Create a mixed-element mesh with quadratic elements:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-e3jncq

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-pderxe

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-krr4q8

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-ibezk2


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-qaee0c

3D Tetrahedron Element Meshes (1)
A linear tetrahedron element mesh with markers:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-hnrx9r
Visualizing the index of the coordinates at their respective positions:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-vf52b6


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-bjnnx9

Visualize the mesh with the elements' markers:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-fr0s8d

3D Hexahedron Element Meshes (1)
Create an element mesh consisting of hexahedra:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-u38ajg

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-14vq8h

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-ronku0


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-9fvicm

Images (2)
Region Markers (1)
Region marker are useful to specify multiple materials in a region and are explained further in the section Markers in the Element Mesh Generation.
Create a mixed-element mesh with region markers:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-mzunnb


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-5ktme9


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-xb9wla

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 markers:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-lutdgp

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-5whk9r

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-e92dz5

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-vvjlqb


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-q535wt


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-71i4k2


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-o6oxyq

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 point markers:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-e2m279

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-staraw

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-wzu9y7

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-z266rb


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-67hvnp

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-8zjkhf


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-4yyppa

Options (41)Common values & functionality for each option
"BoundaryMarkerFunction" (2)
Boundary markers are useful to specify NeumannValue on a region boundary and are explained further in the section Markers in the Element Mesh Generation.
Compute integer markers for edges depending on the coordinates of the edge elements:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-83pijl

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-gize4e


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-u9eiw5

Inspect the boundary elements:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-fdp0nh

If "PointElementMarkers" are also computed, those are accessible as the second argument in the function given to "BoundaryMarkerFunction".
Markers can be specified for quad mesh elements:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-2d98tv

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-6vfjsx


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-tbqtd0

"BoundaryMeshGenerator" (2)
The "Continuation" method uses a curve continuation method that can in many cases resolve corners, cusps, and sharp changes quite well:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-4n5a3t

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-vmcdyp

The "RegionPlot" method is based on improving output from RegionPlot and can sometimes be faster:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-pa1601

More information on the "BoundaryMeshGenerator" option can be found on the ToBoundaryMesh reference page.
The "OpenCascade" boundary mesh generator is well suited for 3D BooleanRegion expressions consisting of Graphics3D primitives.

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-qy0jgz
Use "OpenCascade" as a boundary mesh generator:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-zrcwtn

Generate colors for the boundary markers:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-5mvwlv

Visualize the element mesh with highlighted boundary markers:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-c41p8x

"ElementMeshGenerator" (1)
Replace the internal mesh generator with a custom mesh generator:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-btyilf

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-1zkrma

The numerical region given to the custom mesh generators will contain a "BoundaryMesh". If the interface to the external mesh generator does not need a boundary mesh representation because the mesh generator interface works with a symbolic representation the generation of the boundary mesh can be avoided by setting "BoundaryMeshGenerator"->None.
"ImproveBoundaryPosition" (1)
Approximation of an ImplicitRegion is generally not exact. The "ImproveBoundaryPosition" option helps to improve the position of boundary nodes:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-18d3lh


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-tra0wf
The sum of the squares of the boundary nodes is not necessarily all at value 1:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-3r6saz

Automatic improvement is the default in 2D, and the results are better:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-mkgz2b


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-z9r098

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-txjzfe

When the "ImproveBoundaryPosition" option is set to False, quadratic elements will not have their middle nodes on the boundary of a curved part of the region.
"IncludePoints" (3)

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-0kim8w

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-civoaz

Specify a circle of additional points:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-bgzudk
Create a mesh with the include points:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-o17pk9

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.
Adding include points to a quadrilateral mesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-by2k1o

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-qnyb4


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-70fa1s

"IncludePoints" is an option for ToBoundaryMesh and ToElementMesh that will pass the option on. This means, however, that when ToElementMesh is presented a boundary ElementMesh, it cannot fulfill the request:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-kgv0f


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-zisg7


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-9siw82

The point {0,0} has not been included. The solution to this is to either specify the "IncludePoints" during the call to ToBoundaryMesh or make use of the symbolic region when calling ToElementMesh.
Use "IncludePoints" during the call to ToBoundaryMesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-ei4qeb


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-mvgdz8


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-u2f5lc

The alternative is to use the symbolic region in the call to ToElementMesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-maycwv


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-klp34s

"MaxBoundaryCellMeasure" (2)
"MaxCellMeasure" (4)
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:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-kbjrf2

Find the maximum mesh element area:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-njdxry

Set a smaller max cell measure:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-8zr5iw

Find the maximum mesh element area:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-48x2y

The max cell measure targets linear elements. In the case of a higher-order mesh for a curved boundary, the actual cell measure may be higher.
A specific length can be specified using MaxCellMeasure->{"Length"->len}:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-twuk4t

If a specific length and area are specified using MaxCellMeasure->{"Length"->len,"Area"->area}, the more stringent requirement is satisfied:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-zdr2at

Find the maximum mesh element area:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-ugrvba

Set a maximum cell measure on the boundary:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-o3b5a6

"MeshElementBlocks" (1)
"MeshElementConstraint" (2)
For two-dimensional meshes based on TriangleElement, a minimum triangle angle can be specified via the "MeshElementConstraint" option:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-zo87dq


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-n449c2


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-hapmcn


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-dqru5l


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-jda7d


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-de94ii

The minimum angle specified must be smaller then 33 degrees. Theoretically, the algorithm is guaranteed to terminate for minimum angles smaller than 22.7 degrees, but in practice it often succeeds for minimum angles up to 33 degrees.
For three-dimensional TetrahedronElement meshes, a minimum ratio of the tetrahedral radius to edge length can be specified via the "MeshElementConstraint" option:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-q5mzk1


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-55au4p


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-0cx3lt


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-5va19b


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-iwnhyu


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-g30881

The radius-edge ratio must be larger than . Theoretically, the algorithm is guaranteed to terminate for a radius-edge ratio of 2, but in practice it often succeeds for radius-edge ratios down to
.
"MeshElementType" (1)
Mesh a region with quad mesh elements:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-kseak8


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-rhrohm

Mesh the same region with triangle elements:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-7dcfov


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-xsby2m

Quad elements are currently only generated for rectangular regions.
"MeshOrder" (1)
Create a second-order element mesh for a region:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-1z7u6


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-dzuzy4

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

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-daqkd4

Mesh the same region with a first-order mesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-sh56ir


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-1im36u

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

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-038kj7

More information about the "MeshOrder" option can be found in this section of the Element Mesh Generation tutorial or in this section of the Element Mesh Generation tutorial.
"MeshQualityGoal" (1)
The quality measure is computed so that for regular mesh elements
, and for degenerate mesh elements
:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-8vlu3c


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-dri70u

Triangulate with more regular triangles:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-s2ivoy

"MeshRefinementFunction" (9)
Create a function that returns True if a specific 2D triangle element needs to be refined:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-e08tn1
Create a full mesh of the boundary mesh with the refinement function:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-qa56b4


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-eke55w

Compare to a mesh generated without refinement:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-vrk2el

Create a compiled function that returns True if a specific 2D triangle element needs to be refined:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-cgnoqh
Create a mesh of a disk with the refinement function:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-fq9z0m


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-8nj5ef

Create a gradual refinement toward the center:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-u1l68g

Create a gradual refinement toward the boundary:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-9c5zll

Create a refinement in a subregion:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-jmcojf

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-dq7x5t

Visualize the mesh with the refinement contour:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-hh3voj

Use an image as a refinement function:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-ldyclj
Create a distance transform of that image:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-zg6nbv
Visualize the distance transform of the image:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-rtscsz

Create an interpolation function from the image distance transform:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-h1nu93
Create a compiled refinement function calling the interpolation function:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-4q2un0
Create a triangle mesh with a given refinement:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-l6545v


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-kdgrm

Create a function that returns True if a specific 2D triangle element needs to be refined:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-btvq0j
Create a compiled function that returns True or False :

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-o3zpyx

Create a full mesh of the boundary mesh with the compiled refinement function:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-s48vg4


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-5zzb4d

Create a compiled function that returns True if a specific 3D tetrahedron element needs to be refined:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-qyfvp7

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-4ubngy

Create a full mesh of the boundary mesh with the refinement function:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-spqtnw


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-kmwfxk

In 1D use DiscretizeRegion to do the refinement:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-u5sm8b

"NodeReordering" (2)
Create an ElementMesh from a region:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-xg23b7

Visualize the incidences of the mesh elements:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-lyjmt7

Create a mesh from the same region with node reordering:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-7eiu9r

The pattern of the incidences is much more organized:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-m9jg0b

A function for the node reordering can be provided:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-g1h6ay


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-ckk2o8

"NodeReordering" is also known as matrix bandwidth reduction.
"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.
Compute integer markers for edges depending on the coordinates of the edge nodes:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-7aezk3
Create an element mesh with the point markers:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-btpy3b


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-ey7o77

Inspect the boundary elements:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-wf20dg

The point marker values of the mid-side nodes for second-order meshes are derived from the boundary element markers. Since none are given here, the values are arbitrary:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-g15l8b


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-kidlpi

If "BoundaryMarkerFunction" is also computed, middle nodes will have values derived from the boundary element markers:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-2gerbp

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-lwu1o1


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-wc04mc

"PointMarkers" (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.
The way point markers are set up in a mesh can be done in different ways. One possible option is to derive point markers from boundary markers.
Mesh the region and deduce the point markers from the boundary markers:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-26m44x


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-14j39u

Select from which surfaces the point markers should be constructed:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-6k1xon

Visualize the points with the selected point marker:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-1uadmv

Find the intersection such that only points connected to all surfaces are considered. Boundary element marker ID 7 is the large cylinder body surface:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-drffu8

Visualize the points with the selected point marker:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-m5oris

"RegionHoles" (4)
Create a boundary mesh with an internal region:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-rcympe

Create a full mesh from the boundary mesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-f1a5gk

Create a full mesh from the boundary mesh, with the interior specified as a region hole:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-23ivr8

Create an element mesh with a hole in the middle:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-lf9d5z

Mesh the region, including the hole:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-44w0ix

Mesh the region without the hole by explicitly giving a coordinate in the region that is a hole:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-i6vklo

Create and visualize a region with holes:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-itci3v

Generate a full mesh from the boundary mesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-pwv62k

Specify a region hole and a region marker:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-ip8l2k


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-1eqw2c


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-n6sdx9

Visualize the boundary mesh and a point inside the interior box:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-8a86fx

Create the full element mesh with a hole inside:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-0p0wyk

Visualize the full element mesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-o50s8u

"RegionMarker" (2)

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-gps8yl


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-8b8ltb

The boundary element containing {1/2,3/4} should use the marker 1, and the region containing {1/2,1/4} should use the marker 2:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-9ootmb


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-o7b22y

Additionally, a refinement parameter for the region with marker 1 is given to the markers:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-3mm9ao


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-2ro2qs


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-nl83t6

Create the full element mesh with subregions inside that follow different refinements:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-cl7io7

Visualize the full element mesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-qaqci1

"SteinerPoints" (1)
For 2D triangle meshes, the insertion of Steiner points can be controlled. In this case, the boundary respects the boundary size and does not further subdivide:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-zlz0f

In this case, the second-order mid-side nodes are still present:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-0wippp

Using a first-order mesh avoids mid-side nodes:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-qav2u0

Applications (2)Sample problems that can be solved with this function
Create an ElementMesh of a river from a GeoGraphics:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-jjm5bj

Generate an element mesh of two nested half-annuli with . Each annulus represents a different subdomain. The first subdomain has an inner radius of
and a outer radius of
, and the second subdomain has an inner radius of
and a 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 to represent an inner hole.
Define the inner and outer radius of the first annulus:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-etpgpj
Define the outer radius of the second annulus:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-eeho4r
Create the half-disks using Circle:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-l3fj4
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.

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-72kt1
Generate a union of the half-disks and the lines:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-blal2p
Assign an element marker for each annulus:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-bma7fa
Generate an element mesh with the defined subdomains using RegionMarker and restrict the mesh to :

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-cb7v5q

Visualize the element mesh wireframe:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-lcti1

Properties & Relations (5)Properties of the function, and connections to other functions
An ElementMesh can be part of an InterpolatingFunction returned by NDSolve:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-ehyiyq


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-xczble

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-522tz4

Pass an ElementMesh to NDSolve:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-l20khm

Pass an ElementMesh to NDEigensystem:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-gnxlyf

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

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-yqowvy

Inspect the mesh used to solve the equation:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-kjorkk

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-q17dk3


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-wo44ov

Pass options for ToElementMesh to NDSolve to solve a time-dependent PDE:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-qeclpa

Possible Issues (11)Common pitfalls and unexpected behavior
If the input symbolic region is unbounded, a default bounding box from is assumed in each space direction:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-s7i8l4


By specifying an explicit bounding box, the default can be overridden:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-s68jfd

Some features of the region may be too small to be represented:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-8zcpct

Specifying a smaller boundary size may help:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-faelg

An ImplicitRegion must not have unspecified symbolic parameters:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-z5hg5r



https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-w9qtph


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-iagqzd

If the bounding box intersects with the region specification, low-quality or wrong meshes may result:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-87i2n7


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-0vw83f


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-s4wkqx

Possibly enlarging the bounding box is an option:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-8fciod


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-zg3v08

The mesh elements in an ElementMesh need to be of the same order:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-bsbysc

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-7s7lv5

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-o2zskk

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-18zjo7


The element incidents must be given in counterclockwise order:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-9p5bli



https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-2np70h


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-k2gsyg

Mesh elements in an element mesh may not intersect:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-po5sq2



https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-02kmbn


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-vinig2

Also, combinations of clockwise ordering and self-intersection are detected:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-bgaliu



https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-mrwna7

A conversion of a MeshRegion to an ElementMesh may not always be done in a direct mesh conversion:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-xbbbpl


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-ogwvcj

The reason for this is that ToElementMesh needs to be able to respect mesh options given to it. It is not possible to deduce parameters that were used to generate a MeshRegion and check if ToElementMesh options are satisfied. It may be possible to do a direct conversion of the MeshRegion to an ElementMesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-r3slk0

For this specific case, it is possible to generate the ElementMesh directly by using ToGradedMesh and ElementMeshRegionProduct:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-y634m1


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-175y13

The arguments to ToElementMesh are specified as rules and need to be given in the correct order: "Coordinates", "MeshElements" and optionally "BoundaryElements" and "PointElements":

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-fhsa0t

Specify the arguments in the correct order:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-vswvb8

Some mesh generation algorithms for implicit regions are not entirely deterministic in that they return slightly different meshes for the same input:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-4817ju


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-xfvq75

Note that the number of elements can differ between the runs.
Neat Examples (3)Surprising or curious use cases
Convert the orbiter of the Space Shuttle to an ElementMesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-uz6lh3

To convert an image to an element mesh, first the image is converted to a distance function:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-yj81es

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-mnsz6i

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-or4rub

The image data is extracted and converted into an interpolation function:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-vcenyz
Convert the interpolation function to an element mesh:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-0bfvv4


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-r23qpk

The following extended example creates a Penrose triangle and is based on solving a Laplace equation. Specify parameters:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-9mskf

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-kfkg8b
Generates a list of vertices of the face of a Penrose Triangle:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-0uqsgw

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-uceenq

Create a function that returns the maximum spacing squared between vertices at the given position:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-j1hwj1
Create a function that returns the maximum spacing squared between vertices at the given position:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-jdfgmt
Create a function that gives the height values for various and
values:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-6zir0r

Create a function that interpolates along the edge of the Penrose triangle:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-o3le8g

Create a list of points between the specified points of the vertices:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-4cdzvd
Construct the bounding polygon for the Laplace equation. Vertices are spaced such that when the faces are brought together, all vertices on the edges properly overlap:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-ldtqg2
Create the mesh to solve the Laplace PDE on, without adding additional points to the boundary:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-k8xdup

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-mqt072


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-mn8njn


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-uiu3la

Assemble the full Penrose triangle out of six faces:

https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-z9u10s


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-2cd1nl


https://wolfram.com/xid/0cy39q6twgp82cng00zxgie-pj40lp

Wolfram Research (2014), ToElementMesh, Wolfram Language function, https://reference.wolfram.com/language/FEMDocumentation/ref/ToElementMesh.html (updated 2022).
Text
Wolfram Research (2014), ToElementMesh, Wolfram Language function, https://reference.wolfram.com/language/FEMDocumentation/ref/ToElementMesh.html (updated 2022).
Wolfram Research (2014), ToElementMesh, Wolfram Language function, https://reference.wolfram.com/language/FEMDocumentation/ref/ToElementMesh.html (updated 2022).
CMS
Wolfram Language. 2014. "ToElementMesh." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/FEMDocumentation/ref/ToElementMesh.html.
Wolfram Language. 2014. "ToElementMesh." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/FEMDocumentation/ref/ToElementMesh.html.
APA
Wolfram Language. (2014). ToElementMesh. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/FEMDocumentation/ref/ToElementMesh.html
Wolfram Language. (2014). ToElementMesh. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/FEMDocumentation/ref/ToElementMesh.html
BibTeX
@misc{reference.wolfram_2025_toelementmesh, author="Wolfram Research", title="{ToElementMesh}", year="2022", howpublished="\url{https://reference.wolfram.com/language/FEMDocumentation/ref/ToElementMesh.html}", note=[Accessed: 02-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_toelementmesh, organization={Wolfram Research}, title={ToElementMesh}, year={2022}, url={https://reference.wolfram.com/language/FEMDocumentation/ref/ToElementMesh.html}, note=[Accessed: 02-April-2025
]}