ENH: icoReactingMultiPhaseInterFoam: thermo sharing T

This commit is contained in:
mattijs
2018-06-15 14:05:37 +01:00
committed by Andrew Heather
parent 4cb073e150
commit 636328fc1c
10 changed files with 96 additions and 97 deletions

View File

@ -26,6 +26,22 @@
mesh
);
// Note: construct T to be around before the thermos. The thermos will
// not update T.
Info<< "Reading field T\n" << endl;
volScalarField T
(
IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Calculating field g.h\n" << endl;
#include "readGravitationalAcceleration.H"
@ -45,6 +61,7 @@
p_rgh
);
Info<< "Creating multiphaseSystem\n" << endl;
autoPtr<multiphaseSystem> fluidPtr = multiphaseSystem::New(mesh);
@ -57,8 +74,6 @@
}
volScalarField& T = fluid.T();
// Need to store rho for ddt(rho, U)
volScalarField rho
(

View File

@ -126,10 +126,16 @@ Foam::wordList Foam::basicThermo::heBoundaryTypes()
Foam::volScalarField& Foam::basicThermo::lookupOrConstruct
(
const fvMesh& mesh,
const word& name
) const
const word& name,
bool& isOwner
)
{
if (!mesh.objectRegistry::foundObject<volScalarField>(name))
const volScalarField* p =
mesh.objectRegistry::lookupObjectPtr<volScalarField>(name);
isOwner = !p;
if (!p)
{
volScalarField* fPtr
(
@ -149,12 +155,12 @@ Foam::volScalarField& Foam::basicThermo::lookupOrConstruct
// Transfer ownership of this object to the objectRegistry
fPtr->store(fPtr);
return *fPtr;
}
else
{
return const_cast<volScalarField&>(*p);
}
return const_cast<volScalarField&>
(
mesh.objectRegistry::lookupObject<volScalarField>(name)
);
}
@ -172,12 +178,28 @@ Foam::basicThermo::basicThermo
const fvMesh& mesh,
const word& phaseName
)
:
basicThermo
(
mesh,
phaseName,
phasePropertyName(dictName, phaseName)
)
{}
Foam::basicThermo::basicThermo
(
const fvMesh& mesh,
const word& phaseName,
const word& dictionaryName
)
:
IOdictionary
(
IOobject
(
phasePropertyName(dictName, phaseName),
dictionaryName,
mesh.time().constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
@ -187,9 +209,10 @@ Foam::basicThermo::basicThermo
phaseName_(phaseName),
p_(lookupOrConstruct(mesh, "p")),
p_(lookupOrConstruct(mesh, "p", pOwner_)),
T_(lookupOrConstruct(mesh, phasePropertyName("T"))),
T_(lookupOrConstruct(mesh, phasePropertyName("T"), TOwner_)),
TOwner_(lookupOrDefault<Switch>("updateT", TOwner_)),
alpha_
(
@ -210,10 +233,17 @@ Foam::basicThermo::basicThermo
)
),
dpdt_(lookupOrDefault<Switch>("dpdt", true)),
tempBased_(lookupOrDefault<Switch>("tempBased", false))
{}
dpdt_(lookupOrDefault<Switch>("dpdt", true))
{
if (debug)
{
Pout<< "Constructed thermo : mesh:" << mesh.name()
<< " phase:" << phaseName
<< " dictionary:" << dictionaryName
<< " alphaName:" << alpha_.name()
<< " updateT:" << TOwner_ << endl;
}
}
Foam::basicThermo::basicThermo
@ -238,9 +268,10 @@ Foam::basicThermo::basicThermo
phaseName_(phaseName),
p_(lookupOrConstruct(mesh, "p")),
p_(lookupOrConstruct(mesh, "p", pOwner_)),
T_(lookupOrConstruct(mesh, phasePropertyName("T"))),
T_(lookupOrConstruct(mesh, phasePropertyName("T"), TOwner_)),
TOwner_(lookupOrDefault<Switch>("updateT", TOwner_)),
alpha_
(
@ -259,58 +290,7 @@ Foam::basicThermo::basicThermo
dimensionSet(1, -1, -1, 0, 0),
Zero
)
),
tempBased_(lookupOrDefault<Switch>("tempBased", false))
{}
Foam::basicThermo::basicThermo
(
const fvMesh& mesh,
const word& phaseName,
const word& dictionaryName
)
:
IOdictionary
(
IOobject
(
dictionaryName,
mesh.time().constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
),
phaseName_(phaseName),
p_(lookupOrConstruct(mesh, "p")),
T_(lookupOrConstruct(mesh, "T")),
alpha_
(
IOobject
(
"thermo:alpha",
mesh.time().timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar
(
"zero",
dimensionSet(1, -1, -1, 0, 0),
Zero
)
),
dpdt_(lookupOrDefault<Switch>("dpdt", true)),
tempBased_(lookupOrDefault<Switch>("tempBased", true))
)
{}

View File

@ -27,6 +27,14 @@ Class
Description
Abstract base-class for fluid and solid thermodynamic properties
An important concept is that the thermo can share an existing T
(similar to p) in which case it will not try to update it. This gets
triggered purely on construction order - the first one to register
T is repsonsible for updating it. Note that the mechanism also means
that if multiple thermos are running on the same mesh, only the first one
will update the temperature. The behaviour can be overridden using the
'updateT' dictionary entry.
SourceFiles
basicThermo.C
@ -68,18 +76,19 @@ protected:
//- Pressure [Pa]
volScalarField& p_;
bool pOwner_;
//- Temperature [K]
volScalarField& T_;
bool TOwner_;
//- Laminar thermal diffusivity [kg/m/s]
volScalarField alpha_;
//- Should the dpdt term be included in the enthalpy equation
Switch dpdt_;
//- Temperature based thermo
Switch tempBased_;
// Protected Member Functions
@ -87,11 +96,12 @@ protected:
basicThermo(const basicThermo&);
//- Look up or construct field
volScalarField& lookupOrConstruct
static volScalarField& lookupOrConstruct
(
const fvMesh& mesh,
const word&
) const;
const word&,
bool& isOwner
);
//- Lookup and check out field
void lookupAndCheckout(const char* name) const;
@ -150,8 +160,8 @@ public:
const word& phaseName
);
//- Construct from mesh,dictionary,phase name with a single temperature
// solved on the top level solver (tempBased = true)
//- Construct from mesh, phase name and explicit naming of the
// dictionary (so it can be shared amongst phases).
basicThermo
(
const fvMesh&,
@ -304,10 +314,10 @@ public:
return dpdt_;
}
//- Is the thermo T based
Switch tempBased() const
//- Should T be updated
Switch updateT() const
{
return tempBased_;
return TOwner_;
}

