### Shell Script for Simulation Setup and Execution Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt This script automates the setup and execution of a parallel CFD simulation using OpenFOAM. It determines the number of processors, updates the decomposition dictionary, initializes fields, decomposes the domain, runs the parallel simulation, and reconstructs the results. ```shell # Determine number of processors N_PROCS=$(grep ^cpu\scores /proc/cpuinfo | uniq | awk '{print $4}') [ -z "$N_PROCS" ] && N_PROCS=4 # Update decomposition dictionary foamDictionary system/decomposeParDict -entry numberOfSubdomains -set $N_PROCS # Initialize fields rm -rf 0 cp -r 0.orig 0 # Decompose for parallel run runApplication decomposePar # Run parallel simulation runParallel "$(getApplication)" # Reconstruct results runApplication reconstructPar ``` -------------------------------- ### Install LAPACK Dependencies on Debian Source: https://github.com/aalto-cfd/dlbfoam/blob/v1.1_OFdev/README.md This command installs the necessary LAPACKE development files on Debian-based systems, which is required for DLBFoam's optimized ODE routines when using a standalone LAPACK installation. The 'sudo' command is used for administrative privileges. ```bash (sudo) apt-get install liblapacke-dev ``` -------------------------------- ### Compile DLBFoam with Allwmake Script Source: https://github.com/aalto-cfd/dlbfoam/blob/v1.1_OFdev/README.md This command compiles DLBFoam using the provided Allwmake script. It requires sourcing an appropriate OpenFOAM version and ensuring a valid LAPACK installation. The '--clean' flag ensures a clean build, and '--platform' specifies the LAPACK installation type (MKL, OPENBLAS, or STANDALONE). ```bash ./Allwmake --clean --platform ``` -------------------------------- ### Compile DLBFoam with LAPACK Support Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt Compile DLBFoam with LAPACK support using different backends: Intel MKL (recommended for Intel architecture), OpenBLAS, or standalone LAPACKE. Ensure the OpenFOAM environment is sourced before compilation. For OpenBLAS, the installation root must be specified. ```bash # Source OpenFOAM environment first source $WM_PROJECT_DIR/etc/bashrc # Compile with Intel MKL (recommended for Intel architecture) ./Allwmake --clean --platform MKL # Compile with OpenBLAS export OPENBLAS_INSTALL_ROOT=/path/to/openblas ./Allwmake --clean --platform OPENBLAS # Compile with standalone LAPACKE (personal workstations) # First install: sudo apt-get install liblapacke-dev ./Allwmake --clean --platform STANDALONE ``` -------------------------------- ### Generate Compiled Mechanism Library with Allrun Source: https://github.com/aalto-cfd/dlbfoam/blob/v1.1_OFdev/README.md This command generates a compiled mechanism library by executing the Allrun script in the utilities folder. It requires a mechanism name as an argument and produces a shared object file (libc_pyjac.so) in the specified path. Ensure CMake is installed. ```bash ./Allrun -m ``` -------------------------------- ### Standard Load Balancing Without pyJac (C++) Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt Configures DLBFoam for standard dynamic load balancing without pyJac. This setup uses OpenFOAM's default chemistry solver. It requires specifying the ODE solver and method, along with load balancing and reference mapping parameters. ```cpp // constant/chemistryProperties - standard load balancing FoamFile { version 2; format ascii; class dictionary; location "constant"; object chemistryProperties; } chemistry on; initialChemicalTimeStep 1; // Standard OpenFOAM solver with load balancing chemistryType { solver ode; // Standard ODE solver method loadBalanced; // Load-balanced (without pyJac) } odeCoeffs { solver seulex; // Standard seulex solver absTol 1e-08; relTol 1e-05; } loadbalancing { active true; log true; } refmapping { active true; mixtureFractionProperties { oxidizerMassFractions { N2 0.77; O2 0.23; } fuelMassFractions { NC12H26 1; } #include "$FOAM_CASE/constant/foam/thermo.foam" } tolerance 0.0001; } #include "$FOAM_CASE/constant/reactionsYao" ``` -------------------------------- ### Configure ODE Solver in OpenFOAM Source: https://github.com/aalto-cfd/dlbfoam/blob/v1.1_OFdev/README.md This configuration snippet sets the ODE solver to 'seulex_LAPACK' and specifies absolute and relative tolerances for the ODE integration. Using 'seulex_LAPACK' leverages optimized LAPACK solvers for improved performance in solving the ordinary differential equations governing the chemical kinetics. ```OpenFOAM Dictionary odeCoeffs { solver seulex_LAPACK; absTol 1e-08; relTol 1e-05; } ``` -------------------------------- ### Configure OpenFOAM ControlDict for DLBFOAM Source: https://github.com/aalto-cfd/dlbfoam/blob/v1.1_OFdev/README.md This configuration snippet is added to the system/controlDict file in an OpenFOAM case. It links the necessary DLBFoam libraries, optimized LAPACK solvers, and the compiled analytical Jacobian C subroutines. These libraries are essential for enabling DLBFOAM functionality and analytical Jacobian calculations. ```OpenFOAM Dictionary libs ( "libchemistryModel_DLB.so" "libODE_DLB.so" "$FOAM_CASE/constant/foam/libc_pyjac.so" ); ``` -------------------------------- ### Configure Reference Mapping in OpenFOAM (Optional) Source: https://github.com/aalto-cfd/dlbfoam/blob/v1.1_OFdev/README.md This optional configuration enables the reference mapping method for chemistry calculations. It includes settings for mixture fraction properties (oxidizer and fuel mass fractions) and tolerances for mixture fraction and temperature. This method maps a reference solution to cells satisfying specific conditions, potentially improving computational efficiency. ```OpenFOAM Dictionary refmapping { active true; mixtureFractionProperties { oxidizerMassFractions { N2 0.77; O2 0.23; } fuelMassFractions { NC12H26 1.0; } #include "$FOAM_CASE/constant/foam/thermo.foam" } tolerance 1e-4; // mixture fraction tolerance deltaT 2; // temperature tolerance } ``` -------------------------------- ### Configure Chemistry Solver and Method in OpenFOAM Source: https://github.com/aalto-cfd/dlbfoam/blob/v1.1_OFdev/README.md This configuration snippet is added to the constant/chemistryProperties file. It specifies the chemistry solver as 'ode_pyJac' and the method as 'loadBalanced_pyJac', which are core settings for utilizing DLBFOAM's capabilities. These settings enable the optimized ODE solving and load balancing features. ```OpenFOAM Dictionary chemistryType { solver ode_pyJac; method loadBalanced_pyJac; } ``` -------------------------------- ### Configure DLBFoam Chemistry with pyJac and Load Balancing Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt Configure the chemistry model to use DLBFoam's load-balanced pyJac solver with optimized ODE routines in `constant/chemistryProperties`. This includes selecting the `ode_pyJac` solver and `loadBalanced_pyJac` method, configuring the `seulex_LAPACK` ODE solver, and enabling load balancing. ```cpp // constant/chemistryProperties FoamFile { version 2; format ascii; class dictionary; location "constant"; object chemistryProperties; } chemistry on; initialChemicalTimeStep 1; // Select load-balanced chemistry model with analytical Jacobian chemistryType { solver ode_pyJac; // ODE solver with pyJac support method loadBalanced_pyJac; // Load-balanced chemistry method } // Configure optimized ODE solver with LAPACK odeCoeffs { solver seulex_LAPACK; // LAPACK-optimized extrapolation solver absTol 1e-08; // Absolute tolerance relTol 1e-05; // Relative tolerance } // Enable load balancing loadbalancing { active true; // Enable dynamic load balancing log true; // Log balancing statistics to cpu_solve.out } // Reference mapping configuration (required even if inactive) refmapping { active false; // Set to true to enable reference mapping } reactions { } ``` -------------------------------- ### ISAT Tabulation with pyJac (C++) Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt Enables In-Situ Adaptive Tabulation (ISAT) for speed-up using pyJac. This configuration caches and interpolates chemistry solutions, available from OpenFOAM 12. It requires including ISAT configuration files and setting the tabulation method to `ISAT_pyJac`. ```cpp // constant/chemistryProperties with ISAT tabulation FoamFile { version 2; format ascii; class dictionary; location "constant"; object chemistryProperties; } // Include ISAT configuration #includeEtc "caseDicts/solvers/chemistry/TDAC/chemistryProperties.cfg" // Disable reduction (not supported with pyJac) #remove reduction // Configure ISAT_pyJac tabulation method tabulation { method ISAT_pyJac; // Use pyJac-compatible ISAT implementation } chemistry on; initialChemicalTimeStep 1; chemistryType { solver ode_pyJac; method loadBalanced_pyJac; } odeCoeffs { solver seulex_LAPACK; absTol 1e-08; relTol 1e-05; } loadbalancing { active true; log true; } refmapping { active false; } reactions { } ``` -------------------------------- ### ChemistryProblem and ChemistrySolution Data Structures Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt Core data structures for passing chemistry problems and solutions between MPI ranks in the load balancer. ```APIDOC ## ChemistryProblem and ChemistrySolution Data Structures ### Description Core data structures for passing chemistry problems between MPI ranks in the load balancer. ### Method N/A (Struct Definitions) ### Endpoint N/A (Struct Definitions) ### Parameters N/A (Struct Definitions) ### Request Example N/A (Struct Definitions) ### Response N/A (Struct Definitions) #### ChemistryProblem - `ChemistryProblem(label nSpecie)`: Constructor with number of species. - `scalarField Y`: Species mass fractions. - `scalar Ti`: Temperature [K]. - `scalar pi`: Pressure [Pa]. - `scalar rhoi`: Density [kg/m³]. - `scalar deltaTChem`: Chemistry time step [s]. - `scalar deltaT`: CFD time step [s]. - `scalar cpuTime`: Previous CPU time for this cell. - `label cellid`: Cell index. - `scalar procNo`: Originating MPI rank. #### ChemistrySolution - `ChemistrySolution(label nspecie)`: Constructor with number of species. - `scalarField rr`: Reaction rates: (Y_{i+1} - Y_{i}) * rhoi / deltaT. - `scalar deltaTChem`: Updated chemistry time step. - `scalar cpuTime`: CPU time spent solving. - `label cellid`: Cell index. - `scalar rhoi`: Density. - `bool retrieved`: True if retrieved from ISAT tabulation. ``` -------------------------------- ### Configure Reference Cell Mapping with Bilger's Mixture Fraction (C++) Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt Configures reference cell mapping in `chemistryProperties` using Bilger's mixture fraction. This method reduces computational cost by mapping solutions from reference cells to cells with similar compositions. It requires defining oxidizer and fuel compositions and optionally a temperature tolerance. ```cpp // constant/chemistryProperties with reference mapping FoamFile { version 2; format ascii; class dictionary; location "constant"; object chemistryProperties; } chemistry on; initialChemicalTimeStep 1; chemistryType { solver ode_pyJac; method loadBalanced_pyJac; } odeCoeffs { solver seulex_LAPACK; absTol 1e-08; relTol 1e-05; } loadbalancing { active true; log true; } // Reference mapping using Bilger's mixture fraction refmapping { active true; mixtureFractionProperties { // Define oxidizer composition (Z=0) oxidizerMassFractions { N2 0.77; O2 0.23; } // Define fuel composition (Z=1) fuelMassFractions { NC12H26 1.0; // n-dodecane fuel } // Include thermodynamic properties #include "$FOAM_CASE/constant/foam/thermo.foam" } tolerance 1e-4; // Mixture fraction tolerance for mapping deltaT 2; // Temperature tolerance in Kelvin (optional) } reactions { } ``` -------------------------------- ### Enable Load Balancing in OpenFOAM Source: https://github.com/aalto-cfd/dlbfoam/blob/v1.1_OFdev/README.md This subdictionary is added to the constant/chemistryProperties file to enable and configure load balancing within DLBFOAM. Setting 'active' to true activates the feature, while 'log' to true enables logging of load balancing activities, which can be useful for performance analysis. ```OpenFOAM Dictionary loadbalancing { active true; log true; } ``` -------------------------------- ### ODE Chemistry Solver with pyJac in C++ Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt An ODE chemistry solver designed to interface with pyJac analytical Jacobian routines. It updates concentrations and returns the chemical time, requiring a fluidMulticomponentThermo object and handling species mass fractions, pressure, and temperature. The solver uses an ODESolver instance. ```cpp // Foam::ode_pyJac - ODE solver for chemistry with pyJac routines namespace Foam { template class ode_pyJac : public chemistrySolver { public: // Runtime type name TypeName("ode_pyJac"); // Construct from thermo ode_pyJac(const fluidMulticomponentThermo& thermo); // Destructor virtual ~ode_pyJac(); // Update concentrations and return the chemical time virtual void solve( scalar& p, // Pressure [Pa] scalar& T, // Temperature [K] scalarField& Y, // Species mass fractions const label li, // Cell index scalar& deltaT, // Time step [s] scalar& subDeltaT // Sub-step time [s] ) const; private: dictionary coeffsDict_; mutable autoPtr odeSolver_; // ODE solver instance mutable scalarField YTp_; // Solver data [Y, T, p] }; } // namespace Foam ``` -------------------------------- ### Complete DLBFoam Simulation Workflow (Bash) Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt Provides a complete bash script workflow for running a parallel reactive flow simulation using DLBFoam. This includes sourcing OpenFOAM run functions, building the pyJac mechanism library, copying mechanism files, and generating the mesh using `blockMesh`. ```bash #!/bin/bash # Run from tutorial directory cd ${0%/*} || exit 1 # Source OpenFOAM run functions . "$WM_PROJECT_DIR/bin/tools/RunFunctions" # Build pyJac mechanism library cd pyJac/lib ./runCmake.sh cd - # Copy mechanism files to constant directory cp -r pyJac/foam constant/ cp pyJac/lib/build/libc_pyjac.so constant/foam/ # Generate mesh runApplication blockMesh ``` -------------------------------- ### Link DLBFoam Libraries in controlDict Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt Link DLBFoam libraries and the pyJac mechanism library in the OpenFOAM case `system/controlDict` file. This involves adding the paths to the shared object files (`.so`) of the DLBFoam chemistry model, ODE solver, and pyJac analytical Jacobian to the `libs` entry. ```cpp // system/controlDict FoamFile { version 2.0; format ascii; class dictionary; location "system"; object controlDict; } application foamRun; solver multicomponentFluid; startFrom latestTime; startTime 0; stopAt endTime; endTime 1; deltaT 1e-7; writeControl timeStep; writeInterval 1000; writeFormat binary; adjustTimeStep yes; maxCo 0.7; // Link DLBFoam libraries libs ( "libchemistryModel_DLB.so" // DLBFoam chemistry model "libODE_DLB.so" // Optimized LAPACK ODE solvers "$FOAM_CASE/constant/foam/libc_pyjac.so" // pyJac analytical Jacobian ); ``` -------------------------------- ### Load Balanced Chemistry Model in C++ Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt The `loadBalancedChemistryModel` class extends OpenFOAM's chemistryModel to support load balancing. It manages chemistry solving across multiple processors, including methods for solving single problems, reaction systems over time steps, and accessing chemical source terms. Dependencies include OpenFOAM's `chemistryModel` and `LoadBalancer`. ```cpp // Foam::loadBalancedChemistryModel - Load-balanced chemistry solver namespace Foam { template class loadBalancedChemistryModel : public chemistryModel { public: // Runtime type name TypeName("loadBalanced"); // Construct from thermo loadBalancedChemistryModel(const fluidMulticomponentThermo& thermo); // Destructor virtual ~loadBalancedChemistryModel(); // Solve chemistry for a single problem/solution pair void solveSingle(ChemistryProblem& problem, ChemistrySolution& solution) const; // Solve the reaction system for the given time step // Returns the minimum chemistry time step virtual scalar solve(const scalar deltaT) override; virtual scalar solve(const scalarField& deltaT) override; // Pure virtual ODE solve function (implemented by derived classes) virtual void solve( scalar& p, scalar& T, scalarField& dYTp, const label li, scalar& deltaT, scalar& subDeltaT ) const = 0; // Access to chemical source terms inline const volScalarField::Internal& RR(const label i) const; inline volScalarField::Internal& RR(const label i); private: LoadBalancer balancer_; // Load balancing object mixtureFractionRefMapper mapper_; // Reference mapping object volScalarField cpuTimes_; // Per-cell CPU times volScalarField refMap_; // Reference mapping status field autoPtr tabulationPtr_; // ISAT tabulation }; } // namespace Foam ``` -------------------------------- ### seulex_LAPACK ODE Solver in C++ Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt The `seulex_LAPACK` class is a LAPACK-optimized extrapolation ODE solver. It implements a linearly implicit Euler method with adaptive step size control for solving ODE systems. The solver utilizes LAPACK's `dgetrf` and `dgetrs` for efficient LU decomposition, making it suitable for large-scale problems. Dependencies include `ODESolver` and `ODESystem`. ```cpp // Foam::seulex_LAPACK - LAPACK-optimized extrapolation ODE solver namespace Foam { class seulex_LAPACK : public ODESolver { public: // Runtime type name TypeName("seulex_LAPACK"); // Construct from ODE system seulex_LAPACK(const ODESystem& ode, const dictionary& dict); // Destructor virtual ~seulex_LAPACK() {} // Resize the ODE solver for new problem size virtual bool resize(); // Solve the ODE system and update state // Uses LAPACK dgetrf/dgetrs for optimized LU decomposition virtual void solve( scalar& x, scalarField& y, const label li, stepState& step ) const; private: // Static constants for step control static const label kMaxx_ = 12; static const label iMaxx_ = kMaxx_ + 1; // Compute j-th line of extrapolation table bool seul( const scalar x0, const scalarField& y0, const label li, const scalar dxTot, const label k, scalarField& y, const scalarField& scale ) const; // Polynomial extrapolation void extrapolate( const label k, scalarRectangularMatrix& table, scalarField& y ) const; }; } // namespace Foam ``` -------------------------------- ### pyJac Chemistry Model with Analytical Jacobian in C++ Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt The `loadBalanced_pyJacChemistryModel` class enhances the load-balanced chemistry model by integrating pyJac for analytical Jacobian computations. This significantly speeds up ODE solutions. It provides methods for computing the Jacobian, derivatives, heat release rate, and chemical time scales. Dependencies include `loadBalancedChemistryModel` and pyJac. ```cpp // Foam::loadBalanced_pyJacChemistryModel - Chemistry model with analytical Jacobian namespace Foam { template class loadBalanced_pyJacChemistryModel : public loadBalancedChemistryModel { public: // Runtime type name TypeName("loadBalanced_pyJac"); // Construct from thermo loadBalanced_pyJacChemistryModel(const fluidMulticomponentThermo& thermo); // Destructor virtual ~loadBalanced_pyJacChemistryModel(); // Return number of equations (nSpecie + 1 for pyJac) inline virtual label nEqns() const; // Compute analytical Jacobian using pyJac virtual void jacobian( const scalar t, const scalarField& TYp, const label li, scalarField& dTYpdt, scalarSquareMatrix& J ) const override; // Compute derivatives using pyJac virtual void derivatives( const scalar t, const scalarField& TYp, const label li, scalarField& dTYpdt ) const override; // Heat release rate using pyJac enthalpy of formation virtual tmp Qdot() const override; // Chemical time scale calculation via pyJac virtual tmp tc() const override; private: mutable scalarField Y_; // Temporary concentration field scalarList sp_enth_form; // Enthalpy of formation from pyJac }; } // namespace Foam ``` -------------------------------- ### Generate pyJac Mechanism Libraries (Bash) Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt Generates and compiles pyJac analytical Jacobian libraries for chemical mechanisms like GRI-3.0, Yao, and DRM-19. This involves navigating to the utilities folder and running the `Allrun` script with the desired mechanism name. The output includes compiled libraries and thermodynamic/species files. ```bash # Navigate to utilities folder cd utilities/ # Generate mechanism library for included mechanisms ./Allrun -m gri30 # GRI-3.0 mechanism (53 species) ./Allrun -m yao # Yao mechanism (n-dodecane) ./Allrun -m drm19 # DRM-19 mechanism (reduced methane) # The command generates: # - /lib/build/libc_pyjac.so (compiled Jacobian library) # - /foam/thermo.foam (thermodynamic properties) # - /foam/species.foam (species list) # Copy mechanism files to case directory cp -r /foam $FOAM_CASE/constant/ cp /lib/build/libc_pyjac.so $FOAM_CASE/constant/foam/ ``` -------------------------------- ### LoadBalancer Class API Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt The LoadBalancer class implements MPI-based dynamic load balancing to redistribute chemistry problems and achieve global mean load across all ranks. ```APIDOC ## LoadBalancer Class API ### Description The `LoadBalancer` class implements MPI-based dynamic load balancing that redistributes chemistry problems to achieve global mean load across all ranks. ### Method N/A (Class Definition) ### Endpoint N/A (Class Definition) ### Parameters N/A (Class Definition) ### Request Example N/A (Class Definition) ### Response N/A (Class Definition) #### Nested Structures: **Operation** - `from` (int) - Source MPI rank - `to` (int) - Destination MPI rank - `value` (double) - CPU time to transfer **Methods:** - `LoadBalancer()`: Default constructor. - `LoadBalancer(const dictionary& dict)`: Construct from chemistryProperties dictionary. - `virtual void updateState(const DynamicList& problems)`: Update balancer state based on chemistry problems. Called each timestep to compute load distribution. - `bool active() const`: Check if load balancing is active. - `bool log() const`: Check if logging is enabled. - `static std::vector getOperations(DynamicList& loads, const ChemistryLoad& myLoad)`: Compute operations to balance load to global mean. - `static BalancerState operationsToInfo(const std::vector& operations, const DynamicList& problems, const ChemistryLoad& myLoad)`: Convert operations to send/receive information. ``` -------------------------------- ### Mixture Fraction Reference Mapper Class in C++ Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt Implements reference cell mapping using Bilger's mixture fraction to reduce chemistry evaluations. It checks mass fraction and temperature tolerances for mapping and provides an active status. Dependencies include Foam::dictionary and Foam::fluidMulticomponentThermo. ```cpp // Foam::mixtureFractionRefMapper - Mixture fraction based reference mapping namespace Foam { class mixtureFractionRefMapper { public: // Default constructor mixtureFractionRefMapper() = default; // Construct from dictionary and thermo mixtureFractionRefMapper( const dictionary& dict, const fluidMulticomponentThermo& thermo ); // Check if mass fraction is within Z tolerance for mapping // Returns true if cell should be mapped from reference bool shouldMap(const scalarField& massFraction) const; // Check if temperature is within deltaT tolerance bool temperatureWithinRange(scalar Ti, scalar Tref) const; // Check if reference mapping is active bool active() const; private: const dictionary dict_; const dictionary coeffsDict_; Switch active_; // Reference mapping switch scalar Ztolerance_; // Mixture fraction tolerance scalar Ttolerance_; // Temperature tolerance [K] mixtureFraction mixture_fraction_; // Mixture fraction calculator }; // Foam::mixtureFraction - Bilger's mixture fraction calculation // Z = (beta - beta_0)/(beta_1 - beta_0) // beta = 2*Z_C/W_C + 0.5*Z_H/W_H - Z_O/W_O class mixtureFraction { public: mixtureFraction() = default; // Construct from dictionary and thermo mixtureFraction( const dictionary& mixFracDict, const fluidMulticomponentThermo& thermo ); // Convert mass fractions to mixture fraction scalar massFractionToMixtureFraction(const scalarField& massFraction) const; private: dictionary mixFracDict_; wordList species_; List alpha_; // Coupling coefficients List beta_; // Conserved scalar coefficients }; } // namespace Foam ``` -------------------------------- ### ChemistryProblem and ChemistrySolution Data Structures (C++) Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt These C++ structures define the data passed between MPI ranks for chemistry calculations within the load balancer. ChemistryProblem holds all necessary data for a single chemistry ODE solve, while ChemistrySolution stores the results of such a solve. ```cpp // Foam::ChemistryProblem - Contains all data needed to solve chemistry ODE namespace Foam { struct ChemistryProblem { // Constructor with number of species ChemistryProblem(label nSpecie); scalarField Y; // Species mass fractions scalar Ti; // Temperature [K] scalar pi; // Pressure [Pa] scalar rhoi; // Density [kg/m³] scalar deltaTChem; // Chemistry time step [s] scalar deltaT; // CFD time step [s] scalar cpuTime; // Previous CPU time for this cell label cellid; // Cell index scalar procNo; // Originating MPI rank }; // Foam::ChemistrySolution - Contains results from chemistry ODE solution struct ChemistrySolution { // Constructor with number of species ChemistrySolution(label nspecie); scalarField rr; // Reaction rates: (Y_{i+1} - Y_{i}) * rhoi / deltaT scalar deltaTChem; // Updated chemistry time step scalar cpuTime; // CPU time spent solving label cellid; // Cell index scalar rhoi; // Density bool retrieved; // True if retrieved from ISAT tabulation }; } // namespace Foam ``` -------------------------------- ### LoadBalancer Class API for Dynamic Load Balancing (C++) Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt The LoadBalancer class provides an interface for MPI-based dynamic load balancing in chemistry calculations. It redistributes chemistry problems across ranks to achieve a global mean load. Key functionalities include updating the balancer state, checking activity, and computing load balancing operations. ```cpp // Foam::LoadBalancer - Dynamic load balancing for chemistry calculations namespace Foam { class LoadBalancer : public LoadBalancerBase { public: // Operation struct for load transfer between ranks struct Operation { int from, to; // Source and destination MPI ranks double value; // CPU time to transfer }; // Default constructor LoadBalancer() = default; // Construct from chemistryProperties dictionary LoadBalancer(const dictionary& dict); // Update balancer state based on chemistry problems // Called each timestep to compute load distribution virtual void updateState(const DynamicList& problems); // Check if load balancing is active bool active() const; // Check if logging is enabled bool log() const; protected: // Compute operations to balance load to global mean static std::vector getOperations( DynamicList& loads, const ChemistryLoad& myLoad ); // Convert operations to send/receive information static BalancerState operationsToInfo( const std::vector& operations, const DynamicList& problems, const ChemistryLoad& myLoad ); }; } // namespace Foam ``` -------------------------------- ### Thermophysical Properties Configuration in OpenFOAM Source: https://context7.com/aalto-cfd/dlbfoam/llms.txt Configuration for thermophysical properties in `constant/thermophysicalProperties` for reactive simulations. It specifies the thermodynamic model, mixture type, transport properties, and includes species from a mechanism file. This is a dictionary file used by OpenFOAM. ```cpp // constant/thermophysicalProperties FoamFile { version 2.0; format ascii; class dictionary; location "constant"; object thermophysicalProperties; } thermoType { type hePsiThermo; mixture multicomponentMixture; transport sutherland; thermo janaf; equationOfState perfectGas; specie specie; energy sensibleEnthalpy; } // Include species from mechanism #include "$FOAM_CASE/constant/foam/species.foam" ``` -------------------------------- ### Build pyJac C Library with CMake Source: https://github.com/aalto-cfd/dlbfoam/blob/v1.1_OFdev/tests/validation/pyjacTests/pyjacTestMechanism/lib/CMakeLists.txt Configures CMake to build a shared C library named 'c_pyjac_test'. It sets the C standard to C99, optimization to 'Ofast', and enables Position Independent Code (PIC). Source files are dynamically discovered from the 'src' directory. ```cmake cmake_minimum_required(VERSION 2.6) project(pyJac) set(CMAKE_BUILD_TYPE Release) enable_language(C) #Note, this is not the most optimized compiler setup. set(CMAKE_C_FLAGS "-std=c99 -Ofast -fPIC") include_directories(src) include_directories(src/jacobs) file(GLOB_RECURSE SOURCES "src/*.c") add_library(c_pyjac_test SHARED ${SOURCES}) install(TARGETS c_pyjac_test DESTINATION .) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.