solver: Registered to database

This change lets the solver be looked up from the region database, so
that aspects of the solution algorithm can be accessed by
functionObjects and fvModels and similar. For example, a fluid solver
could be looked up as follows:

    const solvers::fluid& s =
        mesh().lookupObject<solvers::fluid>(solver::typeName);
This commit is contained in:
Will Bainbridge
2023-01-25 12:22:02 +00:00
parent b34e17784a
commit 0f5f4ed62c
18 changed files with 61 additions and 34 deletions

View File

@ -197,7 +197,7 @@ Foam::scalar Foam::solvers::VoFSolver::maxDeltaT() const
void Foam::solvers::VoFSolver::preSolve() void Foam::solvers::VoFSolver::preSolve()
{ {
// Read the controls // Read the controls
read(); readControls();
if (transient()) if (transient())
{ {

View File

@ -100,7 +100,7 @@ Foam::solvers::compressibleMultiphaseVoF::compressibleMultiphaseVoF
momentumTransport(momentumTransport_()) momentumTransport(momentumTransport_())
{ {
// Read the controls // Read the controls
read(); readControls();
if (correctPhi) if (correctPhi)
{ {

View File

@ -114,7 +114,7 @@ Foam::solvers::compressibleVoF::compressibleVoF(fvMesh& mesh)
thermophysicalTransport(momentumTransport) thermophysicalTransport(momentumTransport)
{ {
// Read the controls // Read the controls
read(); readControls();
if (correctPhi) if (correctPhi)
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -42,7 +42,7 @@ namespace solvers
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::solvers::fluidSolver::read() void Foam::solvers::fluidSolver::readControls()
{ {
maxCo = maxCo =
runTime.controlDict().lookupOrDefault<scalar>("maxCo", 1.0); runTime.controlDict().lookupOrDefault<scalar>("maxCo", 1.0);
@ -191,7 +191,7 @@ Foam::solvers::fluidSolver::fluidSolver(fvMesh& mesh)
CoNum(0) CoNum(0)
{ {
// Read the controls // Read the controls
read(); readControls();
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -99,7 +99,7 @@ protected:
scalar CoNum; scalar CoNum;
//- Read controls //- Read controls
void read(); void readControls();
//- Check mesh Courant numbers for moving mesh cases //- Check mesh Courant numbers for moving mesh cases
void meshCourantNo() const; void meshCourantNo() const;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -176,7 +176,7 @@ Foam::solvers::incompressibleFluid::~incompressibleFluid()
void Foam::solvers::incompressibleFluid::preSolve() void Foam::solvers::incompressibleFluid::preSolve()
{ {
// Read the controls // Read the controls
read(); readControls();
fvModels().preUpdateMesh(); fvModels().preUpdateMesh();

View File

@ -100,7 +100,7 @@ Foam::solvers::incompressibleMultiphaseVoF::incompressibleMultiphaseVoF
momentumTransport(momentumTransport_()) momentumTransport(momentumTransport_())
{ {
// Read the controls // Read the controls
read(); readControls();
if (!runTime.restart() || !divergent()) if (!runTime.restart() || !divergent())
{ {

View File

@ -86,7 +86,7 @@ Foam::solvers::incompressibleVoF::incompressibleVoF(fvMesh& mesh)
) )
{ {
// Read the controls // Read the controls
read(); readControls();
if (!runTime.restart() || !divergent()) if (!runTime.restart() || !divergent())
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -180,7 +180,7 @@ Foam::solvers::isothermalFluid::isothermalFluid
MRF(mesh) MRF(mesh)
{ {
// Read the controls // Read the controls
read(); readControls();
mesh.schemes().setFluxRequired(p.name()); mesh.schemes().setFluxRequired(p.name());
momentumTransport->validate(); momentumTransport->validate();
@ -280,7 +280,7 @@ Foam::solvers::isothermalFluid::~isothermalFluid()
void Foam::solvers::isothermalFluid::preSolve() void Foam::solvers::isothermalFluid::preSolve()
{ {
// Read the controls // Read the controls
read(); readControls();
if (transient()) if (transient())
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -45,9 +45,9 @@ namespace solvers
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::solvers::multiphaseEuler::read() void Foam::solvers::multiphaseEuler::readControls()
{ {
fluidSolver::read(); fluidSolver::readControls();
faceMomentum = faceMomentum =
pimple.dict().lookupOrDefault<Switch>("faceMomentum", false); pimple.dict().lookupOrDefault<Switch>("faceMomentum", false);
@ -171,7 +171,7 @@ Foam::solvers::multiphaseEuler::multiphaseEuler(fvMesh& mesh)
MRF(fluid.MRF()) MRF(fluid.MRF())
{ {
// Read the controls // Read the controls
read(); readControls();
mesh.schemes().setFluxRequired(p_rgh.name()); mesh.schemes().setFluxRequired(p_rgh.name());
@ -193,7 +193,7 @@ Foam::solvers::multiphaseEuler::~multiphaseEuler()
void Foam::solvers::multiphaseEuler::preSolve() void Foam::solvers::multiphaseEuler::preSolve()
{ {
// Read the controls // Read the controls
read(); readControls();
if (transient()) if (transient())
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -152,7 +152,7 @@ protected:
tmp<volScalarField> divU; tmp<volScalarField> divU;
//- Read controls //- Read controls
void read(); void readControls();
private: private:

View File

@ -178,7 +178,7 @@ Foam::solvers::shockFluid::shockFluid(fvMesh& mesh)
) )
{ {
// Read the controls // Read the controls
read(); readControls();
thermo.validate(type(), "e"); thermo.validate(type(), "e");
@ -235,7 +235,7 @@ Foam::solvers::shockFluid::~shockFluid()
void Foam::solvers::shockFluid::preSolve() void Foam::solvers::shockFluid::preSolve()
{ {
// Read the controls // Read the controls
read(); readControls();
{ {
const surfaceScalarField amaxSf const surfaceScalarField amaxSf

View File

@ -41,7 +41,7 @@ namespace solvers
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::solvers::solid::read() void Foam::solvers::solid::readControls()
{ {
maxDi = maxDi =
runTime.controlDict().lookupOrDefault<scalar>("maxDi", 1.0); runTime.controlDict().lookupOrDefault<scalar>("maxDi", 1.0);
@ -117,7 +117,7 @@ Foam::solvers::solid::solid(fvMesh& mesh)
solid(mesh, solidThermo::New(mesh)) solid(mesh, solidThermo::New(mesh))
{ {
// Read the controls // Read the controls
read(); readControls();
} }
@ -146,7 +146,7 @@ Foam::scalar Foam::solvers::solid::maxDeltaT() const
void Foam::solvers::solid::preSolve() void Foam::solvers::solid::preSolve()
{ {
// Read the controls // Read the controls
read(); readControls();
fvModels().preUpdateMesh(); fvModels().preUpdateMesh();

View File

@ -88,7 +88,7 @@ protected:
// Protected Member Functions // Protected Member Functions
//- Read controls //- Read controls
virtual void read(); virtual void readControls();
private: private:

View File

@ -45,9 +45,9 @@ namespace solvers
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::solvers::solidDisplacement::read() void Foam::solvers::solidDisplacement::readControls()
{ {
solid::read(); solid::readControls();
nCorr = pimple.dict().lookupOrDefault<int>("nCorrectors", 1); nCorr = pimple.dict().lookupOrDefault<int>("nCorrectors", 1);
convergenceTolerance = pimple.dict().lookupOrDefault<scalar>("D", 0); convergenceTolerance = pimple.dict().lookupOrDefault<scalar>("D", 0);
@ -134,7 +134,7 @@ Foam::solvers::solidDisplacement::solidDisplacement(fvMesh& mesh)
mesh.schemes().setFluxRequired(D.name()); mesh.schemes().setFluxRequired(D.name());
// Read the controls // Read the controls
read(); readControls();
} }

View File

@ -124,7 +124,7 @@ protected:
// Protected Member Functions // Protected Member Functions
//- Read controls //- Read controls
virtual void read(); virtual void readControls();
public: public:

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -35,10 +35,29 @@ namespace Foam
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::solver::writeData(Ostream&) const
{
NotImplemented;
return false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solver::solver(fvMesh& mesh_) Foam::solver::solver(fvMesh& mesh_)
: :
regIOobject
(
IOobject
(
typeName,
mesh_.time().timeName(),
mesh_
)
),
mesh(mesh_), mesh(mesh_),
runTime(mesh.time()), runTime(mesh.time()),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -51,6 +51,8 @@ namespace Foam
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class solver class solver
:
public regIOobject
{ {
public: public:
@ -85,6 +87,12 @@ private:
mutable Foam::fvConstraints* fvConstraintsPtr; mutable Foam::fvConstraints* fvConstraintsPtr;
// Private Member Functions
//- Dummy write for regIOobject
virtual bool writeData(Ostream&) const;
public: public:
//- Runtime type information //- Runtime type information