ENH: function object clean-up

This commit is contained in:
Andrew Heather 2016-10-19 15:28:55 +01:00
parent 4408d47075
commit 95347013a8
23 changed files with 110 additions and 326 deletions

View File

@ -22,10 +22,10 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::ddt2
Foam::functionObjects::ddt2
Group
grpFVFunctionObjects
grpFieldFunctionObjects
Description
This function object calculates the magnitude squared

View File

@ -25,7 +25,7 @@ Class
Foam::functionObjects::externalCoupled
Group
grpUtilitiesFunctionObjects
grpFieldFunctionObjects
Description
This functionObject provides a simple interface for explicit coupling with

View File

@ -28,6 +28,7 @@ Group
grpFieldFunctionObjects
Description
Base class for field expression function objects
See also
Foam::functionObjects::fvMeshFunctionObject

View File

@ -22,9 +22,10 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::surfaceInterpolate
Foam::functionObjects::surfaceInterpolate
Group grpFieldFunctionObjects
Group
grpFieldFunctionObjects
Description
Linearly interpolates volume fields to generate surface fields.

View File

@ -25,7 +25,7 @@ Class
Foam::functionObjects::turbulenceFields
Group
grpUtilitiesFunctionObjects
grpFieldFunctionObjects
Description
Stores turbulence fields on the mesh database for further manipulation.

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::valueAverage
Foam::functionObjects::valueAverage
Group
grpFieldFunctionObjects

View File

@ -22,10 +22,10 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::zeroGradient
Foam::functionObjects::zeroGradient
Group
grpFVFunctionObjects
grpFieldFunctionObjects
Description
This function object creates a volume field with zero-gradient

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -21,13 +21,13 @@ License
You should have received a copy of the GNU General Public License along with
OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\defgroup grpFieldFunctionObjects Field function objects
\defgroup grpSolversFunctionObjects Solver function objects
@{
\ingroup grpFunctionObjects
This group contains field-based function objects
This group contains solver-based function objects
Function objects in this group are packaged into the
libfieldFunctionObjects.so library.
libsolverFunctionObjects.so library.
@}
\*---------------------------------------------------------------------------*/

View File

