fvModels, fvConstraints: Rational separation of fvOptions between physical modelling and numerical constraints

The new fvModels is a general interface to optional physical models in the
finite volume framework, providing sources to the governing conservation
equations, thus ensuring consistency and conservation.  This structure is used
not only for simple sources and forces but also provides a general run-time
selection interface for more complex models such as radiation and film, in the
future this will be extended to Lagrangian, reaction, combustion etc.  For such
complex models the 'correct()' function is provided to update the state of these
models at the beginning of the PIMPLE loop.

fvModels are specified in the optional constant/fvModels dictionary and
backward-compatibility with fvOption is provided by reading the
constant/fvOptions or system/fvOptions dictionary if present.

The new fvConstraints is a general interface to optional numerical constraints
applied to the matrices of the governing equations after construction and/or to
the resulting field after solution.  This system allows arbitrary changes to
either the matrix or solution to ensure numerical or other constraints and hence
violates consistency with the governing equations and conservation but it often
useful to ensure numerical stability, particularly during the initial start-up
period of a run.  Complex manipulations can be achieved with fvConstraints, for
example 'meanVelocityForce' used to maintain a specified mean velocity in a
cyclic channel by manipulating the momentum matrix and the velocity solution.

fvConstraints are specified in the optional system/fvConstraints dictionary and
backward-compatibility with fvOption is provided by reading the
constant/fvOptions or system/fvOptions dictionary if present.

The separation of fvOptions into fvModels and fvConstraints provides a rational
and consistent separation between physical and numerical models which is easier
to understand and reason about, avoids the confusing issue of location of the
controlling dictionary file, improves maintainability and easier to extend to
handle current and future requirements for optional complex physical models and
numerical constraints.
This commit is contained in:
Henry Weller
2021-03-07 22:45:01 +00:00
parent a28fd5552f
commit da3f4cc92e
444 changed files with 4427 additions and 3005 deletions

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -10,7 +10,7 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
object fvOptions;
object fvConstraints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -18,19 +18,4 @@ Description
field tracer;
fvOptions
{
volumeFraction
{
type volumeFractionSource;
volumePhase volume;
}
solidFraction
{
type volumeFractionSource;
volumePhase solid;
}
}
// ************************************************************************* //

View File

