mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
functionObjects: Clear the result field from the objectRegistry if the argument fields are not available
This is needed to handle the processing of many time directories, some of which may have the required fields and some not.
This commit is contained in:
@ -66,6 +66,31 @@ bool Foam::functionObjects::fvMeshFunctionObject::writeField
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fvMeshFunctionObject::clearField
|
||||
(
|
||||
const word& fieldName
|
||||
)
|
||||
{
|
||||
if (foundField<regIOobject>(fieldName))
|
||||
{
|
||||
const regIOobject& resultField = lookupField<regIOobject>(fieldName);
|
||||
|
||||
if (resultField.ownedByRegistry())
|
||||
{
|
||||
return const_cast<regIOobject&>(resultField).checkOut();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fvMeshFunctionObject::fvMeshFunctionObject
|
||||
|
||||
@ -95,6 +95,9 @@ protected:
|
||||
//- Write field if present in objectRegistry
|
||||
bool writeField(const word& fieldName);
|
||||
|
||||
//- Clear field from the objectRegistry if present
|
||||
bool clearField(const word& fieldName);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@ -74,10 +74,22 @@ bool Foam::functionObjects::fvMeshFunctionObject::store
|
||||
&& mesh_.foundObject<FieldType>(fieldName)
|
||||
)
|
||||
{
|
||||
const_cast<FieldType&>
|
||||
const FieldType& field =
|
||||
(
|
||||
mesh_.lookupObject<FieldType>(fieldName)
|
||||
) = tfield;
|
||||
);
|
||||
|
||||
// If there is a result field already registered assign to the new
|
||||
// result field otherwise transfer ownership of the new result field to
|
||||
// the object registry
|
||||
if (&field != &tfield())
|
||||
{
|
||||
const_cast<FieldType&>(field) = tfield;
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh_.objectRegistry::store(tfield.ptr());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -66,41 +66,7 @@ Foam::functionObjects::CourantNo::byRho
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::CourantNo::CourantNo
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "phi", "Co")
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::CourantNo::~CourantNo()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::CourantNo::read(const dictionary& dict)
|
||||
{
|
||||
fieldExpression::read(dict);
|
||||
|
||||
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
|
||||
rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::CourantNo::execute(const bool postProcess)
|
||||
bool Foam::functionObjects::CourantNo::calc()
|
||||
{
|
||||
if (foundField<surfaceScalarField>(phiName_))
|
||||
{
|
||||
@ -163,4 +129,38 @@ bool Foam::functionObjects::CourantNo::execute(const bool postProcess)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::CourantNo::CourantNo
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "phi", "Co")
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::CourantNo::~CourantNo()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::CourantNo::read(const dictionary& dict)
|
||||
{
|
||||
fieldExpression::read(dict);
|
||||
|
||||
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
|
||||
rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -73,12 +73,15 @@ class CourantNo
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Divide Co by rho if required
|
||||
//- Divide the Courant number by rho if required
|
||||
tmp<volScalarField::Internal> byRho
|
||||
(
|
||||
const tmp<volScalarField::Internal>& Co
|
||||
) const;
|
||||
|
||||
//- Calculate the Courant number field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -105,9 +108,6 @@ public:
|
||||
|
||||
//- Read the CourantNo data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Calculate the Courant number
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -45,28 +45,9 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::Lambda2::Lambda2
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U", "Lambda2")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::Lambda2::~Lambda2()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::Lambda2::execute(const bool postProcess)
|
||||
bool Foam::functionObjects::Lambda2::calc()
|
||||
{
|
||||
if (foundField<volVectorField>(fieldName_))
|
||||
{
|
||||
@ -93,4 +74,23 @@ bool Foam::functionObjects::Lambda2::execute(const bool postProcess)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::Lambda2::Lambda2
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U", "Lambda2")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::Lambda2::~Lambda2()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -61,6 +61,11 @@ class Lambda2
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the Lambda2 field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -81,12 +86,6 @@ public:
|
||||
|
||||
//- Destructor
|
||||
virtual ~Lambda2();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the Lambda2 field
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -45,28 +45,9 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::MachNo::MachNo
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U", "Ma")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::MachNo::~MachNo()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::MachNo::execute(const bool postProcess)
|
||||
bool Foam::functionObjects::MachNo::calc()
|
||||
{
|
||||
if
|
||||
(
|
||||
@ -92,4 +73,23 @@ bool Foam::functionObjects::MachNo::execute(const bool postProcess)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::MachNo::MachNo
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U", "Ma")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::MachNo::~MachNo()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -60,6 +60,11 @@ class MachNo
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the Mach number field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -81,12 +86,6 @@ public:
|
||||
|
||||
//- Destructor
|
||||
virtual ~MachNo();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the Mach number field
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -46,6 +46,41 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::PecletNo::calc()
|
||||
{
|
||||
if (foundField<surfaceScalarField>(phiName_))
|
||||
{
|
||||
tmp<volScalarField> nuEff
|
||||
(
|
||||
mesh_.lookupObject<turbulenceModel>
|
||||
(
|
||||
turbulenceModel::propertiesName
|
||||
).nuEff()
|
||||
);
|
||||
|
||||
const surfaceScalarField& phi =
|
||||
mesh_.lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
mag(phi)
|
||||
/(
|
||||
mesh_.magSf()
|
||||
*mesh_.surfaceInterpolation::deltaCoeffs()
|
||||
*fvc::interpolate(nuEff)
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::PecletNo::PecletNo
|
||||
@ -79,37 +114,4 @@ bool Foam::functionObjects::PecletNo::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::PecletNo::execute(const bool postProcess)
|
||||
{
|
||||
if (foundField<surfaceScalarField>(phiName_))
|
||||
{
|
||||
tmp<volScalarField> nuEff
|
||||
(
|
||||
mesh_.lookupObject<turbulenceModel>
|
||||
(
|
||||
turbulenceModel::propertiesName
|
||||
).nuEff()
|
||||
);
|
||||
|
||||
const surfaceScalarField& phi =
|
||||
mesh_.lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
mag(phi)
|
||||
/(
|
||||
mesh_.magSf()
|
||||
*mesh_.surfaceInterpolation::deltaCoeffs()
|
||||
*fvc::interpolate(nuEff)
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -66,6 +66,12 @@ class PecletNo
|
||||
word phiName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the Peclet number field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -92,9 +98,6 @@ public:
|
||||
|
||||
//- Read the PecletNo data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Calculate the Peclet number field
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -45,28 +45,9 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::Q::Q
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U", "Q")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::Q::~Q()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::Q::execute(const bool postProcess)
|
||||
bool Foam::functionObjects::Q::calc()
|
||||
{
|
||||
if (foundField<volVectorField>(fieldName_))
|
||||
{
|
||||
@ -87,4 +68,23 @@ bool Foam::functionObjects::Q::execute(const bool postProcess)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::Q::Q
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U", "Q")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::Q::~Q()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -64,6 +64,11 @@ class Q
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the Q field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -84,12 +89,6 @@ public:
|
||||
|
||||
//- Destructor
|
||||
virtual ~Q();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the Q field
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -38,6 +38,25 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::blendingFactor::calc()
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calcBF<scalar>();
|
||||
processed = processed || calcBF<vector>();
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Unprocessed field " << fieldName_ << endl;
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::blendingFactor::blendingFactor
|
||||
@ -73,21 +92,4 @@ bool Foam::functionObjects::blendingFactor::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::blendingFactor::execute(const bool postProcess)
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calc<scalar>();
|
||||
processed = processed || calc<vector>();
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Unprocessed field " << fieldName_ << endl;
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -69,9 +69,12 @@ class blendingFactor
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the blending factor
|
||||
//- Calculate the blending factor field
|
||||
template<class Type>
|
||||
bool calc();
|
||||
bool calcBF();
|
||||
|
||||
//- Calculate the blending factor field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
@ -99,9 +102,6 @@ public:
|
||||
|
||||
//- Read the blendingFactor data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Calculate the blending-factor
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ License
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::blendingFactor::calc()
|
||||
bool Foam::functionObjects::blendingFactor::calcBF()
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
|
||||
|
||||
|
||||
@ -40,6 +40,19 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::div::calc()
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calcDiv<surfaceScalarField>();
|
||||
processed = processed || calcDiv<volVectorField>();
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::div::div
|
||||
@ -59,23 +72,4 @@ Foam::functionObjects::div::~div()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::div::execute(const bool postProcess)
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calc<surfaceScalarField>();
|
||||
processed = processed || calc<volVectorField>();
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Unprocessed field " << fieldName_ << endl;
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -66,7 +66,10 @@ class div
|
||||
//- Calculate the divergence of either a
|
||||
// volScalarField or a surfaceScalarField and register the result
|
||||
template<class FieldType>
|
||||
bool calc();
|
||||
bool calcDiv();
|
||||
|
||||
//- Calculate the divergence field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
@ -88,12 +91,6 @@ public:
|
||||
|
||||
//- Destructor
|
||||
virtual ~div();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the divergence field
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ License
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class FieldType>
|
||||
bool Foam::functionObjects::div::calc()
|
||||
bool Foam::functionObjects::div::calcDiv()
|
||||
{
|
||||
if (foundField<FieldType>(fieldName_))
|
||||
{
|
||||
|
||||
@ -45,6 +45,27 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::enstrophy::calc()
|
||||
{
|
||||
if (foundField<volVectorField>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
0.5*magSqr(fvc::curl(lookupField<volVectorField>(fieldName_)))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::enstrophy::enstrophy
|
||||
@ -64,25 +85,4 @@ Foam::functionObjects::enstrophy::~enstrophy()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::enstrophy::execute(const bool postProcess)
|
||||
{
|
||||
if (foundField<volVectorField>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
0.5*magSqr(fvc::curl(lookupField<volVectorField>(fieldName_)))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -59,6 +59,11 @@ class enstrophy
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the enstrophy field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -79,12 +84,6 @@ public:
|
||||
|
||||
//- Destructor
|
||||
virtual ~enstrophy();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the enstrophy field
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -36,6 +36,15 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::fieldExpression::calc()
|
||||
{
|
||||
NotImplemented;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::fieldExpression::fieldExpression
|
||||
@ -81,9 +90,35 @@ bool Foam::functionObjects::fieldExpression::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldExpression::execute(const bool postProcess)
|
||||
{
|
||||
if (!calc())
|
||||
{
|
||||
Warning
|
||||
<< "functionObject " << type() << ": Cannot find required field "
|
||||
<< fieldName_ << endl;
|
||||
|
||||
// Clear the result field from the objectRegistry if present
|
||||
clear();
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldExpression::write(const bool postProcess)
|
||||
{
|
||||
return fvMeshFunctionObject::writeField(resultName_);
|
||||
return writeField(resultName_);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldExpression::clear()
|
||||
{
|
||||
return clearField(resultName_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -69,6 +69,11 @@ protected:
|
||||
word resultName_;
|
||||
|
||||
|
||||
// Protected member functions
|
||||
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
@ -109,10 +114,13 @@ public:
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Calculate the fieldExpressionergence field
|
||||
virtual bool execute(const bool postProcess = false) = 0;
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
|
||||
//- Write the fieldExpressionergence field
|
||||
virtual bool write(const bool postProcess = false);
|
||||
|
||||
//- Clear the result field from the objectRegistry
|
||||
virtual bool clear();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -45,28 +45,9 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::flowType::flowType
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U", "flowType")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::flowType::~flowType()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::flowType::execute(const bool postProcess)
|
||||
bool Foam::functionObjects::flowType::calc()
|
||||
{
|
||||
if (foundField<volVectorField>(fieldName_))
|
||||
{
|
||||
@ -97,4 +78,23 @@ bool Foam::functionObjects::flowType::execute(const bool postProcess)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::flowType::flowType
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fieldExpression(name, runTime, dict, "U", "flowType")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::flowType::~flowType()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -70,6 +70,11 @@ class flowType
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the flowType field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -90,12 +95,6 @@ public:
|
||||
|
||||
//- Destructor
|
||||
virtual ~flowType();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the flowType field
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -38,6 +38,19 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::grad::calc()
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calcGrad<scalar>();
|
||||
processed = processed || calcGrad<vector>();
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::grad::grad
|
||||
@ -59,23 +72,4 @@ Foam::functionObjects::grad::~grad()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::grad::execute(const bool postProcess)
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calc<scalar>();
|
||||
processed = processed || calc<vector>();
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Unprocessed field " << fieldName_ << endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -64,7 +64,10 @@ class grad
|
||||
|
||||
//- Calculate the magnitude of the field and register the result
|
||||
template<class Type>
|
||||
bool calc();
|
||||
bool calcGrad();
|
||||
|
||||
//- Calculate the gradient field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
@ -86,12 +89,6 @@ public:
|
||||
|
||||
//- Destructor
|
||||
virtual ~grad();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the gradient field
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ License
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::grad::calc()
|
||||
bool Foam::functionObjects::grad::calcGrad()
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
@ -38,6 +38,28 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::mag::calc()
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calcMag<scalar>();
|
||||
processed = processed || calcMag<vector>();
|
||||
processed = processed || calcMag<sphericalTensor>();
|
||||
processed = processed || calcMag<symmTensor>();
|
||||
processed = processed || calcMag<tensor>();
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Unprocessed field " << fieldName_ << endl;
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::mag::mag
|
||||
@ -59,26 +81,4 @@ Foam::functionObjects::mag::~mag()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::mag::execute(const bool postProcess)
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calc<scalar>();
|
||||
processed = processed || calc<vector>();
|
||||
processed = processed || calc<sphericalTensor>();
|
||||
processed = processed || calc<symmTensor>();
|
||||
processed = processed || calc<tensor>();
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Unprocessed field " << fieldName_ << endl;
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -64,7 +64,10 @@ class mag
|
||||
|
||||
//- Calculate the magnitude of the field and register the result
|
||||
template<class Type>
|
||||
bool calc();
|
||||
bool calcMag();
|
||||
|
||||
//- Calculate the magnitude of the field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
@ -86,12 +89,6 @@ public:
|
||||
|
||||
//- Destructor
|
||||
virtual ~mag();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the magnitude field
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ License
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjects::mag::calc()
|
||||
bool Foam::functionObjects::mag::calcMag()
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
@ -159,6 +159,27 @@ Foam::functionObjects::pressure::coeff
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::pressure::calc()
|
||||
{
|
||||
if (foundField<volScalarField>(fieldName_))
|
||||
{
|
||||
const volScalarField& p = lookupField<volScalarField>(fieldName_);
|
||||
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
coeff(pRef(pDyn(p, rhoScale(p))))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::pressure::pressure
|
||||
@ -238,23 +259,4 @@ bool Foam::functionObjects::pressure::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::pressure::execute(const bool postProcess)
|
||||
{
|
||||
if (foundField<volScalarField>(fieldName_))
|
||||
{
|
||||
const volScalarField& p = lookupField<volScalarField>(fieldName_);
|
||||
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
coeff(pRef(pDyn(p, rhoScale(p))))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -196,6 +196,9 @@ class pressure
|
||||
//- Convert to coeff by applying the freestream dynamic pressure scaling
|
||||
tmp<volScalarField> coeff(const tmp<volScalarField>& tp) const;
|
||||
|
||||
//- Calculate the derived pressure field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -222,9 +225,6 @@ public:
|
||||
|
||||
//- Read the pressure data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Calculate the selected pressure form
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -45,6 +45,27 @@ namespace functionObjects
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::vorticity::calc()
|
||||
{
|
||||
if (foundField<volVectorField>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
fvc::curl(lookupField<volVectorField>(fieldName_))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::vorticity::vorticity
|
||||
@ -64,25 +85,4 @@ Foam::functionObjects::vorticity::~vorticity()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::vorticity::execute(const bool postProcess)
|
||||
{
|
||||
if (foundField<volVectorField>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
fvc::curl(lookupField<volVectorField>(fieldName_))
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -59,6 +59,11 @@ class vorticity
|
||||
:
|
||||
public fieldExpression
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate the vorticity field and return true if successful
|
||||
virtual bool calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -79,12 +84,6 @@ public:
|
||||
|
||||
//- Destructor
|
||||
virtual ~vorticity();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the vorticity field
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user