Commit 546159a8 authored by Henry Weller's avatar Henry Weller
Browse files

functionObjects: Simplified and reorganised using the fieldExpression base-class

parent 3009367a
......@@ -111,8 +111,8 @@ Foam::functionObjects::CourantNo::~CourantNo()
bool Foam::functionObjects::CourantNo::read(const dictionary& dict)
{
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
rhoName_ = dict.lookupOrDefault<word>("rhoName", "rho");
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
return true;
}
......
......@@ -91,7 +91,7 @@ Foam::functionObjects::Lambda2::~Lambda2()
bool Foam::functionObjects::Lambda2::read(const dictionary& dict)
{
UName_ = dict.lookupOrDefault<word>("UName", "U");
UName_ = dict.lookupOrDefault<word>("U", "U");
return true;
}
......
......@@ -36,5 +36,9 @@ fieldExpression/fieldExpression.C
div/div.C
grad/grad.C
mag/mag.C
vorticity/vorticity.C
Q/Q.C
Lambda2/Lambda2.C
CourantNo/CourantNo.C
LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects
......@@ -24,7 +24,6 @@ License
\*---------------------------------------------------------------------------*/
#include "Q.H"
#include "volFields.H"
#include "fvcGrad.H"
#include "addToRunTimeSelectionTable.H"
......@@ -55,29 +54,8 @@ Foam::functionObjects::Q::Q
const dictionary& dict
)
:
fvMeshFunctionObject(name, runTime, dict)
{
read(dict);
volScalarField* QPtr
(
new volScalarField
(
IOobject
(
type(),
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("0", dimless/sqr(dimTime), 0.0)
)
);
mesh_.objectRegistry::store(QPtr);
}
fieldExpression(name, runTime, dict, "U", "Q")
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
......@@ -88,45 +66,24 @@ Foam::functionObjects::Q::~Q()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::Q::read(const dictionary& dict)
{
UName_ = dict.lookupOrDefault<word>("UName", "U");
return true;
}
bool Foam::functionObjects::Q::execute(const bool postProcess)
{
const volVectorField& U =
mesh_.lookupObject<volVectorField>(UName_);
const volTensorField gradU(fvc::grad(U));
if (foundField<volVectorField>(fieldName_))
{
const volVectorField& U = lookupField<volVectorField>(fieldName_);
const tmp<volTensorField> tgradU(fvc::grad(U));
const volTensorField& gradU = tgradU();
volScalarField& Q =
const_cast<volScalarField&>
return store
(
mesh_.lookupObject<volScalarField>(type())
resultName_,
0.5*(sqr(tr(gradU)) - tr(((gradU) & (gradU))))
);
Q = 0.5*(sqr(tr(gradU)) - tr(((gradU) & (gradU))));
return true;
}
bool Foam::functionObjects::Q::write(const bool postProcess)
{
const volScalarField& Q =
mesh_.lookupObject<volScalarField>(type());
Info<< type() << " " << name() << " output:" << nl
<< " writing field " << Q.name() << nl
<< endl;
Q.write();
return true;
}
else
{
return false;
}
}
......
......@@ -36,6 +36,7 @@ Description
\f]
SeeAlso
Foam::functionObjects::fieldExpression
Foam::functionObjects::fvMeshFunctionObject
SourceFiles
......@@ -46,8 +47,7 @@ SourceFiles
#ifndef functionObjects_Q_H
#define functionObjects_Q_H
#include "fvMeshFunctionObject.H"
#include "volFieldsFwd.H"
#include "fieldExpression.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -62,22 +62,8 @@ namespace functionObjects
class Q
:
public fvMeshFunctionObject
public fieldExpression
{
// Private data
//- Name of velocity field, default is "U"
word UName_;
// Private Member Functions
//- Disallow default bitwise copy construct
Q(const Q&);
//- Disallow default bitwise assignment
void operator=(const Q&);
public:
......@@ -102,14 +88,8 @@ public:
// Member Functions
//- Read the Q data
virtual bool read(const dictionary&);
//- Calculate the Q-field
virtual bool execute(const bool postProcess = false);
//- Write the Q-field
virtual bool write(const bool postProcess = false);
};
......
......@@ -33,6 +33,7 @@ Description
volScalarField.
SeeAlso
Foam::functionObjects::fieldExpression
Foam::functionObjects::fvMeshFunctionObject
SourceFiles
......
......@@ -42,10 +42,14 @@ Foam::functionObjects::fieldExpression::fieldExpression
(
const word& name,
const Time& runTime,
const dictionary& dict
const dictionary& dict,
const word& fieldName,
const word& resultName
)
:
fvMeshFunctionObject(name, runTime, dict)
fvMeshFunctionObject(name, runTime, dict),
fieldName_(fieldName),
resultName_(resultName)
{
read(dict);
}
......@@ -61,7 +65,10 @@ Foam::functionObjects::fieldExpression::~fieldExpression()
bool Foam::functionObjects::fieldExpression::read(const dictionary& dict)
{
dict.lookup("field") >> fieldName_;
if (fieldName_ == word::null || dict.found("field"))
{
dict.lookup("field") >> fieldName_;
}
if (dict.found("result"))
{
......
......@@ -93,7 +93,9 @@ public:
(
const word& name,
const Time& runTime,
const dictionary& dict
const dictionary& dict,
const word& fieldName = word::null,
const word& resultName = word::null
);
......
......@@ -91,7 +91,7 @@ Foam::functionObjects::vorticity::~vorticity()
bool Foam::functionObjects::vorticity::read(const dictionary& dict)
{
UName_ = dict.lookupOrDefault<word>("UName", "U");
UName_ = dict.lookupOrDefault<word>("U", "U");
if (UName_ != "U")
{
outputName_ = typeName + "(" + UName_ + ")";
......
codedFunctionObject/codedFunctionObject.C
CourantNo/CourantNo.C
Lambda2/Lambda2.C
Peclet/Peclet.C
Q/Q.C
blendingFactor/blendingFactor.C
dsmcFields/dsmcFields.C
residuals/residuals.C
scalarTransport/scalarTransport.C
timeActivatedFileUpdate/timeActivatedFileUpdate.C
turbulenceFields/turbulenceFields.C
vorticity/vorticity.C
yPlus/yPlus.C
setTimeStep/setTimeStepFunctionObject.C
systemCall/systemCall.C
abort/abort.C
......@@ -18,4 +8,12 @@ removeRegisteredObject/removeRegisteredObject.C
writeDictionary/writeDictionary.C
writeRegisteredObject/writeRegisteredObject.C
scalarTransport/scalarTransport.C
blendingFactor/blendingFactor.C
dsmcFields/dsmcFields.C
turbulenceFields/turbulenceFields.C
Peclet/Peclet.C
yPlus/yPlus.C
LIB = $(FOAM_LIBBIN)/libutilityFunctionObjects
......@@ -94,8 +94,8 @@ Foam::functionObjects::Peclet::~Peclet()
bool Foam::functionObjects::Peclet::read(const dictionary& dict)
{
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
rhoName_ = dict.lookupOrDefault<word>("rhoName", "rho");
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
return true;
}
......
Markdown is supported
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