ENH: Updated second-order restart for thermo fields

This commit is contained in:
Andrew Heather
2017-04-04 12:41:35 +01:00
parent 9fa89e67c6
commit 95c37c0cbb
6 changed files with 186 additions and 102 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -52,11 +52,16 @@ heBoundaryCorrection(volScalarField& h)
template<class BasicThermo, class MixtureType> template<class BasicThermo, class MixtureType>
void Foam::heThermo<BasicThermo, MixtureType>::init() void Foam::heThermo<BasicThermo, MixtureType>::init
(
const volScalarField& p,
const volScalarField& T,
volScalarField& he
)
{ {
scalarField& heCells = he_.primitiveFieldRef(); scalarField& heCells = he.primitiveFieldRef();
const scalarField& pCells = this->p_; const scalarField& pCells = p.primitiveField();
const scalarField& TCells = this->T_; const scalarField& TCells = T.primitiveField();
forAll(heCells, celli) forAll(heCells, celli)
{ {
@ -64,19 +69,25 @@ void Foam::heThermo<BasicThermo, MixtureType>::init()
this->cellMixture(celli).HE(pCells[celli], TCells[celli]); this->cellMixture(celli).HE(pCells[celli], TCells[celli]);
} }
volScalarField::Boundary& heBf = he_.boundaryFieldRef(); volScalarField::Boundary& heBf = he.boundaryFieldRef();
forAll(heBf, patchi) forAll(heBf, patchi)
{ {
heBf[patchi] == he heBf[patchi] == this->he
( (
this->p_.boundaryField()[patchi], p.boundaryField()[patchi],
this->T_.boundaryField()[patchi], T.boundaryField()[patchi],
patchi patchi
); );
} }
this->heBoundaryCorrection(he_); this->heBoundaryCorrection(he);
// Note: T does not have oldTime
if (p.nOldTimes() > 0)
{
init(p.oldTime(), T.oldTime(), he.oldTime());
}
} }
@ -112,7 +123,7 @@ Foam::heThermo<BasicThermo, MixtureType>::heThermo
this->heBoundaryBaseTypes() this->heBoundaryBaseTypes()
) )
{ {
init(); init(this->p_, this->T_, he_);
} }
@ -146,7 +157,7 @@ Foam::heThermo<BasicThermo, MixtureType>::heThermo
this->heBoundaryBaseTypes() this->heBoundaryBaseTypes()
) )
{ {
init(); init(this->p_, this->T_, he_);
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -77,7 +77,12 @@ private:
//- Initialize heThermo //- Initialize heThermo
void init(); void init
(
const volScalarField& p,
const volScalarField& T,
volScalarField& he
);
public: public:

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,15 +28,40 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class BasicPsiThermo, class MixtureType> template<class BasicPsiThermo, class MixtureType>
void Foam::hePsiThermo<BasicPsiThermo, MixtureType>::calculate() void Foam::hePsiThermo<BasicPsiThermo, MixtureType>::calculate
(
const volScalarField& p,
volScalarField& T,
volScalarField& he,
volScalarField& psi,
volScalarField& mu,
volScalarField& alpha,
const bool doOldTimes
)
{ {
const scalarField& hCells = this->he_; // Note: update oldTimes before current time so that if T.oldTime() is
const scalarField& pCells = this->p_; // created from T, it starts from the unconverted T
if (doOldTimes && (p.nOldTimes() || T.nOldTimes()))
{
calculate
(
p.oldTime(),
T.oldTime(),
he.oldTime(),
psi.oldTime(),
mu.oldTime(),
alpha.oldTime(),
true
);
}
scalarField& TCells = this->T_.primitiveFieldRef(); const scalarField& hCells = he.primitiveField();
scalarField& psiCells = this->psi_.primitiveFieldRef(); const scalarField& pCells = p.primitiveField();
scalarField& muCells = this->mu_.primitiveFieldRef();
scalarField& alphaCells = this->alpha_.primitiveFieldRef(); scalarField& TCells = T.primitiveFieldRef();
scalarField& psiCells = psi.primitiveFieldRef();
scalarField& muCells = mu.primitiveFieldRef();
scalarField& alphaCells = alpha.primitiveFieldRef();
forAll(TCells, celli) forAll(TCells, celli)
{ {
@ -56,27 +81,16 @@ void Foam::hePsiThermo<BasicPsiThermo, MixtureType>::calculate()
alphaCells[celli] = mixture_.alphah(pCells[celli], TCells[celli]); alphaCells[celli] = mixture_.alphah(pCells[celli], TCells[celli]);
} }
volScalarField::Boundary& pBf = const volScalarField::Boundary& pBf = p.boundaryField();
this->p_.boundaryFieldRef(); volScalarField::Boundary& TBf = T.boundaryFieldRef();
volScalarField::Boundary& psiBf = psi.boundaryFieldRef();
volScalarField::Boundary& heBf = he.boundaryFieldRef();
volScalarField::Boundary& muBf = mu.boundaryFieldRef();
volScalarField::Boundary& alphaBf = alpha.boundaryFieldRef();
volScalarField::Boundary& TBf = forAll(pBf, patchi)
this->T_.boundaryFieldRef();
volScalarField::Boundary& psiBf =
this->psi_.boundaryFieldRef();
volScalarField::Boundary& heBf =
this->he().boundaryFieldRef();
volScalarField::Boundary& muBf =
this->mu_.boundaryFieldRef();
volScalarField::Boundary& alphaBf =
this->alpha_.boundaryFieldRef();
forAll(this->T_.boundaryField(), patchi)
{ {
fvPatchScalarField& pp = pBf[patchi]; const fvPatchScalarField& pp = pBf[patchi];
fvPatchScalarField& pT = TBf[patchi]; fvPatchScalarField& pT = TBf[patchi];
fvPatchScalarField& ppsi = psiBf[patchi]; fvPatchScalarField& ppsi = psiBf[patchi];
fvPatchScalarField& phe = heBf[patchi]; fvPatchScalarField& phe = heBf[patchi];
@ -126,10 +140,16 @@ Foam::hePsiThermo<BasicPsiThermo, MixtureType>::hePsiThermo
: :
heThermo<BasicPsiThermo, MixtureType>(mesh, phaseName) heThermo<BasicPsiThermo, MixtureType>(mesh, phaseName)
{ {
calculate(); calculate
(
// Switch on saving old time this->p_,
this->psi_.oldTime(); this->T_,
this->he_,
this->psi_,
this->mu_,
this->alpha_,
true // Create old time fields
);
} }
@ -145,20 +165,20 @@ Foam::hePsiThermo<BasicPsiThermo, MixtureType>::~hePsiThermo()
template<class BasicPsiThermo, class MixtureType> template<class BasicPsiThermo, class MixtureType>
void Foam::hePsiThermo<BasicPsiThermo, MixtureType>::correct() void Foam::hePsiThermo<BasicPsiThermo, MixtureType>::correct()
{ {
if (debug) DebugInFunction << endl;
{
InfoInFunction << endl;
}
// force the saving of the old-time values calculate
this->psi_.oldTime(); (
this->p_,
this->T_,
this->he_,
this->psi_,
this->mu_,
this->alpha_,
false // No need to update old times
);
calculate(); DebugInFunction << "Finished" << endl;
if (debug)
{
Info<< " Finished" << endl;
}
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -55,11 +55,21 @@ class hePsiThermo
// Private Member Functions // Private Member Functions
//- Calculate the thermo variables //- Calculate the thermo variables
void calculate(); void calculate
(
const volScalarField& p,
volScalarField& T,
volScalarField& he,
volScalarField& psi,
volScalarField& mu,
volScalarField& alpha,
const bool doOldTimes
);
//- Construct as copy (not implemented) //- Construct as copy (not implemented)
hePsiThermo(const hePsiThermo<BasicPsiThermo, MixtureType>&); hePsiThermo(const hePsiThermo<BasicPsiThermo, MixtureType>&);
public: public:
//- Runtime type information //- Runtime type information

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,16 +28,43 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class BasicPsiThermo, class MixtureType> template<class BasicPsiThermo, class MixtureType>
void Foam::heRhoThermo<BasicPsiThermo, MixtureType>::calculate() void Foam::heRhoThermo<BasicPsiThermo, MixtureType>::calculate
(
const volScalarField& p,
volScalarField& T,
volScalarField& he,
volScalarField& psi,
volScalarField& rho,
volScalarField& mu,
volScalarField& alpha,
const bool doOldTimes
)
{ {
const scalarField& hCells = this->he(); // Note: update oldTimes before current time so that if T.oldTime() is
const scalarField& pCells = this->p_; // created from T, it starts from the unconverted T
if (doOldTimes && (p.nOldTimes() || T.nOldTimes()))
{
calculate
(
p.oldTime(),
T.oldTime(),
he.oldTime(),
psi.oldTime(),
rho.oldTime(),
mu.oldTime(),
alpha.oldTime(),
true
);
}
scalarField& TCells = this->T_.primitiveFieldRef(); const scalarField& hCells = he.primitiveField();
scalarField& psiCells = this->psi_.primitiveFieldRef(); const scalarField& pCells = p.primitiveField();
scalarField& rhoCells = this->rho_.primitiveFieldRef();
scalarField& muCells = this->mu_.primitiveFieldRef(); scalarField& TCells = T.primitiveFieldRef();
scalarField& alphaCells = this->alpha_.primitiveFieldRef(); scalarField& psiCells = psi.primitiveFieldRef();
scalarField& rhoCells = rho.primitiveFieldRef();
scalarField& muCells = mu.primitiveFieldRef();
scalarField& alphaCells = alpha.primitiveFieldRef();
forAll(TCells, celli) forAll(TCells, celli)
{ {
@ -58,30 +85,17 @@ void Foam::heRhoThermo<BasicPsiThermo, MixtureType>::calculate()
alphaCells[celli] = mixture_.alphah(pCells[celli], TCells[celli]); alphaCells[celli] = mixture_.alphah(pCells[celli], TCells[celli]);
} }
volScalarField::Boundary& pBf = const volScalarField::Boundary& pBf = p.boundaryField();
this->p_.boundaryFieldRef(); volScalarField::Boundary& TBf = T.boundaryFieldRef();
volScalarField::Boundary& psiBf = psi.boundaryFieldRef();
volScalarField::Boundary& rhoBf = rho.boundaryFieldRef();
volScalarField::Boundary& heBf = he.boundaryFieldRef();
volScalarField::Boundary& muBf = mu.boundaryFieldRef();
volScalarField::Boundary& alphaBf = alpha.boundaryFieldRef();
volScalarField::Boundary& TBf = forAll(pBf, patchi)
this->T_.boundaryFieldRef();
volScalarField::Boundary& psiBf =
this->psi_.boundaryFieldRef();
volScalarField::Boundary& rhoBf =
this->rho_.boundaryFieldRef();
volScalarField::Boundary& heBf =
this->he().boundaryFieldRef();
volScalarField::Boundary& muBf =
this->mu_.boundaryFieldRef();
volScalarField::Boundary& alphaBf =
this->alpha_.boundaryFieldRef();
forAll(this->T_.boundaryField(), patchi)
{ {
fvPatchScalarField& pp = pBf[patchi]; const fvPatchScalarField& pp = pBf[patchi];
fvPatchScalarField& pT = TBf[patchi]; fvPatchScalarField& pT = TBf[patchi];
fvPatchScalarField& ppsi = psiBf[patchi]; fvPatchScalarField& ppsi = psiBf[patchi];
fvPatchScalarField& prho = rhoBf[patchi]; fvPatchScalarField& prho = rhoBf[patchi];
@ -134,7 +148,17 @@ Foam::heRhoThermo<BasicPsiThermo, MixtureType>::heRhoThermo
: :
heThermo<BasicPsiThermo, MixtureType>(mesh, phaseName) heThermo<BasicPsiThermo, MixtureType>(mesh, phaseName)
{ {
calculate(); calculate
(
this->p_,
this->T_,
this->he_,
this->psi_,
this->rho_,
this->mu_,
this->alpha_,
true // Create old time fields
);
} }
@ -150,17 +174,21 @@ Foam::heRhoThermo<BasicPsiThermo, MixtureType>::~heRhoThermo()
template<class BasicPsiThermo, class MixtureType> template<class BasicPsiThermo, class MixtureType>
void Foam::heRhoThermo<BasicPsiThermo, MixtureType>::correct() void Foam::heRhoThermo<BasicPsiThermo, MixtureType>::correct()
{ {
if (debug) DebugInFunction << endl;
{
InfoInFunction << endl;
}
calculate(); calculate
(
this->p_,
this->T_,
this->he_,
this->psi_,
this->rho_,
this->mu_,
this->alpha_,
false // No need to update old times
);
if (debug) DebugInFunction << "Finished" << endl;
{
Info<< " Finished" << endl;
}
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -55,7 +55,17 @@ class heRhoThermo
// Private Member Functions // Private Member Functions
//- Calculate the thermo variables //- Calculate the thermo variables
void calculate(); void calculate
(
const volScalarField& p,
volScalarField& T,
volScalarField& he,
volScalarField& psi,
volScalarField& rho,
volScalarField& mu,
volScalarField& alpha,
const bool doOldTimes
);
//- Construct as copy (not implemented) //- Construct as copy (not implemented)
heRhoThermo(const heRhoThermo<BasicPsiThermo, MixtureType>&); heRhoThermo(const heRhoThermo<BasicPsiThermo, MixtureType>&);