# sp-droid/fluidlearn architecture

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

- Interactive diagram: https://gitdiagram.com/sp-droid/fluidlearn
- Repository: https://github.com/sp-droid/fluidlearn

## Overview

1. **Project shape**
   FluidLearn is a Python package centered on CFD data handling and visualization. The runtime package lives under `fluidlearn/`, while `data/`, `models/`, `notebooks/`, and `results/` are workspace directories for inputs, artifacts, experiments, and outputs.

2. **Primary entry point**
   `init.py` is the user-facing launcher. The README indicates it starts an interactive CLI rather than a batch pipeline, so the top-level control flow is menu-driven instead of service-based or notebook-driven.

3. **CLI orchestration layer**
   `fluidlearn/cli.py` is the main coordinator. It uses an interactive menu system (the README says InquirerPy) to route the user into workflows such as visualization, with a loop-back behavior after each action. This is the main boundary between human interaction and the underlying package functions.

4. **Data ingestion and dataset layout**
   `fluidlearn/data/dataloader.py` is the data-access boundary for HDF5-based CFD datasets. The repository’s on-disk format is explicit: `data/01_raw/<dataset>/` contains `mesh.h5`, `constants.json`, and per-case `.h5` files. This suggests a split between shared mesh/metadata and case-specific time-varying fields.

5. **Raw case repository vs processed data**
   `data/00_cases/` is a manual case-execution area for OpenFOAM-style simulations, while `data/01_raw/` holds framework-consumable raw datasets. That separation implies the repository supports two phases: external simulation generation first, then Python-side ingestion/processing second.

6. **Visualization subsystem**
   Visualization is a notable subsystem under `fluidlearn/vis/` plus `fluidlearn/visualization.py`. The `vis` package includes GUI-oriented modules (`GUIunstructured.py`, `UIpanel.py`, `mesh_highlighter.py`), indicating interactive inspection of unstructured CFD meshes rather than only static plotting. The `visualization.py` module appears to be the CLI-accessible raw visualization entrypoint.

7. **Numerical and geometry utilities**
   `fluidlearn/utils/` contains shared computation helpers: `gradient.py` for field derivatives, `topology.py` for mesh/connectivity-related logic, `colormap.py` for visualization styling, and `misc.py` for general support. These utilities likely sit below both data processing and visualization, providing reusable domain math and presentation helpers.

8. **Modeling layer**
   `models/` is present as a repository-level artifact directory rather than a code package. Combined with the README’s “training” menu placeholder, this suggests model training/inference is planned or partially externalized, but the current repo emphasis is on data and visualization infrastructure.

9. **Experiment and notebook boundary**
   `fluidlearn/main.ipynb` and the `notebooks/` directory indicate exploratory analysis and prototyping happen in notebooks, separate from the CLI and package code. This is a common boundary in scientific Python projects: reproducible package logic in `fluidlearn/`, exploratory workflows in notebooks.

10. **Configuration and packaging**
   `pyproject.toml`, `requirements.txt`, and editable install support (`pip install -e .`) show the project is a standard Python package, not a service deployment. The README’s CUDA/Torch install notes indicate the computational stack expects GPU-capable PyTorch for downstream ML work.

11. **External scientific tooling**
   OpenFOAM is the key external simulation system implied by `data/00_cases/README.md`. That makes FluidLearn a bridge between CFD solver output and Python-based analysis/visualization rather than the simulator itself.

12. **Artifact/output boundaries**
   `results/` is reserved for generated outputs, while `docs/` and `.gitkeep` files suggest scaffolding for future documentation and empty tracked directories. In an architecture diagram, these should be shown as non-runtime storage zones rather than active components.

13. **Overall data flow**
   The main flow is: CFD case generation in `data/00_cases/` or external OpenFOAM runs → raw HDF5/metadata under `data/01_raw/` → loading through `fluidlearn/data/dataloader.py` → processing/math via `fluidlearn/utils/` → visualization through `fluidlearn/vis/` or `fluidlearn/visualization.py`, with CLI orchestration from `init.py`/`fluidlearn/cli.py`.

14. **Notable repo mismatch**
   The README references a `fluidlearn/visualize.py` processed-visualization module, but the file tree does not include it. For an accurate diagram, treat “processed visualization” as intended/mentioned functionality, but only `visualization.py` and the `vis/` package are present in the current codebase.

