Skip to content
Snippets Groups Projects
Commit 3c44f08d authored by Henry Weller's avatar Henry Weller
Browse files

functionObjects::blendingFactor: simplified, standardized, rationalized

parent 15773bf1
Branches
Tags
No related merge requests found
......@@ -41,5 +41,6 @@ Q/Q.C
Lambda2/Lambda2.C
CourantNo/CourantNo.C
PecletNo/PecletNo.C
blendingFactor/blendingFactor.C
LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects
......@@ -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;
}
......
......@@ -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);
};
......
......@@ -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>())
);
}
......
......@@ -9,7 +9,6 @@ writeDictionary/writeDictionary.C
writeRegisteredObject/writeRegisteredObject.C
scalarTransport/scalarTransport.C
blendingFactor/blendingFactor.C
dsmcFields/dsmcFields.C
turbulenceFields/turbulenceFields.C
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment