# giftbte-developer/giftbte architecture

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

- Interactive diagram: https://gitdiagram.com/giftbte-developer/giftbte
- Repository: https://github.com/giftbte-developer/giftbte

## Overview

Based on your project’s file structure and README, GiftBTE is a high-performance, MPI-parallelized simulation tool written in C++ that numerically solves the phonon Boltzmann transport equation for submicron heat conduction. The design emphasizes modularity with clearly separated components for different physical models (steady-state vs. transient, Fourier-based solvers, etc.), a rich set of example cases (located under bin/examples), a detailed materials database, and interfaces to external mesh generators and simulation packages.

##### Main Components
- Core Solver Modules:
- Simulation Engines: modules like BTEAngle, BTEBand, BTEBoundaryCondition, BTEMesh, StaticBTESynthetic, StaticFourier, TransientBTE, and TransientFourier.
- Utility components (e.g., utility functions in src/utility and includes/utility).
- Input/Preprocessing:
- Material data and mesh generators (see “bin/mesh_generator”, “bin/input”, “bin/materials”, and “includes” directories).
- Configuration and control files used by various examples (located in bin/examples/…/input folders).
- External Interfaces:
- Interaction with external tools such as ShengBTE, ALAMODE, COMSOL, GMSH, and Paraview.
- MPI parallelization interface (the project expects an MPI-ready environment).
- Build & Deployment:
- CMakeLists.txt and cmake-modules folder designate build configuration.
- Binary output folder (“bin”) with example executables.
- Post-processing:
- Scripts and MATLAB/plotting utilities (e.g., plot_temperature.m, plot_heatflux_contour.m) for visualizing simulation results.

##### Relationships and Interactions
- Flow from Input to Simulation:
- Input components (control files, geometry, phonon properties, material databases) feed into mesh generation and preprocessing.
- The preprocessor passes data to the core solver modules that solve the phonon BTE.
- Solver Execution:
- External Dependencies:
- Connectors linking GiftBTE with external simulation/visualization tools and mesh generators.
- Build and Deployment:
- A pipeline showing how CMake configuration compiles various modules and produces the final executables, which then run simulations based on provided example input cases.

##### Architectural Patterns and Design Principles
- Modular Design – Each simulation aspect (angle resolution, band calculation, boundary conditions, etc.) is implemented in its own directory (both in includes and src). Highlight these as separate modules.
- Separation of Concerns – Demonstrate how input-handling, core simulation, and output/visualization are clearly separated.
- Parallel Processing – Indicate that MPI is used; mark simulation modules as operating in a distributed environment.
- Interfacing with Third-party Tools – Show connectors that link GiftBTE to tools such as COMSOL, GMSH, and Paraview.

