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()
{
// Read the controls
read();
readControls();
if (transient())
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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