From e353a07ecfdafdae01893889cd3ed66c7a2a231e Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Sun, 25 Nov 2018 12:41:24 +0000 Subject: [PATCH] functionObjects/field/age: Added schemesField option This allows scheme and solver settings used for the calculation of age to be copied from another variable --- etc/caseDicts/postProcessing/fields/age | 2 ++ src/functionObjects/field/age/age.C | 25 ++++++++++++++++++++----- src/functionObjects/field/age/age.H | 22 ++++++++++++++-------- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/etc/caseDicts/postProcessing/fields/age b/etc/caseDicts/postProcessing/fields/age index 9177b20c65..f4cc7a1d90 100644 --- a/etc/caseDicts/postProcessing/fields/age +++ b/etc/caseDicts/postProcessing/fields/age @@ -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 diff --git a/src/functionObjects/field/age/age.C b/src/functionObjects/field/age/age.C index 203de3fcee..189d6218d4 100644 --- a/src/functionObjects/field/age/age.C +++ b/src/functionObjects/field/age/age.C @@ -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("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_ + ); } } diff --git a/src/functionObjects/field/age/age.H b/src/functionObjects/field/age/age.H index 1ec59e149a..b8b5dfa635 100644 --- a/src/functionObjects/field/age/age.H +++ b/src/functionObjects/field/age/age.H @@ -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