# gladk/palabos architecture

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

- Interactive diagram: https://gitdiagram.com/gladk/palabos
- Repository: https://github.com/gladk/palabos

## Overview

#### Purpose and entry points
Palabos is a C++ lattice-Boltzmann CFD framework for 2D/3D simulation, not a single deployable application. Users build the library and write/run scenario executables. Primary public aggregation headers are `src/palabos2D.h` and `src/palabos3D.h`; representative executable entry points are `examples/showCases/cavity3d/cavity3d.cpp` and `examples/showCases/generalExternalFlow/generalExternalFlow.cpp`.

#### Build, runtime, and dependencies
The native runtime is C++ with serial and MPI-distributed execution. Top-level build entry points are `CMakeLists.txt` and `SConstruct`, with source-library build definition in `src/CMakeLists.txt`. Bundled dependencies include Eigen linear algebra (`externalLibraries/Eigen3/Core`), TinyXML (`externalLibraries/tinyxml/tinyxml.h`), nanoflann, and sitmo PRNG. MPI coordination is centralized by `src/parallelism/mpiManager.h`; MPI-aware output is in `src/io/mpiParallelIO.cpp`.

#### Core lattice model and dynamics
The core object model represents cells, blocks, lattice state, dynamics, and statistics. `src/core/cell.h`, `src/core/dynamics.h`, and `src/core/blockLatticeBase3D.h` define the foundational abstractions. Collision/streaming math and descriptors are template-oriented in `src/latticeBoltzmann/dynamicsTemplates3D.h`, `src/latticeBoltzmann/latticeTemplates3D.h`, and `src/latticeBoltzmann/mrtLattices.h`. Basic BGK-like, thermal, and forced models build on this in `src/basicDynamics/isoThermalDynamics.h` and `src/basicDynamics/externalForceDynamics.h`.

#### Domain decomposition and parallel execution
Atomic blocks hold local lattice/data-field regions; multi-block layers assemble and manage distributed sparse domains. Key boundaries are `src/atomicBlock/atomicBlock3D.h`, `src/multiBlock/multiBlockLattice3D.h`, and `src/multiBlock/multiBlockManagement3D.h`. During each simulation step, halo/non-local transfers and reductions cross this boundary through `src/multiBlock/nonLocalTransfer3D.h` and `src/parallelism/parallelBlockCommunicator3D.h`; parallel lattice wrappers are in `src/parallelism/parallelMultiBlockLattice3D.h`.

#### Simulation composition: boundaries, physics, geometry
Applications configure a lattice, assign dynamics, impose boundaries, then repeatedly execute time steps and processors. Boundary implementations are separated from bulk dynamics in `src/boundaryCondition/boundaryCondition3D.h`, `src/boundaryCondition/bounceBackModels3D.h`, and `src/boundaryCondition/zouHeBoundary3D.h`. Extended models include turbulence/non-Newtonian/advection-diffusion in `src/complexDynamics/smagorinskyDynamics.h` and `src/complexDynamics/carreauDynamics.h`, plus multiphase/free-surface coupling in `src/multiPhysics/shanChenProcessor3D.h` and `src/multiPhysics/freeSurfaceModel3D.h`. STL/triangle geometry is converted into off-lattice boundary handling via `src/offLattice/triangleSet.h`, `src/offLattice/voxelizer.h`, and `src/offLattice/offLatticeBoundaryCondition3D.h`.

#### Processing, analysis, and persistence
Functional/wrapper APIs apply initialization and analysis over fields/lattices: `src/dataProcessors/dataInitializerWrapper3D.h`, `src/dataProcessors/dataAnalysisWrapper3D.h`, and `src/atomicBlock/dataProcessorWrapper3D.h`. Results and checkpoints cross into file formats through `src/io/serializerIO_3D.h`, `src/io/multiBlockWriter3D.h`, and `src/io/vtkDataOutput.h`. XML input is mediated through `src/libraryInterfaces/TINYXML_xmlIO.h`, as used by XML-configured example scenarios.

#### Adaptive and language integration layers
Multi-resolution simulation is a distinct orchestration layer over multi-block lattices: `src/multiGrid/multiGridLattice3D.h`, `src/multiGrid/gridRefinement3D.h`, and octree-oriented `src/gridRefinement/octreeGridGenerator.h`. The repository also ships Jlabos: Java APIs backed by SWIG/C++ wrappers, with public Java lattice classes in `jlabos/src/jlabos/MultiBlockLattice3D.java`, native binding interfaces in `jlabos/src/swig/javaInterface3D.i`, and wrapper implementations in `jlabos/src/plbWrapper/lattice/multiBlockGenerator3D.cpp`.

Main entry points: [`src/multiBlock/multiBlockLattice3D.h`](https://github.com/gladk/palabos/blob/master/src/multiBlock/multiBlockLattice3D.h) (Multi-block domain), [`examples/showCases/cavity3d/cavity3d.cpp`](https://github.com/gladk/palabos/blob/master/examples/showCases/cavity3d/cavity3d.cpp) (Scenario executables), [`src/CMakeLists.txt`](https://github.com/gladk/palabos/blob/master/src/CMakeLists.txt) (Source library build), [`src/palabos3D.h`](https://github.com/gladk/palabos/blob/master/src/palabos3D.h) (2D/3D public headers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Build &amp; Dependencies"]
  node_build_systems{{"CMake &amp; SCons<br/>build entry points<br/>[CMakeLists.txt]"}}
  node_source_build["Source library build<br/>CMake definition<br/>[CMakeLists.txt]"]
  node_bundled_dependencies["Bundled dependencies<br/>Eigen, TinyXML, utilities"]
end

subgraph group_core["Lattice Core"]
  node_public_api["2D/3D public headers<br/>library API<br/>[palabos3D.h]"]
  node_lattice_abstractions["Cell, dynamics &amp; lattice<br/>core object model"]
  node_lattice_math["Descriptors &amp; lattice math<br/>template kernels"]
  node_basic_dynamics["Basic dynamics<br/>BGK, thermal, forcing"]
end

subgraph group_distributed["Distributed Execution"]
  node_atomic_blocks["Atomic blocks<br/>local lattice regions<br/>[atomicBlock3D.h]"]
  node_multiblock_domain["Multi-block domain<br/>distributed sparse lattice"]
  node_domain_management["Domain management<br/>block decomposition"]
  node_communication["Halo exchange &amp; reductions<br/>parallel communication"]
  node_mpi_runtime["MPI runtime<br/>execution coordination<br/>[mpiManager.h]"]
end

subgraph group_simulation["Simulation Features"]
  node_boundaries["Boundary conditions<br/>lattice boundaries"]
  node_advanced_physics["Advanced physics<br/>complex and multiphysics models"]
  node_off_lattice["Off-lattice geometry<br/>STL voxel boundaries"]
  node_processors["Initialization &amp; analysis<br/>data processor wrappers"]
  node_multigrid["Adaptive multi-grid<br/>refinement orchestration"]
end

subgraph group_integration["I/O &amp; Language Integration"]
  node_persistence["Output &amp; checkpoints<br/>serialization and VTK"]
  node_xml_input["XML input<br/>TinyXML interface<br/>[TINYXML_xmlIO.h]"]
  node_jlabos["Jlabos Java bindings<br/>SWIG Java API<br/>[javaInterface3D.i]"]
end

node_scenario_examples(("Scenario executables<br/>C++ example entry points<br/>[cavity3d.cpp]"))

node_build_systems -->|"configures"| node_source_build
node_source_build -->|"builds"| node_public_api
node_source_build -->|"uses"| node_bundled_dependencies
node_public_api -->|"aggregates"| node_lattice_abstractions
node_lattice_abstractions -->|"uses kernels"| node_lattice_math
node_lattice_math -->|"implements"| node_basic_dynamics
node_basic_dynamics -->|"assigned to"| node_atomic_blocks
node_atomic_blocks -->|"compose"| node_multiblock_domain
node_domain_management -->|"partitions"| node_multiblock_domain
node_multiblock_domain -->|"exchanges halos"| node_communication
node_communication -->|"coordinates through"| node_mpi_runtime
node_multiblock_domain -->|"applies"| node_boundaries
node_multiblock_domain -->|"couples"| node_advanced_physics
node_off_lattice -->|"creates geometry-aware"| node_boundaries
node_multiblock_domain -->|"runs processors"| node_processors
node_multiblock_domain -->|"refines"| node_multigrid
node_processors -->|"produces results"| node_persistence
node_multiblock_domain -->|"serializes"| node_persistence
node_xml_input -->|"uses TinyXML"| node_bundled_dependencies
node_jlabos -->|"wraps"| node_multiblock_domain
node_scenario_examples -->|"includes"| node_public_api
node_scenario_examples -->|"configures and steps"| node_multiblock_domain
node_scenario_examples -.->|"may load configuration"| node_xml_input

click node_build_systems "https://github.com/gladk/palabos/blob/master/CMakeLists.txt"
click node_source_build "https://github.com/gladk/palabos/blob/master/src/CMakeLists.txt"
click node_bundled_dependencies "https://github.com/gladk/palabos/blob/master/externalLibraries/Eigen3/Core"
click node_public_api "https://github.com/gladk/palabos/blob/master/src/palabos3D.h"
click node_lattice_abstractions "https://github.com/gladk/palabos/blob/master/src/core/blockLatticeBase3D.h"
click node_lattice_math "https://github.com/gladk/palabos/blob/master/src/latticeBoltzmann/dynamicsTemplates3D.h"
click node_basic_dynamics "https://github.com/gladk/palabos/blob/master/src/basicDynamics/isoThermalDynamics.h"
click node_atomic_blocks "https://github.com/gladk/palabos/blob/master/src/atomicBlock/atomicBlock3D.h"
click node_multiblock_domain "https://github.com/gladk/palabos/blob/master/src/multiBlock/multiBlockLattice3D.h"
click node_domain_management "https://github.com/gladk/palabos/blob/master/src/multiBlock/multiBlockManagement3D.h"
click node_communication "https://github.com/gladk/palabos/blob/master/src/parallelism/parallelBlockCommunicator3D.h"
click node_mpi_runtime "https://github.com/gladk/palabos/blob/master/src/parallelism/mpiManager.h"
click node_boundaries "https://github.com/gladk/palabos/blob/master/src/boundaryCondition/boundaryCondition3D.h"
click node_advanced_physics "https://github.com/gladk/palabos/blob/master/src/multiPhysics/shanChenProcessor3D.h"
click node_off_lattice "https://github.com/gladk/palabos/blob/master/src/offLattice/offLatticeBoundaryCondition3D.h"
click node_processors "https://github.com/gladk/palabos/blob/master/src/dataProcessors/dataAnalysisWrapper3D.h"
click node_multigrid "https://github.com/gladk/palabos/blob/master/src/multiGrid/multiGridLattice3D.h"
click node_persistence "https://github.com/gladk/palabos/blob/master/src/io/multiBlockWriter3D.h"
click node_xml_input "https://github.com/gladk/palabos/blob/master/src/libraryInterfaces/TINYXML_xmlIO.h"
click node_jlabos "https://github.com/gladk/palabos/blob/master/jlabos/src/swig/javaInterface3D.i"
click node_scenario_examples "https://github.com/gladk/palabos/blob/master/examples/showCases/cavity3d/cavity3d.cpp"

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_build_systems,node_source_build,node_bundled_dependencies toneBlue
class node_public_api,node_lattice_abstractions,node_lattice_math,node_basic_dynamics toneAmber
class node_atomic_blocks,node_multiblock_domain,node_domain_management,node_communication,node_mpi_runtime toneMint
class node_boundaries,node_advanced_physics,node_off_lattice,node_processors,node_multigrid toneRose
class node_persistence,node_xml_input,node_jlabos toneIndigo
class node_scenario_examples toneNeutral
```

## Components

### Build & Dependencies

- [CMake & SCons](https://github.com/gladk/palabos/blob/master/CMakeLists.txt): build entry points · Builds the C++ library and scenario executables. · `CMakeLists.txt`
- [Source library build](https://github.com/gladk/palabos/blob/master/src/CMakeLists.txt): CMake definition · `src/CMakeLists.txt`
- [Bundled dependencies](https://github.com/gladk/palabos/blob/master/externalLibraries/Eigen3/Core): Eigen, TinyXML, utilities · `externalLibraries/Eigen3/Core`

### Lattice Core

- [2D/3D public headers](https://github.com/gladk/palabos/blob/master/src/palabos3D.h): library API · `src/palabos3D.h`
- [Cell, dynamics & lattice](https://github.com/gladk/palabos/blob/master/src/core/blockLatticeBase3D.h): core object model · `src/core/blockLatticeBase3D.h`
- [Descriptors & lattice math](https://github.com/gladk/palabos/blob/master/src/latticeBoltzmann/dynamicsTemplates3D.h): template kernels · `src/latticeBoltzmann/dynamicsTemplates3D.h`
- [Basic dynamics](https://github.com/gladk/palabos/blob/master/src/basicDynamics/isoThermalDynamics.h): BGK, thermal, forcing · `src/basicDynamics/isoThermalDynamics.h`

### Distributed Execution

- [Atomic blocks](https://github.com/gladk/palabos/blob/master/src/atomicBlock/atomicBlock3D.h): local lattice regions · `src/atomicBlock/atomicBlock3D.h`
- [Multi-block domain](https://github.com/gladk/palabos/blob/master/src/multiBlock/multiBlockLattice3D.h): distributed sparse lattice · `src/multiBlock/multiBlockLattice3D.h`
- [Domain management](https://github.com/gladk/palabos/blob/master/src/multiBlock/multiBlockManagement3D.h): block decomposition · `src/multiBlock/multiBlockManagement3D.h`
- [Halo exchange & reductions](https://github.com/gladk/palabos/blob/master/src/parallelism/parallelBlockCommunicator3D.h): parallel communication · `src/parallelism/parallelBlockCommunicator3D.h`
- [MPI runtime](https://github.com/gladk/palabos/blob/master/src/parallelism/mpiManager.h): execution coordination · `src/parallelism/mpiManager.h`

### Simulation Features

- [Boundary conditions](https://github.com/gladk/palabos/blob/master/src/boundaryCondition/boundaryCondition3D.h): lattice boundaries · `src/boundaryCondition/boundaryCondition3D.h`
- [Advanced physics](https://github.com/gladk/palabos/blob/master/src/multiPhysics/shanChenProcessor3D.h): complex and multiphysics models · Turbulence, non-Newtonian, multiphase, and free-surface models. · `src/multiPhysics/shanChenProcessor3D.h`
- [Off-lattice geometry](https://github.com/gladk/palabos/blob/master/src/offLattice/offLatticeBoundaryCondition3D.h): STL voxel boundaries · `src/offLattice/offLatticeBoundaryCondition3D.h`
- [Initialization & analysis](https://github.com/gladk/palabos/blob/master/src/dataProcessors/dataAnalysisWrapper3D.h): data processor wrappers · `src/dataProcessors/dataAnalysisWrapper3D.h`
- [Adaptive multi-grid](https://github.com/gladk/palabos/blob/master/src/multiGrid/multiGridLattice3D.h): refinement orchestration · `src/multiGrid/multiGridLattice3D.h`

### I/O & Language Integration

- [Output & checkpoints](https://github.com/gladk/palabos/blob/master/src/io/multiBlockWriter3D.h): serialization and VTK · `src/io/multiBlockWriter3D.h`
- [XML input](https://github.com/gladk/palabos/blob/master/src/libraryInterfaces/TINYXML_xmlIO.h): TinyXML interface · `src/libraryInterfaces/TINYXML_xmlIO.h`
- [Jlabos Java bindings](https://github.com/gladk/palabos/blob/master/jlabos/src/swig/javaInterface3D.i): SWIG Java API · Java lattice APIs backed by native C++ wrappers. · `jlabos/src/swig/javaInterface3D.i`

### Other components

- [Scenario executables](https://github.com/gladk/palabos/blob/master/examples/showCases/cavity3d/cavity3d.cpp): C++ example entry points · `examples/showCases/cavity3d/cavity3d.cpp`

## Connections

- CMake & SCons → Source library build: configures
- Source library build → 2D/3D public headers: builds
- Source library build → Bundled dependencies: uses
- 2D/3D public headers → Cell, dynamics & lattice: aggregates
- Cell, dynamics & lattice → Descriptors & lattice math: uses kernels
- Descriptors & lattice math → Basic dynamics: implements
- Basic dynamics → Atomic blocks: assigned to
- Atomic blocks → Multi-block domain: compose
- Domain management → Multi-block domain: partitions
- Multi-block domain → Halo exchange & reductions: exchanges halos
- Halo exchange & reductions → MPI runtime: coordinates through
- Multi-block domain → Boundary conditions: applies
- Multi-block domain → Advanced physics: couples
- Off-lattice geometry → Boundary conditions: creates geometry-aware
- Multi-block domain → Initialization & analysis: runs processors
- Multi-block domain → Adaptive multi-grid: refines
- Initialization & analysis → Output & checkpoints: produces results
- Multi-block domain → Output & checkpoints: serializes
- XML input → Bundled dependencies: uses TinyXML
- Jlabos Java bindings → Multi-block domain: wraps
- Scenario executables → 2D/3D public headers: includes
- Scenario executables → Multi-block domain: configures and steps
- Scenario executables → XML input: may load configuration