##### Be Detailed and Methodical
- Separation between configuration (e.g., CMake) and runtime components (e.g., MPI-run simulation executables).
- Nuanced data flow – for instance, showing that the “materials” library is used by both preprocessing and solver modules.
- Annotations where necessary that indicate dependencies on external libraries such as MPI and Eigen.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input & Preprocessing Layer
    subgraph "Input & Preprocessing"
        Materials["Materials & Input Files"]:::input
        MeshGen["Mesh Generator"]:::preprocessing
        Examples["Example Cases"]:::input
    end

    %% Core Simulation Engine Layer
    subgraph "Core Simulation Engine"
        BTEAngle["Steady-state Solver: BTEAngle"]:::solver
        BTEBand["Steady-state Solver: BTEBand"]:::solver
        BTEBoundaryCondition["Boundary Condition (BTEBoundaryCondition)"]:::solver
        BTEMesh["Mesh Handler (BTEMesh)"]:::solver
        StaticBTESynthetic["Static Solver: BTESynthetic"]:::solver
        StaticFourier["Static Solver: Fourier"]:::solver
        TransientBTE["Transient Solver: BTE"]:::solver
        TransientFourier["Transient Solver: Fourier"]:::solver
        Utility["Utility Components"]:::utility
    end

    %% External Interfaces Layer
    subgraph "External Interfaces"
        COMSOL["COMSOL Interface"]:::external
        MPI["MPI Parallelization"]:::external
    end

    %% Build & Deployment Layer
    subgraph "Build & Deployment"
        CMake["CMake Build Configurations"]:::build
        cmakeModules["cmake-modules"]:::build
    end

    %% Post-processing Layer
    subgraph "Post-processing"
        VizScripts["Visualization Scripts"]:::post
    end

    %% Data Flow Connections
    Materials --> MeshGen
    Examples --> MeshGen

    MeshGen --> BTEAngle
    MeshGen --> BTEBand
    MeshGen --> BTEBoundaryCondition
    MeshGen --> BTEMesh
    MeshGen --> StaticBTESynthetic
    MeshGen --> StaticFourier
    MeshGen --> TransientBTE
    MeshGen --> TransientFourier

    %% External Interfaces connecting to core modules
    MPI --> BTEAngle
    COMSOL --> BTEMesh

    %% Build influences preprocessing and outputs
    CMake --> MeshGen
    cmakeModules --> MeshGen
    CMake --> VizScripts

    %% Core Simulation output to Post-processing
    BTEMesh --> VizScripts
    StaticBTESynthetic --> VizScripts
    StaticFourier --> VizScripts
    TransientBTE --> VizScripts
    TransientFourier --> VizScripts

    %% Styles
    classDef input fill:#cce5ff,stroke:#1b6ca8,stroke-width:2px;
    classDef preprocessing fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef solver fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef utility fill:#fefbd8,stroke:#c69500,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef build fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef post fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;

    %% Click Events for Core Solver Modules
    click BTEAngle "https://github.com/giftbte-developer/giftbte/tree/master/includes/BTEAngle"
    click BTEAngle "https://github.com/giftbte-developer/giftbte/tree/master/src/BTEAngle"
    click BTEBand "https://github.com/giftbte-developer/giftbte/tree/master/includes/BTEBand"
    click BTEBand "https://github.com/giftbte-developer/giftbte/tree/master/src/BTEBand"
    click BTEBoundaryCondition "https://github.com/giftbte-developer/giftbte/tree/master/includes/BTEBoundaryCondition"
    click BTEBoundaryCondition "https://github.com/giftbte-developer/giftbte/tree/master/src/BTEBoundaryCondition"
    click BTEMesh "https://github.com/giftbte-developer/giftbte/tree/master/includes/BTEMesh"
    click BTEMesh "https://github.com/giftbte-developer/giftbte/tree/master/src/BTEMesh"
    click StaticBTESynthetic "https://github.com/giftbte-developer/giftbte/tree/master/includes/StaticBTESynthetic"
    click StaticBTESynthetic "https://github.com/giftbte-developer/giftbte/tree/master/src/StaticBTESynthetic"
    click StaticFourier "https://github.com/giftbte-developer/giftbte/tree/master/includes/StaticFourier"
    click StaticFourier "https://github.com/giftbte-developer/giftbte/tree/master/src/StaticFourier"
    click TransientBTE "https://github.com/giftbte-developer/giftbte/tree/master/includes/TransientBTE"
    click TransientBTE "https://github.com/giftbte-developer/giftbte/tree/master/src/TransientBTE"
    click TransientFourier "https://github.com/giftbte-developer/giftbte/tree/master/includes/TransientFourier"
    click TransientFourier "https://github.com/giftbte-developer/giftbte/tree/master/src/TransientFourier"

    %% Click Events for Utility Components
    click Utility "https://github.com/giftbte-developer/giftbte/tree/master/includes/utility"
    click Utility "https://github.com/giftbte-developer/giftbte/tree/master/src/utility"

    %% Click Events for Input/Preprocessing Components
    click Materials "https://github.com/giftbte-developer/giftbte/tree/master/bin/input/materials"
    click Materials "https://github.com/giftbte-developer/giftbte/tree/master/bin/input"
    click Materials "https://github.com/giftbte-developer/giftbte/tree/master/bin/materials"
    click MeshGen "https://github.com/giftbte-developer/giftbte/tree/master/bin/mesh_generator"
    click Examples "https://github.com/giftbte-developer/giftbte/tree/master/bin/examples"

    %% Click Events for External Interface Components
    click COMSOL "https://github.com/giftbte-developer/giftbte/blob/master/includes/BTEMesh/COMSOL.h"

    %% Click Events for Build & Deployment
    click CMake "https://github.com/giftbte-developer/giftbte/blob/master/CMakeLists.txt"
    click CMake "https://github.com/giftbte-developer/giftbte/blob/master/src/CMakeLists.txt"
    click cmakeModules "https://github.com/giftbte-developer/giftbte/tree/master/cmake-modules"

    %% Click Events for Post-processing Components
    click VizScripts "https://github.com/giftbte-developer/giftbte/blob/master/bin/plot_heatflux.m"
    click VizScripts "https://github.com/giftbte-developer/giftbte/blob/master/bin/plot_temperature.m"
    click VizScripts "https://github.com/giftbte-developer/giftbte/tree/master/bin/examples"
```
