MMS: Verification of the Incompressible Navier-Stokes Equations

Category: V&V / 製造解法 | Integrated 2026-04-12
MMS verification of incompressible Navier-Stokes equations showing Taylor-Green vortex velocity field and convergence rate plot
製造解法(MMS)によるナビエ・ストークス方程式ソルバーの検証 -- Taylor-Green渦型の製造解と収束次数評価

Theory and Physics

What is MMS?

🧑‍🎓

Professor, I heard that MMS (Method of Manufactured Solutions) is about "creating a fake solution." Why would you deliberately create a fake one? Does that even make sense?

🎓

Good question. MMS (Method of Manufactured Solutions) is the ultimate tool for code verification. The key point is not "fake solution" but "a solution of your own choosing."

Complex equations like the Navier-Stokes equations generally do not have analytical solutions. But with MMS, by arbitrarily declaring any smooth function to be "the solution," you can rigorously check if the solver's implementation is mathematically correct.

🧑‍🎓

Huh, what do you mean by "declaring it to be the solution"? Can you just arbitrarily call a function that doesn't satisfy the equation a solution?

🎓

That's the trick of MMS. For example, if we denote the differential operator of the Navier-Stokes equations as $\mathcal{L}$, then originally we look for $u$ that satisfies

$$ \mathcal{L}(u) = 0 $$

. But with MMS, you choose any $u_\text{mfg}$ you like and substitute it into the equation. Naturally, $\mathcal{L}(u_\text{mfg}) \neq 0$, so we add that residual as a source term $f$ on the right-hand side:

$$ \mathcal{L}(u_\text{mfg}) = f $$

In other words, we artificially create a problem where "in a world with this source term $f$, $u_\text{mfg}$ is the exact solution." We make the solver solve this problem and check if it matches $u_\text{mfg}$.

🧑‍🎓

I see! You back-calculate the source term to make it consistent. But does that really find bugs?

🎓

It does. Because we check the order of accuracy when systematically refining the mesh. If discretized with a 2nd-order scheme, the error should become $1/4$ when the mesh width $h$ is halved. If this breaks, there's a bug somewhere in the code.

For example, there was a case with an automotive exterior CFD code where the discretization of the convection term had a sign error. Standard benchmarks (like Lid-driven cavity) gave results that "looked about right," but MMS revealed the order of convergence dropped to 1st order, leading to the bug being found.

Incompressible Navier-Stokes Equations

🧑‍🎓

Then, please tell me the equations to which this MMS is applied. What is the form of the incompressible Navier-Stokes equations?

🎓

The incompressible NS equations consist of two parts: the momentum conservation equation and the continuity equation (mass conservation). In 2D, they are written as follows:

Momentum Conservation Equation ($x$ direction):

$$ \frac{\partial u}{\partial t} + u\frac{\partial u}{\partial x} + v\frac{\partial u}{\partial y} = -\frac{1}{\rho}\frac{\partial p}{\partial x} + \nu\left(\frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2}\right) + f_x $$

Momentum Conservation Equation ($y$ direction):

$$ \frac{\partial v}{\partial t} + u\frac{\partial v}{\partial x} + v\frac{\partial v}{\partial y} = -\frac{1}{\rho}\frac{\partial p}{\partial y} + \nu\left(\frac{\partial^2 v}{\partial x^2} + \frac{\partial^2 v}{\partial y^2}\right) + f_y $$

Continuity Equation:

$$ \frac{\partial u}{\partial x} + \frac{\partial v}{\partial y} = 0 $$
Physical Meaning of Each Term
  • Unsteady term $\partial u / \partial t$: Rate of change of flow velocity over time. Zero for steady problems.
  • Convection term $(u \cdot \nabla)u$: Nonlinear effect where the fluid itself transports momentum. Dominant at high Reynolds numbers. For example, the phenomenon where flow accelerates at a river confluence.
  • Pressure gradient term $-\nabla p / \rho$: Force from pressure difference pushing the fluid. Source of pump driving force or lift on wing surfaces.
  • Viscous term $\nu \nabla^2 u$: Diffusion of momentum due to molecular viscosity. Flow that spreads slowly like honey.
  • Source term $f$: Gravity or external forces. In MMS, the "consistency adjustment" term goes here.
Assumptions and Applicability Limits
  • Incompressible (Mach number $\ll$ 0.3): Density $\rho$ is constant
  • Newtonian fluid: Viscous stress is linearly proportional to strain rate
  • Isothermal: Ignore property changes due to temperature variation
  • Continuum assumption: Knudsen number $\ll$ 1 (mean free path of molecules is much smaller)

Constructing the Manufactured Solution

🧑‍🎓

When applying MMS to the NS equations, how do you choose the manufactured solution? Can it be anything?

🎓

Theoretically, anything, but there are practical rules to follow:

  1. It must satisfy the continuity equation: If $\nabla \cdot \mathbf{u}_\text{mfg} \neq 0$, you'd be giving contradictory input to an incompressible solver.
  2. It must be sufficiently smooth: If not differentiable, you cannot verify high-order accuracy schemes.
  3. It must "activate" all terms: For example, a constant manufactured solution would make both convection and viscous terms zero, rendering the test meaningless.