View File

@ -68,7 +68,7 @@ void Foam::hePsiThermo<BasicPsiThermo, MixtureType>::calculate
const typename MixtureType::thermoType& mixture_ =
this->cellMixture(celli);
if (!this->tempBased())
if (this->updateT())
{
TCells[celli] = mixture_.THE
(
@ -121,7 +121,7 @@ void Foam::hePsiThermo<BasicPsiThermo, MixtureType>::calculate
const typename MixtureType::thermoType& mixture_ =
this->patchFaceMixture(patchi, facei);
if (!this->tempBased())
if (this->updateT())
{
pT[facei] = mixture_.THE(phe[facei], pp[facei], pT[facei]);
}

View File

@ -66,9 +66,6 @@ class hePsiThermo
const bool doOldTimes
);
//- Calculate the thermo variables for thermos based on T
void calculateT();
//- Construct as copy (not implemented)
hePsiThermo(const hePsiThermo<BasicPsiThermo, MixtureType>&);

View File

@ -71,7 +71,7 @@ void Foam::heRhoThermo<BasicPsiThermo, MixtureType>::calculate
const typename MixtureType::thermoType& mixture_ =
this->cellMixture(celli);
if (!this->tempBased())
if (this->updateT())
{
TCells[celli] = mixture_.THE
(
@ -128,7 +128,7 @@ void Foam::heRhoThermo<BasicPsiThermo, MixtureType>::calculate
const typename MixtureType::thermoType& mixture_ =
this->patchFaceMixture(patchi, facei);
if (!this->tempBased())
if (this->updateT())
{
pT[facei] = mixture_.THE(phe[facei], pp[facei], pT[facei]);
}

View File

@ -67,9 +67,6 @@ class heRhoThermo
const bool doOldTimes
);
//- Calculate the thermo variables based on T
void calculateT();
//- Construct as copy (not implemented)
heRhoThermo(const heRhoThermo<BasicPsiThermo, MixtureType>&);

View File

@ -47,7 +47,7 @@ void Foam::heheuPsiThermo<BasicPsiThermo, MixtureType>::calculate()
const typename MixtureType::thermoType& mixture_ =
this->cellMixture(celli);
if (!this->tempBased())
if (this->updateT())
{
TCells[celli] = mixture_.THE
(
@ -126,7 +126,7 @@ void Foam::heheuPsiThermo<BasicPsiThermo, MixtureType>::calculate()
const typename MixtureType::thermoType& mixture_ =
this->patchFaceMixture(patchi, facei);
if (!this->tempBased())
if (this->updateT())
{
pT[facei] = mixture_.THE(phe[facei], pp[facei], pT[facei]);
}

View File

@ -46,7 +46,7 @@ void Foam::heSolidThermo<BasicSolidThermo, MixtureType>::calculate()
const typename MixtureType::thermoType& volMixture_ =
this->cellVolMixture(pCells[celli], TCells[celli], celli);
if (!this->tempBased())
if (this->updateT())
{
TCells[celli] = mixture_.THE
(
@ -128,7 +128,7 @@ void Foam::heSolidThermo<BasicSolidThermo, MixtureType>::calculate()
facei
);
if (!this->tempBased())
if (this->updateT())
{
pT[facei] = mixture_.THE(phe[facei], pp[facei] ,pT[facei]);
}

View File

@ -16,7 +16,7 @@ FoamFile
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application interThermalDyMFoam;
application icoReactingMultiPhaseInterFoam;
startFrom latestTime;