Spectral examples sequence

This page gives a reading and running order through three programs that add one concept at a time: a spectral model, simulator orchestration, and a nonlinear model with output.

Sequence

Step

Executable

New idea

1

04_diffusion_model

Subclass Model, implement initialize and step, and apply a Fourier-space operator

2

05_simulator

Add Simulator, Time, field modifiers, and lifecycle orchestration

3

12_cahn_hilliard

Add a nonlinear operator split, initial data, and VTK output

Together they mirror how a research application usually grows: first verify the physics step, then add framework-managed lifecycle and output.

Build and run

From the repository root:

cmake --build build --target \
  04_diffusion_model \
  05_simulator \
  12_cahn_hilliard

mpirun -n 1 ./build/examples/04_diffusion_model
mpirun -n 1 ./build/examples/05_simulator
mpirun -n 1 ./build/examples/12_cahn_hilliard

Begin with one rank. After all three programs exit with status zero, repeat with a rank count supported by your launcher allocation and the example dimensions. The programs do not share one mandatory success message; see Example run output.

Read the sources

File

Look for

examples/04_diffusion_model.cpp

Field allocation, Fourier-space operator construction, and forward/backward transforms

examples/05_simulator.cpp

Simulator construction, modifiers, time control, and ownership

examples/12_cahn_hilliard.cpp

Nonlinear split, initial state, and VTK write cadence

Treat these compiled examples as the code-level source of truth. This page explains their order rather than copying their implementations.

Continue by goal

Goal

Next document

Understand Domain, decomposition, and FFT first

Library basics

Build a JSON-driven application

Minimal custom application

Understand JSON-to-simulator wiring

Application pipeline

Inspect output in ParaView

VTK and ParaView workflow

Find every runnable example

Examples catalog

Look up API-focused snippets

API examples walkthrough