A typical example is the Taylor-Green vortex. This is actually an exact solution to the NS equations (holds without a source term), but it's perfect for explaining MMS.

Taylor-Green Vortex Type Manufactured Solution (2D):

$$ u_\text{mfg}(x,y,t) = -\cos(\pi x)\sin(\pi y)\,e^{-2\pi^2 \nu t} $$
$$ v_\text{mfg}(x,y,t) = \sin(\pi x)\cos(\pi y)\,e^{-2\pi^2 \nu t} $$
$$ p_\text{mfg}(x,y,t) = -\frac{1}{4}\bigl(\cos(2\pi x) + \cos(2\pi y)\bigr)\,e^{-4\pi^2 \nu t} $$
🧑‍🎓

How do you confirm that this manufactured solution satisfies the continuity equation?

🎓

Just actually compute the partial derivatives:

$$ \frac{\partial u_\text{mfg}}{\partial x} = \pi\sin(\pi x)\sin(\pi y)\,e^{-2\pi^2\nu t} $$ $$ \frac{\partial v_\text{mfg}}{\partial y} = -\pi\sin(\pi x)\sin(\pi y)\,e^{-2\pi^2\nu t} $$

They sum to zero. It perfectly satisfies the continuity equation. This manufactured solution is designed so that the structures of $u$ and $v$ are "sign inversion + sin/cos swap," ensuring the incompressibility condition is always met.

Derivation of the Source Term

🧑‍🎓

So, finally, the source term calculation, right? You substitute the manufactured solution into the NS equations?

🎓

Exactly. Calculate each term in order. Let's show it for the $x$-direction momentum equation.

First, the unsteady term:

$$ \frac{\partial u_\text{mfg}}{\partial t} = 2\pi^2\nu\cos(\pi x)\sin(\pi y)\,e^{-2\pi^2\nu t} $$

Convection term ($u \cdot \partial u/\partial x + v \cdot \partial u/\partial y$):

$$ u\frac{\partial u}{\partial x} = -\pi\cos(\pi x)\sin(\pi y)\cdot\pi\sin(\pi x)\sin(\pi y)\cdot e^{-4\pi^2\nu t} $$ $$ v\frac{\partial u}{\partial y} = \pi\sin(\pi x)\cos(\pi y)\cdot(-\pi)\cos(\pi x)\cos(\pi y)\cdot e^{-4\pi^2\nu t} $$

Viscous term:

$$ \nu\nabla^2 u = \nu\cdot 2\pi^2\cos(\pi x)\sin(\pi y)\,e^{-2\pi^2\nu t} $$

The unsteady term and the viscous term cancel, and for the Taylor-Green vortex, the source term becomes $f_x = 0$. That is, this manufactured solution is also an exact solution of the NS equations.

🧑‍🎓

Huh, the source term is zero? Can that be used as MMS?

🎓

It can. Even with $f=0$, the fact that "the exact solution is known" remains unchanged, so convergence order verification can be done without issue. However, in practice, more general manufactured solutions are often used. For example:

$$ u_\text{mfg} = \sin(ax)\sin(by) + c $$ $$ v_\text{mfg} = \cos(ax)\cos(by) + d $$

You can choose something like this that does not satisfy the continuity equation and adjust the coefficients $a, b$. In this case, the source term becomes non-zero, so you can also test the source term implementation.

Here we use the Taylor-Green vortex for educational purposes, but in practice, the golden rule is to use more complex manufactured solutions (combinations of polynomials + trigonometric functions) to activate all discretized terms.

Summary of MMS Procedure:

  1. Choose a manufactured solution $u_\text{mfg}$ (designed to satisfy the continuity equation)
  2. Substitute into the NS differential operator $\mathcal{L}$ to calculate the source term $f = \mathcal{L}(u_\text{mfg})$
  3. Add the source term $f$ to the solver's right-hand side and set $u_\text{mfg}$ as the boundary condition
  4. Obtain solutions at multiple mesh resolutions and calculate the error against $u_\text{mfg}$
  5. Check if the convergence order $p$ matches the theoretical value of the discretization scheme

Evaluation of Convergence Order

🧑‍🎓

How do you actually get a number for the convergence order?

🎓

Systematically refine the mesh and calculate the error $e$ on each mesh. The observed convergence order between two meshes is:

$$ p = \frac{\log(e_1 / e_2)}{\log(h_1 / h_2)} $$

where $e_1, e_2$ are the error norms at mesh widths $h_1, h_2$, respectively.

🧑‍🎓

Can you show me with a concrete example? For instance, what happens with a 2nd-order accuracy scheme?

🎓

Let's look at an actual numerical example. When refining the mesh as $h$, $h/2$, $h/4$, $h/8$:

MeshNumber of Elements$h$$L_2$ Error NormObserved Order $p$Judgment
Level 1$16 \times 16$$1/16$$3.87 \times 10^{-3}$----
Level 2$32 \times 32$$1/32$$9.72 \times 10^{-4}$1.99PASS
Level 3$64 \times 64$$1/64$$2.43 \times 10^{-4}$2.00PASS
Level 4$128 \times 128$$1/128$$6.08 \times 10^{-5}$2.00PASS

