fvOptions: Remove type restrictions and rewrite of field-name handling

A number of fvOptions that apply to a user-derined field can now
automatically work what primitive type they apply to. These options can
apply to any field type, and in some cases even multiple fields of
differing type. Example usage of the options to which this change
applies are shown below:

    codedSource1
    {
        type            codedSource;
        name            codedSource1;

        field           h;

        ...
    }

    fixedValueConstraint1
    {
        type            fixedValueConstraint;

        fieldValues
        {
            R           (1 0 0 1 0 1);
            epsilon     150;
        }

        ...
    }

    phaseLimitStabilization11
    {
        type            phaseLimitStabilization;

        field           sigma.liquid;

        ...
    }

Previously to apply to a given type, these options had to be selected
with the name of the type prepended to the option name (e.g., "type
symmTensorPhaseLimitStabilization;") and those that operated on multiple
fields were restricted to those fields being of the same type.

A number of other options have had improvements made to their handling
of user specification of fields. Where possible, the option will now
attempt to work out what field the option applies to automatically. The
following options, therefore, no longer require "field" or "fields"
entries:

    actuationDiskSource
    buoyancyEnergy
    buoyancyForce
    meanVelocityForce
    rotorDiskSource
    volumeFractionSource
    constantHeatTransfer
    function2HeatTransfer
    variableHeatTransfer

Non-standard field names can be overridden in the same way as in
boundary conditions; e.g., the velocity name can be overridden with a "U
<UName>;" entry if it does not have the default name, "U". The name of
the energy field is now always determined from the thermodynamics
model and should always be correct. Some options that can be applied to
an individual phase also support a "phase <phaseName>;" entry;

fvOptions field-name handling has been rewritten to increase its
flexibility and to improve warning messages. The flexibility now allows
for options that apply to all fields, or all fields of a given phase,
rather than being limited to a specific list of field names. Messages
warning about options that have not been applied now always print just
once per time-step.
This commit is contained in:
Will Bainbridge
2021-02-05 13:45:59 +00:00
parent 81ec2012be
commit 07f5080f2e
125 changed files with 3566 additions and 3270 deletions

View File

@ -4,4 +4,4 @@ cd ${0%/*} || exit 1
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase && rm -f constant/alpha.solid
cleanCase && rm -f constant/alpha.*

View File

@ -5,5 +5,5 @@ cd ${0%/*} || exit 1
. $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh
runApplication postProcess -func generateAlphaSolid
runApplication postProcess -func generateAlphas
runApplication $(getApplication)

View File

@ -18,18 +18,19 @@ FoamFile
volumeFraction
{
type volumeFractionSource;
phase solid;
phi phi;
rho rho;
U U;
fields (rho U e);
volumePhase volume;
}
solidFraction
{
type volumeFractionSource;
volumePhase solid;
}
solidEquilibriumEnergy
{
type solidEquilibriumEnergySource;
phase solid;
field e;
solidPhase solid;
}
// ************************************************************************* //

View File

@ -32,6 +32,11 @@ vertices
(0 -56 -1) (256 -56 -1)
(0 -88 1) (256 -88 1)
(0 -56 1) (256 -56 1)
(0 -124 -1) (256 -124 -1)
(0 -92 -1) (256 -92 -1)
(0 -124 1) (256 -124 1)
(0 -92 1) (256 -92 1)
);
blocks
@ -45,6 +50,8 @@ blocks
hex (12 13 19 18 24 25 31 30) (64 32 1) simpleGrading (1 1 1)
hex (32 33 35 34 36 37 39 38) (256 32 1) simpleGrading (1 1 1)
hex (40 41 43 42 44 45 47 46) (256 32 1) simpleGrading (1 1 1)
);
edges
@ -69,6 +76,8 @@ boundary
(8 14 26 20)
(32 34 38 36)
(40 42 46 44)
);
}
outlet
@ -81,6 +90,8 @@ boundary
(13 19 31 25)
(33 35 39 37)
(41 43 47 45)
);
}
walls
@ -104,6 +115,9 @@ boundary
(32 33 37 36)
(34 35 39 38)
(40 41 45 44)
(42 43 47 46)
);
}
);

View File

@ -9,7 +9,7 @@
type coded;
libs ("libutilityFunctionObjects.so");
name generateAlphaSolid;
name generateAlphas;
codeWrite
#{
@ -19,9 +19,26 @@ codeWrite
const volScalarField x(mesh().C() & dx), y(mesh().C() & dy);
const scalar x0 = 0.032, x1 = 0.064, x2 = 0.128, x3 = 0.224;
const scalar y0 = -0.088, y1 = -0.056;
volScalarField alpha
const volScalarField f
(
pos(x - x0)*pos(x1 - x)*(x - x0)/(x1 - x0)
+ pos(x - x1)*pos(x2 - x)
+ pos(x - x2)*pos(x3 - x)*(x3 - x)/(x3 - x2)
);
volScalarField
(
IOobject
(
IOobject::groupName("alpha", "volume"),
mesh().time().constant(),
mesh()
),
0.5*pos(y - (-0.088))*pos((-0.056) - y)*f
).write();
volScalarField
(
IOobject
(
@ -29,21 +46,8 @@ codeWrite
mesh().time().constant(),
mesh()
),
mesh(),
dimless,
zeroGradientFvPatchScalarField::typeName
);
alpha =
0.5
*(
pos(x - x0)*pos(x1 - x)*(x - x0)/(x1 - x0)
+ pos(x - x1)*pos(x2 - x)
+ pos(x - x2)*pos(x3 - x)*(x3 - x)/(x3 - x2)
)
*pos(y - y0)*pos(y1 - y);
alpha.write();
0.5*pos(y - (-0.124))*pos((-0.092) - y)*f
).write();
#};
// ************************************************************************* //

View File

@ -23,11 +23,13 @@ fvOptions
volumeFraction
{
type volumeFractionSource;
phase solid;
phi phi;
rho rho;
U U;
fields (tracer);
volumePhase volume;
}
solidFraction
{
type volumeFractionSource;
volumePhase solid;
}
}

View File

@ -23,6 +23,7 @@ porosity
{
selectionMode cellZone;
cellZone porosity;
type fixedCoeff;
fixedCoeffCoeffs
@ -53,6 +54,7 @@ fixedTemperature
selectionMode cellZone;
cellZone porosity;
mode uniform;
temperature 350;
}
@ -60,10 +62,11 @@ fixedTemperature
porosityTurbulence
{
type scalarFixedValueConstraint;
type fixedValueConstraint;
selectionMode cellZone;
cellZone porosity;
fieldValues
{
k 1;

View File

@ -24,7 +24,6 @@ airToporous
master false;
nbrModel porousToair;
fields (e);
semiImplicit no;
}

View File

@ -10,7 +10,7 @@ FoamFile
version 2.0;
format ascii;
class volScalarField;
location "0";
location "constant";
object AoV;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -24,7 +24,6 @@ porousToair
master true;
nbrModel airToporous;
fields (e);
semiImplicit no;
}

View File

@ -10,7 +10,7 @@ FoamFile
version 2.0;
format ascii;
class volScalarField;
location "0";
location "constant";
object htcConst;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -21,7 +21,6 @@ momentumSource
selectionMode all;
fields (U);
Ubar (0.1335 0 0);
}

View File

@ -4,4 +4,4 @@ cd ${0%/*} || exit 1
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase && rm -f constant/alpha.solid
cleanCase && rm -f constant/alpha.*

View File

@ -5,5 +5,5 @@ cd ${0%/*} || exit 1
. $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh
runApplication postProcess -func generateAlphaSolid
runApplication postProcess -func generateAlphas
runApplication $(getApplication)

View File

@ -18,10 +18,7 @@ FoamFile
volumeFraction
{
type volumeFractionSource;
phase solid;
phi phi;
U U;
fields (U);
volumePhase volume;
}
// ************************************************************************* //

View File

@ -9,7 +9,7 @@
type coded;
libs ("libutilityFunctionObjects.so");
name generateAlphaSolid;
name generateAlpha;
codeWrite
#{
@ -19,31 +19,24 @@ codeWrite
const volScalarField x(mesh().C() & dx), y(mesh().C() & dy);
const scalar x0 = 0.032, x1 = 0.064, x2 = 0.128, x3 = 0.224;
const scalar y0 = -0.088, y1 = -0.056;
volScalarField alpha
const volScalarField f
(
pos(x - x0)*pos(x1 - x)*(x - x0)/(x1 - x0)
+ pos(x - x1)*pos(x2 - x)
+ pos(x - x2)*pos(x3 - x)*(x3 - x)/(x3 - x2)
);
volScalarField
(
IOobject
(
IOobject::groupName("alpha", "solid"),
IOobject::groupName("alpha", "volume"),
mesh().time().constant(),
mesh()
),
mesh(),
dimless,
zeroGradientFvPatchScalarField::typeName
);
alpha =
0.5
*(
pos(x - x0)*pos(x1 - x)*(x - x0)/(x1 - x0)
+ pos(x - x1)*pos(x2 - x)
+ pos(x - x2)*pos(x3 - x)*(x3 - x)/(x3 - x2)
)
*pos(y - y0)*pos(y1 - y);
alpha.write();
0.5*pos(y - (-0.088))*pos((-0.056) - y)*f
).write();
#};
// ************************************************************************* //

View File

@ -23,10 +23,7 @@ fvOptions
volumeFraction
{
type volumeFractionSource;
phase solid;
phi phi;
U U;
fields (tracer);
volumePhase volume;
}
}

View File

@ -21,7 +21,6 @@ disk
selectionMode cellZone;
cellZone rotatingZone;
fields (U); // Names of fields on which to apply source
nBlades 3; // Number of blades
tipEffect 0.96; // Normalised radius above which lift = 0

View File

@ -19,10 +19,9 @@ disk1
{
type actuationDiskSource;
fields (U);
selectionMode cellSet;
cellSet actuationDisk1;
diskDir (1 0 0); // Orientation of the disk
Cp 0.386;
Ct 0.58;
@ -34,10 +33,9 @@ disk2
{
type actuationDiskSource;
fields (U);
selectionMode cellSet;
cellSet actuationDisk2;
diskDir (1 0 0); // Orientation of the disk
Cp 0.53;
Ct 0.58;

View File

@ -17,7 +17,7 @@ FoamFile
stabilization
{
type symmTensorPhaseLimitStabilization;
type phaseLimitStabilization;
field sigma.liquid;
rate rLambda.liquid;

View File

@ -17,7 +17,7 @@ FoamFile
inletTurbulence
{
type vectorFixedValueConstraint;
type fixedValueConstraint;
selectionMode all;