Main entry points: [`fluidlearn/cli.py`](https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/cli.py) (CLI), [`fluidlearn/vis/GUIunstructured.py`](https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/vis/GUIunstructured.py) (GUI view), [`fluidlearn/data/dataloader.py`](https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/data/dataloader.py) (Loader), [`fluidlearn/visualization.py`](https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/visualization.py) (Viz entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_runtime["Runtime package"]
  node_node_init["Launcher<br/>entry script<br/>[init.py]"]
  node_node_cli["CLI<br/>menu orchestrator<br/>[cli.py]"]
  node_node_viz_entry["Viz entry<br/>visualization entrypoint<br/>[visualization.py]"]
  node_node_dataloader[("Loader<br/>HDF5 access<br/>[dataloader.py]")]
  node_node_vis_gui["GUI view<br/>interactive visualization<br/>[GUIunstructured.py]"]
  node_node_vis_panel["Panel UI<br/>controls panel<br/>[UIpanel.py]"]
  node_node_vis_highlighter["Mesh highlight<br/>selection helper"]
  node_node_utils_gradient["Gradients<br/>field math<br/>[gradient.py]"]
  node_node_utils_topology["Topology<br/>mesh logic<br/>[topology.py]"]
  node_node_utils_colormap["Colormaps<br/>visual style<br/>[colormap.py]"]
  node_node_utils_misc["Shared utils<br/>support helpers<br/>[misc.py]"]
end

subgraph group_group_workspace["Workspace data"]
  node_node_raw_cases[("Case area<br/>simulation workspace")]
  node_node_raw_datasets[("Raw data<br/>dataset store")]
  node_node_models[("Models<br/>artifact store")]
  node_node_notebooks["Notebooks<br/>exploration space"]
  node_node_results[("Results<br/>output store")]
end

subgraph group_group_external["External tooling"]
  node_node_openfoam{{"OpenFOAM<br/>external simulator"}}
end

subgraph group_group_meta["Project scaffolding"]
  node_node_pyproject["Packaging<br/>project config<br/>[pyproject.toml]"]
  node_node_readme["README<br/>project docs<br/>[README.md]"]
end

node_node_init -->|"starts"| node_node_cli
node_node_cli -->|"opens"| node_node_viz_entry
node_node_viz_entry -->|"loads"| node_node_dataloader
node_node_cli -.->|"routes"| node_node_dataloader
node_node_dataloader -->|"uses"| node_node_utils_topology
node_node_dataloader -.->|"uses"| node_node_utils_gradient
node_node_viz_entry -->|"renders"| node_node_vis_gui
node_node_vis_gui -->|"contains"| node_node_vis_panel
node_node_vis_gui -->|"uses"| node_node_vis_highlighter
node_node_vis_gui -->|"uses"| node_node_utils_colormap
node_node_vis_gui -.->|"uses"| node_node_utils_topology
node_node_cli -.->|"shares"| node_node_utils_misc
node_node_raw_cases -->|"generated by"| node_node_openfoam
node_node_openfoam -->|"exports"| node_node_raw_datasets
node_node_raw_datasets -->|"ingested by"| node_node_dataloader
node_node_models -.->|"future use"| node_node_cli
node_node_notebooks -.->|"explores"| node_node_raw_datasets
node_node_results -.->|"receives"| node_node_cli
node_node_pyproject -.->|"packages"| node_node_cli
node_node_readme -.->|"documents"| node_node_cli

click node_node_init "https://github.com/sp-droid/fluidlearn/blob/main/init.py"
click node_node_cli "https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/cli.py"
click node_node_viz_entry "https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/visualization.py"
click node_node_dataloader "https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/data/dataloader.py"
click node_node_vis_gui "https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/vis/GUIunstructured.py"
click node_node_vis_panel "https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/vis/UIpanel.py"
click node_node_vis_highlighter "https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/vis/mesh_highlighter.py"
click node_node_utils_gradient "https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/utils/gradient.py"
click node_node_utils_topology "https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/utils/topology.py"
click node_node_utils_colormap "https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/utils/colormap.py"
click node_node_utils_misc "https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/utils/misc.py"
click node_node_raw_cases "https://github.com/sp-droid/fluidlearn/tree/main/data/00_cases"
click node_node_raw_datasets "https://github.com/sp-droid/fluidlearn/tree/main/data/01_raw"
click node_node_models "https://github.com/sp-droid/fluidlearn/tree/main/models"
click node_node_notebooks "https://github.com/sp-droid/fluidlearn/tree/main/notebooks"
click node_node_results "https://github.com/sp-droid/fluidlearn/tree/main/results"
click node_node_pyproject "https://github.com/sp-droid/fluidlearn/blob/main/pyproject.toml"
click node_node_readme "https://github.com/sp-droid/fluidlearn/blob/main/README.md"

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_node_init,node_node_cli,node_node_viz_entry,node_node_dataloader,node_node_vis_gui,node_node_vis_panel,node_node_vis_highlighter,node_node_utils_gradient,node_node_utils_topology,node_node_utils_colormap,node_node_utils_misc toneBlue
class node_node_raw_cases,node_node_raw_datasets,node_node_models,node_node_notebooks,node_node_results toneAmber
class node_node_openfoam toneMint
class node_node_pyproject,node_node_readme toneRose
```

## Components

### Runtime package

Installable Python code that coordinates CLI, data access, utilities, and visualization.

- [Launcher](https://github.com/sp-droid/fluidlearn/blob/main/init.py): entry script · User-facing entry point that starts the interactive workflow. · `init.py`
- [CLI](https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/cli.py): menu orchestrator · Interactive coordinator that routes users into package workflows. · `fluidlearn/cli.py`
- [Viz entry](https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/visualization.py): visualization entrypoint · CLI-accessible visualization module for loading and inspecting data. · `fluidlearn/visualization.py`
- [Loader](https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/data/dataloader.py): HDF5 access · Boundary for reading CFD datasets from raw HDF5 and metadata files. · `fluidlearn/data/dataloader.py`
- [GUI view](https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/vis/GUIunstructured.py): interactive visualization · Unstructured-mesh visualization interface and interaction layer. · `fluidlearn/vis/GUIunstructured.py`
- [Panel UI](https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/vis/UIpanel.py): controls panel · GUI controls and user interaction widgets for visualization. · `fluidlearn/vis/UIpanel.py`
- [Mesh highlight](https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/vis/mesh_highlighter.py): selection helper · Highlights and selection logic for mesh elements in the GUI. · `fluidlearn/vis/mesh_highlighter.py`
- [Gradients](https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/utils/gradient.py): field math · Derivative and gradient computations for CFD fields. · `fluidlearn/utils/gradient.py`
- [Topology](https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/utils/topology.py): mesh logic · Connectivity and mesh-structure helpers. · `fluidlearn/utils/topology.py`
- [Colormaps](https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/utils/colormap.py): visual style · Color mapping utilities for plots and mesh rendering. · `fluidlearn/utils/colormap.py`
- [Shared utils](https://github.com/sp-droid/fluidlearn/blob/main/fluidlearn/utils/misc.py): support helpers · General-purpose helpers used across the package. · `fluidlearn/utils/misc.py`

### Workspace data

Repository directories for simulation cases, raw datasets, notebooks, models, and generated results.

- [Case area](https://github.com/sp-droid/fluidlearn/tree/main/data/00_cases): simulation workspace · Manual OpenFOAM-style case repository used to produce simulations. · `data/00_cases`
- [Raw data](https://github.com/sp-droid/fluidlearn/tree/main/data/01_raw): dataset store · Framework-consumable HDF5 datasets with mesh, constants, and case files. · `data/01_raw`
- [Models](https://github.com/sp-droid/fluidlearn/tree/main/models): artifact store · Repository-level model artifacts and future training outputs. · `models`
- [Notebooks](https://github.com/sp-droid/fluidlearn/tree/main/notebooks): exploration space · Interactive analysis and prototyping notebooks. · `notebooks`
- [Results](https://github.com/sp-droid/fluidlearn/tree/main/results): output store · Generated outputs and experiment results. · `results`

### External tooling

Outside systems used to generate CFD cases and supply data to the package.

- **OpenFOAM**: external simulator · Upstream CFD solver used to generate case data.

### Project scaffolding

Packaging and documentation files that frame the repo but are not runtime subsystems.

- [Packaging](https://github.com/sp-droid/fluidlearn/blob/main/pyproject.toml): project config · Python packaging and dependency definition. · `pyproject.toml`
- [README](https://github.com/sp-droid/fluidlearn/blob/main/README.md): project docs · High-level project description and usage notes. · `README.md`

## Connections

- Launcher → CLI: starts · Launcher enters the interactive CLI loop.
- CLI → Viz entry: opens · Menu routes into visualization workflows.
- Viz entry → Loader: loads · Visualization consumes datasets through the data boundary.
- CLI → Loader: routes · CLI workflows can access dataset loading directly.
- Loader → Topology: uses · Loader relies on mesh/connectivity helpers.
- Loader → Gradients: uses · Field processing can depend on gradient logic.
- Viz entry → GUI view: renders · Visualization entry drives the interactive GUI.
- GUI view → Panel UI: contains · GUI includes control-panel interactions.
- GUI view → Mesh highlight: uses · GUI uses mesh highlighting for selection.
- GUI view → Colormaps: uses · Rendering uses colormap helpers.
- GUI view → Topology: uses · Interactive viewing depends on mesh topology logic.
- CLI → Shared utils: shares · Common helpers support multiple workflows.
- Case area → OpenFOAM: generated by · Simulation cases are produced externally by the CFD solver.
- OpenFOAM → Raw data: exports · Simulation output is converted into raw datasets.
- Raw data → Loader: ingested by · Raw HDF5 datasets are read into the package.
- Models → CLI: future use · Model artifacts are expected to participate in planned training workflows.
- Notebooks → Raw data: explores · Notebooks are used to inspect and prototype on datasets.
- Results → CLI: receives · CLI-driven workflows emit outputs to the results area.
- Packaging → CLI: packages · Project configuration defines the installable Python package.
- README → CLI: documents · README describes the interactive CLI-centered workflow.
