From 95c37c0cbb6c953dca8df2e416750ee9ba865bd3 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 4 Apr 2017 12:41:35 +0100 Subject: [PATCH 1/8] ENH: Updated second-order restart for thermo fields --- .../basic/heThermo/heThermo.C | 35 ++++-- .../basic/heThermo/heThermo.H | 9 +- .../basic/psiThermo/hePsiThermo.C | 106 ++++++++++------- .../basic/psiThermo/hePsiThermo.H | 14 ++- .../basic/rhoThermo/heRhoThermo.C | 110 +++++++++++------- .../basic/rhoThermo/heRhoThermo.H | 14 ++- 6 files changed, 186 insertions(+), 102 deletions(-) diff --git a/src/thermophysicalModels/basic/heThermo/heThermo.C b/src/thermophysicalModels/basic/heThermo/heThermo.C index c06ffb75d7..cb10d720e9 100644 --- a/src/thermophysicalModels/basic/heThermo/heThermo.C +++ b/src/thermophysicalModels/basic/heThermo/heThermo.C @@ -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 -void Foam::heThermo::init() +void Foam::heThermo::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::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::heThermo this->heBoundaryBaseTypes() ) { - init(); + init(this->p_, this->T_, he_); } @@ -146,7 +157,7 @@ Foam::heThermo::heThermo this->heBoundaryBaseTypes() ) { - init(); + init(this->p_, this->T_, he_); } diff --git a/src/thermophysicalModels/basic/heThermo/heThermo.H b/src/thermophysicalModels/basic/heThermo/heThermo.H index 7967cc44cc..02b0ad419e 100644 --- a/src/thermophysicalModels/basic/heThermo/heThermo.H +++ b/src/thermophysicalModels/basic/heThermo/heThermo.H @@ -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: diff --git a/src/thermophysicalModels/basic/psiThermo/hePsiThermo.C b/src/thermophysicalModels/basic/psiThermo/hePsiThermo.C index 71cc38498e..1765619767 100644 --- a/src/thermophysicalModels/basic/psiThermo/hePsiThermo.C +++ b/src/thermophysicalModels/basic/psiThermo/hePsiThermo.C @@ -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 -void Foam::hePsiThermo::calculate() +void Foam::hePsiThermo::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 + ); + } - scalarField& TCells = this->T_.primitiveFieldRef(); - scalarField& psiCells = this->psi_.primitiveFieldRef(); - scalarField& muCells = this->mu_.primitiveFieldRef(); - scalarField& alphaCells = this->alpha_.primitiveFieldRef(); + const scalarField& hCells = he.primitiveField(); + const scalarField& pCells = p.primitiveField(); + + 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::calculate() alphaCells[celli] = mixture_.alphah(pCells[celli], TCells[celli]); } - volScalarField::Boundary& pBf = - this->p_.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& TBf = - 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) + 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::hePsiThermo : heThermo(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::~hePsiThermo() template void Foam::hePsiThermo::correct() { - if (debug) - { - InfoInFunction << endl; - } + DebugInFunction << endl; - // force the saving of the old-time values - this->psi_.oldTime(); + calculate + ( + this->p_, + this->T_, + this->he_, + this->psi_, + this->mu_, + this->alpha_, + false // No need to update old times + ); - calculate(); - - if (debug) - { - Info<< " Finished" << endl; - } + DebugInFunction << "Finished" << endl; } diff --git a/src/thermophysicalModels/basic/psiThermo/hePsiThermo.H b/src/thermophysicalModels/basic/psiThermo/hePsiThermo.H index ca5a89f73f..9b12c53ee7 100644 --- a/src/thermophysicalModels/basic/psiThermo/hePsiThermo.H +++ b/src/thermophysicalModels/basic/psiThermo/hePsiThermo.H @@ -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&); + public: //- Runtime type information diff --git a/src/thermophysicalModels/basic/rhoThermo/heRhoThermo.C b/src/thermophysicalModels/basic/rhoThermo/heRhoThermo.C index 9c889ac7f3..cc545d55e9 100644 --- a/src/thermophysicalModels/basic/rhoThermo/heRhoThermo.C +++ b/src/thermophysicalModels/basic/rhoThermo/heRhoThermo.C @@ -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 -void Foam::heRhoThermo::calculate() +void Foam::heRhoThermo::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 + ); + } - 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(); + const scalarField& hCells = he.primitiveField(); + const scalarField& pCells = p.primitiveField(); + + 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::calculate() alphaCells[celli] = mixture_.alphah(pCells[celli], TCells[celli]); } - volScalarField::Boundary& pBf = - this->p_.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& TBf = - 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) + 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::heRhoThermo : heThermo(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::~heRhoThermo() template void Foam::heRhoThermo::correct() { - if (debug) - { - InfoInFunction << endl; - } + DebugInFunction << 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) - { - Info<< " Finished" << endl; - } + DebugInFunction << "Finished" << endl; } diff --git a/src/thermophysicalModels/basic/rhoThermo/heRhoThermo.H b/src/thermophysicalModels/basic/rhoThermo/heRhoThermo.H index 7e2138d127..042e3c62e8 100644 --- a/src/thermophysicalModels/basic/rhoThermo/heRhoThermo.H +++ b/src/thermophysicalModels/basic/rhoThermo/heRhoThermo.H @@ -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&); From c13d59fa514d245f92233bfa135c05cd40861cb8 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 4 Apr 2017 12:42:39 +0100 Subject: [PATCH 2/8] STYLE: updated debug message --- .../GeometricFields/GeometricField/GeometricField.C | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index c985a3135f..9350649671 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -835,6 +835,17 @@ Foam::GeometricField::oldTime() const ), *this ); + + if (debug) + { + InfoInFunction + << "created old time field " << field0Ptr_->info() << endl; + + if (debug&2) + { + error::printStack(Info); + } + } } else { From 37b0d85dc494dc54af01503d1e4c1476caa5b54e Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 4 Apr 2017 12:50:42 +0100 Subject: [PATCH 3/8] ENH: Updated for setting of old time values --- .../ddtSchemes/backwardDdtScheme/backwardDdtScheme.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.C index 641a645132..06676f037b 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.C @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,7 +58,7 @@ template template scalar backwardDdtScheme::deltaT0_(const GeoField& vf) const { - if (vf.nOldTimes() < 2) + if (mesh().time().timeIndex() < 2) { return GREAT; } From 111c1d2d1293bbbc4415b5ffc714b643379bdcd2 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 4 Apr 2017 12:51:35 +0100 Subject: [PATCH 4/8] ENH: Added include file to calculate the mechanical energy --- .../compressible/rhoPimpleFoam/createFields.H | 3 +-- .../cfdTools/general/include/createK.H | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/finiteVolume/cfdTools/general/include/createK.H diff --git a/applications/solvers/compressible/rhoPimpleFoam/createFields.H b/applications/solvers/compressible/rhoPimpleFoam/createFields.H index 8079428225..10ed80d25a 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/createFields.H +++ b/applications/solvers/compressible/rhoPimpleFoam/createFields.H @@ -69,8 +69,7 @@ volScalarField dpdt dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) ); -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); +#include "createK.H" #include "createMRF.H" diff --git a/src/finiteVolume/cfdTools/general/include/createK.H b/src/finiteVolume/cfdTools/general/include/createK.H new file mode 100644 index 0000000000..a51850a813 --- /dev/null +++ b/src/finiteVolume/cfdTools/general/include/createK.H @@ -0,0 +1,16 @@ +Info<< "Creating field kinetic energy K\n" << endl; +volScalarField K("K", 0.5*magSqr(U)); + +if (U.nOldTimes()) +{ + volVectorField* Uold = &U.oldTime(); + volScalarField* Kold = &K.oldTime(); + *Kold == 0.5*magSqr(*Uold); + + while (Uold->nOldTimes()) + { + Uold = &Uold->oldTime(); + Kold = &Kold->oldTime(); + *Kold == 0.5*magSqr(*Uold); + } +} From aecf9b911254754986d9a61fa5dc2b52ec450b36 Mon Sep 17 00:00:00 2001 From: sergio Date: Wed, 5 Apr 2017 18:17:30 -0700 Subject: [PATCH 5/8] Test on re-start backward time scheme. --- src/finiteVolume/fvMesh/fvMesh.C | 6 +++--- src/finiteVolume/fvMesh/fvMeshGeometry.C | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index 2c667ac619..c473761690 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -197,9 +197,9 @@ void Foam::fvMesh::storeOldVol(const scalarField& V) "V0", time().timeName(), *this, - IOobject::NO_READ, - IOobject::NO_WRITE, - false + IOobject::READ_IF_PRESENT,//NO_READ, + IOobject::AUTO_WRITE, + true ), *this, dimVolume diff --git a/src/finiteVolume/fvMesh/fvMeshGeometry.C b/src/finiteVolume/fvMesh/fvMeshGeometry.C index c530ee0a9a..f5fd168cfa 100644 --- a/src/finiteVolume/fvMesh/fvMeshGeometry.C +++ b/src/finiteVolume/fvMesh/fvMeshGeometry.C @@ -258,9 +258,9 @@ const Foam::volScalarField::Internal& Foam::fvMesh::V00() const "V00", time().timeName(), *this, - IOobject::NO_READ, - IOobject::NO_WRITE, - false + IOobject::READ_IF_PRESENT,//NO_READ, + IOobject::AUTO_WRITE, + true ), V0() ); From 73460a2993f7916c574a0e17ebc2f6b988da0a9b Mon Sep 17 00:00:00 2001 From: sergio Date: Tue, 18 Apr 2017 14:04:27 -0700 Subject: [PATCH 6/8] Test on second order restart using backward time scheme --- .../compressible/rhoPimpleFoam/createFields.H | 7 +++++-- .../GeometricField/GeometricField.C | 3 ++- .../backwardDdtScheme/backwardDdtScheme.H | 18 ++---------------- src/finiteVolume/fvMesh/fvMesh.C | 6 +++--- src/finiteVolume/fvMesh/fvMeshGeometry.C | 5 +++-- 5 files changed, 15 insertions(+), 24 deletions(-) diff --git a/applications/solvers/compressible/rhoPimpleFoam/createFields.H b/applications/solvers/compressible/rhoPimpleFoam/createFields.H index 10ed80d25a..deaba4dd1f 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/createFields.H +++ b/applications/solvers/compressible/rhoPimpleFoam/createFields.H @@ -35,7 +35,8 @@ volVectorField U IOobject::MUST_READ, IOobject::AUTO_WRITE ), - mesh + mesh, + true ); #include "compressibleCreatePhi.H" @@ -63,7 +64,9 @@ volScalarField dpdt ( "dpdt", runTime.timeName(), - mesh + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE ), mesh, dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index 9350649671..ee0677ecbb 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -770,10 +770,11 @@ void Foam::GeometricField::storeOldTimes() const ) { storeOldTime(); + timeIndex_ = this->time().timeIndex(); } // Correct time index - timeIndex_ = this->time().timeIndex(); + //timeIndex_ = this->time().timeIndex(); } diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H b/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H index af321f143f..abedc954a9 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H +++ b/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H @@ -92,27 +92,13 @@ public: backwardDdtScheme(const fvMesh& mesh) : ddtScheme(mesh) - { - // Ensure the old-old-time cell volumes are available - // for moving meshes - if (mesh.moving()) - { - mesh.V00(); - } - } + {} //- Construct from mesh and Istream backwardDdtScheme(const fvMesh& mesh, Istream& is) : ddtScheme(mesh, is) - { - // Ensure the old-old-time cell volumes are available - // for moving meshes - if (mesh.moving()) - { - mesh.V00(); - } - } + {} // Member Functions diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index c473761690..f63acb9b5d 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -197,7 +197,7 @@ void Foam::fvMesh::storeOldVol(const scalarField& V) "V0", time().timeName(), *this, - IOobject::READ_IF_PRESENT,//NO_READ, + IOobject::NO_READ, IOobject::AUTO_WRITE, true ), @@ -281,8 +281,8 @@ Foam::fvMesh::fvMesh(const IOobject& io) time().timeName(), *this, IOobject::MUST_READ, - IOobject::NO_WRITE, - false + IOobject::AUTO_WRITE, + true ), *this ); diff --git a/src/finiteVolume/fvMesh/fvMeshGeometry.C b/src/finiteVolume/fvMesh/fvMeshGeometry.C index f5fd168cfa..a987398bb7 100644 --- a/src/finiteVolume/fvMesh/fvMeshGeometry.C +++ b/src/finiteVolume/fvMesh/fvMeshGeometry.C @@ -258,13 +258,14 @@ const Foam::volScalarField::Internal& Foam::fvMesh::V00() const "V00", time().timeName(), *this, - IOobject::READ_IF_PRESENT,//NO_READ, - IOobject::AUTO_WRITE, + IOobject::NO_READ, + IOobject::NO_WRITE, true ), V0() ); + // If V00 is used then V0 should be stored for restart V0Ptr_->writeOpt() = IOobject::AUTO_WRITE; } From 2883311a23e5e6ca8f341217f7e768f940a6773d Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Thu, 15 Jun 2017 14:51:27 +0100 Subject: [PATCH 7/8] ENH: rhoPimple[DyM]Foam - updated treatment for dpdt --- .../compressible/rhoPimpleFoam/createFields.H | 18 ++---------------- .../cfdTools/compressible/createDpdt.H | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 src/finiteVolume/cfdTools/compressible/createDpdt.H diff --git a/applications/solvers/compressible/rhoPimpleFoam/createFields.H b/applications/solvers/compressible/rhoPimpleFoam/createFields.H index deaba4dd1f..9d2307d418 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/createFields.H +++ b/applications/solvers/compressible/rhoPimpleFoam/createFields.H @@ -35,8 +35,7 @@ volVectorField U IOobject::MUST_READ, IOobject::AUTO_WRITE ), - mesh, - true + mesh ); #include "compressibleCreatePhi.H" @@ -57,20 +56,7 @@ autoPtr turbulence ) ); -Info<< "Creating field dpdt\n" << endl; -volScalarField dpdt -( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE - ), - mesh, - dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) -); +#include "createDpdt.H" #include "createK.H" diff --git a/src/finiteVolume/cfdTools/compressible/createDpdt.H b/src/finiteVolume/cfdTools/compressible/createDpdt.H new file mode 100644 index 0000000000..7c73006924 --- /dev/null +++ b/src/finiteVolume/cfdTools/compressible/createDpdt.H @@ -0,0 +1,18 @@ +Info<< "Creating field dpdt\n" << endl; +volScalarField dpdt +( + IOobject + ( + "dpdt", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + fvc::ddt(p) +); + +if (!thermo.dpdt()) +{ + dpdt == dimensionedScalar("0", dpdt.dimensions(), 0); +} From 65071b95987dde8bdb99e1e501538996ebec1e7a Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Wed, 21 Jun 2017 12:20:58 +0100 Subject: [PATCH 8/8] ENH: Updated dpdt and K field construction --- .../solvers/combustion/PDRFoam/createFields.H | 21 ++++-------------- .../solvers/combustion/XiFoam/createFields.H | 19 ++++------------ .../combustion/coldEngineFoam/createFields.H | 16 ++------------ .../combustion/fireFoam/createFields.H | 17 ++------------ .../combustion/reactingFoam/createFields.H | 22 ++++--------------- .../rhoReactingBuoyantFoam/createFields.H | 21 ++++-------------- .../rhoReactingFoam/createFields.H | 22 ++++--------------- .../compressible/sonicFoam/createFields.H | 3 +-- .../buoyantPimpleFoam/createFields.H | 20 ++++------------- .../heatTransfer/thermoFoam/createFields.H | 16 ++------------ .../coalChemistryFoam/createFields.H | 20 ++++------------- .../reactingParcelFilmFoam/createFields.H | 21 ++++-------------- .../reactingParcelFoam/createFields.H | 20 ++++------------- .../lagrangian/sprayFoam/createFields.H | 19 ++++------------ .../compressibleInterFoam/createFields.H | 3 +-- .../createFields.H | 3 +-- .../createFields.H | 3 --- .../interCondensingEvaporatingFoam/pEqn.H | 1 - .../cfdTools/compressible/createDpdt.H | 2 +- 19 files changed, 50 insertions(+), 219 deletions(-) diff --git a/applications/solvers/combustion/PDRFoam/createFields.H b/applications/solvers/combustion/PDRFoam/createFields.H index 1341894242..84155c4849 100644 --- a/applications/solvers/combustion/PDRFoam/createFields.H +++ b/applications/solvers/combustion/PDRFoam/createFields.H @@ -58,23 +58,6 @@ autoPtr turbulence ); -Info<< "Creating field dpdt\n" << endl; -volScalarField dpdt -( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) -); - -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); - - Info<< "Creating the unstrained laminar flame speed\n" << endl; autoPtr unstrainedLaminarFlameSpeed ( @@ -227,4 +210,8 @@ fields.add(thermo.he()); fields.add(thermo.heu()); flameWrinkling->addXi(fields); +#include "createDpdt.H" + +#include "createK.H" + #include "createMRF.H" diff --git a/applications/solvers/combustion/XiFoam/createFields.H b/applications/solvers/combustion/XiFoam/createFields.H index 9dd4b6560f..0d4c403b13 100644 --- a/applications/solvers/combustion/XiFoam/createFields.H +++ b/applications/solvers/combustion/XiFoam/createFields.H @@ -58,21 +58,6 @@ autoPtr turbulence ) ); -Info<< "Creating field dpdt\n" << endl; -volScalarField dpdt -( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) -); - -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); Info<< "Creating field Xi\n" << endl; volScalarField Xi @@ -139,4 +124,8 @@ fields.add(b); fields.add(thermo.he()); fields.add(thermo.heu()); +#include "createDpdt.H" + +#include "createK.H" + #include "createMRF.H" diff --git a/applications/solvers/combustion/coldEngineFoam/createFields.H b/applications/solvers/combustion/coldEngineFoam/createFields.H index 10e1546584..19b655e21c 100644 --- a/applications/solvers/combustion/coldEngineFoam/createFields.H +++ b/applications/solvers/combustion/coldEngineFoam/createFields.H @@ -51,20 +51,8 @@ autoPtr turbulence ) ); -Info<< "Creating field dpdt\n" << endl; -volScalarField dpdt -( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) -); +#include "createDpdt.H" -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); +#include "createK.H" #include "createMRF.H" diff --git a/applications/solvers/combustion/fireFoam/createFields.H b/applications/solvers/combustion/fireFoam/createFields.H index 85d26aed87..626e1652ef 100644 --- a/applications/solvers/combustion/fireFoam/createFields.H +++ b/applications/solvers/combustion/fireFoam/createFields.H @@ -145,22 +145,9 @@ volScalarField Qdot dimensionedScalar("Qdot", dimEnergy/dimVolume/dimTime, 0.0) ); +#include "createDpdt.H" -Info<< "Creating field dpdt\n" << endl; -volScalarField dpdt -( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) -); - -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); +#include "createK.H" #include "createClouds.H" #include "createSurfaceFilmModel.H" diff --git a/applications/solvers/combustion/reactingFoam/createFields.H b/applications/solvers/combustion/reactingFoam/createFields.H index bc09358193..708cab0b42 100644 --- a/applications/solvers/combustion/reactingFoam/createFields.H +++ b/applications/solvers/combustion/reactingFoam/createFields.H @@ -71,24 +71,6 @@ autoPtr turbulence // Set the turbulence into the reaction model reaction->setTurbulence(turbulence()); - -Info<< "Creating field dpdt\n" << endl; -volScalarField dpdt -( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) -); - -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); - - multivariateSurfaceInterpolationScheme::fieldTable fields; forAll(Y, i) @@ -111,4 +93,8 @@ volScalarField Qdot dimensionedScalar("Qdot", dimEnergy/dimVolume/dimTime, 0.0) ); +#include "createDpdt.H" + +#include "createK.H" + #include "createMRF.H" diff --git a/applications/solvers/combustion/reactingFoam/rhoReactingBuoyantFoam/createFields.H b/applications/solvers/combustion/reactingFoam/rhoReactingBuoyantFoam/createFields.H index 675aef3f5a..8e56e940fb 100644 --- a/applications/solvers/combustion/reactingFoam/rhoReactingBuoyantFoam/createFields.H +++ b/applications/solvers/combustion/reactingFoam/rhoReactingBuoyantFoam/createFields.H @@ -92,23 +92,6 @@ volScalarField p_rgh // Force p_rgh to be consistent with p p_rgh = p - rho*gh; -Info<< "Creating field dpdt\n" << endl; -volScalarField dpdt -( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) -); - -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); - - multivariateSurfaceInterpolationScheme::fieldTable fields; forAll(Y, i) @@ -131,4 +114,8 @@ volScalarField Qdot dimensionedScalar("Qdot", dimEnergy/dimVolume/dimTime, 0.0) ); +#include "createDpdt.H" + +#include "createK.H" + #include "createMRF.H" diff --git a/applications/solvers/combustion/reactingFoam/rhoReactingFoam/createFields.H b/applications/solvers/combustion/reactingFoam/rhoReactingFoam/createFields.H index 3ad7cb7464..6f0c93cc5d 100644 --- a/applications/solvers/combustion/reactingFoam/rhoReactingFoam/createFields.H +++ b/applications/solvers/combustion/reactingFoam/rhoReactingFoam/createFields.H @@ -72,24 +72,6 @@ autoPtr turbulence // Set the turbulence into the reaction model reaction->setTurbulence(turbulence()); - -Info<< "Creating field dpdt\n" << endl; -volScalarField dpdt -( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) -); - -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); - - multivariateSurfaceInterpolationScheme::fieldTable fields; forAll(Y, i) @@ -112,6 +94,10 @@ volScalarField Qdot dimensionedScalar("Qdot", dimEnergy/dimVolume/dimTime, 0.0) ); +#include "createDpdt.H" + +#include "createK.H" + #include "createMRF.H" dimensionedScalar rhoMax diff --git a/applications/solvers/compressible/sonicFoam/createFields.H b/applications/solvers/compressible/sonicFoam/createFields.H index 1b54f4a912..0c929b3ffb 100644 --- a/applications/solvers/compressible/sonicFoam/createFields.H +++ b/applications/solvers/compressible/sonicFoam/createFields.H @@ -50,7 +50,6 @@ autoPtr turbulence ) ); -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); +#include "createK.H" #include "createMRF.H" diff --git a/applications/solvers/heatTransfer/buoyantPimpleFoam/createFields.H b/applications/solvers/heatTransfer/buoyantPimpleFoam/createFields.H index cc0bc64f0a..d4f6eb54e7 100644 --- a/applications/solvers/heatTransfer/buoyantPimpleFoam/createFields.H +++ b/applications/solvers/heatTransfer/buoyantPimpleFoam/createFields.H @@ -73,22 +73,6 @@ p_rgh = p - rho*gh; mesh.setFluxRequired(p_rgh.name()); -Info<< "Creating field dpdt\n" << endl; -volScalarField dpdt -( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) -); - -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); - label pRefCell = 0; scalar pRefValue = 0.0; @@ -113,5 +97,9 @@ if (p_rgh.needReference()) dimensionedScalar initialMass("initialMass", fvc::domainIntegrate(rho)); +#include "createDpdt.H" + +#include "createK.H" + #include "createMRF.H" #include "createRadiationModel.H" diff --git a/applications/solvers/heatTransfer/thermoFoam/createFields.H b/applications/solvers/heatTransfer/thermoFoam/createFields.H index 3a217895f6..90f25a89a3 100644 --- a/applications/solvers/heatTransfer/thermoFoam/createFields.H +++ b/applications/solvers/heatTransfer/thermoFoam/createFields.H @@ -37,20 +37,8 @@ volVectorField U #include "setAlphaEff.H" -Info<< "Creating field dpdt\n" << endl; -volScalarField dpdt -( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) -); +#include "createDpdt.H" -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); +#include "createK.H" #include "createRadiationModel.H" diff --git a/applications/solvers/lagrangian/coalChemistryFoam/createFields.H b/applications/solvers/lagrangian/coalChemistryFoam/createFields.H index 4e4f45e721..f97d5af51e 100644 --- a/applications/solvers/lagrangian/coalChemistryFoam/createFields.H +++ b/applications/solvers/lagrangian/coalChemistryFoam/createFields.H @@ -115,22 +115,6 @@ autoPtr turbulence // Set the turbulence into the combustion model combustion->setTurbulence(turbulence()); -Info<< "Creating field dpdt\n" << endl; -volScalarField dpdt -( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) -); - -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); - volScalarField Qdot ( IOobject @@ -145,6 +129,10 @@ volScalarField Qdot dimensionedScalar("Qdot", dimEnergy/dimVolume/dimTime, 0.0) ); +#include "createDpdt.H" + +#include "createK.H" + #include "createMRF.H" #include "createClouds.H" #include "createRadiationModel.H" diff --git a/applications/solvers/lagrangian/reactingParcelFilmFoam/createFields.H b/applications/solvers/lagrangian/reactingParcelFilmFoam/createFields.H index 0159cdba15..6ecb8c7e44 100644 --- a/applications/solvers/lagrangian/reactingParcelFilmFoam/createFields.H +++ b/applications/solvers/lagrangian/reactingParcelFilmFoam/createFields.H @@ -69,23 +69,6 @@ autoPtr turbulence // Set the turbulence into the combustion model combustion->setTurbulence(turbulence()); -Info<< "Creating field dpdt\n" << endl; -volScalarField dpdt -( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) -); - -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); - - #include "readGravitationalAcceleration.H" #include "readhRef.H" #include "gh.H" @@ -148,6 +131,10 @@ volScalarField Qdot dimensionedScalar("Qdot", dimEnergy/dimVolume/dimTime, 0.0) ); +#include "createDpdt.H" + +#include "createK.H" + #include "createMRF.H" #include "createClouds.H" #include "createRadiationModel.H" diff --git a/applications/solvers/lagrangian/reactingParcelFoam/createFields.H b/applications/solvers/lagrangian/reactingParcelFoam/createFields.H index 2da47d4ced..ce7e5441e0 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/createFields.H +++ b/applications/solvers/lagrangian/reactingParcelFoam/createFields.H @@ -96,22 +96,6 @@ autoPtr turbulence // Set the turbulence into the combustion model combustion->setTurbulence(turbulence()); -Info<< "Creating field dpdt\n" << endl; -volScalarField dpdt -( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) -); - -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); - Info<< "Creating multi-variate interpolation scheme\n" << endl; multivariateSurfaceInterpolationScheme::fieldTable fields; @@ -135,6 +119,10 @@ volScalarField Qdot dimensionedScalar("Qdot", dimEnergy/dimVolume/dimTime, 0.0) ); +#include "createDpdt.H" + +#include "createK.H" + #include "createMRF.H" #include "createRadiationModel.H" #include "createClouds.H" diff --git a/applications/solvers/lagrangian/sprayFoam/createFields.H b/applications/solvers/lagrangian/sprayFoam/createFields.H index e2124b3685..df9df8fbf3 100644 --- a/applications/solvers/lagrangian/sprayFoam/createFields.H +++ b/applications/solvers/lagrangian/sprayFoam/createFields.H @@ -94,21 +94,6 @@ autoPtr turbulence // Set the turbulence into the combustion model combustion->setTurbulence(turbulence()); -Info<< "Creating field dpdt\n" << endl; -volScalarField dpdt -( - IOobject - ( - "dpdt", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) -); - -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); multivariateSurfaceInterpolationScheme::fieldTable fields; forAll(Y, i) @@ -131,6 +116,10 @@ volScalarField Qdot dimensionedScalar("Qdot", dimEnergy/dimVolume/dimTime, 0.0) ); +#include "createDpdt.H" + +#include "createK.H" + #include "createMRF.H" #include "createClouds.H" #include "createRadiationModel.H" diff --git a/applications/solvers/multiphase/compressibleInterFoam/createFields.H b/applications/solvers/multiphase/compressibleInterFoam/createFields.H index 0616b80ea8..c1f3538169 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/createFields.H +++ b/applications/solvers/multiphase/compressibleInterFoam/createFields.H @@ -98,7 +98,6 @@ autoPtr turbulence compressible::turbulenceModel::New(rho, U, rhoPhi, mixture) ); -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); +#include "createK.H" #include "createMRF.H" diff --git a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/createFields.H b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/createFields.H index dcb89c35b9..39930ed638 100644 --- a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/createFields.H +++ b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/createFields.H @@ -65,5 +65,4 @@ autoPtr turbulence ) ); -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); +#include "createK.H" diff --git a/applications/solvers/multiphase/interCondensingEvaporatingFoam/createFields.H b/applications/solvers/multiphase/interCondensingEvaporatingFoam/createFields.H index 4d43cf3d5d..87a9b2bbc0 100644 --- a/applications/solvers/multiphase/interCondensingEvaporatingFoam/createFields.H +++ b/applications/solvers/multiphase/interCondensingEvaporatingFoam/createFields.H @@ -124,9 +124,6 @@ volScalarField kappaEff thermo->kappa() ); -Info<< "Creating field kinetic energy K\n" << endl; -volScalarField K("K", 0.5*magSqr(U)); - Info<< "Creating field pDivU\n" << endl; volScalarField pDivU ( diff --git a/applications/solvers/multiphase/interCondensingEvaporatingFoam/pEqn.H b/applications/solvers/multiphase/interCondensingEvaporatingFoam/pEqn.H index 366dc78a12..5c7eec6d3c 100644 --- a/applications/solvers/multiphase/interCondensingEvaporatingFoam/pEqn.H +++ b/applications/solvers/multiphase/interCondensingEvaporatingFoam/pEqn.H @@ -47,7 +47,6 @@ U = HbyA + rAU*fvc::reconstruct((phig + p_rghEqn.flux())/rAUf); U.correctBoundaryConditions(); fvOptions.correct(U); - K = 0.5*magSqr(U); } } diff --git a/src/finiteVolume/cfdTools/compressible/createDpdt.H b/src/finiteVolume/cfdTools/compressible/createDpdt.H index 7c73006924..2d645e5e1d 100644 --- a/src/finiteVolume/cfdTools/compressible/createDpdt.H +++ b/src/finiteVolume/cfdTools/compressible/createDpdt.H @@ -1,7 +1,7 @@ Info<< "Creating field dpdt\n" << endl; volScalarField dpdt ( - IOobject + IOobject ( "dpdt", runTime.timeName(),