---
title: "Calculate static mesh deflection under load in C#"
url: https://recursiveai.org/onephysics/cookbook/calculate-static-mesh-deflection/
description: "Calculate how far a supported tetrahedral mesh bends under load in C#. Fix a face, apply a force, and read the signed tip deflection in millimeters."
version: "1.3.0"
---

# Calculate static mesh deflection under load in C#

**OnePhysics** is a free, open-source physics library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OnePhysics.Tools) · [GitHub](https://github.com/recursive-ai-oss/onephysics-csharp) · [Docs](https://recursiveai.org/onephysics/docs/) · [Download example (.zip)](https://recursiveai.org/onephysics/cookbook/calculate-static-mesh-deflection/calculate-static-mesh-deflection.zip)

Use `StaticSolver.Solve` to find how far a part bends under a steady load. It needs a mesh of tetrahedra, not surface triangles.

```shell
dotnet add package RecursiveAI.OnePhysics.Tools
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using RecursiveAI.OneMath;
using RecursiveAI.OnePhysics.Tools;

Vector3F[] nodes =
    [new(0, 0, 0), new(.1f, 0, 0),
     new(0, .02f, 0), new(0, 0, .02f)];
var load = new StaticProblem
{
    Material = ElasticMaterial.Create(2e9, .35)
};
foreach (int node in new[] { 0, 2, 3 })
    load.Supports.Add(new StaticSupport(node));
load.PointLoads.Add(new(1, new(0, 0, -1)));
var result = StaticSolver.Solve(
    nodes, [0, 1, 2, 3], load);
if (!result.Converged)
    throw new InvalidOperationException();
double mm = result.Displacements[1].Z * 1000;
Console.WriteLine(FormattableString.Invariant(
    $"Tip Z deflection: {mm:F3} mm"));
```

`ElasticMaterial.Create(2e9, .35)` sets Young’s modulus to 2 × 10⁹ Pa and Poisson’s ratio to 0.35.

Unzip [the example](https://recursiveai.org/onephysics/cookbook/calculate-static-mesh-deflection/calculate-static-mesh-deflection.zip), then `dotnet run`.

Prints:

```text
Tip Z deflection: -0.123 mm
```

## The full program

The four positions are in meters, with zero-based indices `[0, 1, 2, 3]` making one tetrahedron. The three nodes on the X = 0 face are fixed. A 1 N force pushes node 1 in the negative Z direction. The download prints the signed deflection at that node and the upward reaction carried by the supports. No mesh file is needed.

```csharp
using RecursiveAI.OneMath;
using RecursiveAI.OnePhysics.Tools;

Vector3F[] nodes = [new(0, 0, 0), new(.1f, 0, 0),
    new(0, .02f, 0), new(0, 0, .02f)];
var load = new StaticProblem
{
    Material = ElasticMaterial.Create(2e9, .35)
};
foreach (int node in new[] { 0, 2, 3 })
    load.Supports.Add(new StaticSupport(node));
load.PointLoads.Add(new(1, new(0, 0, -1)));
var result = StaticSolver.Solve(
    nodes, [0, 1, 2, 3], load);
if (!result.Converged)
    throw new InvalidOperationException("Static solve did not converge.");
double mm = result.Displacements[1].Z * 1000;
Console.WriteLine(FormattableString.Invariant(
    $"Tip Z deflection: {mm:F3} mm"));
Console.WriteLine(FormattableString.Invariant(
    $"Support reaction Z: {result.TotalReaction.Z:F3} N"));
```

```text
Tip Z deflection: -0.123 mm
Support reaction Z: 1.000 N
```

An inverted tetrahedron or supports that let the part move as a rigid body cause `StaticSolveException`. If the iterations stop without converging, don’t use the last displacement as a finished answer.

## Variations

If your mesh uses millimeters, replace the input positions and `Solve` call with these lines; leave the forces and output conversion as they are:

```csharp
// Replace the input positions before constructing load.
Vector3F[] nodes =
    [new(0, 0, 0), new(100, 0, 0),
     new(0, 20, 0), new(0, 0, 20)];

// Replace the solve after adding supports and loads.
var result = StaticSolver.Solve(
    nodes, [0, 1, 2, 3], load,
    new() { MetresPerUnit = 0.001 });
```

The converted mesh also prints `Tip Z deflection: -0.123 mm`.

## Related recipes

- [Tetrahedralize a triangle mesh](https://recursiveai.org/onephysics/cookbook/tetrahedralize-surface-mesh/)
- [Simulate a volumetric soft body](https://recursiveai.org/onephysics/cookbook/simulate-volumetric-soft-body/)

## The short answer

Pass the tetrahedral mesh, elastic material, fixed nodes and forces to `StaticSolver.Solve` from `RecursiveAI.OnePhysics.Tools`. Check `Converged`, then read `Displacements` at the vertex you care about. The example reads the Z component at the loaded tip. `MaxDisplacement` answers a different question: it gives the largest displacement magnitude, not the signed displacement at a particular vertex.

## What is a mesh in finite element analysis?

A mesh divides a part into small elements so the solver can calculate how their displacements fit together under load. Here the elements are tetrahedra: each group of four indices describes a piece of the solid, not just its surface. If you have only a closed triangle mesh, fill it first, for example with `Tetrahedralizer.Generate`. If you already have a positively oriented tetrahedral mesh, pass its vertex and index arrays directly as in the example.

Supports and loads are part of the model. The example fixes an entire face, so the tetrahedron can’t translate or rotate freely. For a real part, constrain the directions its actual mount restrains; a support that fixes only Z still allows X and Y motion. Apply loads where the part carries them: gravity acts on the material’s mass, a point load acts at a vertex, and a `FaceLoad` puts pressure or traction on a boundary triangle. Use newtons for forces and pascals for material stiffness and pressure. Even when you import geometry in millimeters, displacements come back in meters.

## How do you check deflection from a finite element solve?

First check the signs and units. Here a downward force gives a negative Z displacement and a positive Z support reaction; the two forces balance. Then check the residual, which indicates how closely the computed solution satisfies the discrete equations. A small residual doesn’t establish that the geometry, material, supports, or load represent the real part.

Run the same load case on a finer mesh and compare the displacement at the same physical location. The default ten-node elements capture bending; the optional four-node elements can be too stiff in bending on a coarse mesh. The one-tetrahedron example illustrates the API, not a mesh to use for design decisions. In particular, stress at a point load or the edge of a fixed support can rise with mesh refinement even when deflection is settling. Compare stress away from those locations, or model the load over the area it actually covers.

This is a linear-elastic static solve: it estimates displacement under a steady load without simulating the motion toward equilibrium or permanent deformation. See the [static solve guide](https://recursiveai.org/onephysics/docs/statics/) for the result fields and how the solver handles stress and material strength.
