etc/codeTemplates/dynamicCode: Added basicChemistryModel dynamic compilation support
for chemFoam, fireFoam, buoyantReactingFoam, reactingFoam, chtMultiRegionFoam, buoyantReactingParticleFoam, reactingParticleFoam, simpleReactingParticleFoam If the combination of chemistry model and solver selected in chemistryProperties is not already compiled and present in the standard libraries for the selected thermophysical properties the chemistry package will be constructed and compiled automatically using the standard dynamicCode system provided in OpenFOAM. The chemistry package is constructed automatically from the etc/codeTemplates/dynamicCode/basicChemistryModel.* files, if these files do not exist the standard chemistry lookup error message is generated as before. As with all other dynamicCode options in OpenFOAM (codeStream, codedFunctionObject etc.) dynamic compilation of the chemistry package is only enabled if allowSystemOperations is set true.
This commit is contained in:
54
etc/codeTemplates/dynamicCode/basicChemistryModel
Normal file
54
etc/codeTemplates/dynamicCode/basicChemistryModel
Normal file
@ -0,0 +1,54 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Version: dev
|
||||
\\/ M anipulation |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object basicChemistryModel;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
solver
|
||||
(
|
||||
EulerImplicit
|
||||
ode
|
||||
noChemistrySolver
|
||||
);
|
||||
|
||||
solverRenamed
|
||||
(
|
||||
none noChemistrySolver
|
||||
);
|
||||
|
||||
method
|
||||
(
|
||||
Standard
|
||||
TDAC
|
||||
);
|
||||
|
||||
methodRenamed
|
||||
(
|
||||
standard Standard
|
||||
);
|
||||
|
||||
codeOptions
|
||||
#{
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/transportModels/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \
|
||||
-I$(LIB_SRC)/ODE/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
#};
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
235
etc/codeTemplates/dynamicCode/basicChemistryModel.C
Normal file
235
etc/codeTemplates/dynamicCode/basicChemistryModel.C
Normal file
@ -0,0 +1,235 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) YEAR OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "makeChemistrySolver.H"
|
||||
#include "${method}ChemistryModel.H"
|
||||
#include "${solver}.H"
|
||||
|
||||
#include "typedefThermo.H"
|
||||
|
||||
#include "${specie}.H"
|
||||
|
||||
#include "thermo.H"
|
||||
|
||||
// EoS
|
||||
#include "${equationOfState}.H"
|
||||
|
||||
// Thermo
|
||||
#include "${thermo}Thermo.H"
|
||||
#include "${energy}.H"
|
||||
|
||||
// Transport
|
||||
#include "${transport}Transport.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// dynamicCode:
|
||||
// SHA1 = ${SHA1sum}
|
||||
//
|
||||
// Unique function name that can be checked if the correct library version
|
||||
// has been loaded
|
||||
void ${typeName}_${SHA1sum}(bool load)
|
||||
{
|
||||
if (load)
|
||||
{
|
||||
// code that can be explicitly executed after loading
|
||||
}
|
||||
else
|
||||
{
|
||||
// code that can be explicitly executed before unloading
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define ThermoPhysics \
|
||||
${transport}Transport${energy}${thermo}Thermo${equationOfState}${specie}
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedefThermo
|
||||
(
|
||||
${transport}Transport,
|
||||
${energy},
|
||||
${thermo}Thermo,
|
||||
${equationOfState},
|
||||
${specie}
|
||||
);
|
||||
|
||||
defineChemistrySolver(${method}ChemistryModel, ThermoPhysics);
|
||||
makeChemistrySolver(${solver}, ${method}ChemistryModel, ThermoPhysics);
|
||||
}
|
||||
|
||||
|
||||
#if ${method} == TDAC
|
||||
|
||||
#include "makeChemistryReductionMethod.H"
|
||||
#include "makeChemistryTabulationMethod.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineChemistrySolver(StandardChemistryModel, ThermoPhysics);
|
||||
defineChemistryReductionMethod(nullArg, ThermoPhysics);
|
||||
defineChemistryTabulationMethod(nullArg, ThermoPhysics);
|
||||
}
|
||||
|
||||
#include "noChemistryReduction.H"
|
||||
#include "DAC.H"
|
||||
#include "DRG.H"
|
||||
#include "DRGEP.H"
|
||||
#include "EFA.H"
|
||||
#include "PFA.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeChemistryReductionMethod(none, ThermoPhysics);
|
||||
makeChemistryReductionMethod(DAC, ThermoPhysics);
|
||||
makeChemistryReductionMethod(DRG, ThermoPhysics);
|
||||
makeChemistryReductionMethod(DRGEP, ThermoPhysics);
|
||||
makeChemistryReductionMethod(EFA, ThermoPhysics);
|
||||
makeChemistryReductionMethod(PFA, ThermoPhysics);
|
||||
}
|
||||
|
||||
#include "noChemistryTabulation.H"
|
||||
#include "ISAT.H"
|
||||
namespace Foam
|
||||
{
|
||||
makeChemistryTabulationMethod(none, ThermoPhysics);
|
||||
makeChemistryTabulationMethod(ISAT, ThermoPhysics);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "makeReaction.H"
|
||||
|
||||
#include "ArrheniusReactionRate.H"
|
||||
#include "LandauTellerReactionRate.H"
|
||||
#include "thirdBodyArrheniusReactionRate.H"
|
||||
|
||||
#include "JanevReactionRate.H"
|
||||
#include "powerSeriesReactionRate.H"
|
||||
|
||||
#include "ChemicallyActivatedReactionRate.H"
|
||||
#include "FallOffReactionRate.H"
|
||||
|
||||
#include "LindemannFallOffFunction.H"
|
||||
#include "SRIFallOffFunction.H"
|
||||
#include "TroeFallOffFunction.H"
|
||||
|
||||
#include "LangmuirHinshelwoodReactionRate.H"
|
||||
|
||||
#include "MichaelisMentenReactionRate.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineReaction(nullArg, ThermoPhysics);
|
||||
|
||||
makeIRNReactions(ArrheniusReactionRate, ThermoPhysics);
|
||||
makeIRNReactions(LandauTellerReactionRate, ThermoPhysics);
|
||||
makeIRNReactions(thirdBodyArrheniusReactionRate, ThermoPhysics);
|
||||
makeIRReactions(JanevReactionRate, ThermoPhysics);
|
||||
makeIRReactions(powerSeriesReactionRate, ThermoPhysics);
|
||||
|
||||
makeIRRPressureDependentReactions
|
||||
(
|
||||
FallOffReactionRate,
|
||||
ArrheniusReactionRate,
|
||||
LindemannFallOffFunction,
|
||||
ThermoPhysics
|
||||
);
|
||||
|
||||
makeIRRPressureDependentReactions
|
||||
(
|
||||
FallOffReactionRate,
|
||||
ArrheniusReactionRate,
|
||||
TroeFallOffFunction,
|
||||
ThermoPhysics
|
||||
);
|
||||
|
||||
makeIRRPressureDependentReactions
|
||||
(
|
||||
FallOffReactionRate,
|
||||
ArrheniusReactionRate,
|
||||
SRIFallOffFunction,
|
||||
ThermoPhysics
|
||||
);
|
||||
|
||||
makeIRRPressureDependentReactions
|
||||
(
|
||||
ChemicallyActivatedReactionRate,
|
||||
ArrheniusReactionRate,
|
||||
LindemannFallOffFunction,
|
||||
ThermoPhysics
|
||||
);
|
||||
|
||||
makeIRRPressureDependentReactions
|
||||
(
|
||||
ChemicallyActivatedReactionRate,
|
||||
ArrheniusReactionRate,
|
||||
TroeFallOffFunction,
|
||||
ThermoPhysics
|
||||
);
|
||||
|
||||
makeIRRPressureDependentReactions
|
||||
(
|
||||
ChemicallyActivatedReactionRate,
|
||||
ArrheniusReactionRate,
|
||||
SRIFallOffFunction,
|
||||
ThermoPhysics
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "LangmuirHinshelwoodReactionRate.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeIRReactions(LangmuirHinshelwoodReactionRate, ThermoPhysics);
|
||||
}
|
||||
|
||||
|
||||
#include "fluxLimitedLangmuirHinshelwoodReactionRate.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeGeneralReaction
|
||||
(
|
||||
IrreversibleReaction,
|
||||
fluxLimitedLangmuirHinshelwoodReactionRate,
|
||||
ThermoPhysics
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -10,7 +10,7 @@ FoamFile
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object fluidThermo;
|
||||
object fluidReactionThermo;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -20,7 +20,7 @@ type
|
||||
heRhoThermo
|
||||
);
|
||||
|
||||
baseType
|
||||
typeBase
|
||||
(
|
||||
hePsiThermo psiReactionThermo
|
||||
heRhoThermo rhoReactionThermo
|
||||
@ -42,7 +42,7 @@ mixture
|
||||
coefficientWilkeMultiComponentMixture
|
||||
);
|
||||
|
||||
renameMixture
|
||||
mixtureRenamed
|
||||
(
|
||||
pureMixture singleComponentMixture
|
||||
multiComponentMixture coefficientMultiComponentMixture
|
||||
@ -90,6 +90,11 @@ equationOfState
|
||||
rPolynomial
|
||||
);
|
||||
|
||||
specie
|
||||
(
|
||||
specie
|
||||
);
|
||||
|
||||
codeOptions
|
||||
#{
|
||||
EXE_INC = \
|
||||
@ -100,14 +105,5 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
#};
|
||||
|
||||
codeLibs
|
||||
#{
|
||||
LIB_LIBS = \
|
||||
-ltransportModels \
|
||||
-lspecie \
|
||||
-lfluidThermophysicalModels \
|
||||
-lfiniteVolume
|
||||
#};
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -26,7 +26,7 @@ License
|
||||
#include "forThermo.H"
|
||||
#include "makeReactionThermo.H"
|
||||
|
||||
#include "specie.H"
|
||||
#include "${specie}.H"
|
||||
|
||||
#include "thermo.H"
|
||||
|
||||
@ -41,9 +41,8 @@ License
|
||||
#include "${transport}Transport.H"
|
||||
|
||||
// psi/rho
|
||||
#include "${baseType}.H"
|
||||
#include "${typeBase}.H"
|
||||
#include "${type}.H"
|
||||
#include "psiReactionThermo.H"
|
||||
|
||||
// Mixture
|
||||
#include "${mixture}.H"
|
||||
@ -82,12 +81,13 @@ namespace Foam
|
||||
${energy},
|
||||
${thermo}Thermo,
|
||||
${equationOfState},
|
||||
specie,
|
||||
${specie},
|
||||
makeReactionThermo,
|
||||
${baseType},
|
||||
${typeBase},
|
||||
${type},
|
||||
${mixture}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -20,7 +20,7 @@ type
|
||||
heRhoThermo
|
||||
);
|
||||
|
||||
baseType
|
||||
typeBase
|
||||
(
|
||||
hePsiThermo psiThermo
|
||||
heRhoThermo rhoThermo
|
||||
@ -81,6 +81,11 @@ equationOfState
|
||||
rPolynomial
|
||||
);
|
||||
|
||||
specie
|
||||
(
|
||||
specie
|
||||
);
|
||||
|
||||
codeOptions
|
||||
#{
|
||||
EXE_INC = \
|
||||
@ -91,15 +96,5 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
#};
|
||||
|
||||
codeLibs
|
||||
#{
|
||||
LIB_LIBS = \
|
||||
-ltransportModels \
|
||||
-lspecie \
|
||||
-lthermophysicalProperties \
|
||||
-lfluidThermophysicalModels \
|
||||
-lfiniteVolume
|
||||
#};
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -26,7 +26,7 @@ License
|
||||
#include "forThermo.H"
|
||||
#include "makeThermo.H"
|
||||
|
||||
#include "specie.H"
|
||||
#include "${specie}.H"
|
||||
|
||||
#include "thermo.H"
|
||||
|
||||
@ -41,7 +41,7 @@ License
|
||||
#include "${transport}Transport.H"
|
||||
|
||||
// psi/rho
|
||||
#include "${baseType}.H"
|
||||
#include "${typeBase}.H"
|
||||
#include "${type}.H"
|
||||
|
||||
// Mixture
|
||||
@ -81,9 +81,9 @@ namespace Foam
|
||||
${energy},
|
||||
${thermo}Thermo,
|
||||
${equationOfState},
|
||||
specie,
|
||||
${specie},
|
||||
makeThermo,
|
||||
${baseType},
|
||||
${typeBase},
|
||||
${type},
|
||||
${mixture}
|
||||
);
|
||||
|
||||
@ -19,7 +19,7 @@ type
|
||||
hePsiThermo
|
||||
);
|
||||
|
||||
baseType
|
||||
typeBase
|
||||
(
|
||||
hePsiThermo psiThermo
|
||||
);
|
||||
@ -66,6 +66,11 @@ equationOfState
|
||||
perfectGas
|
||||
);
|
||||
|
||||
specie
|
||||
(
|
||||
specie
|
||||
);
|
||||
|
||||
codeOptions
|
||||
#{
|
||||
EXE_INC = \
|
||||
@ -76,15 +81,5 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
#};
|
||||
|
||||
codeLibs
|
||||
#{
|
||||
LIB_LIBS = \
|
||||
-ltransportModels \
|
||||
-lspecie \
|
||||
-lthermophysicalProperties \
|
||||
-lfluidThermophysicalModels \
|
||||
-lfiniteVolume
|
||||
#};
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -19,7 +19,7 @@ type
|
||||
heheuPsiThermo
|
||||
);
|
||||
|
||||
baseType
|
||||
typeBase
|
||||
(
|
||||
heheuPsiThermo psiuReactionThermo
|
||||
);
|
||||
@ -65,6 +65,11 @@ equationOfState
|
||||
perfectGas
|
||||
);
|
||||
|
||||
specie
|
||||
(
|
||||
specie
|
||||
);
|
||||
|
||||
codeOptions
|
||||
#{
|
||||
EXE_INC = \
|
||||
@ -75,13 +80,5 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
#};
|
||||
|
||||
codeLibs
|
||||
#{
|
||||
LIB_LIBS = \
|
||||
-lfluidThermophysicalModels \
|
||||
-lspecie \
|
||||
-lfiniteVolume
|
||||
#};
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -26,7 +26,7 @@ License
|
||||
#include "forThermo.H"
|
||||
#include "makeReactionThermo.H"
|
||||
|
||||
#include "specie.H"
|
||||
#include "${specie}.H"
|
||||
|
||||
#include "thermo.H"
|
||||
|
||||
@ -41,7 +41,7 @@ License
|
||||
#include "${transport}Transport.H"
|
||||
|
||||
// psi/rho
|
||||
#include "${baseType}.H"
|
||||
#include "${typeBase}.H"
|
||||
#include "${type}.H"
|
||||
|
||||
// Mixture
|
||||
@ -81,7 +81,7 @@ namespace Foam
|
||||
${energy},
|
||||
${thermo}Thermo,
|
||||
${equationOfState},
|
||||
specie,
|
||||
${specie},
|
||||
makePsiuReactionThermo,
|
||||
${mixture}
|
||||
);
|
||||
|
||||
@ -268,6 +268,7 @@ $(dll)/dlLibraryTable/dlLibraryTable.C
|
||||
$(dll)/dynamicCode/dynamicCode.C
|
||||
$(dll)/dynamicCode/dynamicCodeContext.C
|
||||
$(dll)/codedBase/codedBase.C
|
||||
$(dll)/compileTemplate/compileTemplate.C
|
||||
|
||||
db/functionObjects/functionObject/functionObject.C
|
||||
db/functionObjects/functionObjectList/functionObjectList.C
|
||||
|
||||
@ -23,8 +23,7 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "basicThermo.H"
|
||||
#include "compileThermo.H"
|
||||
#include "compileTemplate.H"
|
||||
#include "dynamicCodeContext.H"
|
||||
#include "Time.H"
|
||||
#include "IFstream.H"
|
||||
@ -33,40 +32,40 @@ License
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
const Foam::wordList Foam::CodedBase<Foam::compileThermo>::codeKeys_ =
|
||||
const Foam::wordList Foam::CodedBase<Foam::compileTemplate>::codeKeys_ =
|
||||
{};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::dictionary Foam::compileThermo::optionsDict
|
||||
Foam::dictionary Foam::compileTemplate::optionsDict
|
||||
(
|
||||
const word& thermoTypeName,
|
||||
const word& instantiatedThermoName
|
||||
const word& templateName,
|
||||
const word& instantiatedName
|
||||
) const
|
||||
{
|
||||
IFstream optionsFile(dynamicCode::resolveTemplate(thermoTypeName));
|
||||
IFstream optionsFile(dynamicCode::resolveTemplate(templateName));
|
||||
if (!optionsFile.good())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Failed to open dictionary file " << thermoTypeName
|
||||
<< "Failed to open dictionary file " << templateName
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
dictionary dict(optionsFile);
|
||||
|
||||
fileName thermoTypeFileName(instantiatedThermoName);
|
||||
thermoTypeFileName.replaceAll(',', '_');
|
||||
thermoTypeFileName.replaceAll('<', '_');
|
||||
thermoTypeFileName.replaceAll('>', '_');
|
||||
fileName templateFileName(instantiatedName);
|
||||
templateFileName.replaceAll(',', '_');
|
||||
templateFileName.replaceAll('<', '_');
|
||||
templateFileName.replaceAll('>', '_');
|
||||
|
||||
dict.add("name", thermoTypeFileName);
|
||||
dict.add("name", templateFileName);
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
|
||||
void Foam::compileThermo::setFilterVariable
|
||||
void Foam::compileTemplate::setFilterVariable
|
||||
(
|
||||
dynamicCode& dynCode,
|
||||
const dynamicCodeContext& context,
|
||||
@ -74,45 +73,32 @@ void Foam::compileThermo::setFilterVariable
|
||||
const word& type
|
||||
) const
|
||||
{
|
||||
if (context.dict().found(name))
|
||||
{
|
||||
const HashSet<word> types(context.dict().lookup(name));
|
||||
if (!types.found(type))
|
||||
{
|
||||
FatalIOErrorInFunction(thermoTypeDict_)
|
||||
FatalIOErrorInFunction(context.dict())
|
||||
<< "Unknown " << name << " type " << type << nl
|
||||
<< "Supported " << name << " types: " << types
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
dynCode.setFilterVariable(name, type);
|
||||
}
|
||||
|
||||
|
||||
void Foam::compileThermo::setFilterVariable
|
||||
void Foam::compileTemplate::setFilterVariable
|
||||
(
|
||||
dynamicCode& dynCode,
|
||||
const dynamicCodeContext& context,
|
||||
const word& name
|
||||
const Pair<word>& substitution
|
||||
) const
|
||||
{
|
||||
setFilterVariable
|
||||
(
|
||||
dynCode,
|
||||
context,
|
||||
name,
|
||||
thermoTypeDict_.lookup<word>(name)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::compileThermo::setFilterRenamedVariable
|
||||
(
|
||||
dynamicCode& dynCode,
|
||||
const dynamicCodeContext& context,
|
||||
const word& name,
|
||||
const word& typeRenameMapName
|
||||
) const
|
||||
{
|
||||
word type(thermoTypeDict_.lookup<word>(name));
|
||||
const word& name(substitution.first());
|
||||
word type(substitution.second());
|
||||
const word typeRenameMapName(name + "Renamed");
|
||||
|
||||
if (context.dict().found(typeRenameMapName))
|
||||
{
|
||||
@ -128,10 +114,17 @@ void Foam::compileThermo::setFilterRenamedVariable
|
||||
}
|
||||
|
||||
setFilterVariable(dynCode, context, name, type);
|
||||
|
||||
const word typeBase(name + "Base");
|
||||
if (context.dict().found(typeBase))
|
||||
{
|
||||
const HashTable<word> typeToBaseMap(context.dict().lookup(typeBase));
|
||||
dynCode.setFilterVariable(typeBase, typeToBaseMap[type]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::compileThermo::prepare
|
||||
void Foam::compileTemplate::prepare
|
||||
(
|
||||
dynamicCode& dynCode,
|
||||
const dynamicCodeContext& context
|
||||
@ -139,20 +132,13 @@ void Foam::compileThermo::prepare
|
||||
{
|
||||
dynCode.setFilterVariable("typeName", codeName());
|
||||
|
||||
const word type(thermoTypeDict_.lookup<word>("type"));
|
||||
dynCode.setFilterVariable("type", type);
|
||||
|
||||
const HashTable<word> typeToBaseMap(context.dict().lookup("baseType"));
|
||||
dynCode.setFilterVariable("baseType", typeToBaseMap[type]);
|
||||
|
||||
setFilterRenamedVariable(dynCode, context, "mixture", "renameMixture");
|
||||
setFilterVariable(dynCode, context, "transport");
|
||||
setFilterVariable(dynCode, context, "thermo");
|
||||
setFilterVariable(dynCode, context, "equationOfState");
|
||||
setFilterVariable(dynCode, context, "energy");
|
||||
forAll(substitutions_, i)
|
||||
{
|
||||
setFilterVariable(dynCode, context, substitutions_[i]);
|
||||
}
|
||||
|
||||
// Compile filtered C template
|
||||
dynCode.addCompileFile(thermoTypeName_ + ".C");
|
||||
dynCode.addCompileFile(templateName_ + ".C");
|
||||
|
||||
// Define Make/options
|
||||
dynCode.setMakeOptions(context.options() + "\n\n" + context.libs());
|
||||
@ -169,19 +155,19 @@ void Foam::compileThermo::prepare
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::compileThermo::compileThermo
|
||||
Foam::compileTemplate::compileTemplate
|
||||
(
|
||||
const word& thermoTypeName,
|
||||
const word& instantiatedThermoName,
|
||||
const dictionary& thermoTypeDict
|
||||
const word& templateName,
|
||||
const word& instantiatedName,
|
||||
const List<Pair<word>>& substitutions
|
||||
)
|
||||
:
|
||||
CodedBase<compileThermo>
|
||||
CodedBase<compileTemplate>
|
||||
(
|
||||
optionsDict(thermoTypeName, instantiatedThermoName)
|
||||
optionsDict(templateName, instantiatedName)
|
||||
),
|
||||
thermoTypeName_(thermoTypeName),
|
||||
thermoTypeDict_(thermoTypeDict)
|
||||
templateName_(templateName),
|
||||
substitutions_(substitutions)
|
||||
{
|
||||
this->updateLibrary();
|
||||
}
|
||||
@ -23,8 +23,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef compileThermo_H
|
||||
#define compileThermo_H
|
||||
#ifndef compileTemplate_H
|
||||
#define compileTemplate_H
|
||||
|
||||
#include "CodedBase.H"
|
||||
#include "dynamicCode.H"
|
||||
@ -35,28 +35,28 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class compileThermo Declaration
|
||||
Class compileTemplate Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class compileThermo
|
||||
class compileTemplate
|
||||
:
|
||||
public CodedBase<compileThermo>
|
||||
public CodedBase<compileTemplate>
|
||||
{
|
||||
// Private Member Data
|
||||
|
||||
//- Name of the class Thermo basicThermo is instantiated on
|
||||
const word thermoTypeName_;
|
||||
const word templateName_;
|
||||
|
||||
//- Reference to the dictionary containing the thermo components
|
||||
const dictionary& thermoTypeDict_;
|
||||
//- List of template argument substitutions
|
||||
const List<Pair<word>> substitutions_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
dictionary optionsDict
|
||||
(
|
||||
const word& thermoTypeName,
|
||||
const word& instantiatedThermoName
|
||||
const word& templateName,
|
||||
const word& instantiatedName
|
||||
) const;
|
||||
|
||||
void setFilterVariable
|
||||
@ -71,15 +71,7 @@ class compileThermo
|
||||
(
|
||||
dynamicCode& dynCode,
|
||||
const dynamicCodeContext& context,
|
||||
const word& name
|
||||
) const;
|
||||
|
||||
void setFilterRenamedVariable
|
||||
(
|
||||
dynamicCode& dynCode,
|
||||
const dynamicCodeContext& context,
|
||||
const word& name,
|
||||
const word& typeRenameMapName
|
||||
const Pair<word>& substitution
|
||||
) const;
|
||||
|
||||
//- Adapt the context for the current object
|
||||
@ -95,11 +87,11 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from name and dictionary
|
||||
compileThermo
|
||||
compileTemplate
|
||||
(
|
||||
const word& thermoTypeName,
|
||||
const word& instantiatedThermoName,
|
||||
const dictionary& thermoTypeDict
|
||||
const word& templateName,
|
||||
const word& instantiatedName,
|
||||
const List<Pair<word>>& substitutions
|
||||
);
|
||||
};
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
basicThermo/basicThermo.C
|
||||
basicThermo/compileThermo.C
|
||||
|
||||
fluidThermo/fluidThermo.C
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -179,6 +179,24 @@ Foam::wordList Foam::basicThermo::splitThermoName
|
||||
}
|
||||
|
||||
|
||||
Foam::List<Foam::Pair<Foam::word>> Foam::basicThermo::thermoNameComponents
|
||||
(
|
||||
const word& thermoName
|
||||
)
|
||||
{
|
||||
const wordList components(splitThermoName(thermoName, 5));
|
||||
|
||||
return List<Pair<word>>
|
||||
{
|
||||
{"transport", components[0]},
|
||||
{"thermo", components[1]},
|
||||
{"equationOfState", components[2]},
|
||||
{"specie", components[3]},
|
||||
{"energy", components[4]}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::wordList Foam::basicThermo::heBoundaryBaseTypes()
|
||||
|
||||
@ -169,6 +169,12 @@ public:
|
||||
const int nCmpt
|
||||
);
|
||||
|
||||
//- Split name of thermo package into a list of named components names
|
||||
static List<Pair<word>> thermoNameComponents
|
||||
(
|
||||
const word& thermoName
|
||||
);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ License
|
||||
|
||||
#include "basicThermo.H"
|
||||
#include "wordIOList.H"
|
||||
#include "compileThermo.H"
|
||||
#include "compileTemplate.H"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
@ -50,11 +50,23 @@ typename Table::iterator Foam::basicThermo::lookupCstrIter
|
||||
&& !dynamicCode::resolveTemplate(Thermo::typeName).empty()
|
||||
)
|
||||
{
|
||||
compileThermo thermo
|
||||
compileTemplate thermo
|
||||
(
|
||||
Thermo::typeName,
|
||||
thermoTypeName,
|
||||
thermoTypeDict
|
||||
List<Pair<word>>
|
||||
{
|
||||
{"type", thermoTypeDict.lookup("type")},
|
||||
{"mixture", thermoTypeDict.lookup("mixture")},
|
||||
{"transport", thermoTypeDict.lookup("transport")},
|
||||
{"thermo", thermoTypeDict.lookup("thermo")},
|
||||
{
|
||||
"equationOfState",
|
||||
thermoTypeDict.lookup("equationOfState")
|
||||
},
|
||||
{"specie", thermoTypeDict.lookup("specie")},
|
||||
{"energy", thermoTypeDict.lookup("energy")}
|
||||
}
|
||||
);
|
||||
cstrIter = tablePtr->find(thermoTypeName);
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ License
|
||||
|
||||
#include "basicChemistryModel.H"
|
||||
#include "basicThermo.H"
|
||||
#include "compileTemplate.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -93,6 +94,39 @@ Foam::autoPtr<Foam::basicChemistryModel> Foam::basicChemistryModel::New
|
||||
thermoConstructorTablePtr_->find(chemSolverNameName);
|
||||
|
||||
if (cstrIter == thermoConstructorTablePtr_->end())
|
||||
{
|
||||
if
|
||||
(
|
||||
dynamicCode::allowSystemOperations
|
||||
&& !dynamicCode::resolveTemplate(basicChemistryModel::typeName).empty()
|
||||
)
|
||||
{
|
||||
List<Pair<word>> substitutions
|
||||
(
|
||||
basicThermo::thermoNameComponents(thermo.thermoName())
|
||||
);
|
||||
|
||||
substitutions.append({"solver", solverName});
|
||||
substitutions.append({"method", methodName});
|
||||
|
||||
compileTemplate chemistryModel
|
||||
(
|
||||
basicChemistryModel::typeName,
|
||||
chemSolverNameName,
|
||||
substitutions
|
||||
);
|
||||
cstrIter = thermoConstructorTablePtr_->find(chemSolverNameName);
|
||||
|
||||
if (cstrIter == thermoConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Compilation and linkage of "
|
||||
<< basicChemistryModel::typeName << " type " << nl
|
||||
<< "chemistryType" << chemistryTypeDict << nl << nl
|
||||
<< "failed." << exit(FatalError);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown " << typeName_() << " type " << chemistryTypeDictNew
|
||||
@ -103,7 +137,10 @@ Foam::autoPtr<Foam::basicChemistryModel> Foam::basicChemistryModel::New
|
||||
wordList thisCmpts;
|
||||
thisCmpts.append(word::null);
|
||||
thisCmpts.append(word::null);
|
||||
thisCmpts.append(basicThermo::splitThermoName(thermo.thermoName(), 5));
|
||||
thisCmpts.append
|
||||
(
|
||||
basicThermo::splitThermoName(thermo.thermoName(), 5)
|
||||
);
|
||||
|
||||
List<wordList> validNames;
|
||||
validNames.append(wordList(2, word::null));
|
||||
@ -113,7 +150,11 @@ Foam::autoPtr<Foam::basicChemistryModel> Foam::basicChemistryModel::New
|
||||
{
|
||||
const wordList cmpts(basicThermo::splitThermoName(names[i], 7));
|
||||
|
||||
if (SubList<word>(cmpts, 5, 2) == SubList<word>(thisCmpts, 5, 2))
|
||||
if
|
||||
(
|
||||
SubList<word>(cmpts, 5, 2)
|
||||
== SubList<word>(thisCmpts, 5, 2)
|
||||
)
|
||||
{
|
||||
validNames.append(SubList<word>(cmpts, 2));
|
||||
}
|
||||
@ -149,8 +190,10 @@ Foam::autoPtr<Foam::basicChemistryModel> Foam::basicChemistryModel::New
|
||||
|
||||
FatalErrorInFunction << exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
return autoPtr<basicChemistryModel>(cstrIter()(thermo));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user