TL;DR
A computational mesh divides a region of space into many small, simple cells, such as triangles, quadrilaterals or tetrahedra, and records which cells share which corner points, called nodes. A simulation of heat, air or stress stores its unknown values at the nodes and approximates the solution between them, so the mesh decides where the computer keeps information and how finely it can see the shape. Almost every numerical solver for a Partial Differential Equation works on some kind of mesh, and the quality of the mesh often limits the quality of the answer.
Builds on: Partial Differential Equation, Boundary Condition · Leads to: Finite Element Method, Finite Difference Method
Where it's used
Aircraft and car aerodynamics. Engineers simulate air around a wing or a car body by filling the space around the shape with a mesh that is very fine near the surface and coarse far away. Detailed airflow studies can use meshes of tens of millions of cells, which is why mesh generation takes a large share of the work in a project.
Structural strength. A bridge component or an engine bracket is analysed with a mesh of the solid part. Stress is largest near corners and holes, so the mesh is refined there. A finite element solver then computes the displacement at each node and reports stress in each cell.
Learned simulators. Some recent research trains neural networks to predict how a deforming object or a fluid will move, using the mesh as the structure the network reads. The paper MeshGraphNets treats a mesh as a Graph, with nodes as points and edges as connections between them, so the same mesh that a traditional solver would use becomes the input to the learned model.
How it works
Take the smallest case: a line segment from to that carries a temperature we want to simulate. Divide it into four equal pieces.
- Choose the cell size. Four equal pieces of length 1 give a spacing of . Check: , the full length.
- Place the nodes. The nodes sit at the cell boundaries: . Five nodes. Check: four cells need five boundaries, one more than the number of cells.
- Define the cells. Each cell joins two neighbouring nodes. Cell 1 joins nodes at 0 and 0.25, cell 2 joins 0.25 and 0.5, and so on. The mesh is now the list of cells and their nodes. Check: each interior node belongs to two cells, and each end node belongs to one.
- Store the unknowns at the nodes. Suppose the solver has found temperatures at and at . Check: these two numbers are the only values held for the cell .
- Approximate between the nodes. For a point inside a cell, write , which runs from 0 at the left node to 1 at the right node. The temperature is the straight-line blend . At , , so . Check: 5.4 lies between 5 and 6.
The mesh has given the solver a finite set of unknowns and a rule for filling in everything else. The same idea holds in two and three dimensions, where the cells are triangles or cubes instead of intervals.
flowchart LR A[Geometry of the object] --> B[Mesh: cells and nodes] B --> C[Solver stores values at nodes] C --> D[Interpolate inside cells] D --> E[Results: stress, temperature or flow]
The math
Let the region be and let the mesh divide it into cells , , with nodes . A mesh is specified by its node coordinates and by a table that lists, for each cell, the nodes it uses. This table is the connectivity.
A computational mesh is a partition of a region into non-overlapping cells, where the cells meet only at shared faces, edges or nodes, together with the connectivity that says which nodes belong to each cell. The mesh size is the typical diameter of a cell.
Step 2 in symbols
For a one-dimensional interval of length cut into equal cells, the size is and the number of nodes is . With and , and .
Step 5 in symbols
Inside a cell with left node and right node , the local coordinate is
and the approximate solution is
The two functions and are called shape functions. Each equals 1 at its own node and 0 at the other, which is why the stored node values are exactly the solution at the nodes. In two dimensions the same idea uses shape functions that are linear over each triangle.
Counting cells
For a rectangle of width and height , cut into squares of side , the count is . Halving multiplies the number of cells by 4 in two dimensions and by 8 in three. This growth is the main cost limit on how fine a mesh can be, and it is why solvers store the equations as sparse matrices that couple only neighbouring nodes.
Worked examples
A unit square is cut into a grid of equal squares, each split into two triangles.
- Square cells: .
- Triangles: each square splits into 2, so .
- Nodes: a grid of cells has corner points, so nodes.
- Cell side: .
Interpretation: 16 unknowns describe the whole square, and the 18 triangles say how they connect. The solver stores 16 numbers, not a value at every point of the square.
A plate m by m is meshed with square cells of side m.
- Cells along each side: .
- Total cells: .
- Halve the side to m. Cells along each side: .
- Total cells: .
- Interpretation: the cell count grows by a factor of when the size halves, because both directions double. The same rule in three dimensions gives a factor of , so a m cube meshed at m with cells needs cells at m.
A heated steel block measures mm by mm by mm. A uniform mesh with mm cells is used first.
- Cells along each side: , , and .
- Total cells: .
- Refine everywhere to mm cells. Each side doubles in count, so the total is multiplied by : cells.
- Compare with grading. Suppose the temperature changes steeply across the mm by mm face but gently through the mm thickness, so only the two in-face directions need mm cells, and the thickness stays at mm. The count is .
- Try it: the grading halves the cell count compared with full refinement. How many cells does full refinement use? Answer: , so the graded mesh uses , which is half.
Interpretation: refining only where the physics changes saves half the cells here, and more when the refined region is small compared with the whole block.
Common mistakes and tradeoffs
It is tempting to think a finer mesh always gives a more accurate answer. In fact accuracy improves only while the numerical method converges. A very fine mesh with badly shaped cells, such as long thin triangles, can give worse results than a moderate mesh with well-shaped cells, and the run costs far more.
It is tempting to think the mesh is only a picture for display. In fact the mesh defines the approximation. The solver stores its unknowns at the nodes, and the cell shapes set which functions it can represent.
It is tempting to think a uniform mesh is always the best. In fact sharp corners, holes and boundary layers need fine cells locally, and a grid that is coarse there will miss the largest gradients.
| Choice | Strength | Weakness |
|---|---|---|
| Structured grid (regular rows of cells) | Simple, fast, easy to index | Hard to fit curved or complex shapes |
| Unstructured mesh (triangles or tetrahedra) | Fits complex shapes and grades smoothly | More complex to generate and store |
Use a structured grid when the shape is simple and speed matters most. Use an unstructured mesh when the geometry is complicated or the solution needs local refinement.
History
The idea of splitting a domain into simple pieces and solving on them is much older than the computer. Its modern form owes a great deal to the work of Richard Courant, who in 1943 used triangular pieces with a variational method for problems in torsion and vibration. Delaunay triangulation, a method for building triangle meshes with good shapes, was introduced by Boris Delaunay in 1934.
The term "finite element" is usually credited to Ray Clough in 1960, and the approach spread through structural engineering in the 1960s with the arrival of digital computers. Mesh generation became a research field in its own right as the shapes simulated grew more complex. Meshing still takes a large share of the time in engineering simulation, and automating it remains an active problem.
Recap
- A mesh divides a region into cells that share nodes, and it stores the connectivity between them.
- Solvers keep unknowns at the nodes and approximate the solution inside each cell, for example by linear blending in one dimension.
- Halving the cell size multiplies the cell count by 4 in two dimensions and by 8 in three, so refinement must be targeted.
- Cell shape matters as much as cell size, and grading the mesh where the solution changes fastest saves cost.
- Read next: Finite Element Method, which uses meshes with shape functions as its basis, and Finite Difference Method, which uses regular grids of points.
Check yourself
QuestionRecall: why does a mesh with four cells on a line have five nodes, and what does the solver store at the nodes?Show answer
Each cell is bounded by two nodes, and neighbouring cells share a node. Four cells in a row need five boundary points, one more than the number of cells. The solver stores the unknown value (such as the temperature) at each node. Values between nodes are filled in by the shape functions inside each cell.
QuestionComputation: a 2 m by 1 m plate is meshed with square cells of side 0.1 m. How many cells does it have, and how many after the side is halved to 0.05 m?Show answer
At 0.1 m, the plate has cells along its length and along its width, so cells. At 0.05 m, there are cells. The count multiplies by 4, as expected in two dimensions.
QuestionWhy: why does refining a mesh near a hole in a plate usually work better than refining the whole plate?Show answer
Stress and temperature change fastest near the hole, so the mesh needs small cells there to capture them. Away from the hole the solution changes slowly, and large cells are accurate enough. Refining everywhere multiplies the total number of cells, most of which add cost without adding information about the features that matter.
QuestionApplied: a team finds that their simulation gives a different answer after they refine the mesh, but the answer stops changing after a further refinement. What have they checked, and what should they report?Show answer
They have shown that the solution is converging with mesh refinement: the change from the last refinement is small, so the answer is no longer limited by the cell size. They should report the result with the mesh sizes used, state that the answer has converged to a stated tolerance, and check that the cell shapes are well formed, since converged results on distorted cells can still be wrong.