# krebeljk/openinjmoldsim architecture

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

- Interactive diagram: https://gitdiagram.com/krebeljk/openinjmoldsim
- Repository: https://github.com/krebeljk/openinjmoldsim

## Overview

##### Project type and purpose
- openInjMoldSim is an extension to the OpenFOAM CFD toolkit: a C++-based scientific solver for simulating injection-molding processes (filling, packing, cooling).
- It is not a web or GUI application but a command-line plugin that compiles against OpenFOAM and runs on “case” directories containing input decks.

##### File structure
- Top level:
- applications/solvers/multiphase/openInjMoldSim – contains multiple solver variants and custom library modules (thermo, transport, forces, fiber orientation) plus build scripts (Make, Allwmake).
- tutorials/demo and tutorials/test – example “case” directories (dogbone, fill_pack, crossWLF, etc.) with OpenFOAM-style system/constant/org0 folders and Python post-processing scripts.
- Configuration files: .gitignore, LICENSE.md, VERSION.md, README.md.
- Patterns:
- Each solver variant (openInjMoldSim.C, compressibleInterDyMFoam.C, openInjMoldSimF.C) links to a set of H/C modules under subfolders (mojThermo, crossWlfInSorodno, mojLibForces, polymerPVT, mojTurbulentFluidThermoModel, etc.).
- Build flow: invoke Allwmake in solver directory → generates library objects → links executables.

##### README for additional insights
- Indicates underlying dependency on OpenFOAM 7, compilation via Allwmake, runtime flow (mesh → run → paraFoam).
- Highlights core physics modules: Tait equation of state, Cross-WLF viscosity, non-isothermal laminar flow, elastic stresses, fiber orientation.

a. Main components
1. OpenFOAM Core Framework
– Mesh handling, linear solvers, IO, time loop
2. openInjMoldSim Plugin Modules
– Solver executables: openInjMoldSim, openInjMoldSimF, compressibleInterDyMFoam
– Physics libraries:
- Thermodynamics (mojThermo, polymerPVT, twoPhaseMixtureThermo)
- Transport (crossWlfInSorodno, mojConstTransport)
- Forces (mojLibForces)
- Fiber orientation (openInjMoldSimF: Advani-Folgar-Tucker)
– Equation definitions (UEqn.H, TEqn.H, alphaEqns.H, pEqn.H, etc.)
3. Build System
– Makefiles, Allwmake scripts orchestrating compilation and linking
4. Case Workflow & Post-Processing
– Input “case” directories (system/, constant/, org0/) holding mesh, material tables, simulation settings (controlDict, fvSchemes, fvSolution)
– Python scripts for plotting results and notebook tutorials
– paraFoam visualization

b. Relationships & interactions
- Build System → compiles Plugin Modules → links against OpenFOAM Core → produces Solver Executables
- At runtime: Solver Executables → read Case Input (system/, constant/, org0/) → instantiate physics modules → perform time-loop computations (mass, momentum, energy, phase fraction equations) → write field data (U, p, T, alpha.poly, stresses)
- Post-Processing Scripts & paraFoam ← read output fields

c. Architectural patterns & design principles
- Modular C++ plugin structure: each physical model implemented in its own namespace/folder, separated by headers (H) and implementations (C, I.H)
- Plugin-style build via OpenFOAM’s wmake/Allwmake conventions
- Case directory separation of concerns: mesh, control parameters, boundary/initial conditions

