momentumTransportModels: Added a new predict() function in addition to the existing correct() function

Some momentumTransportModels like the laminar Stokes and generalisedNewtonian
models do no solve transport equations and the transport coefficients they
provide can be predicted at the beginning of the time-step rather than corrected
at the end, after conservative fluxes are available.  A particular advantage of
this approach is that complex data cached in the momentumTransportModels
can now be deleted following mesh topology changes and recreated in the
predict() call which is more efficient than attempting to register and map the
data.

Currently the predict() function is only used for the Stokes and
generalisedNewtonian models but it will be extended in the future to cover many
LES models which also do not require the solution of transport equations.

All solvers and solver modules have been update to call the
momentumTransportModel::predict() function at the beginning of the time-step,
controlled by the new PIMPLE transportPredictionFirst control as appropriate.
This commit is contained in:
Henry Weller
2022-12-16 10:12:22 +00:00
parent 96974f8914
commit d9ba28b427
47 changed files with 276 additions and 53 deletions

View File

@ -123,7 +123,12 @@ int main(int argc, char *argv[])
while (pimple.loop())
{
fvModels.correct();
thermophysicalTransport.predict();
if (pimple.predictTransport())
{
turbulence->predict();
thermophysicalTransport.predict();
}
#include "UEqn.H"
@ -143,7 +148,7 @@ int main(int argc, char *argv[])
#include "pEqn.H"
}
if (pimple.turbCorr())
if (pimple.correctTransport())
{
turbulence->correct();
thermophysicalTransport.correct();

View File

@ -173,7 +173,12 @@ int main(int argc, char *argv[])
while (pimple.loop())
{
fvModels.correct();
thermophysicalTransport->predict();
if (pimple.predictTransport())
{
turbulence->predict();
thermophysicalTransport->predict();
}
#include "UEqn.H"
@ -193,7 +198,7 @@ int main(int argc, char *argv[])
#include "pEqn.H"
}
if (pimple.turbCorr())
if (pimple.correctTransport())
{
turbulence->correct();
thermophysicalTransport->correct();

View File

@ -157,7 +157,12 @@ int main(int argc, char *argv[])
}
fvModels.correct();
thermophysicalTransport.predict();
if (pimple.predictTransport())
{
turbulence->predict();
thermophysicalTransport.predict();
}
#include "UEqn.H"
#include "ftEqn.H"
@ -176,7 +181,7 @@ int main(int argc, char *argv[])
#include "pEqn.H"
}
if (pimple.turbCorr())
if (pimple.correctTransport())
{
turbulence->correct();
thermophysicalTransport.correct();

View File

@ -200,6 +200,7 @@ int main(int argc, char *argv[])
// --- Solve density
solve(fvm::ddt(rho) + fvc::div(phi));
turbulence->predict();
thermophysicalTransport->predict();
// --- Solve momentum

View File

@ -64,6 +64,7 @@ int main(int argc, char *argv[])
{
Info<< "Time = " << runTime.userTimeName() << nl << endl;
turbulence->predict();
thermophysicalTransport->predict();
// Pressure-velocity SIMPLE corrector

View File

@ -103,6 +103,8 @@ int main(int argc, char *argv[])
zeroCells(alpha, inletCells);
// zeroCells(alpha, outletCells);
turbulence->predict();
// Pressure-velocity SIMPLE corrector
{
fvModels.correct();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -69,6 +69,8 @@ int main(int argc, char *argv[])
fvModels.correct();
turbulence->predict();
fvVectorMatrix divR(turbulence->divDevSigma(U));
divR.source() = flowMask & divR.source();

View File

@ -67,6 +67,8 @@ int main(int argc, char *argv[])
fvModels.correct();
turbulence->predict();
// Pressure-velocity SIMPLE corrector
{
#include "UEqn.H"

View File

@ -220,7 +220,7 @@ int main(int argc, char *argv[])
#include "pEqn.H"
}
if (pimple.turbCorr())
if (pimple.correctTransport())
{
continuousPhaseTurbulence->correct();
}

View File

@ -167,6 +167,20 @@ void Foam::compressibleInterPhaseTransportModel::correctPhasePhi()
}
void Foam::compressibleInterPhaseTransportModel::predict()
{
if (twoPhaseTransport_)
{
momentumTransport1_->predict();
momentumTransport2_->predict();
}
else
{
mixtureMomentumTransport_->predict();
}
}
void Foam::compressibleInterPhaseTransportModel::correct()
{
if (twoPhaseTransport_)

View File

@ -125,6 +125,9 @@ public:
// (required for the two-phase transport option)
void correctPhasePhi();
//- Predict the phase or mixture transport models
void predict();
//- Correct the phase or mixture transport models
void correct();

View File

@ -331,13 +331,18 @@ void Foam::solvers::compressibleVoF::prePredictor()
fvModels().correct();
alphaPredictor();
momentumTransport.correctPhasePhi();
thermophysicalTransport.predict();
if (pimple.predictTransport())
{
momentumTransport.predict();
thermophysicalTransport.predict();
}
}
void Foam::solvers::compressibleVoF::postCorrector()
{
if (pimple.transportCorr())
if (pimple.correctTransport())
{
momentumTransport.correct();
thermophysicalTransport.correct();

View File

@ -66,7 +66,11 @@ Foam::solvers::fluid::~fluid()
void Foam::solvers::fluid::prePredictor()
{
isothermalFluid::prePredictor();
thermophysicalTransport->predict();
if (pimple.predictTransport())
{
thermophysicalTransport->predict();
}
}
@ -74,7 +78,7 @@ void Foam::solvers::fluid::postCorrector()
{
isothermalFluid::postCorrector();
if (pimple.transportCorr())
if (pimple.correctTransport())
{
thermophysicalTransport->correct();
}

View File

@ -197,6 +197,11 @@ void Foam::solvers::incompressibleFluid::preSolve()
void Foam::solvers::incompressibleFluid::prePredictor()
{
fvModels().correct();
if (pimple.predictTransport())
{
momentumTransport->predict();
}
}
@ -217,7 +222,7 @@ void Foam::solvers::incompressibleFluid::pressureCorrector()
void Foam::solvers::incompressibleFluid::postCorrector()
{
if (pimple.transportCorr())
if (pimple.correctTransport())
{
viscosity->correct();
momentumTransport->correct();

View File

@ -344,7 +344,7 @@ void Foam::solvers::isothermalFluid::pressureCorrector()
void Foam::solvers::isothermalFluid::postCorrector()
{
if (pimple.transportCorr())
if (pimple.correctTransport())
{
momentumTransport->correct();
}

View File

@ -40,6 +40,11 @@ void Foam::solvers::isothermalFluid::prePredictor()
}
fvModels().correct();
if (pimple.predictTransport())
{
momentumTransport->predict();
}
}

View File

@ -85,7 +85,11 @@ Foam::solvers::multicomponentFluid::~multicomponentFluid()
void Foam::solvers::multicomponentFluid::prePredictor()
{
isothermalFluid::prePredictor();
thermophysicalTransport->predict();
if (pimple.predictTransport())
{
thermophysicalTransport->predict();
}
}
@ -93,7 +97,7 @@ void Foam::solvers::multicomponentFluid::postCorrector()
{
isothermalFluid::postCorrector();
if (pimple.transportCorr())
if (pimple.correctTransport())
{
thermophysicalTransport->correct();
}

View File

@ -241,6 +241,12 @@ void Foam::solvers::multiphaseEuler::prePredictor()
fluid.correctContinuityError();
}
if (pimple.flow() && pimple.predictTransport())
{
fluid.predictMomentumTransport();
fluid.predictThermophysicalTransport();
}
if (pimple.thermophysics())
{
compositionPredictor();
@ -250,7 +256,7 @@ void Foam::solvers::multiphaseEuler::prePredictor()
void Foam::solvers::multiphaseEuler::postCorrector()
{
if (pimple.flow() && pimple.transportCorr())
if (pimple.flow() && pimple.correctTransport())
{
fluid.correctMomentumTransport();
fluid.correctThermophysicalTransport();

View File

@ -241,7 +241,6 @@ template<class BasePhaseModel>
void Foam::MovingPhaseModel<BasePhaseModel>::correct()
{
BasePhaseModel::correct();
thermophysicalTransport_->predict();
}
@ -269,6 +268,22 @@ void Foam::MovingPhaseModel<BasePhaseModel>::correctKinematics()
}
template<class BasePhaseModel>
void Foam::MovingPhaseModel<BasePhaseModel>::predictMomentumTransport()
{
BasePhaseModel::predictMomentumTransport();
momentumTransport_->predict();
}
template<class BasePhaseModel>
void Foam::MovingPhaseModel<BasePhaseModel>::predictThermophysicalTransport()
{
BasePhaseModel::predictThermophysicalTransport();
thermophysicalTransport_->predict();
}
template<class BasePhaseModel>
void Foam::MovingPhaseModel<BasePhaseModel>::correctMomentumTransport()
{

View File

@ -178,6 +178,12 @@ public:
//- Correct the kinematics
virtual void correctKinematics();
//- Predict the momentumTransport
virtual void predictMomentumTransport();
//- Predict the energy transport e.g. alphat
virtual void predictThermophysicalTransport();
//- Correct the momentumTransport
virtual void correctMomentumTransport();

View File

@ -180,6 +180,14 @@ void Foam::phaseModel::correctSpecies()
{}
void Foam::phaseModel::predictMomentumTransport()
{}
void Foam::phaseModel::predictThermophysicalTransport()
{}
void Foam::phaseModel::correctMomentumTransport()
{}

View File

@ -215,6 +215,12 @@ public:
//- Correct the species concentrations
virtual void correctSpecies();
//- Predict the momentumTransport
virtual void predictMomentumTransport();
//- Predict the energy transport
virtual void predictThermophysicalTransport();
//- Correct the momentumTransport
virtual void correctMomentumTransport();

View File

@ -644,6 +644,24 @@ void Foam::phaseSystem::correctSpecies()
}
void Foam::phaseSystem::predictMomentumTransport()
{
forAll(phaseModels_, phasei)
{
phaseModels_[phasei].predictMomentumTransport();
}
}
void Foam::phaseSystem::predictThermophysicalTransport()
{
forAll(phaseModels_, phasei)
{
phaseModels_[phasei].predictThermophysicalTransport();
}
}
void Foam::phaseSystem::correctMomentumTransport()
{
forAll(phaseModels_, phasei)

View File

@ -635,6 +635,12 @@ public:
//- Correct the species mass fractions
virtual void correctSpecies();
//- Predict the momentumTransport
virtual void predictMomentumTransport();
//- Predict the energy transport e.g. alphat
virtual void predictThermophysicalTransport();
//- Correct the momentumTransport
virtual void correctMomentumTransport();

View File

@ -157,7 +157,10 @@ bool Foam::solvers::solid::moveMesh()
void Foam::solvers::solid::prePredictor()
{
thermophysicalTransport->predict();
if (pimple.predictTransport())
{
thermophysicalTransport->predict();
}
}
@ -199,7 +202,7 @@ void Foam::solvers::solid::pressureCorrector()
void Foam::solvers::solid::postCorrector()
{
if (pimple.transportCorr())
if (pimple.correctTransport())
{
thermophysicalTransport->correct();
}

View File

@ -91,6 +91,12 @@ int main(int argc, char *argv[])
{
#include "rhoEqn.H"
#include "alphavPsi.H"
if (pimple.predictTransport())
{
turbulence->predict();
}
#include "UEqn.H"
// --- Pressure corrector loop
@ -99,7 +105,7 @@ int main(int argc, char *argv[])
#include "pEqn.H"
}
if (pimple.turbCorr())
if (pimple.correctTransport())
{
turbulence->correct();
}

View File

@ -86,6 +86,11 @@ int main(int argc, char *argv[])
#include "contErr.H"
if (pimple.predictTransport())
{
turbulence->predict();
}
#include "UEqn.H"
#include "TEqn.H"
@ -95,7 +100,7 @@ int main(int argc, char *argv[])
#include "pEqn.H"
}
if (pimple.turbCorr())
if (pimple.correctTransport())
{
turbulence->correct();
}

View File

@ -89,6 +89,11 @@ int main(int argc, char *argv[])
mixture.correct();
if (pimple.predictTransport())
{
turbulence->predict();
}
#include "UEqn.H"
// --- Pressure corrector loop
@ -97,7 +102,7 @@ int main(int argc, char *argv[])
#include "pEqn.H"
}
if (pimple.turbCorr())
if (pimple.correctTransport())
{
turbulence->correct();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2021-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -148,6 +148,20 @@ void Foam::incompressibleInterPhaseTransportModel::correctPhasePhi()
}
void Foam::incompressibleInterPhaseTransportModel::predict()
{
if (twoPhaseTransport_)
{
turbulence1_->predict();
turbulence2_->predict();
}
else
{
turbulence_->predict();
}
}
void Foam::incompressibleInterPhaseTransportModel::correct()
{
if (twoPhaseTransport_)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2021-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -118,6 +118,9 @@ public:
// (required for the two-phase transport option)
void correctPhasePhi();
//- Predict the phase or mixture transport models
void predict();
//- Correct the phase or mixture transport models
void correct();

View File

@ -191,6 +191,11 @@ int main(int argc, char *argv[])
mixture.correct();
if (pimple.predictTransport())
{
turbulence.predict();
}
#include "UEqn.H"
// --- Pressure corrector loop
@ -199,7 +204,7 @@ int main(int argc, char *argv[])
#include "pEqn.H"
}
if (pimple.turbCorr())
if (pimple.correctTransport())
{
turbulence.correct();
}

View File

@ -132,6 +132,11 @@ int main(int argc, char *argv[])
mixture.correct();
if (pimple.predictTransport())
{
turbulence->predict();
}
#include "UEqn.H"
// --- Pressure corrector loop
@ -140,7 +145,7 @@ int main(int argc, char *argv[])
#include "pEqn.H"
}
if (pimple.turbCorr())
if (pimple.correctTransport())
{
turbulence->correct();
}

View File

@ -124,6 +124,11 @@ int main(int argc, char *argv[])
mixture.solve();
rho = mixture.rho();
if (pimple.predictTransport())
{
turbulence->predict();
}
#include "UEqn.H"
// --- Pressure corrector loop
@ -132,7 +137,7 @@ int main(int argc, char *argv[])
#include "pEqn.H"
}
if (pimple.turbCorr())
if (pimple.correctTransport())
{
turbulence->correct();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -225,6 +225,11 @@ public:
return this->nut(patchi) + this->nu(patchi);
}
//- Predict the turbulence transport coefficients if possible
// without solving turbulence transport model equations
virtual void predict()
{}
//- Solve the turbulence equations and correct the turbulence viscosity
virtual void correct();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -233,6 +233,11 @@ public:
return this->nut(patchi) + this->nu(patchi);
}
//- Predict the turbulence transport coefficients if possible
// without solving turbulence transport model equations
virtual void predict()
{}
//- Solve the turbulence equations and correct the turbulence viscosity
virtual void correct();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -181,8 +181,11 @@ public:
volVectorField& U
) const;
//- Solve the turbulence equations and correct eddy-Viscosity and
// related properties
//- The Maxwell stress is not predicted
virtual void predict()
{}
//- Correct the Maxwell stress
virtual void correct();
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -101,9 +101,9 @@ tmp<scalarField> Stokes<BasicMomentumTransportModel>::nuEff
template<class BasicMomentumTransportModel>
void Stokes<BasicMomentumTransportModel>::correct()
void Stokes<BasicMomentumTransportModel>::predict()
{
laminarModel<BasicMomentumTransportModel>::correct();
laminarModel<BasicMomentumTransportModel>::predict();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -112,8 +112,12 @@ public:
//- Return the effective viscosity on patch
virtual tmp<scalarField> nuEff(const label patchi) const;
//- Correct the Stokes viscosity
virtual void correct();
//- Predict the Stokes viscosity
virtual void predict();
//- The Stokes viscosity is not corrected
virtual void correct()
{}
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -108,10 +108,10 @@ generalisedNewtonian<BasicMomentumTransportModel>::nuEff
template<class BasicMomentumTransportModel>
void generalisedNewtonian<BasicMomentumTransportModel>::correct()
void generalisedNewtonian<BasicMomentumTransportModel>::predict()
{
viscosityModel_->correct();
laminarModel<BasicMomentumTransportModel>::correct();
laminarModel<BasicMomentumTransportModel>::predict();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -119,8 +119,12 @@ public:
//- Return the effective viscosity on patch
virtual tmp<scalarField> nuEff(const label patchi) const;
//- Correct the generalisedNewtonian viscosity
virtual void correct();
//- Predict the generalisedNewtonian viscosity
virtual void predict();
//- The generalisedNewtonian viscosity is not corrected
virtual void correct()
{}
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2020-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -171,6 +171,10 @@ public:
//- Return the effective viscosity on patch
virtual tmp<scalarField> nuEff(const label patchi) const;
//- The lambdaThixotropic viscosity is not predicted
virtual void predict()
{}
//- Correct the lambdaThixotropic viscosity
virtual void correct();
};

View File

@ -256,6 +256,13 @@ Foam::laminarModel<BasicMomentumTransportModel>::sigma() const
}
template<class BasicMomentumTransportModel>
void Foam::laminarModel<BasicMomentumTransportModel>::predict()
{
BasicMomentumTransportModel::predict();
}
template<class BasicMomentumTransportModel>
void Foam::laminarModel<BasicMomentumTransportModel>::correct()
{

View File

@ -175,7 +175,10 @@ public:
//- Return the stress tensor [m^2/s^2], i.e. 0 for laminar flow
virtual tmp<volSymmTensorField> sigma() const;
//- Correct the laminar viscosity
//- Predict the laminar viscosity
virtual void predict();
//- Predict the laminar viscosity
virtual void correct();

View File

@ -134,6 +134,10 @@ void Foam::momentumTransportModel::validate()
{}
void Foam::momentumTransportModel::predict()
{}
void Foam::momentumTransportModel::correct()
{}

View File

@ -205,11 +205,16 @@ public:
//- Return the stress tensor [m^2/s^2]
virtual tmp<volSymmTensorField> sigma() const = 0;
//- Validate the turbulence fields after construction
//- Validate the fields after construction
// Update derived fields as required
virtual void validate();
//- Solve the turbulence equations and correct the turbulence viscosity
//- Predict the momentum transport coefficients if possible
// without solving momentum transport model equations
virtual void predict() = 0;
//- Solve the momentum transport model equations
// and correct the momentum transport coefficients
virtual void correct() = 0;

View File

@ -158,12 +158,12 @@ public:
//- Return the source term for the energy equation
virtual tmp<fvScalarMatrix> divq(volScalarField& he) const = 0;
//- Predict the transport coefficients if possible
//- Predict the thermophysical transport coefficients if possible
// without solving thermophysical transport model equations
virtual void predict() = 0;
//- Solve the thermophysical transport model equations
// and correct the transport coefficients
// and correct the thermophysical transport coefficients
virtual void correct();
};

View File

@ -105,12 +105,12 @@ public:
//- Return the source term for the energy equation
virtual tmp<fvScalarMatrix> divq(volScalarField& he) const = 0;
//- Predict the transport coefficients if possible
//- Predict the thermophysical transport coefficients if possible
// without solving thermophysical transport model equations
virtual void predict() = 0;
//- Solve the thermophysical transport model equations
// and correct the transport coefficients
// and correct the thermophysical transport coefficients
virtual void correct();