# gustavoverneck/lattelab architecture

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

- Interactive diagram: https://gitdiagram.com/gustavoverneck/lattelab
- Repository: https://github.com/gustavoverneck/lattelab

## Overview

##### Main Components
a. Application Entry Point:
- Main binary (src/main.rs) which initializes and controls the simulation flow.

b. LBM Core:
- Detail the simulation engine components contained in src/core. Break these down as follows:
- kernels.rs: Represents the mathematical kernels or collision/streaming operations crucial to LBM.
- lbm.rs: Contains the core LBM simulation logic implementing the fluid dynamics algorithms.
- mod.rs: Acts as the organization module for all core functionality.
- That these modules implement the key computational routines and simulation steps.

c. Utilities:
- Src/utils as the repository for supportive functions:
- terminal_utils.rs: Responsible for any CLI/terminal interaction, debugging, or logging outputs.
- velocity.rs: Likely handles computations related to velocity vectors or fluid dynamics properties.
- mod.rs: Organizes the utility functions and makes integration easier with the core simulation.

d. Supporting Components:
- Examples: The examples directory illustrates different simulation setups (e.g., liddriven_cavity.rs, taylor_green_vortex.rs). Represent these as sample clients interacting with the LBM Core.
- Documentation & Licenses: Although not code components, these support understanding, maintenance, and contribution.

##### Establish Relationships and Data Flow
- Examples as separate client nodes that demonstrate integration with the core simulation engine.

##### Architectural Patterns and Design Principles
- Modularity: Separate the core simulation logic (LBM Core) from utility helper functions (Utilities). This separation exemplifies clean modular design.
- Potential use of the MVC (or a similar separation of concerns) pattern where the simulation data (model) is manipulated by the LBM core and then processed or output via utilities/plotting.
- Extensibility points especially in the LBM Core where additional kernels or simulation methods might be integrated in future updates.

##### Relevant Technology & Frameworks
- That the project is built in Rust and relies on Rust’s package management and build system (Cargo).
- Planned support for OpenCL for GPU acceleration even if not immediately visible in the code structure. This could be represented as an external service/component that the LBM core might interact with in subsequent versions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    main["src/main.rs"]:::app
    subgraph "LBM Core"
        lbk["kernels.rs"]:::core
        lbl["lbm.rs"]:::core
        lbm_mod["mod.rs (core)"]:::core
    end
    subgraph "Utilities"
        tu["terminal_utils.rs"]:::utils
        vel["velocity.rs"]:::utils
        util_mod["mod.rs (utils)"]:::utils
    end
    examples["Examples"]:::external
    plot["Plotting Scripts"]:::external
    docs["Documentation & Licensing"]:::external
    opencl["OpenCL (Future)"]:::external

    %% Primary Initialization Flow
    main -->|"init"| lbl
    main -->|"init"| tu
    main -->|"init"| vel
    main --> lbm_mod

    %% LBM Core internal connections
    lbl -->|"calls"| lbk

    %% Interaction between LBM Core and Utilities
    lbl -->|"uses"| tu
    lbl -->|"uses"| vel
    lbl <-->|"logging_and_data"| util_mod
    util_mod --> tu
    util_mod --> vel

    %% External interactions
    lbl -->|"outputs_to"| plot
    examples -->|"demonstrates"| lbl
    opencl -.->|"potential_integration"| lbl
    docs ---|"supports"| main
    docs ---|"supports"| lbl
    docs ---|"supports"| tu

    %% Styles
    classDef app fill:#f9f,stroke:#333,stroke-width:2px;
    classDef core fill:#ffcc00,stroke:#000,stroke-width:2px;
    classDef utils fill:#ccffcc,stroke:#000,stroke-width:2px;
    classDef external fill:#add8e6,stroke:#000,stroke-width:2px;

    %% Click Events
    click main "https://github.com/gustavoverneck/lattelab/blob/main/src/main.rs"
    click lbk "https://github.com/gustavoverneck/lattelab/blob/main/src/core/kernels.rs"
    click lbl "https://github.com/gustavoverneck/lattelab/blob/main/src/core/lbm.rs"
    click lbm_mod "https://github.com/gustavoverneck/lattelab/blob/main/src/core/mod.rs"
    click tu "https://github.com/gustavoverneck/lattelab/blob/main/src/utils/terminal_utils.rs"
    click vel "https://github.com/gustavoverneck/lattelab/blob/main/src/utils/velocity.rs"
    click util_mod "https://github.com/gustavoverneck/lattelab/blob/main/src/utils/mod.rs"
    click examples "https://github.com/gustavoverneck/lattelab/tree/main/examples"
    click plot "https://github.com/gustavoverneck/lattelab/tree/main/plotting_scripts"
    click docs "https://github.com/gustavoverneck/lattelab/tree/main/docs"
```
