Skip to content

Commit

Permalink
Merge pull request #151 from parikshitbajpai/caching_utils
Browse files Browse the repository at this point in the history
GEM iteration in reinit data
  • Loading branch information
parikshitbajpai authored Dec 22, 2023
2 parents 4591607 + a50a59c commit fc5cdf3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
12 changes: 10 additions & 2 deletions src/Thermochimica-cxx.C
Original file line number Diff line number Diff line change
Expand Up @@ -476,17 +476,25 @@ namespace Thermochimica
getReinitData()
{
ReinitializationData data;
int available;
int available, iterations;
auto [elements, species] = getReinitDataSizes();
data.assemblage.resize(elements);
data.molesPhase.resize(elements);
data.elementPotential.resize(elements);
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;
}
Expand Down
1 change: 1 addition & 0 deletions src/Thermochimica-cxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ namespace Thermochimica
int nPeriodicTable = 169;
std::vector<int> elementsUsed = std::vector<int>(nPeriodicTable);
bool reinitAvailable;
int GEM_iterations;
};

ReinitializationData getReinitData();
Expand Down
2 changes: 1 addition & 1 deletion src/Thermochimica.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/api/CouplingUtilities.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -624,6 +625,7 @@ subroutine getReinitData(mAssemblage,mMolesPhase,mElementPotential, &
mMolFraction = dMolFraction_Old
mElementsUsed = iElementsUsed_Old
mReinitAvailable = 1
mIterations = iterGlobal
else
mReinitAvailable = 0
end if
Expand Down
6 changes: 3 additions & 3 deletions src/api/CouplingUtilitiesISO_C.f90
Original file line number Diff line number Diff line change
Expand Up @@ -668,22 +668,22 @@ 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

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

Expand Down

0 comments on commit fc5cdf3

Please sign in to comment.