# flexi-framework/galaexi architecture

> Architecture diagram of the GitHub repository flexi-framework/galaexi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/flexi-framework/galaexi
- Repository: https://github.com/flexi-framework/galaexi

## Overview

1. **Overall shape**
   This repository is a high-order CFD framework built around a main solver plus a separate postprocessing suite. The code is organized for HPC execution with MPI and GPU offload, and the primary runtime artifact is the `galaexi` executable built from `src/`.

2. **Core simulation engine (`src/`)**
   `src/` contains the production solver: mesh handling, interpolation, DGSEM operators, finite-volume fallback/blending, physics equations, time integration, output, restart, filtering, and analysis. The architecture is modular, with most physics- and method-specific behavior isolated in subdirectories rather than hard-coded into one main loop.

3. **Discretization layer**
   The numerical core is DGSEM on hexahedral meshes. The DG machinery is split into volume/surface integration, lifting, overintegration, basis changes, Jacobian application, and mortar interfaces. This indicates the solver is built to handle high-order curved/unstructured elements and nonconforming interfaces.

4. **Physics models**
   Equation families are separated under `src/equations/`: linear scalar advection, Navier–Stokes, and RANS-SA. Each has its own fluxes, Jacobians, Riemann solvers, timestep calculation, exact solutions, and boundary treatments. Navier–Stokes also includes ideal-gas thermodynamics and optional eddy-viscosity models such as Smagorinsky, Vreman, and sigma.

5. **Numerics safety and shock handling**
   The solver includes a finite-volume subsystem in `src/fv/` plus indicator and limiter/filter code. That tells you the DG method can locally switch to or blend with FV treatment for robustness on under-resolved or discontinuous flows, rather than relying purely on one discretization.

6. **Time stepping, implicit support, and preconditioning**
   `src/timedisc/` implements the time discretization framework. There is also `src/implicit/` and `src/precond/`, including sparse ILU and Jacobian-based preconditioner code. So the solver supports both explicit and more advanced implicit/preconditioned workflows, which is important for stiff flows and convergence acceleration.

7. **Mesh, geometry, and parallel runtime**
   Mesh reading and metrics are handled in `src/mesh/`, while MPI wrappers live in `src/mpi/`. The `globals/` area contains shared runtime utilities, GPU hooks, command-line handling, math/vector helpers, and preprocessing support. The code is structured to run distributed across ranks and to offload compute-heavy parts to NVIDIA GPUs.

8. **I/O and persistence**
   HDF5 is the main data exchange format through `src/io_hdf5/`. The solver writes state, restart, and derived outputs, and can also emit VTK-style visualization data. That makes HDF5 the primary simulation storage boundary, with output and restart files serving as the handoff between solver runs and downstream analysis.

9. **Postprocessing suite (`posti/`)**
   `posti/` is a separate set of Fortran executables for analysis and data transformation, not part of the main simulation loop. It includes tools such as averaging, FFT-based channel analysis, DMD, record-point preparation/visualization/evaluation, mesh swapping, conversion to 3D or DG formats, visualization readers, and wall-distance processing. The presence of a ParaView plugin under `posti/visu/paraviewReader/` shows that visualization is a first-class postprocessing concern.

10. **Workflow boundary: simulation vs analysis**
    A typical data flow is: parameter files and meshes from `tutorials/` or `ini/` feed the solver, the solver produces HDF5 state/restart/output files, and `posti/` or external scripts consume those files for analysis and visualization. This cleanly separates runtime simulation from offline postprocessing and keeps the solver core focused on PDE execution.

11. **Tutorials and input cases**
    `tutorials/` and `ini/` contain curated cases, meshes, and parameter files for canonical flows such as freestream, cavity, NACA0012, Taylor–Green vortex, Sod, cylinder, flat plate, channel flow, and linear advection. These are not just examples; they define the expected operational workflows and file layouts for preprocessing, simulation, and postprocessing.

12. **Regression and unit testing**
    `regressioncheck/` holds end-to-end reference cases with input decks, meshes, and golden outputs, covering solver variants like Riemann solvers, FV blending, preconditioning, turbulence cases, and time discretization. `unitTests/` covers numerical kernels such as basis transforms, derivative matrices, prolongation, surface integration, and read-in tools. Together they validate both low-level math and full application behavior.

13. **Build and integration**
    The project is CMake-based, with separate top-level CMake files for the core library/executable and the postprocessing tools. That suggests the repository produces multiple binaries from shared source, rather than a single application. CI and githooks are present, reinforcing that builds and regression runs are part of the repo’s expected workflow.

