Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Chapter 5 — Spectral, FEM, MUSCL, and Matrix-Free Methods

Figure 10.1 — Spectral Methods, FEM, and MUSCL Schemes

CFDrs’s solver layer decomposes into discretization (stencil/FEM), linear algebra (matrix-free, sparse direct, Krylov), and time integration (explicit, implicit, adaptive). Commonalities across the crates — including trait frontiers, error budgets, and atlas backends — live in [cfd-math] so that they are not redeclared per solver.

Spatial Discretization Surfaces

Three surfaces dominate CFDrs:

SurfaceCrateBackend trait
Stencil (finite-volume)cfd-2d::stencil, cfd-3d::stencilStencilOp<F>
FEM (P1, P2 tetrahedral)cfd-3d::femFEMOp<F>
Spectral (FFT-based)cfd-3d::spectral, cfd-2d::spectralSpectralOp<F>

All three consume the boundary-and-state triple introduced in Foundations.

Matrix-Free Operator Application

For details on linear operator traits, Krylov actions, and iterative solvers, see Matrix-Free Operators and Krylov Solvers.

Iterative Solvers

The Krylov solver APIs (BiCGSTAB, GMRES, IDR(s)) are documented in the Matrix-Free Operators and Krylov Solvers chapter.

Time Integration

pub trait Integrator<F: FloatElement> {
    fn step(&mut self, x: &mut NdArray<F, Ix3>, dt: F);
}

pub struct ForwardEuler<F>(PhantomData<F>);            // explicit
pub struct AdamsBashforth2<F>(PhantomData<F>);         // explicit, 2nd order
pub struct CrankNicolson<F>(PhantomData<F>);          // implicit
pub struct AdaptiveRungeKutta<F>(...);                 // adaptive

Adaptive Runge-Kutta is the default for stiff boundary-driven flows; the explicit Adams-Bashforth pair is the default for incompressible time-stepping.

Adaptive Time-Stepping

let stepping = AdaptiveStepping::builder()
    .cfl_max(0.5)
    .atol_field(1e-6)
    .build();

stepping.run(&mut solver, &state)?;

The adaptive scheme refines dt until local truncation error falls below atol_field per cell. This matches the Atlas Krylov trait frontier, so callers can swap solvers without re-tuning tolerances.

Examples Referenced by This Chapter

Part V opens with six example chapters:

Further Reading