# ivanzanardi/hypersonicfoam architecture

> Architecture diagram of the GitHub repository ivanzanardi/hypersonicfoam, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ivanzanardi/hypersonicfoam
- Repository: https://github.com/ivanzanardi/hypersonicfoam

## Overview

##### Project type and purpose
- HypersonicFOAM is an open-source, C++-based suite of high-performance computational fluid dynamics (CFD) solvers built on the OpenFOAM framework.
- It comprises two main modules:
- hyStrath – the core library of object-oriented CFD components (finiteVolume, turbulenceModels, functionObjects, fvOptions, hTCModels, mhdModel, thermophysicalModels) plus solvers (hyFoam, hy2Foam, hy2MhdFoam) and utilities.
- hyPoliMi – an extension with a specialized supersonic reacting solver (rhoCentralReactingFoam) and case-management scripts.

##### File structure
- Top-level directories:
- hyStrath/
– applications/solvers & utilities/mesh generation: C++ executables and mesh tools.
– compilers/: build orchestration scripts (Allwmake).
– src/: modular libraries (turbulenceModels, finiteVolume, functionObjects, fvOptions, hTCModels, mhdModel, thermophysicalModels).
– run/: example cases with system, constant, 0.bak subdirectories, gnuplot and ParaView files.
– install-*.sh: installer scripts.
- hyPoliMi/
– applications/solvers/compressible/rhoCentralReactingFoam/: source, headers, Makefiles.
– run/: simplified example cases (shockTube).
– install.sh, run scripts.

##### Extract README insights
- Dependencies: OpenFOAM (v1706 for hyStrath, v1912 for hyPoliMi).
- Build instructions: Allwmake and install.sh drive parallel compilation.
- Features: plugin schemes (Kurganov, electron-ion models, mixing rules), extensions for magnetohydrodynamics.

a. Main components
- External dependency: OpenFOAM core libraries and runtime.
- Build system: Bash scripts (install-*.sh, Allwmake, Makefiles per module).
- Core libraries (hyStrath/src modules):
- finiteVolume
- turbulenceModels
- functionObjects
- fvOptions
- hTCModels
- mhdModel
- thermophysicalModels
- Solver executables: hyFoam, hy2Foam, hy2MhdFoam, rhoCentralReactingFoam (hyPoliMi).
- Utilities and mesh generators.
- Case-management: run/ directories, sample input files (0, constant, system), post-processing scripts (gnuplot, ParaView).
b. Relationships and interactions
- Build scripts invoke Makefiles in each module → compile core libraries → link solver executables.
- Solvers link against OpenFOAM APIs and core libraries.
- User runs install.sh → deploys executables.
- run/ scripts call solver executables with case directories → produce output fields.
c. Architectural patterns/design principles
- Modular, plugin-style C++ directories: each physics model lives in its own folder, with its own Make/options.
- Object-oriented inheritance for boundary conditions (fvPatchFields), solvers, numerics.
- Separation of concerns: core CFD kernels (finiteVolume) vs. physics extensions (hTCModels, mhdModel) vs. utilities.
- Consistent build pattern: Allwmake orchestrates per-module Makefiles.
d. Key technologies/frameworks
- C++ (OO patterns, templates).
- OpenFOAM library.
- GNU Make, custom Make/options.
- Bash scripts for installation and case execution.
- Gnuplot, ParaView for post-processing.

