functionObjects/field/age: Added schemesField option

This allows scheme and solver settings used for the calculation of age
to be copied from another variable
This commit is contained in:
Will Bainbridge
2018-11-25 12:41:24 +00:00
parent b9f8eb8dd1
commit e353a07ecf
3 changed files with 36 additions and 13 deletions

View File

@ -11,6 +11,8 @@ Description
This will output a field, age, with units of time. This field needs a
solver setting in fvSolution and a div(phi,age) scheme in fvSchemes.
Alternatively, a schemesField entry can be used to reuse settings from
another field.
The number of correctors, nCorr, determines how many times the solution is
repeated to iterate away any non-linearities in the choice of scheme. If

View File

@ -74,9 +74,11 @@ Foam::functionObjects::age::age
)
:
fvMeshFunctionObject(name, runTime, dict),
nCorr_(readLabel(dict.lookup("nCorr"))),
phiName_(),
rhoName_()
rhoName_(),
nCorr_(0),
schemesField_()
{
read(dict);
}
@ -97,6 +99,8 @@ bool Foam::functionObjects::age::read(const dictionary& dict)
dict.readIfPresent("nCorr", nCorr_);
schemesField_ = dict.lookupOrDefault<word>("schemesField", typeName);
return true;
}
@ -107,7 +111,7 @@ bool Foam::functionObjects::age::execute()
(
IOobject
(
"age",
typeName,
mesh_.time().timeName(),
mesh_,
IOobject::READ_IF_PRESENT,
@ -118,6 +122,8 @@ bool Foam::functionObjects::age::execute()
patchTypes()
);
const word divScheme("div(phi," + schemesField_ + ")");
// This only works because the null constructed inletValue for an
// inletOutletFvPatchField is zero. If we needed any other value we would
// have to loop over the inletOutlet patches and explicitly set the
@ -134,14 +140,23 @@ bool Foam::functionObjects::age::execute()
for (label i = 0; i <= nCorr_; ++ i)
{
solve(fvm::div(phi, t) == rho);
solve
(
fvm::div(phi, t, divScheme) == rho,
schemesField_
);
}
}
else
{
for (label i = 0; i <= nCorr_; ++ i)
{
solve(fvm::div(phi, t) == dimensionedScalar("one", dimless, 1));
solve
(
fvm::div(phi, t, divScheme)
== dimensionedScalar("one", dimless, 1),
schemesField_
);
}
}

View File

@ -40,10 +40,12 @@ Description
Usage
\table
Property | Description | Required | Default value
nCorr | The number of correctors | yes |
phi | The name of the flux field | no | phi
rho | The name of the density field | no | rho
Property | Description | Required | Default value
phi | The name of the flux field | no | phi
rho | The name of the density field | no | rho
nCorr | The number of correctors | no | 0
schemesField | The name of the field from which schemes are taken | \\
no | age
\endtable
\verbatim
@ -55,9 +57,10 @@ Usage
writeControl writeTime;
writeInterval 1;
nCorr 10;
phi phi;
rho rho;
nCorr 10;
schemesField k;
}
\endverbatim
@ -89,15 +92,18 @@ class age
{
// Private data
//- Number of corrections
label nCorr_;
//- The name of the flux field
word phiName_;
//- The name of the density field
word rhoName_;
//- Number of corrections
label nCorr_;
//- Name of field from which schemes are taken
word schemesField_;
// Private Member Functions