ToGradedMesh
Details and Options
- A graded mesh is a nonuniform or anisotropic mesh where the spacing between coordinates varies exponentially.
- A graded mesh is used to capture steep gradients or discontinuities in partial differential equations or their boundaries.
- The following optional properties prop can be given:
-
"Alignment"adir "Uniform" use alignment direction adir "ElementCount"n Automatic use n elements "ElementMarker"m 0 use ElementMarker m "GradingRatio"r Automatic use grading ratio r "MaximalDistance"dmax Automatic choose coordinates so that the maximal distance between coordinates is dmax "MinimalDistance"dmin Automatic choose coordinates so that the minimum distance between coordinates is dmin - The following alignments adir can be given:
-
"Left" high coordinate concentration on the left "Right" high coordinate concentration on the right "BothEnds" high coordinate concentration at both ends "Central" high coordinate concentration in the center "Uniform" use uniform spacing between coordinates fun[interval,props] use the function fun for interval interval and properties props - ToGradedMesh accepts a 1D Line primitive and returns a graded 1D ElementMesh.
- The default minimal distance between the element end coordinates is computed as
, where
is the distance between the endpoints of the input Line element and
is the element count.
- ToGradedMesh has the following options:
-
"MeshOrder" Automatic order of the element mesh
Examples
open allclose allBasic Examples (3)Summary of the most common use cases

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-h51mgu
Create a uniform mesh for the interval :

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-7fot3


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-eaz4z

Create a graded mesh with a high coordinate concentration on the left:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-d2vssm


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-yl9cou

Convert the Line to a graded mesh with a "BothEnds" point distribution using default values:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-td2r


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-f4tgl8

Scope (26)Survey of the scope of standard use cases
Basic Usage (5)
Convert the Line from –1 to 1 to a graded mesh with a "Right" point distribution:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-w4ilg9


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-8dzrzu

Convert the Line from –1 to 1 to a graded mesh with a "Central" point distribution:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-1pfy13


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-xur85u

Convert the Line from –1 to 1 to a graded mesh with a "Left" point distribution:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-zqnyld


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-jcvfkp

Convert the Line from –1 to 1 to a graded mesh with a "Left" point distribution:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-ncc3c9


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-cgpiay

Create a graded mesh with two central alignments:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-vjdzq8


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-866vfk

Alignment (4)
Make a uniform 1D mesh on the unit interval:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-bfsq60


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-bzscjj


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-ymc5u


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-mhimt5

Convert the Line to a graded mesh with a "Central" point distribution, 10 elements and a minimal coordinate distance of :

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-0bw7m8


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-ufviqx

Compute the minimal distance between the coordinates:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-h94rgp

Convert the Line to a graded mesh with a "Central" point distribution using 20 elements:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-c49ilo

For the "Center" and "BothEnds" alignments, the mesh has a coordinate at the center if the number of elements is even:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-2osqqk


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-i3n4zq

No center coordinates for an odd number of elements:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-vrcuv3

Specify a function to give a mesh with Chebyshev node spacing:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-cvfhi
Create a graded mesh with a Chebyshev alignment:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-0v9nl3


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-f6e0gw

ElementCount (3)
Make a uniform 1D mesh on the unit interval using 47 elements:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-b8152q

Convert the Line to a graded mesh having more points on the right and creating 50 elements:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-ngtysu


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-291dxi

Convert the Line from –1 to 1 to a graded mesh with a "Central" point distribution using default values:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-h6iv6q


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-djunar

The number of default elements is 20. This produces the same mesh:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-nj9umi

MaximalDistance (1)
MinimalDistance (4)
Convert the Line to a graded mesh having more points on the right, where the initial spacing is 1/50:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-db9do7


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-6lnzw6

Find the minimal distance used:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-xmxz09

Make a uniform 1D mesh on the unit interval using a distance of 0.025 between points:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-duj3mb
Find the minimal distance used:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-nobqoi


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-pcta97

Convert the Line to a graded mesh with a "Central" point distribution:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-gij5oy


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-obdovl

Compute the minimal distance between the adjacent coordinates:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-vh5wjz

At the central points, the distance between the adjacent first-order coordinates is computed by dividing the length of the region by two times the number of elements: .
This constructs the same mesh:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-8ab754

Compute the minimal distance between the adjacent coordinates:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-lhxj6p

Convert the Line to a graded mesh having more points on the left and creating 10 elements, where the minimal spacing is 1/33:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-qv96ta


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-7ymjhw