##### Detail
- That hyStrath’s utilities mesh generators feed mesh data into solvers.
- Parallelization parameter (<np>) passed through install scripts into Makefiles.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Framework
    subgraph "External Framework"
        OF["OpenFOAM API"]:::external
    end

    %% Build System
    subgraph "Build System"
        Allwmake["Allwmake"]:::script
        installCFD["install-CFD.sh"]:::script
        installMHD["install-MHD.sh"]:::script
        installAll["install-all.sh"]:::script
        installPoliMi["install.sh (hyPoliMi)"]:::script
    end

    %% Core Libraries
    subgraph "Core Libraries"
        FV["finiteVolume"]:::core
        TM["turbulenceModels"]:::core
        FO["functionObjects"]:::core
        FVO["fvOptions"]:::core
        HTC["hTCModels"]:::core
        MHDLib["mhdModel"]:::core
        TP["thermophysicalModels"]:::core
    end

    %% Utilities
    subgraph "Utilities"
        blockMeshDG["blockMeshDG"]:::utility
        makeAxialMesh["makeAxialMesh"]:::utility
    end

    %% Solvers
    subgraph "Solvers"
        hy2Foam["hy2Foam"]:::exec
        hy2MhdFoam["hy2MhdFoam"]:::exec
        rhoCentral["rhoCentralReactingFoam"]:::exec
    end

    %% Case Management
    subgraph "Case Management"
        hyStrathRun["hyStrath run cases"]:::data
        shockTube["shockTube (hyPoliMi)"]:::data
    end

    %% Post-Processing
    subgraph "Post-Processing"
        Gnuplot["Gnuplot scripts"]:::post
        ParaView["ParaView macros"]:::post
    end

    %% Build Flow
    Allwmake -->|"invoke"| FV
    Allwmake -->|"invoke"| TM
    Allwmake -->|"invoke"| FO
    Allwmake -->|"invoke"| FVO
    Allwmake -->|"invoke"| HTC
    Allwmake -->|"invoke"| MHDLib
    Allwmake -->|"invoke"| TP
    installCFD -->|"calls Allwmake"| Allwmake
    installMHD -->|"calls Allwmake"| Allwmake
    installAll -->|"calls Allwmake"| Allwmake
    installPoliMi -->|"calls Makefiles"| rhoCentral

    %% Compile and Link
    FV -->|"compile"| hy2Foam
    TM -->|"compile"| hy2Foam
    FO -->|"compile"| hy2Foam
    FVO -->|"compile"| hy2Foam
    HTC -->|"compile"| hy2MhdFoam
    MHDLib -->|"compile"| hy2MhdFoam
    TP -->|"compile"| hy2Foam
    FV -->|"compile"| rhoCentral
    TM -->|"compile"| rhoCentral
    FO -->|"compile"| rhoCentral
    FVO -->|"compile"| rhoCentral
    HTC -->|"compile"| rhoCentral
    MHDLib -->|"compile"| rhoCentral
    TP -->|"compile"| rhoCentral
    OF -->|"link"| hy2Foam
    OF -->|"link"| hy2MhdFoam
    OF -->|"link"| rhoCentral

    %% Utilities to Solvers
    blockMeshDG -->|"generate mesh"| hy2Foam
    makeAxialMesh -->|"generate mesh"| hy2Foam

    %% Run Flow
    hy2Foam -->|"run"| hyStrathRun
    hy2MhdFoam -->|"run"| hyStrathRun
    rhoCentral -->|"run"| shockTube

    %% Post-Processing Flow
    hyStrathRun -->|"output data"| Gnuplot
    hyStrathRun -->|"output data"| ParaView
    shockTube -->|"output data"| Gnuplot
    shockTube -->|"output data"| ParaView

    %% Click Events
    click Allwmake "https://github.com/ivanzanardi/hypersonicfoam/tree/main/hyStrath/compilers/Allwmake"
    click installCFD "https://github.com/ivanzanardi/hypersonicfoam/blob/main/hyStrath/install-CFD.sh"
    click installMHD "https://github.com/ivanzanardi/hypersonicfoam/blob/main/hyStrath/install-MHD.sh"
    click installAll "https://github.com/ivanzanardi/hypersonicfoam/blob/main/hyStrath/install-all.sh"
    click installPoliMi "https://github.com/ivanzanardi/hypersonicfoam/blob/main/hyPoliMi/install.sh"
    click FV "https://github.com/ivanzanardi/hypersonicfoam/tree/main/hyStrath/src/finiteVolume"
    click TM "https://github.com/ivanzanardi/hypersonicfoam/tree/main/hyStrath/src/TurbulenceModels"
    click FO "https://github.com/ivanzanardi/hypersonicfoam/tree/main/hyStrath/src/functionObjects"
    click FVO "https://github.com/ivanzanardi/hypersonicfoam/tree/main/hyStrath/src/fvOptions"
    click HTC "https://github.com/ivanzanardi/hypersonicfoam/tree/main/hyStrath/src/hTCModels"
    click MHDLib "https://github.com/ivanzanardi/hypersonicfoam/tree/main/hyStrath/src/mhdModel"
    click TP "https://github.com/ivanzanardi/hypersonicfoam/tree/main/hyStrath/src/thermophysicalModels"
    click hy2Foam "https://github.com/ivanzanardi/hypersonicfoam/tree/main/hyStrath/applications/solvers/compressible/hy2Foam"
    click hy2MhdFoam "https://github.com/ivanzanardi/hypersonicfoam/tree/main/hyStrath/applications/solvers/compressible/hy2MhdFoam"
    click rhoCentral "https://github.com/ivanzanardi/hypersonicfoam/tree/main/hyPoliMi/applications/solvers/compressible/rhoCentralReactingFoam"
    click blockMeshDG "https://github.com/ivanzanardi/hypersonicfoam/tree/main/hyStrath/applications/utilities/mesh/generation/blockMeshDG"
    click makeAxialMesh "https://github.com/ivanzanardi/hypersonicfoam/tree/main/hyStrath/applications/utilities/mesh/generation/makeAxialMesh"
    click hyStrathRun "https://github.com/ivanzanardi/hypersonicfoam/tree/main/hyStrath/run"
    click shockTube "https://github.com/ivanzanardi/hypersonicfoam/tree/main/hyPoliMi/run/shockTube"

    %% Styles
    classDef external fill:#CCE5FF,stroke:#3399FF,color:#004080;
    classDef script fill:#FFF2CC,stroke:#D6B656,color:#999900;
    classDef core fill:#E2F0D9,stroke:#6AA84F,color:#38761D;
    classDef utility fill:#F4CCCC,stroke:#CC0000,color:#990000;
    classDef exec fill:#D9D2E9,stroke:#674EA7,color:#351C75,stroke-dasharray: 5 5;
    classDef data fill:#FFE6CC,stroke:#E69138,color:#994C00;
    classDef post fill:#D0E0E3,stroke:#45818E,color:#134F5C;
```