Judgment criteria: PASS if observed order is within $\pm 0.1$ of theoretical value (2.0). If systematically low, suspect a bug.

🎓

Let's also write the formula for the $L_2$ norm:

$$ \|e\|_{L_2} = \sqrt{\frac{1}{\Omega}\int_\Omega \bigl(u_\text{numerical} - u_\text{mfg}\bigr)^2 \, d\Omega} $$

Discretely:

$$ \|e\|_{L_2} \approx \sqrt{\frac{\sum_{i=1}^{N} (u_i - u_{\text{mfg},i})^2 \cdot V_i}{\sum_{i=1}^{N} V_i}} $$

where $V_i$ is the volume (area) of cell $i$.

Numerical Methods and Implementation

Discretization by Finite Volume Method

🧑‍🎓

In CFD, the Finite Volume Method (FVM) is mainstream, right? How is the MMS source term handled in FVM?

🎓

Since FVM deals with cell-averaged values, the source term is also integrated over the cell volume. The discretized momentum equation for cell $i$ is:

$$ \sum_f \phi_f u_f - \sum_f \nu (\nabla u)_f \cdot \mathbf{S}_f = -\frac{1}{\rho}\sum_f p_f \mathbf{S}_f + \int_{V_i} f \, dV $$

Here, $\phi_f = \mathbf{u}_f \cdot \mathbf{S}_f$ is the face flux, $\mathbf{S}_f$ is the face normal vector. The volume integral of the source term $\int_{V_i} f \, dV$ is approximated by the cell center value $f_i \cdot V_i$ (single-point approximation at cell center).

🧑‍🎓

Is the single-point approximation accurate enough?

🎓

Good point. The cell center single-point approximation is 2nd-order accurate, so it's fine for verifying 2nd-order schemes. However, if you want to verify 3rd-order or higher accuracy, you need to integrate the source term with higher precision using Gauss quadrature. This is an easily overlooked point, so be careful.

Source Term Implementation

🧑‍🎓

How do you add the source term to the solver?

🎓

There are two main methods:

  • Method 1: Explicitly add the source term -- Add a user-defined source term function to the right-hand side of the momentum equation. In OpenFOAM, use fvOptions; in Fluent, use the UDF macro DEFINE_SOURCE.
  • Method 2: Add as a body force -- Give the source term in the same form as the gravity term. Implementation is simple, but sometimes the source term for the pressure term needs to be handled separately.

In practice, Method 1 is common. Implement the source term function either hard-coded or as a user function taking coordinates and time as arguments.

Error Norm Calculation

🎓

It is desirable to calculate three types of error norms: $L_1$, $L_2$, $L_\infty$:

$$ \|e\|_{L_1} = \frac{1}{N}\sum_{i=1}^{N} |u_i - u_{\text{mfg},i}| $$
$$ \|e\|_{L_\infty} = \max_{i} |u_i - u_{\text{mfg},i}| $$
🧑‍🎓

What's the point of calculating three types? Isn't $L_2$ enough?

🎓

I wouldn't say it's not enough, but there are cases where the $L_\infty$ (maximum error) norm breaks down. For example, a bug where accuracy drops only near the boundary might be obscured by averaging in $L_2$, but $L_\infty$ would reveal it instantly. If all three norms show the correct convergence order, the code's reliability is quite high.

Automatic Derivation of Source Term Using SymPy

🧑‍🎓

Manual calculation of the source term seems scary... I'm afraid I'd make mistakes with the convection term derivatives...

🎓

In practice, the golden rule is to use SymPy (Python's symbolic computation library) for automatic derivation. Keep manual calculations only for verification. Especially, sign errors frequently occur when expanding the nonlinear convection term $(u \cdot \nabla)u$, so I strongly recommend cross-checking with symbolic computation. Reference code:

import sympy as sp

x, y, t, nu = sp.symbols('x y t nu')
pi = sp.pi

# Definition of manufactured solution
u = -sp.cos(pi*x) * sp.sin(pi*y) * sp.exp(-2*pi**2*nu*t)
v =  sp.sin(pi*x) * sp.cos(pi*y) * sp.exp(-2*pi**2*nu*t)
p = -sp.Rational(1,4)*(sp.cos(2*pi*x)+sp.cos(2*pi*y))*sp.exp(-4*pi**2*nu*t)

# Verification of continuity equation
div = sp.diff(u, x) + sp.diff(v, y)
print("div(u) =", sp.simplify(div))  # =>
関連シミュレーター

この分野のインタラクティブシミュレーターで理論を体感しよう

シミュレーター一覧

関連する分野

流体解析V&V熱解析
この記事の評価
ご回答ありがとうございます!
参考に
なった
もっと
詳しく
誤りを
報告
参考になった
0
もっと詳しく
0
誤りを報告
0
Written by NovaSolver Contributors
Anonymous Engineers & AI — サイトマップ
About the Authors