From a50a59cc6d0d175def82098ea4f5da6b10156d35 Mon Sep 17 00:00:00 2001 From: Parikshit Bajpai Date: Thu, 16 Nov 2023 15:07:43 -0700 Subject: [PATCH] Add number of GEM iterations to reinit data for comparison when caching --- src/Thermochimica-cxx.C | 12 ++++++++++-- src/Thermochimica-cxx.h | 1 + src/Thermochimica.h | 2 +- src/api/CouplingUtilities.f90 | 6 ++++-- src/api/CouplingUtilitiesISO_C.f90 | 6 +++--- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Thermochimica-cxx.C b/src/Thermochimica-cxx.C index 93430332..18c43c18 100644 --- a/src/Thermochimica-cxx.C +++ b/src/Thermochimica-cxx.C @@ -476,7 +476,7 @@ namespace Thermochimica getReinitData() { ReinitializationData data; - int available; + int available, iterations; auto [elements, species] = getReinitDataSizes(); data.assemblage.resize(elements); data.molesPhase.resize(elements); @@ -484,9 +484,17 @@ namespace Thermochimica data.chemicalPotential.resize(species); data.moleFraction.resize(species); - TCAPI_getReinitData(data.assemblage.data(), data.molesPhase.data(), data.elementPotential.data(), data.chemicalPotential.data(), data.moleFraction.data(), data.elementsUsed.data(), &available); + TCAPI_getReinitData(data.assemblage.data(), + data.molesPhase.data(), + data.elementPotential.data(), + data.chemicalPotential.data(), + data.moleFraction.data(), + data.elementsUsed.data(), + &available, + &iterations); data.reinitAvailable = available; + data.GEM_iterations = iterations; return data; } diff --git a/src/Thermochimica-cxx.h b/src/Thermochimica-cxx.h index 0c1b9a02..80c2260e 100644 --- a/src/Thermochimica-cxx.h +++ b/src/Thermochimica-cxx.h @@ -101,6 +101,7 @@ namespace Thermochimica int nPeriodicTable = 169; std::vector elementsUsed = std::vector(nPeriodicTable); bool reinitAvailable; + int GEM_iterations; }; ReinitializationData getReinitData(); diff --git a/src/Thermochimica.h b/src/Thermochimica.h index 9e0ea8b4..a7f7d33f 100644 --- a/src/Thermochimica.h +++ b/src/Thermochimica.h @@ -85,7 +85,7 @@ extern "C" char *TCAPI_getMqmqaPairAtIndex(int *, int *, int *); // MOOSE reinit functions - void TCAPI_getReinitData(int *, double *, double *, double *, double *, int *, int *); + void TCAPI_getReinitData(int *, double *, double *, double *, double *, int *, int *, int *); void TCAPI_setReinitData(const int *, const int *, const int *, const double *, const double *, const double *, const double *, const int *); // Heat capacity, enthalpy, and entropy diff --git a/src/api/CouplingUtilities.f90 b/src/api/CouplingUtilities.f90 index e9f2bd17..c0c5d9c5 100644 --- a/src/api/CouplingUtilities.f90 +++ b/src/api/CouplingUtilities.f90 @@ -603,13 +603,14 @@ subroutine getReinitDataSizes(mElements,mSpecies) end subroutine getReinitDataSizes subroutine getReinitData(mAssemblage,mMolesPhase,mElementPotential, & - mChemicalPotential,mMolFraction,mElementsUsed,mReinitAvailable) + mChemicalPotential,mMolFraction,mElementsUsed,mReinitAvailable,mIterations) USE ModuleReinit USE ModuleThermoIO USE ModuleThermo, ONLY: nElements, nSpecies + USE ModuleGEMSolver, ONLY: iterGlobal implicit none - integer, intent(out) :: mReinitAvailable + integer, intent(out) :: mReinitAvailable, mIterations integer, intent(out), dimension(nElements) :: mAssemblage real(8), intent(out), dimension(nElements) :: mMolesPhase, mElementPotential real(8), intent(out), dimension(nSpecies) :: mChemicalPotential, mMolFraction @@ -624,6 +625,7 @@ subroutine getReinitData(mAssemblage,mMolesPhase,mElementPotential, & mMolFraction = dMolFraction_Old mElementsUsed = iElementsUsed_Old mReinitAvailable = 1 + mIterations = iterGlobal else mReinitAvailable = 0 end if diff --git a/src/api/CouplingUtilitiesISO_C.f90 b/src/api/CouplingUtilitiesISO_C.f90 index fa431fb6..89de2ae6 100644 --- a/src/api/CouplingUtilitiesISO_C.f90 +++ b/src/api/CouplingUtilitiesISO_C.f90 @@ -668,7 +668,7 @@ subroutine getReinitDataSizesISO(mElements, mSpecies) & end subroutine getReinitDataSizesISO subroutine getReinitDataISO(mAssemblage,mMolesPhase,mElementPotential, & - mChemicalPotential,mMolFraction,mElementsUsed,mReinitAvailable) & + mChemicalPotential,mMolFraction,mElementsUsed,mReinitAvailable, mIterations) & bind(C, name="TCAPI_getReinitData") USE,INTRINSIC :: ISO_C_BINDING @@ -676,14 +676,14 @@ subroutine getReinitDataISO(mAssemblage,mMolesPhase,mElementPotential, & USE ModuleThermo, ONLY: nElements, nSpecies implicit none - integer(C_INT), intent(out) :: mReinitAvailable + integer(C_INT), intent(out) :: mReinitAvailable, mIterations integer(C_INT), intent(out), dimension(nElements) :: mAssemblage real(C_DOUBLE), intent(out), dimension(nElements) :: mMolesPhase, mElementPotential real(C_DOUBLE), intent(out), dimension(nSpecies) :: mChemicalPotential, mMolFraction integer(C_INT), intent(out), dimension(0:168) :: mElementsUsed call getReinitData(mAssemblage,mMolesPhase,mElementPotential, & - mChemicalPotential,mMolFraction,mElementsUsed,mReinitAvailable) + mChemicalPotential,mMolFraction,mElementsUsed,mReinitAvailable,mIterations) return