d. Key technologies/frameworks
- OpenFOAM 7 (C++ CFD framework)
- GNU Make / Allwmake build scripts
- Python (post-processing, data plotting)
- ParaView (paraFoam) for visualization

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "OpenFOAM Core"
        OF["OpenFOAM Core Framework"]:::core
    end

    subgraph "Build System"
        AW["Allwmake"]:::build
        AC["Allwclean"]:::build
        MF["Makefiles"]:::build
    end

    subgraph "Plugin Modules"
        subgraph "Solver Executables"
            SIM["openInjMoldSim"]:::exe
            SIMF["openInjMoldSimF"]:::exe
            CIDF["compressibleInterDyMFoam"]:::exe
        end
        subgraph "Physics Modules"
            THM["mojThermo"]:::plugin
            PVT["polymerPVT"]:::plugin
            TPM["Two-PhaseMixtureThermo"]:::plugin
            TRF["crossWlfInSorodno"]:::plugin
            CTP["mojConstTransport"]:::plugin
            FRC["mojLibForces"]:::plugin
            TFM["mojTurbulentFluidThermoModel"]:::plugin
            EQ["Core Equation Headers"]:::plugin
        end
    end

    subgraph "Case Workflow & Visualization"
        CI["Tutorials Demo"]:::case
        TEST["Tutorials Test"]:::case
        OUT["Field Output"]:::case
        PP["Post-Processing Scripts"]:::case
        PF["paraFoam Visualization"]:::case
    end

    %% Build Flow
    AW -->|"builds modules"| THM
    AW --> PVT
    AW --> TPM
    AW --> TRF
    AW --> CTP
    AW --> FRC
    AW --> TFM
    AW --> EQ
    MF -->|"orchestrates"| AW
    AC -->|"cleans build"| MF

    THM -->|"linked into"| SIM
    PVT --> SIM
    TPM --> SIM
    TRF --> SIM
    CTP --> SIM
    FRC --> SIM
    TFM --> SIM
    EQ --> SIM

    THM -->|"linked into"| SIMF
    PVT --> SIMF
    TPM --> SIMF
    TRF --> SIMF
    CTP --> SIMF
    FRC --> SIMF
    TFM --> SIMF
    EQ --> SIMF

    THM -->|"linked into"| CIDF
    PVT --> CIDF
    TPM --> CIDF
    TRF --> CIDF
    CTP --> CIDF
    FRC --> CIDF
    TFM --> CIDF
    EQ --> CIDF

    %% Runtime Flow
    SIM -->|"reads case input"| CI
    SIMF --> CI
    CIDF --> CI

    SIM -->|"writes fields"| OUT
    SIMF --> OUT
    CIDF --> OUT

    PP -->|"reads fields"| OUT
    PF -->|"visualizes fields"| OUT

    %% Click Events
    click AW "https://github.com/krebeljk/openinjmoldsim/tree/master/applications/solvers/multiphase/openInjMoldSim/Allwmake"
    click AC "https://github.com/krebeljk/openinjmoldsim/tree/master/applications/solvers/multiphase/openInjMoldSim/Allwclean"
    click MF "https://github.com/krebeljk/openinjmoldsim/tree/master/applications/solvers/multiphase/openInjMoldSim/Make"
    click SIM "https://github.com/krebeljk/openinjmoldsim/blob/master/applications/solvers/multiphase/openInjMoldSim/openInjMoldSim.C"
    click SIMF "https://github.com/krebeljk/openinjmoldsim/blob/master/applications/solvers/multiphase/openInjMoldSim/openInjMoldSimF/openInjMoldSimF.C"
    click CIDF "https://github.com/krebeljk/openinjmoldsim/blob/master/applications/solvers/multiphase/openInjMoldSim/compressibleInterDyMFoam/compressibleInterDyMFoam.C"
    click THM "https://github.com/krebeljk/openinjmoldsim/blob/master/applications/solvers/multiphase/openInjMoldSim/mojThermo/mojThermo.C"
    click PVT "https://github.com/krebeljk/openinjmoldsim/blob/master/applications/solvers/multiphase/openInjMoldSim/polymerPVT/polymerPVT.C"
    click TPM "https://github.com/krebeljk/openinjmoldsim/blob/master/applications/solvers/multiphase/openInjMoldSim/mojTwoPhaseMixtureThermo/mojTwoPhaseMixtureThermo.C"
    click TRF "https://github.com/krebeljk/openinjmoldsim/blob/master/applications/solvers/multiphase/openInjMoldSim/crossWlfInSorodno/crossWLFTransport.C"
    click CTP "https://github.com/krebeljk/openinjmoldsim/blob/master/applications/solvers/multiphase/openInjMoldSim/mojConstTransport/mojConstTransport.C"
    click FRC "https://github.com/krebeljk/openinjmoldsim/blob/master/applications/solvers/multiphase/openInjMoldSim/mojLibForces/forces/mojForces.C"
    click TFM "https://github.com/krebeljk/openinjmoldsim/blob/master/applications/solvers/multiphase/openInjMoldSim/mojTurbulentFluidThermoModel/mojTurbulentFluidThermoModel.C"
    click CI "https://github.com/krebeljk/openinjmoldsim/tree/master/tutorials/demo"
    click TEST "https://github.com/krebeljk/openinjmoldsim/tree/master/tutorials/test"
    click PP "https://github.com/krebeljk/openinjmoldsim/blob/master/tutorials/demo/dogbone/constant/plot_cp.py"

    %% Styles
    classDef core fill:#d3d33,stroke:#333;
    classDef build fill:#c6efce,stroke:#333;
    classDef plugin fill:#cce5ff,stroke:#333;
    classDef exe fill:#9ecae1,stroke:#333;
    classDef case fill:#ffe6cc,stroke:#333;
```