14. **External dependencies that matter architecturally**
    The runtime model depends materially on MPI, HDF5, LAPACK, FFTW, CUDA, and NVIDIA HPC Fortran. MPI governs distributed decomposition, HDF5 governs persistent simulation data, FFTW supports spectral analysis in postprocessing, and CUDA/NVHPC define the accelerator execution boundary.

Main entry points: [`src/flexi.f90`](https://github.com/flexi-framework/galaexi/blob/main/src/flexi.f90) (Solver core), [`src/equations/navierstokes/equation.f90`](https://github.com/flexi-framework/galaexi/blob/main/src/equations/navierstokes/equation.f90) (Physics models), [`posti/CMakeLists.txt`](https://github.com/flexi-framework/galaexi/blob/main/posti/CMakeLists.txt) (Posti suite), [`unitTests/unittest.f90`](https://github.com/flexi-framework/galaexi/blob/main/unitTests/unittest.f90) (Unit tests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Build & packages"]
  node_cmake["CMake<br/>build system<br/>[CMakeLists.txt]"]
end

subgraph group_solver["Main solver"]
  node_src_main["Solver core<br/>runtime executable<br/>[flexi.f90]"]
  node_globals["Runtime infra<br/>shared runtime<br/>[globals.f90]"]
  node_mesh["Mesh & metrics<br/>geometry layer<br/>[mesh.f90]"]
  node_interpolation["Basis tools<br/>numerics kernel<br/>[interpolation.f90]"]
  node_dg["DGSEM core<br/>discretization<br/>[dg.f90]"]
  node_mortar["Mortar interfaces<br/>interface coupling<br/>[mortar.f90]"]
  node_fv["FV fallback<br/>robustness subsystem<br/>[fv.f90]"]
  node_timedisc["Time stepping<br/>integration framework<br/>[timedisc.f90]"]
  node_implicit["Implicit solve<br/>solver support<br/>[implicit.f90]"]
  node_precond["Preconditioners<br/>linear algebra<br/>[precond.f90]"]
  node_io[("HDF5 I/O<br/>persistence layer<br/>[io_hdf5.f90]")]
  node_equations["Physics models<br/>equation family<br/>[equation.f90]"]
  node_linearscalaradvection["Linear advection<br/>physics model<br/>[equation.f90]"]
  node_navierstokes["Navier–Stokes<br/>physics model<br/>[equation.f90]"]
  node_ranssa["RANS-SA<br/>physics model<br/>[equation.f90]"]
end

subgraph group_posti["Postprocessing"]
  node_posti_suite["Posti suite<br/>analysis executables<br/>[CMakeLists.txt]"]
  node_visu_plugin["Visu plugin<br/>visualization plugin<br/>[visuReader.cxx]"]
end

subgraph group_cases["Cases & docs"]
  node_tutorials["Tutorial cases<br/>input cases"]
end

subgraph group_qa["Quality assurance"]
  node_regression["Regression suite<br/>integration tests<br/>[parameter.ini]"]
  node_unittests["Unit tests<br/>kernel tests<br/>[unittest.f90]"]
end

node_cmake -->|"builds"| node_src_main
node_cmake -->|"builds"| node_posti_suite
node_src_main -->|"uses"| node_globals
node_src_main -->|"depends on"| node_mesh
node_src_main -->|"uses"| node_interpolation
node_src_main -->|"advances with"| node_dg
node_src_main -->|"couples via"| node_mortar
node_src_main -->|"falls back to"| node_fv
node_src_main -->|"orchestrates"| node_timedisc
node_timedisc -->|"optionally uses"| node_implicit
node_implicit -->|"accelerates with"| node_precond
node_src_main -->|"reads/writes"| node_io
node_src_main -->|"instantiates"| node_equations
node_equations -->|"includes"| node_linearscalaradvection
node_equations -->|"includes"| node_navierstokes
node_equations -->|"includes"| node_ranssa
node_navierstokes -->|"supports"| node_fv
node_posti_suite -->|"consumes"| node_io
node_posti_suite -->|"extends"| node_visu_plugin
node_tutorials -->|"drives"| node_src_main
node_regression -->|"verifies"| node_src_main
node_regression -->|"verifies"| node_posti_suite
node_unittests -->|"checks"| node_interpolation
node_unittests -->|"checks"| node_dg
node_unittests -->|"checks"| node_globals

click node_cmake "https://github.com/flexi-framework/galaexi/blob/main/CMakeLists.txt"
click node_src_main "https://github.com/flexi-framework/galaexi/blob/main/src/flexi.f90"
click node_globals "https://github.com/flexi-framework/galaexi/blob/main/src/globals/globals.f90"
click node_mesh "https://github.com/flexi-framework/galaexi/blob/main/src/mesh/mesh.f90"
click node_interpolation "https://github.com/flexi-framework/galaexi/blob/main/src/interpolation/interpolation.f90"
click node_dg "https://github.com/flexi-framework/galaexi/blob/main/src/dg/dg.f90"
click node_mortar "https://github.com/flexi-framework/galaexi/blob/main/src/mortar/mortar.f90"
click node_fv "https://github.com/flexi-framework/galaexi/blob/main/src/fv/fv.f90"
click node_timedisc "https://github.com/flexi-framework/galaexi/blob/main/src/timedisc/timedisc.f90"
click node_implicit "https://github.com/flexi-framework/galaexi/blob/main/src/implicit/implicit.f90"
click node_precond "https://github.com/flexi-framework/galaexi/blob/main/src/precond/precond.f90"
click node_io "https://github.com/flexi-framework/galaexi/blob/main/src/io_hdf5/io_hdf5.f90"
click node_equations "https://github.com/flexi-framework/galaexi/blob/main/src/equations/navierstokes/equation.f90"
click node_linearscalaradvection "https://github.com/flexi-framework/galaexi/blob/main/src/equations/linearscalaradvection/equation.f90"
click node_navierstokes "https://github.com/flexi-framework/galaexi/blob/main/src/equations/navierstokes/equation.f90"
click node_ranssa "https://github.com/flexi-framework/galaexi/blob/main/src/equations/rans_sa/equation.f90"
click node_posti_suite "https://github.com/flexi-framework/galaexi/blob/main/posti/CMakeLists.txt"
click node_visu_plugin "https://github.com/flexi-framework/galaexi/blob/main/posti/visu/paraviewReader/Reader/visuReader.cxx"
click node_tutorials "https://github.com/flexi-framework/galaexi/blob/main/tutorials/freestream/parameter_flexi.ini"
click node_regression "https://github.com/flexi-framework/galaexi/blob/main/regressioncheck/checks/run_basic/freestream_3D/parameter.ini"
click node_unittests "https://github.com/flexi-framework/galaexi/blob/main/unitTests/unittest.f90"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cmake toneBlue
class node_src_main,node_globals,node_mesh,node_interpolation,node_dg,node_mortar,node_fv,node_timedisc,node_implicit,node_precond,node_io,node_equations,node_linearscalaradvection,node_navierstokes,node_ranssa toneAmber
class node_posti_suite,node_visu_plugin toneMint
class node_tutorials toneRose
class node_regression,node_unittests toneIndigo
```

## Components

### Build & packages

CMake-based build and packaging/integration files

- [CMake](https://github.com/flexi-framework/galaexi/blob/main/CMakeLists.txt): build system · Top-level build configuration for solver and tools · `CMakeLists.txt`

### Main solver

Production CFD runtime in src/

- [Solver core](https://github.com/flexi-framework/galaexi/blob/main/src/flexi.f90): runtime executable · Main galaexi simulation executable and library entry points · `src/flexi.f90`
- [Runtime infra](https://github.com/flexi-framework/galaexi/blob/main/src/globals/globals.f90): shared runtime · MPI, GPU, command-line, math, and preprocessing utilities · `src/globals/globals.f90`
- [Mesh & metrics](https://github.com/flexi-framework/galaexi/blob/main/src/mesh/mesh.f90): geometry layer · Mesh reading, geometry preparation, and metric terms · `src/mesh/mesh.f90`
- [Basis tools](https://github.com/flexi-framework/galaexi/blob/main/src/interpolation/interpolation.f90): numerics kernel · Basis changes, prolongation, Jacobians, and interpolation support · `src/interpolation/interpolation.f90`
- [DGSEM core](https://github.com/flexi-framework/galaexi/blob/main/src/dg/dg.f90): discretization · Volume/surface integration, lifting, overintegration, and flux assembly · `src/dg/dg.f90`
- [Mortar interfaces](https://github.com/flexi-framework/galaexi/blob/main/src/mortar/mortar.f90): interface coupling · Nonconforming interface handling and mortar metrics · `src/mortar/mortar.f90`
- [FV fallback](https://github.com/flexi-framework/galaexi/blob/main/src/fv/fv.f90): robustness subsystem · Finite-volume reconstruction, switching, blending, and limiter path · `src/fv/fv.f90`
- [Time stepping](https://github.com/flexi-framework/galaexi/blob/main/src/timedisc/timedisc.f90): integration framework · Explicit/implicit time discretization driver and timestep control · `src/timedisc/timedisc.f90`
- [Implicit solve](https://github.com/flexi-framework/galaexi/blob/main/src/implicit/implicit.f90): solver support · Implicit predictor and residual coupling support · `src/implicit/implicit.f90`
- [Preconditioners](https://github.com/flexi-framework/galaexi/blob/main/src/precond/precond.f90): linear algebra · Jacobian-based and sparse ILU preconditioning · `src/precond/precond.f90`
- [HDF5 I/O](https://github.com/flexi-framework/galaexi/blob/main/src/io_hdf5/io_hdf5.f90): persistence layer · State, restart, and output exchange through HDF5 · `src/io_hdf5/io_hdf5.f90`
- [Physics models](https://github.com/flexi-framework/galaexi/blob/main/src/equations/navierstokes/equation.f90): equation family · Equation-specific fluxes, Riemann solvers, boundaries, and diagnostics · `src/equations/navierstokes/equation.f90`
- [Linear advection](https://github.com/flexi-framework/galaexi/blob/main/src/equations/linearscalaradvection/equation.f90): physics model · Scalar advection equation family and exact solutions · `src/equations/linearscalaradvection/equation.f90`
- [Navier–Stokes](https://github.com/flexi-framework/galaexi/blob/main/src/equations/navierstokes/equation.f90): physics model · Compressible flow model with thermodynamics and eddy viscosity options · `src/equations/navierstokes/equation.f90`
- [RANS-SA](https://github.com/flexi-framework/galaexi/blob/main/src/equations/rans_sa/equation.f90): physics model · Turbulence-aware Spalart–Allmaras equation family · `src/equations/rans_sa/equation.f90`

### Postprocessing

Separate Fortran analysis and visualization tools

- [Posti suite](https://github.com/flexi-framework/galaexi/blob/main/posti/CMakeLists.txt): analysis executables · Standalone Fortran postprocessing and transformation tools · `posti/CMakeLists.txt`
- [Visu plugin](https://github.com/flexi-framework/galaexi/blob/main/posti/visu/paraviewReader/Reader/visuReader.cxx): visualization plugin · ParaView reader and visualization bridge · `posti/visu/paraviewReader/Reader/visuReader.cxx`

### Cases & docs

Tutorials, ini inputs, and repository documentation

- [Tutorial cases](https://github.com/flexi-framework/galaexi/blob/main/tutorials/freestream/parameter_flexi.ini): input cases · Curated meshes and parameter files for canonical workflows · `tutorials/freestream/parameter_flexi.ini`

### Quality assurance

Regression and unit-test coverage

- [Regression suite](https://github.com/flexi-framework/galaexi/blob/main/regressioncheck/checks/run_basic/freestream_3D/parameter.ini): integration tests · End-to-end reference cases and golden outputs · `regressioncheck/checks/run_basic/freestream_3D/parameter.ini`
- [Unit tests](https://github.com/flexi-framework/galaexi/blob/main/unitTests/unittest.f90): kernel tests · Low-level numerical and input parsing checks · `unitTests/unittest.f90`

## Connections

- CMake → Solver core: builds · Configures the main solver targets
- CMake → Posti suite: builds · Configures postprocessing executables
- Solver core → Runtime infra: uses · Shares runtime services and preprocessing
- Solver core → Mesh & metrics: depends on · Loads and prepares computational meshes
- Solver core → Basis tools: uses · Transforms bases and prolongs data
- Solver core → DGSEM core: advances with · Applies DGSEM operators each step
- Solver core → Mortar interfaces: couples via · Handles nonconforming interfaces
- Solver core → FV fallback: falls back to · Switches or blends to FV for robustness
- Solver core → Time stepping: orchestrates · Coordinates the time-integration loop
- Time stepping → Implicit solve: optionally uses · Activates implicit workflow when needed
- Implicit solve → Preconditioners: accelerates with · Uses preconditioners for stiff solves
- Solver core → HDF5 I/O: reads/writes · Persists state, restart, and outputs
- Solver core → Physics models: instantiates · Selects a physics family at runtime
- Physics models → Linear advection: includes · Scalar advection specialization
- Physics models → Navier–Stokes: includes · Compressible flow specialization
- Physics models → RANS-SA: includes · Turbulence model specialization
- Navier–Stokes → FV fallback: supports · FV path is important for shocks and under-resolution
- Posti suite → HDF5 I/O: consumes · Reads solver HDF5 state and restart files
- Posti suite → Visu plugin: extends · Provides ParaView visualization integration
- Tutorial cases → Solver core: drives · Supplies canonical solver inputs and meshes
- Regression suite → Solver core: verifies · Exercises full solver workflows
- Regression suite → Posti suite: verifies · Checks postprocessing outputs and transforms
- Unit tests → Basis tools: checks · Validates basis and prolongation kernels
- Unit tests → DGSEM core: checks · Validates surface and volume integration kernels
- Unit tests → Runtime infra: checks · Covers input and utility helpers
