# venturi123/drlinfluids architecture

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

- Interactive diagram: https://gitdiagram.com/venturi123/drlinfluids
- Repository: https://github.com/venturi123/drlinfluids

## Overview

DRLinFluids couples reinforcement-learning agents to OpenFOAM simulations through framework-specific environment adapters. An agent supplies actions; the environment advances the CFD case, derives observations and rewards, and returns them for the next interaction. The package also provides OpenFOAM result parsing, dictionary-editing helpers, training logs, and parallel-environment support. The README documents scalable dictionary editing and parallel interfaces, but their internal wiring is not established by the sampled excerpts; those links are therefore omitted or marked unverified.

Main entry points: [`src/drlinfluids/environments/tianshou.py`](https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/environments/tianshou.py) (Tianshou environment), [`src/drlinfluids/environments/tensorforce.py`](https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/environments/tensorforce.py) (Tensorforce environment), [`src/drlinfluids/runner.py`](https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/runner.py) (CFD runner), [`src/drlinfluids/utils.py`](https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/utils.py) (CFD utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Agent interfaces"]
  node_gym["Gym API<br/>[gym.py]"]
  node_tf_env["Tensorforce environment<br/>[tensorforce.py]"]
  node_ts_env["Tianshou environment<br/>[tianshou.py]"]
  node_parallel["Parallel interfaces"]
end

subgraph group_simulation["CFD execution"]
  node_runner["CFD runner<br/>[runner.py]"]
  node_foam["OpenFOAM case"]
  node_dict_edit["Dictionary editor<br/>[wrapper.py]"]
end

subgraph group_analysis["Data and analysis"]
  node_utils["CFD utilities<br/>[utils.py]"]
  node_extractor["Result extractor<br/>[extractor.py]"]
end

subgraph group_support["Training support"]
  node_logger["Training logger<br/>[logger.py]"]
  node_trainer["Trainer namespace"]
end

node_agent(("RL agent"))

node_agent -.->|"sends actions"| node_tf_env
node_agent -.->|"sends actions"| node_ts_env
node_tf_env -->|"initializes case"| node_runner
node_ts_env -->|"runs simulation"| node_runner
node_runner -->|"runs solver"| node_foam
node_tf_env -->|"reads probe data"| node_utils
node_ts_env -->|"reads probe data"| node_utils
node_ts_env -->|"uses API"| node_gym
node_utils -->|"imports"| node_extractor
node_dict_edit -.->|"edits dictionaries"| node_foam
node_parallel -.->|"supports parallel use"| node_agent

click node_gym "https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/environments/gym.py"
click node_tf_env "https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/environments/tensorforce.py"
click node_ts_env "https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/environments/tianshou.py"
click node_parallel "https://github.com/venturi123/drlinfluids/tree/main/src/drlinfluids/environments"
click node_runner "https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/runner.py"
click node_dict_edit "https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/wrapper.py"
click node_utils "https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/utils.py"
click node_extractor "https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/extractor.py"
click node_logger "https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/logger.py"
click node_trainer "https://github.com/venturi123/drlinfluids/tree/main/src/drlinfluids/trainer"

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_gym,node_tf_env,node_ts_env,node_parallel toneBlue
class node_runner,node_foam,node_dict_edit toneAmber
class node_utils,node_extractor toneMint
class node_logger,node_trainer toneRose
class node_agent toneIndigo
```

## Components

### Agent interfaces

- [Gym API](https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/environments/gym.py): `src/drlinfluids/environments/gym.py`
- [Tensorforce environment](https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/environments/tensorforce.py): `src/drlinfluids/environments/tensorforce.py`
- [Tianshou environment](https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/environments/tianshou.py): `src/drlinfluids/environments/tianshou.py`
- [Parallel interfaces](https://github.com/venturi123/drlinfluids/tree/main/src/drlinfluids/environments): `src/drlinfluids/environments`

### CFD execution

- [CFD runner](https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/runner.py): `src/drlinfluids/runner.py`
- **OpenFOAM case**
- [Dictionary editor](https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/wrapper.py): `src/drlinfluids/wrapper.py`

### Data and analysis

- [CFD utilities](https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/utils.py): `src/drlinfluids/utils.py`
- [Result extractor](https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/extractor.py): `src/drlinfluids/extractor.py`

### Training support

- [Training logger](https://github.com/venturi123/drlinfluids/blob/main/src/drlinfluids/logger.py): `src/drlinfluids/logger.py`
- [Trainer namespace](https://github.com/venturi123/drlinfluids/tree/main/src/drlinfluids/trainer): `src/drlinfluids/trainer`

### Other components

- **RL agent**

## Connections

- RL agent → Tensorforce environment: sends actions (evidence: `README.md`)
- RL agent → Tianshou environment: sends actions (evidence: `README.md`)
- Tensorforce environment → CFD runner: initializes case (evidence: `src/drlinfluids/environments/tensorforce.py`)
- Tianshou environment → CFD runner: runs simulation (evidence: `src/drlinfluids/environments/tianshou.py`)
- CFD runner → OpenFOAM case: runs solver (evidence: `src/drlinfluids/runner.py`)
- Tensorforce environment → CFD utilities: reads probe data (evidence: `src/drlinfluids/environments/tensorforce.py`)
- Tianshou environment → CFD utilities: reads probe data (evidence: `src/drlinfluids/environments/tianshou.py`)
- Tianshou environment → Gym API: uses API (evidence: `src/drlinfluids/environments/tianshou.py`)
- CFD utilities → Result extractor: imports (evidence: `src/drlinfluids/utils.py`)
- Dictionary editor → OpenFOAM case: edits dictionaries (evidence: `README.md`)
- Parallel interfaces → RL agent: supports parallel use (evidence: `README.md`)