Compute the minimal distance between the adjacent coordinates:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-hfpis4

GradingRatio (4)
Convert the Line to a graded mesh with a "Central" point distribution and a grading ratio :

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-ltatf


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-kz9287

Convert the Line to a graded mesh having more points on the right and creating 10 elements, where the grading ratio is :

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-vabypu


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-qjea9t

Convert the Line to a graded mesh having more points on the right, where the grading ratio is :

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-2hk7m4

Compute the distance between the adjacent coordinates:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-r3kmc2

Note the growth factor is two.
Convert the Line to a graded mesh having more points at the ends, where the grading ratio is :

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-qkdxrh


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-buqr2x

Compute the distance between the adjacent coordinates:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-iaqsr

Note that the length of the elements from the ends to the center grows with a factor of 2.
Multi-material Regions (5)
Create a right-, both ends– and left-aligned mesh from three line primitives:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-icebd2


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-r5edvo

Create a left-aligned mesh with a maximal distance that is connected to a uniform mesh with the same maximal distance:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-deeni0


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-ja7aa3

Create the same mesh with an element marker in the different sections:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-1a2ea6

Extract the union of the element markers:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-yk6914

Convert three Line primitives to a graded mesh, assigning a mesh coordinate distribution to each line and three region markers: :

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-b47uh1

Visualize the mesh coordinate distribution and the markers:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-pv2g04

Convert three Line primitives to a graded mesh, assigning a mesh coordinate distribution and an element region marker to each line:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-ts3y8h

Visualize the mesh coordinate distribution and the markers:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-2l5r7j

Options (4)Common values & functionality for each option
"MeshOrder" (4)
Create a graded mesh with a high coordinate concentration on the left:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-pvizg6


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-5sh1c4

Create a first-order mesh with a high coordinate concentration on the left:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-u7no6r


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-zy1ezg

Create a graded first-order mesh with a high coordinate concentration on the right:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-luvlg


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-88upoj

Using a log scale, visualize how the nodes are distributed along the anisotropic mesh:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-ddmsj8

Create a second-order graded mesh with a high coordinate concentration on the left:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-m79s10


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-848xyd

Using a log scale, visualize how the second-order nodes are distributed along the graded mesh:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-b3m9t7

The mesh data structure stores the second-order nodes after the first-order nodes. Using a log scale, visualize how the sorted second-order nodes are distributed along the graded mesh:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-o1nrvz

Applications (4)Sample problems that can be solved with this function
Create a 2D graded mesh from a product of two 1D graded meshes:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-dab58f

Create a 1D graded mesh with a "Central" point distribution:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-emjm4z
Create a second 1D graded mesh with a "Central" point distribution and 50 elements:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-4e6zqi

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-3nigoy

Visualize the region product of the anisotropic mesh:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-yb7rgi

Create a third 1D graded mesh with a "BothEnds" point distribution, 50 elements and an endpoint distance of 1/200:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-u0sgo


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-bcvf0m


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-s7iof2

Solve the following system of diffusion equations over the domain of :

With initial conditions and
and boundary conditions at
,
and
. At
,
and
.
To model the infinite domain, create a left-aligned graded mesh over the Line segments from with 150 elements and a minimal distance of 1/1000:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-rf065w
This mesh allows you to have a fine mesh resolution on the left and only few elements on the right, just to extend the domain far enough to mimic an infinite domain without needing an excessive amount of mesh elements and thus unnecessarily increasing computation time.
Set up the variables and parameters where and
:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-beoahl
Set up the PDE with initial conditions :

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-130zso

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-66u1do
For comparison, solve the PDE just over the domain :

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-pa954n
Visualize the solution in the domain for time
:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-0tatq9

Note that the extension to a larger domain is necessary to capture the behavior of the boundary condition at infinity.
Over the unit square domain, solve an orthotropic diffusion equation with a large difference in scale of the diffusion coefficient. A constant Dirichlet boundary condition is given on the left and a discontinuous Dirichlet boundary condition is given on the right boundary. Define the PDE:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-l8fje2

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-ercepa
Due to the large difference in scale of the diffusion coefficient in the direction, the PDE is essentially one-dimensional in the
direction. To deal with the discontinuity of the Dirichlet condition at
and
, a graded mesh is constructed.
Create a 1D mesh with 10 elements:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-fb8ilm
Create a graded mesh with "Central" alignment and 50 elements in each:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-kdh13w

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-e9jlsx