@ -36,6 +36,8 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(codedFunctionObject, 0);
@ -46,10 +48,11 @@ namespace Foam
dictionary
);
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::codedFunctionObject::prepare
void Foam::functionObjects::codedFunctionObject::prepare
(
dynamicCode& dynCode,
const dynamicCodeContext& context
@ -90,25 +93,26 @@ void Foam::codedFunctionObject::prepare
}
Foam::dlLibraryTable& Foam::codedFunctionObject::libs() const
Foam::dlLibraryTable& Foam::functionObjects::codedFunctionObject::libs() const
{
return const_cast<Time&>(time_).libs();
}
Foam::string Foam::codedFunctionObject::description() const
Foam::string Foam::functionObjects::codedFunctionObject::description() const
{
return "functionObject " + name();
}
void Foam::codedFunctionObject::clearRedirect() const
void Foam::functionObjects::codedFunctionObject::clearRedirect() const
{
redirectFunctionObjectPtr_.clear();
}
const Foam::dictionary& Foam::codedFunctionObject::codeDict() const
const Foam::dictionary&
Foam::functionObjects::codedFunctionObject::codeDict() const
{
return dict_;
}
@ -116,7 +120,7 @@ const Foam::dictionary& Foam::codedFunctionObject::codeDict() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::codedFunctionObject::codedFunctionObject
Foam::functionObjects::codedFunctionObject::codedFunctionObject
(
const word& name,
const Time& time,
@ -137,13 +141,14 @@ Foam::codedFunctionObject::codedFunctionObject
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::codedFunctionObject::~codedFunctionObject()
Foam::functionObjects::codedFunctionObject::~codedFunctionObject()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::functionObject& Foam::codedFunctionObject::redirectFunctionObject() const
Foam::functionObject&
Foam::functionObjects::codedFunctionObject::redirectFunctionObject() const
{
if (!redirectFunctionObjectPtr_.valid())
{
@ -161,28 +166,28 @@ Foam::functionObject& Foam::codedFunctionObject::redirectFunctionObject() const
}
bool Foam::codedFunctionObject::execute()
bool Foam::functionObjects::codedFunctionObject::execute()
{
updateLibrary(name_);
return redirectFunctionObject().execute();
}
bool Foam::codedFunctionObject::write()
bool Foam::functionObjects::codedFunctionObject::write()
{
updateLibrary(name_);
return redirectFunctionObject().write();
}
bool Foam::codedFunctionObject::end()
bool Foam::functionObjects::codedFunctionObject::end()
{
updateLibrary(name_);
return redirectFunctionObject().end();
}
bool Foam::codedFunctionObject::read(const dictionary& dict)
bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
{
functionObject::read(dict);

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::codedFunctionObject
Foam::functionObjects::codedFunctionObject
Group
grpUtilitiesFunctionObjects
@ -80,6 +80,8 @@ SourceFiles
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class codedFunctionObject Declaration
@ -186,6 +188,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -25,6 +25,9 @@ License
@{
\ingroup grpFunctionObjects
This group contains utility-based function objects
Function objects in this group are packaged into the
libutilityFunctionObjects.so library.
@}
\*---------------------------------------------------------------------------*/

View File

@ -66,10 +66,6 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
namespace functionObjects
{

View File

@ -33,37 +33,30 @@ using namespace Foam::constant;
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(thermoCoupleProbes, 0);
addToRunTimeSelectionTable(functionObject, thermoCoupleProbes, dictionary);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::thermoCoupleProbes::readDict(const dictionary& dict)
{
rho_ = readScalar(dict.lookup("rho"));
Cp_ = readScalar(dict.lookup("Cp"));
d_ = readScalar(dict.lookup("d"));
epsilon_ = readScalar(dict.lookup("epsilon"));
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::thermoCoupleProbes::thermoCoupleProbes
Foam::functionObjects::thermoCoupleProbes::thermoCoupleProbes
(
const word& name,
const Time& runTime,
const dictionary& dict,
const bool loadFromFiles,
const bool doFindElements
const bool readFields
)
:
probes(name, runTime, dict, loadFromFiles, doFindElements),
probes(name, runTime, dict, loadFromFiles, false),
ODESystem(),
radName_(dict.lookup("radName")),
UName_(dict.lookup("U")),
radiationFieldName_(dict.lookup("radiationField")),
thermo_
(
mesh_.lookupObject<fluidThermo>(basicThermo::dictName)
@ -71,8 +64,10 @@ Foam::thermoCoupleProbes::thermoCoupleProbes
odeSolver_(ODESolver::New(*this, dict)),
Ttc_(this->size(), 0.0)
{
readDict(dict);
if (readFields)
{
read(dict);
}
// Check if the property exist (resume old calculation)
// or of it is new.
@ -85,35 +80,24 @@ Foam::thermoCoupleProbes::thermoCoupleProbes
}
else
{
Ttc_ = probes::sample(thermo_.T());
}
// Initialize thermocouple at initial T (room temperature)
if (doFindElements)
{
// Find the elements
findElements(mesh_);
// Open the probe streams
prepare();
Ttc_ = probes::sample(thermo_.T());
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::thermoCoupleProbes::~thermoCoupleProbes()
Foam::functionObjects::thermoCoupleProbes::~thermoCoupleProbes()
{}
Foam::label Foam::thermoCoupleProbes::nEqns() const
Foam::label Foam::functionObjects::thermoCoupleProbes::nEqns() const
{
return this->size();
}
void Foam::thermoCoupleProbes::derivatives
void Foam::functionObjects::thermoCoupleProbes::derivatives
(
const scalar x,
const scalarField& y,
@ -128,14 +112,14 @@ void Foam::thermoCoupleProbes::derivatives
scalarField Cpc(y.size(), 0.0);
scalarField kappac(y.size(), 0.0);
if (radName_ != "none")
if (radiationFieldName_ != "none")
{
G = sample(mesh_.lookupObject<volScalarField>(radName_));
G = sample(mesh_.lookupObject<volScalarField>(radiationFieldName_));
}
Tc = probes::sample(thermo_.T());
Uc = mag(this->sample(mesh_.lookupObject<volVectorField>("U")));
Uc = mag(this->sample(mesh_.lookupObject<volVectorField>(UName_)));
rhoc = this->sample(thermo_.rho()());
kappac = this->sample(thermo_.kappa()());
@ -150,8 +134,8 @@ void Foam::thermoCoupleProbes::derivatives
const scalar sigma = physicoChemical::sigma.value();
scalar area = 4*constant::mathematical::pi*sqr(d_/2);
scalar volume = (4/3)*constant::mathematical::pi*pow(d_/2, 3);
scalar area = 4*constant::mathematical::pi*sqr(0.5*d_);
scalar volume = (4/3)*constant::mathematical::pi*pow3(0.5*d_);
dydx =
(epsilon_*(G/4 - sigma*pow(y, 4.0))*area + htc*(Tc - y)*area)
@ -159,7 +143,7 @@ void Foam::thermoCoupleProbes::derivatives
}
void Foam::thermoCoupleProbes::jacobian
void Foam::functionObjects::thermoCoupleProbes::jacobian
(
const scalar x,
const scalarField& y,
@ -168,18 +152,20 @@ void Foam::thermoCoupleProbes::jacobian
) const
{
derivatives(x, y, dfdt);
for (label i=0; i<nEqns(); i++)
const label n = nEqns();
for (label i=0; i<n; i++)
{
for (label j=0; j<nEqns(); j++)
for (label j=0; j<n; j++)
{
dfdy(i, j) = 0.0;
}
}
}
bool Foam::thermoCoupleProbes::write()
bool Foam::functionObjects::thermoCoupleProbes::write()
{
if (this->size())
{
@ -190,11 +176,12 @@ bool Foam::thermoCoupleProbes::write()
setProperty(typeName, probeDict);
return true;
}
return false;
return false;
}
bool Foam::thermoCoupleProbes::execute()
bool Foam::functionObjects::thermoCoupleProbes::execute()
{
if (this->size())
{
@ -208,11 +195,18 @@ bool Foam::thermoCoupleProbes::execute()
}
bool Foam::thermoCoupleProbes::read(const dictionary& dict)
bool Foam::functionObjects::thermoCoupleProbes::read(const dictionary& dict)
{
readDict(dict);
probes::read(dict);
return true;
if (probes::read(dict))
{
rho_ = readScalar(dict.lookup("rho"));
Cp_ = readScalar(dict.lookup("Cp"));
d_ = readScalar(dict.lookup("d"));
epsilon_ = readScalar(dict.lookup("epsilon"));
return true;
}
return false;
}

View File

@ -24,10 +24,17 @@ License
Class
Foam::functionObjects::thermoCoupleProbes
Description
Sample probe for temperature using a thermocouple. Uses the correlation:
Group
grpUtilitiesFunctionObjects
Nu = 2.0 + (0.4*sqrt(Re) + 0.06*pow(Re, 2/3))*pow(Pr, 0.4)
Description
Sample probe for temperature using a thermocouple.
Uses the correlation:
\f[
Nu = 2.0 + \left(0.4 Re^{0.5} + 0.06 Re^{2/3}\right)*Pr^{0.4}
\f]
Example of function object specification:
\verbatim
@ -47,14 +54,14 @@ Description
d 1e-3;
epsilon 0.85;
radName G;
radiationField G;
functionObjectLibs ("libsampling.so");
outputControl timeStep;
outputInterval 1;
libs ("libutilityFunctionObjects.so");
writeControl timeStep;
writeInterval 1;
probeLocations
(
( 0.5 0.5 0.5 )
(0.5 0.5 0.5)
);
fields
(
@ -69,8 +76,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef thermoCoupleProbes_H
#define thermoCoupleProbes_H
#ifndef functionObjects_hermoCoupleProbes_H
#define functionObjects_hermoCoupleProbes_H
#include "probes.H"
#include "ODESystem.H"
@ -82,9 +89,11 @@ SourceFiles
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class thermoCoupleProbes Declaration
Class thermoCoupleProbes Declaration
\*---------------------------------------------------------------------------*/
class thermoCoupleProbes
@ -108,8 +117,11 @@ protected:
//- Thermocouple emissivity
scalar epsilon_;
//- Name for the incident radiation field
word radName_;
//- Name of the velocity field
word UName_;
//- Name of the incident radiation field
word radiationFieldName_;
//- Fluid thermo reference
const fluidThermo& thermo_;
@ -131,10 +143,6 @@ protected:
);
//- Read dictionary settings
void readDict(const dictionary& dict);
private:
//- Disallow default bitwise copy construct
@ -160,7 +168,7 @@ public:
const Time& runTime,
const dictionary& dict,
const bool loadFromFiles = false,
const bool findElements = true
const bool readFields = true
);
@ -202,6 +210,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -29,7 +29,7 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::thermoCoupleProbes::sampleAndWrite
void Foam::functionObjects::thermoCoupleProbes::sampleAndWrite
(
const GeometricField<Type, fvPatchField, volMesh>& vField
)
@ -50,4 +50,6 @@ void Foam::thermoCoupleProbes::sampleAndWrite
probeStream << endl;
}
}
// ************************************************************************* //

View File

@ -46,10 +46,6 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
namespace functionObjects
{

View File

@ -1,30 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\defgroup grpIOFunctionObjects Input/output function objects
@{
\ingroup grpFunctionObjects
This group contains input/output-based function objects
@}
\*---------------------------------------------------------------------------*/

View File

@ -1,33 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\defgroup grpCloudFunctionObjects Cloud function objects
@{
\ingroup grpFunctionObjects
This group contains cloud-based function objects.
Function objects in this group are packaged into the
libcloudFunctionObjects.so library.
@}
\*---------------------------------------------------------------------------*/

View File

@ -1,100 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
\page pagePostProcessing Post-processing
\section secFunctionObjects Function objects
OpenFOAM includes a collection of \ref grpFunctionObjects that offer users the
opportunity to closely manage their computational analyses. These objects can
be applied to manipulate the workflow process, and provide a mechanism to
extract predicted field and derived quantities at run-time. Alternatively,
the actions can be executed afterwards using the \c execFlowFunctionObjects
utility.
\linebreak
The current range of features comprises of:
- \ref grpCloudFunctionObjects
- \ref grpFieldFunctionObjects
- \ref grpForcesFunctionObjects
- \ref grpFVFunctionObjects
- \ref grpGraphicsFunctionObjects
- \ref grpIOFunctionObjects
- \ref grpJobControlFunctionObjects
- \ref grpUtilitiesFunctionObjects
- \ref grpThermophysicalFunctionObjects
\linebreak
\subsection secFieldFunctionObjectUsage Using function objects
Function objects are defined by additional entries in the
$FOAM_CASE/system/controlDict input dictionary. Each object is listed in a
\c functions sub-dictionary entry, e.g. the following shows the input options
applicable to `output' -type objects:
\verbatim
functions
{
myFunctionObject // user-defined name of function object entry
{
type functionObjectType;
functionObjectLibs ("libMyFunctionObjectlib.so");
region defaultRegion;
enabled yes;
timeStart 0;
timeEnd 10;
evaluateControl timeStep;
evaluateInterval 1;
outputControl outputTime;
outputInterval 1;
...
}
}
\endverbatim
Where:
\table
Property | Description | Required | Default value
type | type of function object | yes |
functionObjectLibs | libraries containing object implementation | yes |
region | name of region for multi-region cases | no |
enabled | on/off switch | no | yes
timeStart| start time | no |
timeEnd | end time | no |
evaluateControl | when to evaluate: either 'outputTime' or 'timeStep'| no | timeStep
evaluateInterval| steps between evaluation when evaluateControl=timeStep | no | 1
outputControl | when to output: either 'outputTime' or 'timeStep'| no | timeStep
outputInterval| steps between output when outputControl=timeStep | no | 1
\endtable
The sub-dictionary name \c myFunctionObject is chosen by the user, and is
typically used as the name of the output directory for any derived data. The
\c type entry defines the type of function object properties that follow.
Since the function objects are packaged into separate libraries, the user must
tell the code where to find the function object implementation, identified
using the \c functionObjectLibs entry.
\*---------------------------------------------------------------------------*/

View File

@ -1,33 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\defgroup grpForcesFunctionObjects Forces function objects
@{
\ingroup grpFunctionObjects
This group contains force-based function objects
Function objects in this group are packaged into the
libforcesFunctionObjects.so library.
@}
\*---------------------------------------------------------------------------*/

View File

@ -1,30 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\defgroup grpJobControlFunctionObjects Job control function objects
@{
\ingroup grpFunctionObjects
This group contains job control-based function objects
@}
\*---------------------------------------------------------------------------*/