@ -10,8 +10,8 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvOptions;
location "system";
object fvConstraints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -10,7 +10,7 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
object fvOptions;
object fvConstraints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -48,31 +48,4 @@ porosity
}
fixedTemperature
{
type fixedTemperatureConstraint;
selectionMode cellZone;
cellZone porosity;
mode uniform;
temperature 350;
}
porosityTurbulence
{
type fixedValueConstraint;
selectionMode cellZone;
cellZone porosity;
fieldValues
{
k 1;
epsilon 150;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,45 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvConstraints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
fixedTemperature
{
type fixedTemperatureConstraint;
selectionMode cellZone;
cellZone porosity;
mode uniform;
temperature 350;
}
porosityTurbulence
{
type fixedValueConstraint;
selectionMode cellZone;
cellZone porosity;
fieldValues
{
k 1;
epsilon 150;
}
}
// ************************************************************************* //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,24 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
radiation
{
type radiation;
libs ("libradiationModels.so");
}
// ************************************************************************* //

View File

@ -1,24 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
radiation
{
type radiation;
libs ("libradiationModels.so");
}
// ************************************************************************* //

View File

@ -10,7 +10,7 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -10,20 +10,10 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// fixedTemperature
// {
// type fixedTemperatureConstraint;
// selectionMode all;
// mode uniform;
// temperature constant 300; // Set temperature (K)
// }
// fixedPower
// {
// type semiImplicitSource;

View File

@ -0,0 +1,27 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvConstraints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// fixedTemperature
// {
// type fixedTemperatureConstraint;
// selectionMode all;
// mode uniform;
// temperature constant 300; // Set temperature (K)
// }
//************************************************************************** //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,36 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant/heater";
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
energySource
{
type semiImplicitSource;
selectionMode all;
volumeMode specific;
sources
{
e
{
explicit 1e7; // W/m^3 == kg/m/s^3
implicit 0;
}
}
}
// ************************************************************************* //

View File

@ -1,39 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant/heater";
object fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
options
{
energySource
{
type semiImplicitSource;
selectionMode all;
volumeMode specific;
sources
{
e
{
explicit 1e7; // W/m^3 == kg/m/s^3
implicit 0;
}
}
}
}
// ************************************************************************* //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,24 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
radiation
{
type radiation;
libs ("libradiationModels.so");
}
// ************************************************************************* //

View File

@ -1,24 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
radiation
{
type radiation;
libs ("libradiationModels.so");
}
// ************************************************************************* //

View File

@ -15,7 +15,7 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
momentumSource
momentumForce
{
type meanVelocityForce;

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -18,13 +18,4 @@ Description
field tracer;
fvOptions
{
volumeFraction
{
type volumeFractionSource;
volumePhase volume;
}
}
// ************************************************************************* //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -38,11 +38,11 @@ const scalar lambda = MaxwellCoeffs.lookup<scalar>("lambda");
const scalar rho = 1;
Info<< "Reading pressure gradient\n" << endl;
IOdictionary fvOptions
IOdictionary fvModels
(
IOobject
(
"fvOptions",
"fvModels",
runTime.constant(),
mesh,
IOobject::MUST_READ,
@ -50,7 +50,7 @@ IOdictionary fvOptions
)
);
const dictionary& gradPDict =
fvOptions.subDict("momentumSource").subDict("sources");
fvModels.subDict("momentumSource").subDict("sources");
const scalar K(vector(gradPDict.subDict("U").lookup("explicit")).x());
dictionary probes(IFstream(runTime.system()/"probes")());

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -10,7 +10,7 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,25 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
radiation
{
type radiation;
libs ("libradiationModels.so");
}
// ************************************************************************* //

View File

@ -10,8 +10,8 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvOptions;
location "system";
object fvConstraints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -30,11 +30,5 @@ source1
temperature 2000;
}
radiation
{
type radiation;
libs ("libradiationModels.so");
}
// ************************************************************************* //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -10,8 +10,8 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvOptions;
location "system";
object fvConstraints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -11,7 +11,7 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -11,32 +11,31 @@ FoamFile
format ascii;
class dictionary;
location "constant";
object fvOptions;
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
options
massSource
{
massSource
type massSource;
selectionMode cellZone;
cellZone injection;
massFlowRate 6e-7;
phase air1;
rho thermo:rho.air1;
fieldValues
{
type massSource;
selectionMode points;
points ((0.075 0.925 0.05));
volumeMode absolute;
massFlowRate 1;
phase water;
rho thermo:rho.water;
fieldValues
{
U.water (0 0 0);
}
f1.air1 0;
f2.air1 0;
f3.air1 1;
f4.air1 0;
f5.air1 0;
U.air1 (0 0 0);
}
}
// ************************************************************************* //

View File

@ -1,42 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
options
{
massSource
{
type massSource;
selectionMode cellZone;
cellZone injection;
massFlowRate 6e-7;
phase air1;
rho thermo:rho.air1;
fieldValues
{
f1.air1 0;
f2.air1 0;
f3.air1 1;
f4.air1 0;
f5.air1 0;
U.air1 (0 0 0);
}
}
}

View File

@ -0,0 +1,39 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
massSource
{
type massSource;
selectionMode points;
points ((0.075 0.925 0.05));
volumeMode absolute;
massFlowRate 1;
phase water;
rho thermo:rho.water;
fieldValues
{
U.water (0 0 0);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
massSource
{
type massSource;
selectionMode points;
points
(
(0.075 0.2 0.05)
);
volumeMode absolute;
phase air;
rho thermo:rho.air;
massFlowRate
{
type scale;
scale squarePulse;
start 0.1;
duration 5;
value 1e-3;
}
fieldValues
{
U.air (0 -10 0);
T.air 300;
}
}
// ************************************************************************* //

View File

@ -1,53 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
options
{
massSource
{
type massSource;
selectionMode points;
points
(
(0.075 0.2 0.05)
);
volumeMode absolute;
phase air;
rho thermo:rho.air;
massFlowRate
{
type scale;
scale squarePulse;
start 0.1;
duration 5;
value 1e-3;
}
fieldValues
{
U.air (0 -10 0);
T.air 300;
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvModels;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
massSource
{
type massSource;
selectionMode points;
points
(
(0.075 0.2 0.05)
);
volumeMode absolute;
phase steam;
rho thermo:rho.steam;
massFlowRate
{
type scale;
scale squarePulse;
start 1;
duration 1e6;
value 1e-3;
}
fieldValues
{
U.steam (0 10 0);
h.steam 3700000;
}
}
// ************************************************************************* //

View File

@ -1,71 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object fvOptions;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
options
{
massSource
{
type massSource;
selectionMode points;
points
(
(0.075 0.2 0.05)
);
volumeMode absolute;
phase steam;
rho thermo:rho.steam;
massFlowRate
{
type scale;
scale squarePulse;
start 1;
duration 1e6;
value 1e-3;
}
fieldValues
{
U.steam (0 10 0);
h.steam 3700000;
}
}
limitTsteam
{
type limitTemperature;
selectionMode all;
min 270;
max 2000;
phase steam;
}
limitTwater
{
type limitTemperature;
selectionMode all;
min 270;
max 2000;
phase water;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,37 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvConstraints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
limitTsteam
{
type limitTemperature;
selectionMode all;
min 270;
max 2000;
phase steam;
}
limitTwater
{
type limitTemperature;
selectionMode all;
min 270;
max 2000;
phase water;
}
// ************************************************************************* //