Visualize the region product of the anisotropic mesh:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-on2e3


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-fu81bd
Visualize the density plot of the result:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-4fj4z


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-deiqdj

Visualize the derivative of ϕ in the x direction at x=1:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-kzm2cp

To assess the quality of the solutions, it is instructive to compare the solution with a graded mesh to a default mesh solution:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-te4qvv

Note that the function behavior has less overshoot with the anisotropic mesh:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-pagw4x

Note that the anisotropic mesh solution function derivative has more overshoot but in a smaller region.
Possible Issues (7)Common pitfalls and unexpected behavior
With "Left" or "Right" alignment, the minimum number of elements is 1:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-jts2u



https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-gmx2z2

With "Central" or "BothEnds" alignment, the minimum value of , the number of elements, is 2:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-zc4gqv



https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-o6fduo

A "Right" or "Left" point distribution cannot be created if the minimal distance with the length
of the input Line and the element count
:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-cc5vhr


Use a smaller minimal distance :

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-gcfo19

A "BothEnds" or "Central" point distribution cannot be created if the minimal distance with the length
of the input Line and the element count
:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-bqgcv0


Use a smaller minimal distance :

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-x33vlw

A ToGradedMesh cannot be created if the grading ratio is less than or equal to 0:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-d8lap8


Use a positive grading ratio :

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-cxnbcy

Mesh generation will not work as expected when the distance between the closest coordinates is greater than the distance between the endpoints of the input mesh over the number of elements.
Consider an input Line with a distance between endpoints equal to 2 (). The input Line will be converted to a graded mesh with 5 elements (
), a distance between closest coordinates equal to 1 (
) and a "Left" alignment:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-wwyuck



https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-kun9s9

Use a smaller minimal distance:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-6nork8


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-uy9ydq

The property "GradingRatio" has no meaning for a uniform alignment:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-gbandg


Neat Examples (1)Surprising or curious use cases
Specify a function to describe a point distribution:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-9uwmc
Create a graded mesh where the point distribution is given by a function:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-s3efsm


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-w4lcf9

Compare this to a function that uses Fibonacci numbers as a distribution. Write a function to get a Fibonacci distribution:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-f4v86p
Convert the Line to a graded mesh using a function to specify the distribution of points:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-813f0i


https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-1ldz4e

Verify that distance between the elements follows a Fibonacci pattern:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-soth6q

Compare the two different distributions:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-j4daza

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-p8n8op

Using a log scale, visualize the node distribution in fibmesh and mesh:

https://wolfram.com/xid/0jukwedz0461x2o59dj52xna-evhof6

Note that for the construction of the Fibonacci distribution it is not necessary to provide the initial spacing, because a Fibonacci sequence only needs the number of elements, while other distributions use a power law approach to achieve a more uniform grading with a specified minimal distance.
Wolfram Research (2021), ToGradedMesh, Wolfram Language function, https://reference.wolfram.com/language/FEMDocumentation/ref/ToGradedMesh.html.
Text
Wolfram Research (2021), ToGradedMesh, Wolfram Language function, https://reference.wolfram.com/language/FEMDocumentation/ref/ToGradedMesh.html.
Wolfram Research (2021), ToGradedMesh, Wolfram Language function, https://reference.wolfram.com/language/FEMDocumentation/ref/ToGradedMesh.html.
CMS
Wolfram Language. 2021. "ToGradedMesh." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/FEMDocumentation/ref/ToGradedMesh.html.
Wolfram Language. 2021. "ToGradedMesh." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/FEMDocumentation/ref/ToGradedMesh.html.
APA
Wolfram Language. (2021). ToGradedMesh. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/FEMDocumentation/ref/ToGradedMesh.html
Wolfram Language. (2021). ToGradedMesh. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/FEMDocumentation/ref/ToGradedMesh.html
BibTeX
@misc{reference.wolfram_2025_togradedmesh, author="Wolfram Research", title="{ToGradedMesh}", year="2021", howpublished="\url{https://reference.wolfram.com/language/FEMDocumentation/ref/ToGradedMesh.html}", note=[Accessed: 10-July-2025
]}
BibLaTeX
@online{reference.wolfram_2025_togradedmesh, organization={Wolfram Research}, title={ToGradedMesh}, year={2021}, url={https://reference.wolfram.com/language/FEMDocumentation/ref/ToGradedMesh.html}, note=[Accessed: 10-July-2025
]}