Commit df54fa02 authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: Updated second-order restart for thermo fields

parent ce5d08c5
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -52,11 +52,16 @@ heBoundaryCorrection(volScalarField& h)
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();
const scalarField& pCells = this->p_;
const scalarField& TCells = this->T_;
scalarField& heCells = he.primitiveFieldRef();
const scalarField& pCells = p.primitiveField();
const scalarField& TCells = T.primitiveField();
forAll(heCells, celli)
{
......@@ -64,19 +69,25 @@ void Foam::heThermo<BasicThermo, MixtureType>::init()
this->cellMixture(celli).HE(pCells[celli], TCells[celli]);
}
volScalarField::Boundary& heBf = he_.boundaryFieldRef();
volScalarField::Boundary& heBf = he.boundaryFieldRef();
forAll(heBf, patchi)
{
heBf[patchi] == he
heBf[patchi] == this->he
(
this->p_.boundaryField()[patchi],
this->T_.boundaryField()[patchi],
p.boundaryField()[patchi],
T.boundaryField()[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()
)
{
init();
init(this->p_, this->T_, he_);
}
......@@ -146,7 +157,7 @@ Foam::heThermo<BasicThermo, MixtureType>::heThermo
this->heBoundaryBaseTypes()
)
{
init();
init(this->p_, this->T_, he_);
}
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -77,7 +77,12 @@ private:
//- Initialize heThermo
void init();
void init
(
const volScalarField& p,
const volScalarField& T,
volScalarField& he
);
public:
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -28,15 +28,40 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
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_;
const scalarField& pCells = this->p_;
// Note: update oldTimes before current time so that if T.oldTime() is
// 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
);
}
const scalarField& hCells = he.primitiveField();
const scalarField& pCells = p.primitiveField();
scalarField& TCells = this->T_.primitiveFieldRef();
scalarField& psiCells = this->psi_.primitiveFieldRef();
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)
{
......@@ -56,27 +81,16 @@ void Foam::hePsiThermo<BasicPsiThermo, MixtureType>::calculate()
alphaCells[celli] = mixture_.alphah(pCells[celli], TCells[celli]);
}
volScalarField::Boundary& pBf =
this->p_.boundaryFieldRef();
volScalarField::Boundary& TBf =
this->T_.boundaryFieldRef();
volScalarField::Boundary& psiBf =
this->psi_.boundaryFieldRef();
volScalarField::Boundary& heBf =
this->he().boundaryFieldRef();
const volScalarField::Boundary& pBf = p.boundaryField();
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& muBf =
this->mu_.boundaryFieldRef();
volScalarField::Boundary& alphaBf =
this->alpha_.boundaryFieldRef();
forAll(this->T_.boundaryField(), patchi)
forAll(pBf, patchi)
{
fvPatchScalarField& pp = pBf[patchi];
const fvPatchScalarField& pp = pBf[patchi];
fvPatchScalarField& pT = TBf[patchi];
fvPatchScalarField& ppsi = psiBf[patchi];
fvPatchScalarField& phe = heBf[patchi];
......@@ -126,10 +140,16 @@ Foam::hePsiThermo<BasicPsiThermo, MixtureType>::hePsiThermo
:
heThermo<BasicPsiThermo, MixtureType>(mesh, phaseName)
{
calculate();
// Switch on saving old time
this->psi_.oldTime();
calculate
(
this->p_,
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>
void Foam::hePsiThermo<BasicPsiThermo, MixtureType>::correct()
{
if (debug)
{
InfoInFunction << endl;
}
// force the saving of the old-time values
this->psi_.oldTime();
calculate();
if (debug)
{
Info<< " Finished" << endl;
}
DebugInFunction << endl;
calculate
(
this->p_,
this->T_,
this->he_,
this->psi_,
this->mu_,
this->alpha_,
false // No need to update old times
);
DebugInFunction << "Finished" << endl;
}
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -55,11 +55,21 @@ class hePsiThermo
// Private Member Functions
//- 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)
hePsiThermo(const hePsiThermo<BasicPsiThermo, MixtureType>&);
public:
//- Runtime type information
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -28,16 +28,43 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
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();
const scalarField& pCells = this->p_;
// Note: update oldTimes before current time so that if T.oldTime() is
// 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
);
}
const scalarField& hCells = he.primitiveField();
const scalarField& pCells = p.primitiveField();
scalarField& TCells = this->T_.primitiveFieldRef();
scalarField& psiCells = this->psi_.primitiveFieldRef();
scalarField& rhoCells = this->rho_.primitiveFieldRef();
scalarField& muCells = this->mu_.primitiveFieldRef();
scalarField& alphaCells = this->alpha_.primitiveFieldRef();
scalarField& TCells = T.primitiveFieldRef();
scalarField& psiCells = psi.primitiveFieldRef();
scalarField& rhoCells = rho.primitiveFieldRef();
scalarField& muCells = mu.primitiveFieldRef();
scalarField& alphaCells = alpha.primitiveFieldRef();
forAll(TCells, celli)
{
......@@ -58,30 +85,17 @@ void Foam::heRhoThermo<BasicPsiThermo, MixtureType>::calculate()
alphaCells[celli] = mixture_.alphah(pCells[celli], TCells[celli]);
}
volScalarField::Boundary& pBf =
this->p_.boundaryFieldRef();
volScalarField::Boundary& TBf =
this->T_.boundaryFieldRef();
volScalarField::Boundary& psiBf =
this->psi_.boundaryFieldRef();
volScalarField::Boundary& rhoBf =
this->rho_.boundaryFieldRef();
const volScalarField::Boundary& pBf = p.boundaryField();
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& heBf =
this->he().boundaryFieldRef();
volScalarField::Boundary& muBf =
this->mu_.boundaryFieldRef();
volScalarField::Boundary& alphaBf =
this->alpha_.boundaryFieldRef();
forAll(this->T_.boundaryField(), patchi)
forAll(pBf, patchi)
{
fvPatchScalarField& pp = pBf[patchi];
const fvPatchScalarField& pp = pBf[patchi];
fvPatchScalarField& pT = TBf[patchi];
fvPatchScalarField& ppsi = psiBf[patchi];
fvPatchScalarField& prho = rhoBf[patchi];
......@@ -134,7 +148,17 @@ Foam::heRhoThermo<BasicPsiThermo, MixtureType>::heRhoThermo
:
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>
void Foam::heRhoThermo<BasicPsiThermo, MixtureType>::correct()
{
if (debug)
{
InfoInFunction << endl;
}
calculate();
if (debug)
{
Info<< " Finished" << endl;
}
DebugInFunction << endl;
calculate
(
this->p_,
this->T_,
this->he_,
this->psi_,
this->rho_,
this->mu_,
this->alpha_,
false // No need to update old times
);
DebugInFunction << "Finished" << endl;
}
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -55,7 +55,17 @@ class heRhoThermo
// Private Member Functions
//- 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)
heRhoThermo(const heRhoThermo<BasicPsiThermo, MixtureType>&);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment