diff --git a/src/postProcessing/functionObjects/field/Make/files b/src/postProcessing/functionObjects/field/Make/files index 1ba35cee0293698301eeb8b1262bc6c5f59532d1..8b1788a4e6735d3559788a5a1505739cc6eb2e3b 100644 --- a/src/postProcessing/functionObjects/field/Make/files +++ b/src/postProcessing/functionObjects/field/Make/files @@ -41,5 +41,6 @@ Q/Q.C Lambda2/Lambda2.C CourantNo/CourantNo.C PecletNo/PecletNo.C +blendingFactor/blendingFactor.C LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects diff --git a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.C b/src/postProcessing/functionObjects/field/blendingFactor/blendingFactor.C similarity index 79% rename from src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.C rename to src/postProcessing/functionObjects/field/blendingFactor/blendingFactor.C index a063ce82b007fd6892b529d2be4bd6cdecf6456f..50a055c0a6baf21789bc2184768fa04479a4f493 100644 --- a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.C +++ b/src/postProcessing/functionObjects/field/blendingFactor/blendingFactor.C @@ -24,7 +24,6 @@ License \*---------------------------------------------------------------------------*/ #include "blendingFactor.H" -#include "volFields.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -48,7 +47,7 @@ Foam::functionObjects::blendingFactor::blendingFactor const dictionary& dict ) : - fvMeshFunctionObject(name, runTime, dict) + fieldExpression(name, runTime, dict) { read(dict); } @@ -64,36 +63,30 @@ Foam::functionObjects::blendingFactor::~blendingFactor() bool Foam::functionObjects::blendingFactor::read(const dictionary& dict) { - phiName_ = dict.lookupOrDefault<word>("phi", "phi"); - dict.lookup("field") >> fieldName_; - - return true; -} + fieldExpression::read(dict); + phiName_ = dict.lookupOrDefault<word>("phi", "phi"); -bool Foam::functionObjects::blendingFactor::execute(const bool postProcess) -{ - calc<scalar>(); - calc<vector>(); + resultName_ = "blendingFactor:" + fieldName_; return true; } -bool Foam::functionObjects::blendingFactor::write(const bool postProcess) +bool Foam::functionObjects::blendingFactor::execute(const bool postProcess) { - const word fieldName = "blendingFactor:" + fieldName_; + bool processed = false; - const volScalarField& blendingFactor = - obr_.lookupObject<volScalarField>(fieldName); + processed = processed || calc<scalar>(); + processed = processed || calc<vector>(); - Info<< type() << " " << name() << " output:" << nl - << " writing field " << blendingFactor.name() << nl - << endl; + if (!processed) + { + WarningInFunction + << "Unprocessed field " << fieldName_ << endl; + } - blendingFactor.write(); - - return true; + return processed; } diff --git a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H b/src/postProcessing/functionObjects/field/blendingFactor/blendingFactor.H similarity index 81% rename from src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H rename to src/postProcessing/functionObjects/field/blendingFactor/blendingFactor.H index f0d7dc61b86cd5835a232192a9622499d825dfe8..7c7c66434be0f44f775815c9f0a1b7160a489d30 100644 --- a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H +++ b/src/postProcessing/functionObjects/field/blendingFactor/blendingFactor.H @@ -33,6 +33,7 @@ Description value is calculated via the maximum blending factor for any cell face. SeeAlso + Foam::functionObjects::fieldExpression Foam::functionObjects::fvMeshFunctionObject SourceFiles @@ -43,17 +44,12 @@ SourceFiles #ifndef functionObjects_blendingFactor_H #define functionObjects_blendingFactor_H -#include "fvMeshFunctionObject.H" -#include "volFieldsFwd.H" +#include "fieldExpression.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - -// Forward declaration of classes -class objectRegistry; - namespace functionObjects { @@ -63,35 +59,19 @@ namespace functionObjects class blendingFactor : - public fvMeshFunctionObject + public fieldExpression { // Private data //- Name of flux field, default is "phi" word phiName_; - //- Field name - word fieldName_; - // Private Member Functions - //- Disallow default bitwise copy construct - blendingFactor(const blendingFactor&); - - //- Disallow default bitwise assignment - void operator=(const blendingFactor&); - - //- Return the blending factor field from the database - template<class Type> - volScalarField& factor - ( - const GeometricField<Type, fvPatchField, volMesh>& field - ); - //- Calculate the blending factor template<class Type> - void calc(); + bool calc(); public: @@ -122,9 +102,6 @@ public: //- Calculate the blending-factor virtual bool execute(const bool postProcess = false); - - //- Write the blending-factor - virtual bool write(const bool postProcess = false); }; diff --git a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorTemplates.C b/src/postProcessing/functionObjects/field/blendingFactor/blendingFactorTemplates.C similarity index 57% rename from src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorTemplates.C rename to src/postProcessing/functionObjects/field/blendingFactor/blendingFactorTemplates.C index d9262f7ffaa097043099fcfd1be4a79d251be0fc..565b77c0d75355b1b494fd4dc25aca045005b1f2 100644 --- a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorTemplates.C +++ b/src/postProcessing/functionObjects/field/blendingFactor/blendingFactorTemplates.C @@ -26,64 +26,25 @@ License #include "gaussConvectionScheme.H" #include "blendedSchemeBase.H" #include "fvcCellReduce.H" -#include "zeroGradientFvPatchFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template<class Type> -Foam::volScalarField& Foam::functionObjects::blendingFactor::factor -( - const GeometricField<Type, fvPatchField, volMesh>& field -) +bool Foam::functionObjects::blendingFactor::calc() { - const word fieldName = "blendingFactor:" + field.name(); + typedef GeometricField<Type, fvPatchField, volMesh> FieldType; - if (!mesh_.foundObject<volScalarField>(fieldName)) + if (!foundField<FieldType>(fieldName_)) { - volScalarField* factorPtr = - new volScalarField - ( - IOobject - ( - fieldName, - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar("0", dimless, 0.0), - zeroGradientFvPatchScalarField::typeName - ); - - obr_.store(factorPtr); + return false; } - return - const_cast<volScalarField&> - ( - mesh_.lookupObject<volScalarField>(fieldName) - ); -} - - -template<class Type> -void Foam::functionObjects::blendingFactor::calc() -{ - typedef GeometricField<Type, fvPatchField, volMesh> fieldType; - - if (!mesh_.foundObject<fieldType>(fieldName_)) - { - return; - } - - const fieldType& field = mesh_.lookupObject<fieldType>(fieldName_); + const FieldType& field = lookupField<FieldType>(fieldName_); const word divScheme("div(" + phiName_ + ',' + fieldName_ + ')'); ITstream& its = mesh_.divScheme(divScheme); - const surfaceScalarField& phi = - mesh_.lookupObject<surfaceScalarField>(phiName_); + const surfaceScalarField& phi = lookupField<surfaceScalarField>(phiName_); tmp<fv::convectionScheme<Type>> cs = fv::convectionScheme<Type>::New(mesh_, phi, its); @@ -101,15 +62,17 @@ void Foam::functionObjects::blendingFactor::calc() << exit(FatalError); } - // retrieve the face-based blending factor + // Retrieve the face-based blending factor const blendedSchemeBase<Type>& blendedScheme = refCast<const blendedSchemeBase<Type>>(interpScheme); - const surfaceScalarField factorf(blendedScheme.blendingFactor(field)); - - // convert into vol field whose values represent the local face maxima - volScalarField& factor = this->factor(field); - factor = fvc::cellReduce(factorf, maxEqOp<scalar>()); - factor.correctBoundaryConditions(); + tmp<surfaceScalarField> factorf(blendedScheme.blendingFactor(field)); + + // Convert into vol field whose values represent the local face maxima + return store + ( + resultName_, + fvc::cellReduce(factorf, maxEqOp<scalar>()) + ); } diff --git a/src/postProcessing/functionObjects/utilities/Make/files b/src/postProcessing/functionObjects/utilities/Make/files index 7e7e618e3d2eae038cf09371df10c3eabd818ea4..e9578cdb67602b4079ce4373d6eab7882b21cfc6 100644 --- a/src/postProcessing/functionObjects/utilities/Make/files +++ b/src/postProcessing/functionObjects/utilities/Make/files @@ -9,7 +9,6 @@ writeDictionary/writeDictionary.C writeRegisteredObject/writeRegisteredObject.C scalarTransport/scalarTransport.C -blendingFactor/blendingFactor.C dsmcFields/dsmcFields.C turbulenceFields/turbulenceFields.C