functionObjects: Moved into the functionObjects namespace and rationalized and simplified failable construction

Rather than requiring each functionObject to handle failed construction
internally (using the active_ flag) the static member function "viable"
is provided which returns true if construction of the functionObject is
likely to be successful.  Failed construction is then handled by the
wrapper-class which constructs the functionObject,
e.g. "OutputFilterFunctionObject".
This commit is contained in:
Henry Weller
2016-05-02 16:28:24 +01:00
parent 66a6700a4b
commit f83975a701
175 changed files with 4667 additions and 4353 deletions

View File

@ -138,7 +138,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
return; return;
} }
dsmcFields dF functionObjects::dsmcFields dF
( (
"dsmcFieldsUtility", "dsmcFieldsUtility",
mesh, mesh,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -76,6 +76,18 @@ ${typeName}FunctionObject::${typeName}FunctionObject
} }
bool ${typeName}FunctionObject::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool
)
{
return true;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
${typeName}FunctionObject::~${typeName}FunctionObject() ${typeName}FunctionObject::~${typeName}FunctionObject()

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -102,6 +102,16 @@ public:
const bool loadFromFilesUnused = false const bool loadFromFilesUnused = false
); );
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
static bool viable
(
const word& name,
const objectRegistry& unused,
const dictionary&,
const bool loadFromFilesUnused = false
);
//- Destructor //- Destructor
virtual ~${typeName}FunctionObject(); virtual ~${typeName}FunctionObject();

View File

@ -71,21 +71,15 @@ void Foam::FUNCTIONOBJECT::read(const dictionary& dict)
void Foam::FUNCTIONOBJECT::execute() void Foam::FUNCTIONOBJECT::execute()
{ {}
// Do nothing - only valid on write
}
void Foam::FUNCTIONOBJECT::end() void Foam::FUNCTIONOBJECT::end()
{ {}
// Do nothing - only valid on write
}
void Foam::FUNCTIONOBJECT::timeSet() void Foam::FUNCTIONOBJECT::timeSet()
{ {}
// Do nothing - only valid on write
}
void Foam::FUNCTIONOBJECT::write() void Foam::FUNCTIONOBJECT::write()

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -66,6 +66,32 @@ Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
{} {}
template<class OutputFilter>
bool Foam::IOOutputFilter<OutputFilter>::viable
(
const word& outputFilterName,
const objectRegistry& obr,
const word& dictName,
const IOobject::readOption rOpt,
const bool readFromFiles
)
{
IOdictionary dict
(
IOobject
(
dictName,
obr.time().system(),
obr,
rOpt,
IOobject::NO_WRITE
)
);
return OutputFilter::viable(outputFilterName, obr, dict, readFromFiles);
}
template<class OutputFilter> template<class OutputFilter>
Foam::IOOutputFilter<OutputFilter>::IOOutputFilter Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
( (
@ -99,6 +125,13 @@ Foam::IOOutputFilter<OutputFilter>::~IOOutputFilter()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class OutputFilter>
const Foam::word& Foam::IOOutputFilter<OutputFilter>::name() const
{
return IOdictionary::name();
}
template<class OutputFilter> template<class OutputFilter>
bool Foam::IOOutputFilter<OutputFilter>::read() bool Foam::IOOutputFilter<OutputFilter>::read()
{ {
@ -121,4 +154,20 @@ void Foam::IOOutputFilter<OutputFilter>::write()
} }
template<class OutputFilter>
void Foam::IOOutputFilter<OutputFilter>::updateMesh(const mapPolyMesh& mpm)
{
read();
OutputFilter::updateMesh(mpm);
}
template<class OutputFilter>
void Foam::IOOutputFilter<OutputFilter>::movePoints(const polyMesh& mesh)
{
read();
OutputFilter::movePoints(mesh);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -94,6 +94,16 @@ public:
const bool loadFromFile = false const bool loadFromFile = false
); );
//- Return true if the construction of this functionObject is viable
static bool viable
(
const word& outputFilterName,
const objectRegistry&,
const word& dictName = OutputFilter::typeName() + "Dict",
const IOobject::readOption rOpt = IOobject::MUST_READ_IF_MODIFIED,
const bool loadFromFiles = false
);
//- Construct for given objectRegistry and dictionary //- Construct for given objectRegistry and dictionary
// Dictionary read from full path. // Dictionary read from full path.
// Allow the possibility to load fields from files // Allow the possibility to load fields from files
@ -114,10 +124,7 @@ public:
// Member Functions // Member Functions
//- Return name //- Return name
virtual const word& name() const virtual const word& name() const;
{
return IOdictionary::name();
}
//- Inherit read from OutputFilter //- Inherit read from OutputFilter
using OutputFilter::read; using OutputFilter::read;
@ -132,18 +139,10 @@ public:
virtual void write(); virtual void write();
//- Update for changes of mesh //- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh& mpm) virtual void updateMesh(const mapPolyMesh& mpm);
{
read();
OutputFilter::updateMesh(mpm);
}
//- Update for changes of mesh //- Update for changes of mesh
virtual void movePoints(const polyMesh& mesh) virtual void movePoints(const polyMesh& mesh);
{
read();
OutputFilter::movePoints(mesh);
}
}; };

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -55,9 +55,19 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::active() const
template<class OutputFilter> template<class OutputFilter>
void Foam::OutputFilterFunctionObject<OutputFilter>::allocateFilter() bool Foam::OutputFilterFunctionObject<OutputFilter>::allocateFilter()
{ {
if (dictName_.size()) if (dictName_.size())
{
if
(
IOOutputFilter<OutputFilter>::viable
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dictName_
)
)
{ {
ptr_.reset ptr_.reset
( (
@ -70,6 +80,21 @@ void Foam::OutputFilterFunctionObject<OutputFilter>::allocateFilter()
); );
} }
else else
{
enabled_ = false;
}
}
else
{
if
(
OutputFilter::viable
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dict_
)
)
{ {
ptr_.reset ptr_.reset
( (
@ -81,6 +106,13 @@ void Foam::OutputFilterFunctionObject<OutputFilter>::allocateFilter()
) )
); );
} }
else
{
enabled_ = false;
}
}
return enabled_;
} }
@ -144,11 +176,13 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::start()
if (enabled_ && storeFilter_) if (enabled_ && storeFilter_)
{ {
allocateFilter(); return allocateFilter();
} }
else
{
return true; return true;
} }
}
template<class OutputFilter> template<class OutputFilter>
@ -159,9 +193,9 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::execute
{ {
if (active()) if (active())
{ {
if (!storeFilter_) if (!storeFilter_ && !allocateFilter())
{ {
allocateFilter(); return false;
} }
if (evaluateControl_.output()) if (evaluateControl_.output())
@ -189,9 +223,9 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::end()
{ {
if (enabled_) if (enabled_)
{ {
if (!storeFilter_) if (!storeFilter_ && !allocateFilter())
{ {
allocateFilter(); return false;
} }
ptr_->end(); ptr_->end();

View File

@ -111,7 +111,7 @@ class OutputFilterFunctionObject
void readDict(); void readDict();
//- Creates most of the data associated with this object. //- Creates most of the data associated with this object.
void allocateFilter(); bool allocateFilter();
//- Destroys most of the data associated with this object. //- Destroys most of the data associated with this object.
void destroyFilter(); void destroyFilter();

View File

@ -96,7 +96,6 @@ void Foam::fv::rotorDiskSource::checkData()
} }
case ifLocal: case ifLocal:
{ {
// Do nothing
break; break;
} }
default: default:

View File

@ -58,8 +58,7 @@ Foam::functionObjects::partialWrite::partialWrite
} }
Foam::autoPtr<Foam::functionObjects::partialWrite> bool Foam::functionObjects::partialWrite::viable
Foam::functionObjects::partialWrite::New
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -67,17 +66,8 @@ Foam::functionObjects::partialWrite::New
const bool loadFromFiles const bool loadFromFiles
) )
{ {
if (isA<fvMesh>(obr)) // Construction is viable if the available mesh is an fvMesh
{ return isA<fvMesh>(obr);
return autoPtr<partialWrite>
(
new partialWrite(name, obr, dict, loadFromFiles)
);
}
else
{
return autoPtr<partialWrite>();
}
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::partialWrite Foam::functionObjects::partialWrite
Group Group
grpIOFunctionObjects grpIOFunctionObjects
@ -171,9 +171,9 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Construct on free-store and return pointer if successful //- Return true if the construction of this functionObject is viable
// otherwise return a null-pointer // i.e. the prerequisites for construction are available
static autoPtr<partialWrite> New static bool viable
( (
const word& name, const word& name,
const objectRegistry&, const objectRegistry&,

View File

@ -56,8 +56,7 @@ Foam::functionObjects::removeRegisteredObject::removeRegisteredObject
} }
Foam::autoPtr<Foam::functionObjects::removeRegisteredObject> bool Foam::functionObjects::removeRegisteredObject::viable
Foam::functionObjects::removeRegisteredObject::New
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -65,10 +64,7 @@ Foam::functionObjects::removeRegisteredObject::New
const bool loadFromFiles const bool loadFromFiles
) )
{ {
return autoPtr<removeRegisteredObject> return true;
(
new removeRegisteredObject(name, obr, dict, loadFromFiles)
);
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::removeRegisteredObject Foam::functionObjects::removeRegisteredObject
Group Group
grpIOFunctionObjects grpIOFunctionObjects
@ -128,9 +128,9 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Construct on free-store and return pointer if successful //- Return true if the construction of this functionObject is viable
// otherwise return a null-pointer // i.e. the prerequisites for construction are available
static autoPtr<removeRegisteredObject> New static bool viable
( (
const word& name, const word& name,
const objectRegistry&, const objectRegistry&,

View File

@ -107,8 +107,7 @@ Foam::functionObjects::writeDictionary::writeDictionary
} }
Foam::autoPtr<Foam::functionObjects::writeDictionary> bool Foam::functionObjects::writeDictionary::viable
Foam::functionObjects::writeDictionary::New
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -116,10 +115,7 @@ Foam::functionObjects::writeDictionary::New
const bool loadFromFiles const bool loadFromFiles
) )
{ {
return autoPtr<writeDictionary> return true;
(
new writeDictionary(name, obr, dict, loadFromFiles)
);
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::writeDictionary Foam::functionObjects::writeDictionary
Group Group
grpUtilitiesFunctionObjects grpUtilitiesFunctionObjects
@ -120,9 +120,9 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Construct on free-store and return pointer if successful //- Return true if the construction of this functionObject is viable
// otherwise return a null-pointer // i.e. the prerequisites for construction are available
static autoPtr<writeDictionary> New static bool viable
( (
const word& name, const word& name,
const objectRegistry&, const objectRegistry&,

View File

@ -57,8 +57,7 @@ Foam::functionObjects::writeRegisteredObject::writeRegisteredObject
} }
Foam::autoPtr<Foam::functionObjects::writeRegisteredObject> bool Foam::functionObjects::writeRegisteredObject::viable
Foam::functionObjects::writeRegisteredObject::New
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -66,10 +65,7 @@ Foam::functionObjects::writeRegisteredObject::New
const bool loadFromFiles const bool loadFromFiles
) )
{ {
return autoPtr<writeRegisteredObject> return true;
(
new writeRegisteredObject(name, obr, dict, loadFromFiles)
);
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::writeRegisteredObject Foam::functionObjects::writeRegisteredObject
Group Group
grpIOFunctionObjects grpIOFunctionObjects
@ -143,9 +143,9 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Construct on free-store and return pointer if successful //- Return true if the construction of this functionObject is viable
// otherwise return a null-pointer // i.e. the prerequisites for construction are available
static autoPtr<writeRegisteredObject> New static bool viable
( (
const word& name, const word& name,
const objectRegistry&, const objectRegistry&,

View File

@ -62,15 +62,13 @@ Foam::functionObjects::cloudInfo::cloudInfo
: :
functionObjectFiles(obr, name), functionObjectFiles(obr, name),
name_(name), name_(name),
obr_(obr), obr_(obr)
active_(true)
{ {
read(dict); read(dict);
} }
Foam::autoPtr<Foam::functionObjects::cloudInfo> bool Foam::functionObjects::cloudInfo::viable
Foam::functionObjects::cloudInfo::New
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -78,10 +76,7 @@ Foam::functionObjects::cloudInfo::New
const bool loadFromFiles const bool loadFromFiles
) )
{ {
return autoPtr<cloudInfo> return true;
(
new cloudInfo(name, obr, dict, loadFromFiles)
);
} }
@ -94,8 +89,6 @@ Foam::functionObjects::cloudInfo::~cloudInfo()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::functionObjects::cloudInfo::read(const dictionary& dict) void Foam::functionObjects::cloudInfo::read(const dictionary& dict)
{
if (active_)
{ {
functionObjectFiles::resetNames(dict.lookup("clouds")); functionObjectFiles::resetNames(dict.lookup("clouds"));
@ -114,7 +107,6 @@ void Foam::functionObjects::cloudInfo::read(const dictionary& dict)
Info<< "no clouds to be processed" << nl << endl; Info<< "no clouds to be processed" << nl << endl;
} }
} }
}
void Foam::functionObjects::cloudInfo::execute() void Foam::functionObjects::cloudInfo::execute()
@ -130,8 +122,6 @@ void Foam::functionObjects::cloudInfo::timeSet()
void Foam::functionObjects::cloudInfo::write() void Foam::functionObjects::cloudInfo::write()
{
if (active_)
{ {
functionObjectFiles::write(); functionObjectFiles::write();
@ -156,7 +146,6 @@ void Foam::functionObjects::cloudInfo::write()
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::cloudInfo Foam::functionObjects::cloudInfo
Group Group
grpCloudFunctionObjects grpCloudFunctionObjects
@ -109,9 +109,6 @@ protected:
//- Reference to the database //- Reference to the database
const objectRegistry& obr_; const objectRegistry& obr_;
//- on/off switch
bool active_;
// Protected Member Functions // Protected Member Functions
@ -148,9 +145,9 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Construct on free-store and return pointer if successful //- Return true if the construction of this functionObject is viable
// otherwise return a null-pointer // i.e. the prerequisites for construction are available
static autoPtr<cloudInfo> New static bool viable
( (
const word& name, const word& name,
const objectRegistry&, const objectRegistry&,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -39,7 +39,7 @@ Description
namespace Foam namespace Foam
{ {
typedef IOOutputFilter<fieldAverage> IOFieldAverage; typedef IOOutputFilter<functionObjects::fieldAverage> IOFieldAverage;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -26,20 +26,22 @@ License
#include "fieldAverage.H" #include "fieldAverage.H"
#include "volFields.H" #include "volFields.H"
#include "Time.H" #include "Time.H"
#include "fieldAverageItem.H" #include "fieldAverageItem.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{
namespace functionObjects
{ {
defineTypeNameAndDebug(fieldAverage, 0); defineTypeNameAndDebug(fieldAverage, 0);
} }
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::fieldAverage::resetFields() void Foam::functionObjects::fieldAverage::resetFields()
{ {
forAll(faItems_, i) forAll(faItems_, i)
{ {
@ -62,7 +64,7 @@ void Foam::fieldAverage::resetFields()
} }
void Foam::fieldAverage::initialize() void Foam::functionObjects::fieldAverage::initialize()
{ {
resetFields(); resetFields();
@ -85,16 +87,6 @@ void Foam::fieldAverage::initialize()
addPrime2MeanField<vector, symmTensor>(fieldI); addPrime2MeanField<vector, symmTensor>(fieldI);
} }
forAll(faItems_, fieldI)
{
if (!faItems_[fieldI].active())
{
WarningInFunction
<< "Field " << faItems_[fieldI].fieldName()
<< " not found in database for averaging";
}
}
// ensure first averaging works unconditionally // ensure first averaging works unconditionally
prevTimeIndex_ = -1; prevTimeIndex_ = -1;
@ -104,7 +96,7 @@ void Foam::fieldAverage::initialize()
} }
void Foam::fieldAverage::restart() void Foam::functionObjects::fieldAverage::restart()
{ {
Info<< " Restarting averaging at time " << obr_.time().timeName() Info<< " Restarting averaging at time " << obr_.time().timeName()
<< nl << endl; << nl << endl;
@ -119,7 +111,7 @@ void Foam::fieldAverage::restart()
} }
void Foam::fieldAverage::calcAverages() void Foam::functionObjects::fieldAverage::calcAverages()
{ {
if (!initialised_) if (!initialised_)
{ {
@ -168,7 +160,7 @@ void Foam::fieldAverage::calcAverages()
} }
void Foam::fieldAverage::writeAverages() const void Foam::functionObjects::fieldAverage::writeAverages() const
{ {
Info<< " Writing average fields" << endl; Info<< " Writing average fields" << endl;
@ -180,7 +172,7 @@ void Foam::fieldAverage::writeAverages() const
} }
void Foam::fieldAverage::writeAveragingProperties() const void Foam::functionObjects::fieldAverage::writeAveragingProperties() const
{ {
IOdictionary propsDict IOdictionary propsDict
( (
@ -208,7 +200,7 @@ void Foam::fieldAverage::writeAveragingProperties() const
} }
void Foam::fieldAverage::readAveragingProperties() void Foam::functionObjects::fieldAverage::readAveragingProperties()
{ {
totalIter_.clear(); totalIter_.clear();
totalIter_.setSize(faItems_.size(), 1); totalIter_.setSize(faItems_.size(), 1);
@ -264,7 +256,7 @@ void Foam::fieldAverage::readAveragingProperties()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldAverage::fieldAverage Foam::functionObjects::fieldAverage::fieldAverage
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -274,7 +266,6 @@ Foam::fieldAverage::fieldAverage
: :
name_(name), name_(name),
obr_(obr), obr_(obr),
active_(true),
prevTimeIndex_(-1), prevTimeIndex_(-1),
restartOnRestart_(false), restartOnRestart_(false),
restartOnOutput_(false), restartOnOutput_(false),
@ -285,33 +276,33 @@ Foam::fieldAverage::fieldAverage
totalIter_(), totalIter_(),
totalTime_(), totalTime_(),
periodIndex_(1) periodIndex_(1)
{
// Only active if a fvMesh is available
if (isA<fvMesh>(obr_))
{ {
read(dict); read(dict);
} }
else
bool Foam::functionObjects::fieldAverage::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{ {
active_ = false; // Construction is viable if the available mesh is an fvMesh
WarningInFunction return isA<fvMesh>(obr);
<< "No fvMesh available, deactivating " << name_ << nl
<< endl;
}
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fieldAverage::~fieldAverage() Foam::functionObjects::fieldAverage::~fieldAverage()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fieldAverage::read(const dictionary& dict) void Foam::functionObjects::fieldAverage::read(const dictionary& dict)
{
if (active_)
{ {
initialised_ = false; initialised_ = false;
@ -331,36 +322,27 @@ void Foam::fieldAverage::read(const dictionary& dict)
Info<< endl; Info<< endl;
} }
}
void Foam::fieldAverage::execute() void Foam::functionObjects::fieldAverage::execute()
{
if (active_)
{ {
calcAverages(); calcAverages();
Info<< endl; Info<< endl;
} }
}
void Foam::fieldAverage::end() void Foam::functionObjects::fieldAverage::end()
{
if (active_)
{ {
calcAverages(); calcAverages();
Info<< endl; Info<< endl;
} }
}
void Foam::fieldAverage::timeSet() void Foam::functionObjects::fieldAverage::timeSet()
{} {}
void Foam::fieldAverage::write() void Foam::functionObjects::fieldAverage::write()
{
if (active_)
{ {
writeAverages(); writeAverages();
writeAveragingProperties(); writeAveragingProperties();
@ -372,19 +354,14 @@ void Foam::fieldAverage::write()
Info<< endl; Info<< endl;
} }
}
void Foam::fieldAverage::updateMesh(const mapPolyMesh&) void Foam::functionObjects::fieldAverage::updateMesh(const mapPolyMesh&)
{ {}
// Do nothing
}
void Foam::fieldAverage::movePoints(const polyMesh&) void Foam::functionObjects::fieldAverage::movePoints(const polyMesh&)
{ {}
// Do nothing
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::fieldAverage Foam::functionObjects::fieldAverage
Group Group
grpFieldFunctionObjects grpFieldFunctionObjects
@ -133,12 +133,17 @@ namespace Foam
// Forward declaration of classes // Forward declaration of classes
class objectRegistry; class objectRegistry;
class dictionary; class dictionary;
class fieldAverageItem;
template<class Type> template<class Type>
class List; class List;
class polyMesh; class polyMesh;
class mapPolyMesh; class mapPolyMesh;
namespace functionObjects
{
// Forward declaration of classes
class fieldAverageItem;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class fieldAverage Declaration Class fieldAverage Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -155,9 +160,6 @@ protected:
//- Database this class is registered to //- Database this class is registered to
const objectRegistry& obr_; const objectRegistry& obr_;
//- On/off switch
bool active_;
//- Time at last call, prevents repeated averaging //- Time at last call, prevents repeated averaging
label prevTimeIndex_; label prevTimeIndex_;
@ -299,6 +301,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~fieldAverage(); virtual ~fieldAverage();
@ -337,6 +349,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -31,10 +31,8 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::fieldAverage::addMeanFieldType(const label fieldI) void Foam::functionObjects::fieldAverage::addMeanFieldType(const label fieldI)
{ {
faItems_[fieldI].active() = true;
const word& fieldName = faItems_[fieldI].fieldName(); const word& fieldName = faItems_[fieldI].fieldName();
const word& meanFieldName = faItems_[fieldI].meanFieldName(); const word& meanFieldName = faItems_[fieldI].meanFieldName();
@ -79,7 +77,7 @@ void Foam::fieldAverage::addMeanFieldType(const label fieldI)
template<class Type> template<class Type>
void Foam::fieldAverage::addMeanField(const label fieldI) void Foam::functionObjects::fieldAverage::addMeanField(const label fieldI)
{ {
if (faItems_[fieldI].mean()) if (faItems_[fieldI].mean())
{ {
@ -101,7 +99,10 @@ void Foam::fieldAverage::addMeanField(const label fieldI)
template<class Type1, class Type2> template<class Type1, class Type2>
void Foam::fieldAverage::addPrime2MeanFieldType(const label fieldI) void Foam::functionObjects::fieldAverage::addPrime2MeanFieldType
(
const label fieldI
)
{ {
const word& fieldName = faItems_[fieldI].fieldName(); const word& fieldName = faItems_[fieldI].fieldName();
const word& meanFieldName = faItems_[fieldI].meanFieldName(); const word& meanFieldName = faItems_[fieldI].meanFieldName();
@ -149,7 +150,7 @@ void Foam::fieldAverage::addPrime2MeanFieldType(const label fieldI)
template<class Type1, class Type2> template<class Type1, class Type2>
void Foam::fieldAverage::addPrime2MeanField(const label fieldI) void Foam::functionObjects::fieldAverage::addPrime2MeanField(const label fieldI)
{ {
typedef GeometricField<Type1, fvPatchField, volMesh> volFieldType1; typedef GeometricField<Type1, fvPatchField, volMesh> volFieldType1;
typedef GeometricField<Type1, fvsPatchField, surfaceMesh> surfFieldType1; typedef GeometricField<Type1, fvsPatchField, surfaceMesh> surfFieldType1;
@ -182,7 +183,10 @@ void Foam::fieldAverage::addPrime2MeanField(const label fieldI)
template<class Type> template<class Type>
void Foam::fieldAverage::calculateMeanFieldType(const label fieldI) const void Foam::functionObjects::fieldAverage::calculateMeanFieldType
(
const label fieldI
) const
{ {
const word& fieldName = faItems_[fieldI].fieldName(); const word& fieldName = faItems_[fieldI].fieldName();
@ -224,7 +228,7 @@ void Foam::fieldAverage::calculateMeanFieldType(const label fieldI) const
template<class Type> template<class Type>
void Foam::fieldAverage::calculateMeanFields() const void Foam::functionObjects::fieldAverage::calculateMeanFields() const
{ {
typedef GeometricField<Type, fvPatchField, volMesh> volFieldType; typedef GeometricField<Type, fvPatchField, volMesh> volFieldType;
typedef GeometricField<Type, fvsPatchField, surfaceMesh> surfFieldType; typedef GeometricField<Type, fvsPatchField, surfaceMesh> surfFieldType;
@ -241,7 +245,10 @@ void Foam::fieldAverage::calculateMeanFields() const
template<class Type1, class Type2> template<class Type1, class Type2>
void Foam::fieldAverage::calculatePrime2MeanFieldType(const label fieldI) const void Foam::functionObjects::fieldAverage::calculatePrime2MeanFieldType
(
const label fieldI
) const
{ {
const word& fieldName = faItems_[fieldI].fieldName(); const word& fieldName = faItems_[fieldI].fieldName();
@ -288,7 +295,7 @@ void Foam::fieldAverage::calculatePrime2MeanFieldType(const label fieldI) const
template<class Type1, class Type2> template<class Type1, class Type2>
void Foam::fieldAverage::calculatePrime2MeanFields() const void Foam::functionObjects::fieldAverage::calculatePrime2MeanFields() const
{ {
typedef GeometricField<Type1, fvPatchField, volMesh> volFieldType1; typedef GeometricField<Type1, fvPatchField, volMesh> volFieldType1;
typedef GeometricField<Type1, fvsPatchField, surfaceMesh> surfFieldType1; typedef GeometricField<Type1, fvsPatchField, surfaceMesh> surfFieldType1;
@ -308,7 +315,10 @@ void Foam::fieldAverage::calculatePrime2MeanFields() const
template<class Type1, class Type2> template<class Type1, class Type2>
void Foam::fieldAverage::addMeanSqrToPrime2MeanType(const label fieldI) const void Foam::functionObjects::fieldAverage::addMeanSqrToPrime2MeanType
(
const label fieldI
) const
{ {
const word& fieldName = faItems_[fieldI].fieldName(); const word& fieldName = faItems_[fieldI].fieldName();
@ -328,7 +338,7 @@ void Foam::fieldAverage::addMeanSqrToPrime2MeanType(const label fieldI) const
template<class Type1, class Type2> template<class Type1, class Type2>
void Foam::fieldAverage::addMeanSqrToPrime2Mean() const void Foam::functionObjects::fieldAverage::addMeanSqrToPrime2Mean() const
{ {
typedef GeometricField<Type1, fvPatchField, volMesh> volFieldType1; typedef GeometricField<Type1, fvPatchField, volMesh> volFieldType1;
typedef GeometricField<Type1, fvsPatchField, surfaceMesh> surfFieldType1; typedef GeometricField<Type1, fvsPatchField, surfaceMesh> surfFieldType1;
@ -348,7 +358,10 @@ void Foam::fieldAverage::addMeanSqrToPrime2Mean() const
template<class Type> template<class Type>
void Foam::fieldAverage::writeFieldType(const word& fieldName) const void Foam::functionObjects::fieldAverage::writeFieldType
(
const word& fieldName
) const
{ {
if (obr_.foundObject<Type>(fieldName)) if (obr_.foundObject<Type>(fieldName))
{ {
@ -359,7 +372,7 @@ void Foam::fieldAverage::writeFieldType(const word& fieldName) const
template<class Type> template<class Type>
void Foam::fieldAverage::writeFields() const void Foam::functionObjects::fieldAverage::writeFields() const
{ {
typedef GeometricField<Type, fvPatchField, volMesh> volFieldType; typedef GeometricField<Type, fvPatchField, volMesh> volFieldType;
typedef GeometricField<Type, fvsPatchField, surfaceMesh> surfFieldType; typedef GeometricField<Type, fvsPatchField, surfaceMesh> surfFieldType;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,7 +43,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<fieldAverage> typedef OutputFilterFunctionObject<functionObjects::fieldAverage>
fieldAverageFunctionObject; fieldAverageFunctionObject;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -27,33 +27,34 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam const Foam::word Foam::functionObjects::fieldAverageItem::EXT_MEAN
{ (
const word fieldAverageItem::EXT_MEAN = "Mean"; "Mean"
const word fieldAverageItem::EXT_PRIME2MEAN = "Prime2Mean"; );
const Foam::word Foam::functionObjects::fieldAverageItem::EXT_PRIME2MEAN
(
"Prime2Mean"
);
template<> template<>
const char* Foam::NamedEnum const char* Foam::NamedEnum
< <
Foam::fieldAverageItem::baseType, Foam::functionObjects::fieldAverageItem::baseType,
2 2
>::names[] = >::names[] = { "iteration", "time"};
{
"iteration",
"time"
};
}
const Foam::NamedEnum
const Foam::NamedEnum<Foam::fieldAverageItem::baseType, 2> <
Foam::fieldAverageItem::baseTypeNames_; Foam::functionObjects::fieldAverageItem::baseType,
2
> Foam::functionObjects::fieldAverageItem::baseTypeNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldAverageItem::fieldAverageItem() Foam::functionObjects::fieldAverageItem::fieldAverageItem()
: :
active_(false),
fieldName_("unknown"), fieldName_("unknown"),
mean_(0), mean_(0),
meanFieldName_("unknown"), meanFieldName_("unknown"),
@ -65,9 +66,11 @@ Foam::fieldAverageItem::fieldAverageItem()
{} {}
Foam::fieldAverageItem::fieldAverageItem(const fieldAverageItem& faItem) Foam::functionObjects::fieldAverageItem::fieldAverageItem
(
const fieldAverageItem& faItem
)
: :
active_(faItem.active_),
fieldName_(faItem.fieldName_), fieldName_(faItem.fieldName_),
mean_(faItem.mean_), mean_(faItem.mean_),
meanFieldName_(faItem.meanFieldName_), meanFieldName_(faItem.meanFieldName_),
@ -81,13 +84,16 @@ Foam::fieldAverageItem::fieldAverageItem(const fieldAverageItem& faItem)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fieldAverageItem::~fieldAverageItem() Foam::functionObjects::fieldAverageItem::~fieldAverageItem()
{} {}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::fieldAverageItem::operator=(const fieldAverageItem& rhs) void Foam::functionObjects::fieldAverageItem::operator=
(
const fieldAverageItem& rhs
)
{ {
// Check for assignment to self // Check for assignment to self
if (this == &rhs) if (this == &rhs)
@ -98,7 +104,6 @@ void Foam::fieldAverageItem::operator=(const fieldAverageItem& rhs)
} }
// Set updated values // Set updated values
active_ = rhs.active_;
fieldName_ = rhs.fieldName_; fieldName_ = rhs.fieldName_;
mean_ = rhs.mean_; mean_ = rhs.mean_;
meanFieldName_ = rhs.meanFieldName_; meanFieldName_ = rhs.meanFieldName_;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::fieldAverageItem Foam::functionObjects::fieldAverageItem
Description Description
Helper class to describe what form of averaging to apply. A set will be Helper class to describe what form of averaging to apply. A set will be
@ -62,12 +62,14 @@ namespace Foam
class Istream; class Istream;
class Ostream; class Ostream;
namespace functionObjects
{
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
class fieldAverageItem; class fieldAverageItem;
Istream& operator>>(Istream&, fieldAverageItem&); Istream& operator>>(Istream&, fieldAverageItem&);
Ostream& operator<<(Ostream&, const fieldAverageItem&); Ostream& operator<<(Ostream&, const fieldAverageItem&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class fieldAverageItem Declaration Class fieldAverageItem Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -98,9 +100,6 @@ private:
// Private data // Private data
//- Active flag
Switch active_;
//- Field name //- Field name
word fieldName_; word fieldName_;
@ -151,18 +150,6 @@ public:
// Access // Access
//- Return const access to the active flag
const Switch& active() const
{
return active_;
}
//- Return non-const access to the active flag
Switch& active()
{
return active_;
}
//- Return const access to the field name //- Return const access to the field name
const word& fieldName() const const word& fieldName() const
{ {
@ -277,6 +264,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,9 +29,8 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldAverageItem::fieldAverageItem(Istream& is) Foam::functionObjects::fieldAverageItem::fieldAverageItem(Istream& is)
: :
active_(false),
fieldName_("unknown"), fieldName_("unknown"),
mean_(0), mean_(0),
meanFieldName_("unknown"), meanFieldName_("unknown"),
@ -40,7 +39,11 @@ Foam::fieldAverageItem::fieldAverageItem(Istream& is)
base_(ITER), base_(ITER),
window_(-1.0) window_(-1.0)
{ {
is.check("Foam::fieldAverageItem::fieldAverageItem(Foam::Istream&)"); is.check
(
"Foam::functionObjects::fieldAverageItem::fieldAverageItem"
"(Foam::Istream&)"
);
const dictionaryEntry entry(dictionary::null, is); const dictionaryEntry entry(dictionary::null, is);
@ -63,17 +66,20 @@ Foam::fieldAverageItem::fieldAverageItem(Istream& is)
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, fieldAverageItem& faItem) Foam::Istream& Foam::functionObjects::operator>>
(
Istream& is,
fieldAverageItem& faItem
)
{ {
is.check is.check
( (
"Foam::Istream& Foam::operator>>" "Foam::Istream& Foam::operator>>"
"(Foam::Istream&, Foam::fieldAverageItem&)" "(Foam::Istream&, Foam::functionObjects::fieldAverageItem&)"
); );
const dictionaryEntry entry(dictionary::null, is); const dictionaryEntry entry(dictionary::null, is);
faItem.active_ = false;
faItem.fieldName_ = entry.keyword(); faItem.fieldName_ = entry.keyword();
entry.lookup("mean") >> faItem.mean_; entry.lookup("mean") >> faItem.mean_;
entry.lookup("prime2Mean") >> faItem.prime2Mean_; entry.lookup("prime2Mean") >> faItem.prime2Mean_;
@ -97,12 +103,16 @@ Foam::Istream& Foam::operator>>(Istream& is, fieldAverageItem& faItem)
} }
Foam::Ostream& Foam::operator<<(Ostream& os, const fieldAverageItem& faItem) Foam::Ostream& Foam::functionObjects::operator<<
(
Ostream& os,
const fieldAverageItem& faItem
)
{ {
os.check os.check
( (
"Foam::Ostream& Foam::operator<<" "Foam::Ostream& Foam::operator<<"
"(Foam::Ostream&, const Foam::fieldAverageItem&)" "(Foam::Ostream&, const Foam::functionObjects::fieldAverageItem&)"
); );
os << faItem.fieldName_ << nl << token::BEGIN_BLOCK << nl; os << faItem.fieldName_ << nl << token::BEGIN_BLOCK << nl;
@ -129,7 +139,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const fieldAverageItem& faItem)
os.check os.check
( (
"Foam::Ostream& Foam::operator<<" "Foam::Ostream& Foam::operator<<"
"(Foam::Ostream&, const Foam::fieldAverageItem&)" "(Foam::Ostream&, const Foam::functionObjects::fieldAverageItem&)"
); );
return os; return os;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,14 +29,18 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{
namespace functionObjects
{ {
defineTypeNameAndDebug(fieldCoordinateSystemTransform, 0); defineTypeNameAndDebug(fieldCoordinateSystemTransform, 0);
} }
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldCoordinateSystemTransform::fieldCoordinateSystemTransform Foam::functionObjects::fieldCoordinateSystemTransform::
fieldCoordinateSystemTransform
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -46,12 +50,8 @@ Foam::fieldCoordinateSystemTransform::fieldCoordinateSystemTransform
: :
name_(name), name_(name),
obr_(obr), obr_(obr),
active_(true),
fieldSet_(), fieldSet_(),
coordSys_(obr, dict) coordSys_(obr, dict)
{
// Check if the available mesh is an fvMesh otherise deactivate
if (isA<fvMesh>(obr_))
{ {
read(dict); read(dict);
@ -59,36 +59,40 @@ Foam::fieldCoordinateSystemTransform::fieldCoordinateSystemTransform
<< " Applying transformation from global Cartesian to local " << " Applying transformation from global Cartesian to local "
<< coordSys_ << nl << endl; << coordSys_ << nl << endl;
} }
else
bool Foam::functionObjects::fieldCoordinateSystemTransform::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{ {
active_ = false; // Construction is viable if the available mesh is an fvMesh
WarningInFunction return isA<fvMesh>(obr);
<< "No fvMesh available, deactivating " << name_
<< endl;
}
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fieldCoordinateSystemTransform::~fieldCoordinateSystemTransform() Foam::functionObjects::fieldCoordinateSystemTransform::
~fieldCoordinateSystemTransform()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fieldCoordinateSystemTransform::read(const dictionary& dict) void Foam::functionObjects::fieldCoordinateSystemTransform::read
{ (
if (active_) const dictionary& dict
)
{ {
dict.lookup("fields") >> fieldSet_; dict.lookup("fields") >> fieldSet_;
} }
}
void Foam::fieldCoordinateSystemTransform::execute() void Foam::functionObjects::fieldCoordinateSystemTransform::execute()
{
if (active_)
{ {
Info<< type() << " " << name_ << " output:" << nl; Info<< type() << " " << name_ << " output:" << nl;
@ -102,27 +106,19 @@ void Foam::fieldCoordinateSystemTransform::execute()
transform<tensor>(fieldSet_[fieldI]); transform<tensor>(fieldSet_[fieldI]);
} }
} }
}
void Foam::fieldCoordinateSystemTransform::end() void Foam::functionObjects::fieldCoordinateSystemTransform::end()
{
if (active_)
{ {
execute(); execute();
} }
}
void Foam::fieldCoordinateSystemTransform::timeSet() void Foam::functionObjects::fieldCoordinateSystemTransform::timeSet()
{ {}
// Do nothing
}
void Foam::fieldCoordinateSystemTransform::write() void Foam::functionObjects::fieldCoordinateSystemTransform::write()
{
if (active_)
{ {
Info<< type() << " " << name_ << " output:" << nl; Info<< type() << " " << name_ << " output:" << nl;
@ -140,7 +136,6 @@ void Foam::fieldCoordinateSystemTransform::write()
Info<< endl; Info<< endl;
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::fieldCoordinateSystemTransform Foam::functionObjects::fieldCoordinateSystemTransform
Group Group
grpFieldFunctionObjects grpFieldFunctionObjects
@ -93,6 +93,9 @@ class dictionary;
class polyMesh; class polyMesh;
class mapPolyMesh; class mapPolyMesh;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class fieldCoordinateSystemTransform Declaration Class fieldCoordinateSystemTransform Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -108,9 +111,6 @@ protected:
const objectRegistry& obr_; const objectRegistry& obr_;
//- on/off switch
bool active_;
//- Fields to transform //- Fields to transform
wordList fieldSet_; wordList fieldSet_;
@ -156,6 +156,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~fieldCoordinateSystemTransform(); virtual ~fieldCoordinateSystemTransform();
@ -196,6 +206,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,8 +43,10 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<fieldCoordinateSystemTransform> typedef OutputFilterFunctionObject
fieldCoordinateSystemTransformFunctionObject; <
functionObjects::fieldCoordinateSystemTransform
> fieldCoordinateSystemTransformFunctionObject;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -32,7 +32,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::fieldCoordinateSystemTransform::transformField void Foam::functionObjects::fieldCoordinateSystemTransform::transformField
( (
const Type& field const Type& field
) const ) const
@ -74,7 +74,7 @@ void Foam::fieldCoordinateSystemTransform::transformField
template<class Type> template<class Type>
void Foam::fieldCoordinateSystemTransform::transform void Foam::functionObjects::fieldCoordinateSystemTransform::transform
( (
const word& fieldName const word& fieldName
) const ) const

View File

@ -30,28 +30,29 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(fieldMinMax, 0); namespace functionObjects
template<>
const char* NamedEnum
<
fieldMinMax::modeType,
2
>::names[] =
{ {
"magnitude", defineTypeNameAndDebug(fieldMinMax, 0);
"component" }
};
} }
template<>
const char* Foam::NamedEnum
<
Foam::functionObjects::fieldMinMax::modeType,
2
>::names[] = {"magnitude", "component"};
const Foam::NamedEnum<Foam::fieldMinMax::modeType, 2> const Foam::NamedEnum
Foam::fieldMinMax::modeTypeNames_; <
Foam::functionObjects::fieldMinMax::modeType,
2
> Foam::functionObjects::fieldMinMax::modeTypeNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldMinMax::fieldMinMax Foam::functionObjects::fieldMinMax::fieldMinMax
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -62,36 +63,37 @@ Foam::fieldMinMax::fieldMinMax
functionObjectFiles(obr, name, typeName), functionObjectFiles(obr, name, typeName),
name_(name), name_(name),
obr_(obr), obr_(obr),
active_(true),
log_(true), log_(true),
location_(true), location_(true),
mode_(mdMag), mode_(mdMag),
fieldSet_() fieldSet_()
{ {
// Check if the available mesh is an fvMesh otherise deactivate read(dict);
if (!isA<fvMesh>(obr_))
{
active_ = false;
WarningInFunction
<< "No fvMesh available, deactivating " << name_
<< endl;
} }
read(dict);
bool Foam::functionObjects::fieldMinMax::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
// Construction is viable if the available mesh is an fvMesh
return isA<fvMesh>(obr);
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fieldMinMax::~fieldMinMax() Foam::functionObjects::fieldMinMax::~fieldMinMax()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fieldMinMax::read(const dictionary& dict) void Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
{
if (active_)
{ {
log_ = dict.lookupOrDefault<Switch>("log", true); log_ = dict.lookupOrDefault<Switch>("log", true);
location_ = dict.lookupOrDefault<Switch>("location", true); location_ = dict.lookupOrDefault<Switch>("location", true);
@ -99,10 +101,9 @@ void Foam::fieldMinMax::read(const dictionary& dict)
mode_ = modeTypeNames_[dict.lookupOrDefault<word>("mode", "magnitude")]; mode_ = modeTypeNames_[dict.lookupOrDefault<word>("mode", "magnitude")];
dict.lookup("fields") >> fieldSet_; dict.lookup("fields") >> fieldSet_;
} }
}
void Foam::fieldMinMax::writeFileHeader(const label i) void Foam::functionObjects::fieldMinMax::writeFileHeader(const label i)
{ {
OFstream& file = this->file(); OFstream& file = this->file();
@ -142,27 +143,19 @@ void Foam::fieldMinMax::writeFileHeader(const label i)
} }
void Foam::fieldMinMax::execute() void Foam::functionObjects::fieldMinMax::execute()
{ {}
// Do nothing - only valid on write
}
void Foam::fieldMinMax::end() void Foam::functionObjects::fieldMinMax::end()
{ {}
// Do nothing - only valid on write
}
void Foam::fieldMinMax::timeSet() void Foam::functionObjects::fieldMinMax::timeSet()
{ {}
// Do nothing - only valid on write
}
void Foam::fieldMinMax::write() void Foam::functionObjects::fieldMinMax::write()
{
if (active_)
{ {
functionObjectFiles::write(); functionObjectFiles::write();
@ -181,7 +174,6 @@ void Foam::fieldMinMax::write()
if (!location_) file()<< endl; if (!location_) file()<< endl;
if (log_) Info<< endl; if (log_) Info<< endl;
} }
}

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::fieldMinMax Foam::functionObjects::fieldMinMax
Group Group
grpFieldFunctionObjects grpFieldFunctionObjects
@ -93,6 +93,9 @@ class dictionary;
class polyMesh; class polyMesh;
class mapPolyMesh; class mapPolyMesh;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class fieldMinMax Declaration Class fieldMinMax Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -122,9 +125,6 @@ protected:
const objectRegistry& obr_; const objectRegistry& obr_;
//- on/off switch
bool active_;
//- Switch to send output to Info as well //- Switch to send output to Info as well
Switch log_; Switch log_;
@ -182,6 +182,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~fieldMinMax(); virtual ~fieldMinMax();
@ -230,6 +240,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,7 +43,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<fieldMinMax> typedef OutputFilterFunctionObject<functionObjects::fieldMinMax>
fieldMinMaxFunctionObject; fieldMinMaxFunctionObject;
} }

View File

@ -29,7 +29,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::fieldMinMax::output void Foam::functionObjects::fieldMinMax::output
( (
const word& fieldName, const word& fieldName,
const word& outputName, const word& outputName,
@ -99,7 +99,7 @@ void Foam::fieldMinMax::output
template<class Type> template<class Type>
void Foam::fieldMinMax::calcMinMaxFields void Foam::functionObjects::fieldMinMax::calcMinMaxFields
( (
const word& fieldName, const word& fieldName,
const modeType& mode const modeType& mode

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -32,16 +32,31 @@ License
namespace Foam namespace Foam
{ {
template<> namespace functionObjects
const char* NamedEnum<fieldValues::cellSource::sourceType, 2>::names[] =
{ {
"cellZone", namespace fieldValues
"all" {
}; defineTypeNameAndDebug(cellSource, 0);
addToRunTimeSelectionTable(fieldValue, cellSource, dictionary);
}
}
}
template<> template<>
const char* NamedEnum<fieldValues::cellSource::operationType, 11>::names[] = const char*
Foam::NamedEnum
<
Foam::functionObjects::fieldValues::cellSource::sourceType,
2
>::names[] = {"cellZone", "all"};
template<>
const char*
Foam::NamedEnum
<
Foam::functionObjects::fieldValues::cellSource::operationType,
11
>::names[] =
{ {
"none", "none",
"sum", "sum",
@ -56,24 +71,22 @@ namespace Foam
"CoV" "CoV"
}; };
namespace fieldValues const Foam::NamedEnum
{ <
defineTypeNameAndDebug(cellSource, 0); Foam::functionObjects::fieldValues::cellSource::sourceType,
addToRunTimeSelectionTable(fieldValue, cellSource, dictionary); 2
} > Foam::functionObjects::fieldValues::cellSource::sourceTypeNames_;
}
const Foam::NamedEnum
const Foam::NamedEnum<Foam::fieldValues::cellSource::sourceType, 2> <
Foam::fieldValues::cellSource::sourceTypeNames_; Foam::functionObjects::fieldValues::cellSource::operationType,
11
const Foam::NamedEnum<Foam::fieldValues::cellSource::operationType, 11> > Foam::functionObjects::fieldValues::cellSource::operationTypeNames_;
Foam::fieldValues::cellSource::operationTypeNames_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::fieldValues::cellSource::setCellZoneCells() void Foam::functionObjects::fieldValues::cellSource::setCellZoneCells()
{ {
switch (source_) switch (source_)
{ {
@ -118,7 +131,7 @@ void Foam::fieldValues::cellSource::setCellZoneCells()
} }
Foam::scalar Foam::fieldValues::cellSource::volume() const Foam::scalar Foam::functionObjects::fieldValues::cellSource::volume() const
{ {
return gSum(filterField(mesh().V())); return gSum(filterField(mesh().V()));
} }
@ -126,19 +139,19 @@ Foam::scalar Foam::fieldValues::cellSource::volume() const
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::fieldValues::cellSource::initialise(const dictionary& dict) void Foam::functionObjects::fieldValues::cellSource::initialise
(
const dictionary& dict
)
{ {
setCellZoneCells(); setCellZoneCells();
if (nCells_ == 0) if (nCells_ == 0)
{ {
WarningInFunction FatalErrorInFunction
<< type() << " " << name_ << ": " << type() << " " << name_ << ": "
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl
<< " Source has no cells - deactivating" << endl; << " Source has no cells" << exit(FatalError);
active_ = false;
return;
} }
volume_ = volume(); volume_ = volume();
@ -158,7 +171,10 @@ void Foam::fieldValues::cellSource::initialise(const dictionary& dict)
} }
void Foam::fieldValues::cellSource::writeFileHeader(const label i) void Foam::functionObjects::fieldValues::cellSource::writeFileHeader
(
const label i
)
{ {
writeCommented(file(), "Source : "); writeCommented(file(), "Source : ");
file() << sourceTypeNames_[source_] << " " << sourceName_ << endl; file() << sourceTypeNames_[source_] << " " << sourceName_ << endl;
@ -186,7 +202,7 @@ void Foam::fieldValues::cellSource::writeFileHeader(const label i)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldValues::cellSource::cellSource Foam::functionObjects::fieldValues::cellSource::cellSource
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -206,32 +222,43 @@ Foam::fieldValues::cellSource::cellSource
} }
bool Foam::functionObjects::fieldValues::cellSource::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
// Construction is viable if the available mesh is an fvMesh
return isA<fvMesh>(obr);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fieldValues::cellSource::~cellSource() Foam::functionObjects::fieldValues::cellSource::~cellSource()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fieldValues::cellSource::read(const dictionary& dict) void Foam::functionObjects::fieldValues::cellSource::read
(
const dictionary& dict
)
{ {
fieldValue::read(dict); fieldValue::read(dict);
if (active_) // No additional info to read
{
// no additional info to read
initialise(dict); initialise(dict);
} }
}
void Foam::fieldValues::cellSource::write() void Foam::functionObjects::fieldValues::cellSource::write()
{ {
fieldValue::write(); fieldValue::write();
if (active_)
{
if (Pstream::master()) if (Pstream::master())
{ {
writeTime(file()); writeTime(file());
@ -274,7 +301,6 @@ void Foam::fieldValues::cellSource::write()
if (log_) Info<< endl; if (log_) Info<< endl;
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::fieldValues::cellSource Foam::functionObjects::fieldValues::cellSource
Group Group
grpFieldFunctionObjects grpFieldFunctionObjects
@ -114,6 +114,8 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace functionObjects
{
namespace fieldValues namespace fieldValues
{ {
@ -237,6 +239,8 @@ public:
TypeName("cellSource"); TypeName("cellSource");
// Constructors
//- Construct from components //- Construct from components
cellSource cellSource
( (
@ -246,6 +250,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~cellSource(); virtual ~cellSource();
@ -283,6 +297,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fieldValues } // End namespace fieldValues
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,8 +43,10 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<fieldValues::cellSource> typedef OutputFilterFunctionObject
cellSourceFunctionObject; <
functionObjects::fieldValues::cellSource
> cellSourceFunctionObject;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -27,19 +27,18 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::fieldValues::cellSource::sourceType& inline const Foam::functionObjects::fieldValues::cellSource::sourceType&
Foam::fieldValues::cellSource::source() const Foam::functionObjects::fieldValues::cellSource::source() const
{ {
return source_; return source_;
} }
inline const Foam::labelList& inline const Foam::labelList&
Foam::fieldValues::cellSource::cellId() const Foam::functionObjects::fieldValues::cellSource::cellId() const
{ {
return cellId_; return cellId_;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -29,7 +29,10 @@ License
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type> template<class Type>
bool Foam::fieldValues::cellSource::validField(const word& fieldName) const bool Foam::functionObjects::fieldValues::cellSource::validField
(
const word& fieldName
) const
{ {
typedef GeometricField<Type, fvPatchField, volMesh> vf; typedef GeometricField<Type, fvPatchField, volMesh> vf;
@ -43,7 +46,8 @@ bool Foam::fieldValues::cellSource::validField(const word& fieldName) const
template<class Type> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::fieldValues::cellSource::setFieldValues Foam::tmp<Foam::Field<Type>>
Foam::functionObjects::fieldValues::cellSource::setFieldValues
( (
const word& fieldName, const word& fieldName,
const bool mustGet const bool mustGet
@ -68,7 +72,7 @@ Foam::tmp<Foam::Field<Type>> Foam::fieldValues::cellSource::setFieldValues
template<class Type> template<class Type>
Type Foam::fieldValues::cellSource::processValues Type Foam::functionObjects::fieldValues::cellSource::processValues
( (
const Field<Type>& values, const Field<Type>& values,
const scalarField& V, const scalarField& V,
@ -140,10 +144,8 @@ Type Foam::fieldValues::cellSource::processValues
break; break;
} }
default: case opNone:
{ {}
// Do nothing
}
} }
return result; return result;
@ -153,7 +155,10 @@ Type Foam::fieldValues::cellSource::processValues
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
bool Foam::fieldValues::cellSource::writeValues(const word& fieldName) bool Foam::functionObjects::fieldValues::cellSource::writeValues
(
const word& fieldName
)
{ {
const bool ok = validField<Type>(fieldName); const bool ok = validField<Type>(fieldName);
@ -211,7 +216,8 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
template<class Type> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::fieldValues::cellSource::filterField Foam::tmp<Foam::Field<Type>>
Foam::functionObjects::fieldValues::cellSource::filterField
( (
const Field<Type>& field const Field<Type>& field
) const ) const

View File

@ -38,17 +38,34 @@ License
namespace Foam namespace Foam
{ {
namespace functionObjects
{
namespace fieldValues
{
defineTypeNameAndDebug(faceSource, 0);
addToRunTimeSelectionTable(fieldValue, faceSource, dictionary);
}
}
}
template<> template<>
const char* NamedEnum<fieldValues::faceSource::sourceType, 3>::names[] = const char* Foam::NamedEnum
<
Foam::functionObjects::fieldValues::faceSource::sourceType,
3
>::names[] =
{ {
"faceZone", "faceZone",
"patch", "patch",
"sampledSurface" "sampledSurface"
}; };
template<> template<>
const char* NamedEnum<fieldValues::faceSource::operationType, 15>::names[] = const char* Foam::NamedEnum
<
Foam::functionObjects::fieldValues::faceSource::operationType,
15
>::names[] =
{ {
"none", "none",
"sum", "sum",
@ -67,24 +84,22 @@ namespace Foam
"areaNormalIntegrate" "areaNormalIntegrate"
}; };
namespace fieldValues const Foam::NamedEnum
{ <
defineTypeNameAndDebug(faceSource, 0); Foam::functionObjects::fieldValues::faceSource::sourceType,
addToRunTimeSelectionTable(fieldValue, faceSource, dictionary); 3
} > Foam::functionObjects::fieldValues::faceSource::sourceTypeNames_;
}
const Foam::NamedEnum
const Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 3> <
Foam::fieldValues::faceSource::sourceTypeNames_; Foam::functionObjects::fieldValues::faceSource::operationType,
15
const Foam::NamedEnum<Foam::fieldValues::faceSource::operationType, 15> > Foam::functionObjects::fieldValues::faceSource::operationTypeNames_;
Foam::fieldValues::faceSource::operationTypeNames_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::fieldValues::faceSource::setFaceZoneFaces() void Foam::functionObjects::fieldValues::faceSource::setFaceZoneFaces()
{ {
label zoneId = mesh().faceZones().findZoneID(sourceName_); label zoneId = mesh().faceZones().findZoneID(sourceName_);
@ -169,7 +184,7 @@ void Foam::fieldValues::faceSource::setFaceZoneFaces()
} }
void Foam::fieldValues::faceSource::setPatchFaces() void Foam::functionObjects::fieldValues::faceSource::setPatchFaces()
{ {
const label patchid = mesh().boundaryMesh().findPatchID(sourceName_); const label patchid = mesh().boundaryMesh().findPatchID(sourceName_);
@ -206,7 +221,10 @@ void Foam::fieldValues::faceSource::setPatchFaces()
} }
void Foam::fieldValues::faceSource::sampledSurfaceFaces(const dictionary& dict) void Foam::functionObjects::fieldValues::faceSource::sampledSurfaceFaces
(
const dictionary& dict
)
{ {
surfacePtr_ = sampledSurface::New surfacePtr_ = sampledSurface::New
( (
@ -219,7 +237,7 @@ void Foam::fieldValues::faceSource::sampledSurfaceFaces(const dictionary& dict)
} }
void Foam::fieldValues::faceSource::combineMeshGeometry void Foam::functionObjects::fieldValues::faceSource::combineMeshGeometry
( (
faceList& faces, faceList& faces,
pointField& points pointField& points
@ -340,7 +358,7 @@ void Foam::fieldValues::faceSource::combineMeshGeometry
} }
void Foam::fieldValues::faceSource::combineSurfaceGeometry void Foam::functionObjects::fieldValues::faceSource::combineSurfaceGeometry
( (
faceList& faces, faceList& faces,
pointField& points pointField& points
@ -379,7 +397,7 @@ void Foam::fieldValues::faceSource::combineSurfaceGeometry
} }
Foam::scalar Foam::fieldValues::faceSource::totalArea() const Foam::scalar Foam::functionObjects::fieldValues::faceSource::totalArea() const
{ {
scalar totalArea; scalar totalArea;
@ -398,7 +416,10 @@ Foam::scalar Foam::fieldValues::faceSource::totalArea() const
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::fieldValues::faceSource::initialise(const dictionary& dict) void Foam::functionObjects::fieldValues::faceSource::initialise
(
const dictionary& dict
)
{ {
dict.lookup("sourceName") >> sourceName_; dict.lookup("sourceName") >> sourceName_;
@ -431,13 +452,10 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
if (nFaces_ == 0) if (nFaces_ == 0)
{ {
WarningInFunction FatalErrorInFunction
<< type() << " " << name_ << ": " << type() << " " << name_ << ": "
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl
<< " Source has no faces - deactivating" << endl; << " Source has no faces" << exit(FatalError);
active_ = false;
return;
} }
if (surfacePtr_.valid()) if (surfacePtr_.valid())
@ -513,7 +531,10 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
} }
void Foam::fieldValues::faceSource::writeFileHeader(const label i) void Foam::functionObjects::fieldValues::faceSource::writeFileHeader
(
const label i
)
{ {
writeCommented(file(), "Source : "); writeCommented(file(), "Source : ");
file() << sourceTypeNames_[source_] << " " << sourceName_ << endl; file() << sourceTypeNames_[source_] << " " << sourceName_ << endl;
@ -540,7 +561,7 @@ void Foam::fieldValues::faceSource::writeFileHeader(const label i)
template<> template<>
Foam::scalar Foam::fieldValues::faceSource::processValues Foam::scalar Foam::functionObjects::fieldValues::faceSource::processValues
( (
const Field<scalar>& values, const Field<scalar>& values,
const vectorField& Sf, const vectorField& Sf,
@ -571,7 +592,7 @@ Foam::scalar Foam::fieldValues::faceSource::processValues
template<> template<>
Foam::vector Foam::fieldValues::faceSource::processValues Foam::vector Foam::functionObjects::fieldValues::faceSource::processValues
( (
const Field<vector>& values, const Field<vector>& values,
const vectorField& Sf, const vectorField& Sf,
@ -617,7 +638,7 @@ Foam::vector Foam::fieldValues::faceSource::processValues
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldValues::faceSource::faceSource Foam::functionObjects::fieldValues::faceSource::faceSource
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -643,31 +664,41 @@ Foam::fieldValues::faceSource::faceSource
} }
bool Foam::functionObjects::fieldValues::faceSource::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
// Construction is viable if the available mesh is an fvMesh
return isA<fvMesh>(obr);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fieldValues::faceSource::~faceSource() Foam::functionObjects::fieldValues::faceSource::~faceSource()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fieldValues::faceSource::read(const dictionary& dict) void Foam::functionObjects::fieldValues::faceSource::read
(
const dictionary& dict
)
{ {
fieldValue::read(dict); fieldValue::read(dict);
if (active_)
{
initialise(dict); initialise(dict);
} }
}
void Foam::fieldValues::faceSource::write() void Foam::functionObjects::fieldValues::faceSource::write()
{ {
fieldValue::write(); fieldValue::write();
if (active_)
{
if (surfacePtr_.valid()) if (surfacePtr_.valid())
{ {
surfacePtr_().update(); surfacePtr_().update();
@ -734,7 +765,6 @@ void Foam::fieldValues::faceSource::write()
if (log_) Info<< endl; if (log_) Info<< endl;
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::fieldValues::faceSource Foam::functionObjects::fieldValues::faceSource
Group Group
grpFieldFunctionObjects grpFieldFunctionObjects
@ -152,6 +152,8 @@ namespace Foam
class sampledSurface; class sampledSurface;
namespace functionObjects
{
namespace fieldValues namespace fieldValues
{ {
@ -337,6 +339,8 @@ public:
TypeName("faceSource"); TypeName("faceSource");
// Constructors
//- Construct from components //- Construct from components
faceSource faceSource
( (
@ -346,6 +350,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~faceSource(); virtual ~faceSource();
@ -426,6 +440,7 @@ vector faceSource::processValues
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fieldValues } // End namespace fieldValues
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,8 +43,10 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<fieldValues::faceSource> typedef OutputFilterFunctionObject
faceSourceFunctionObject; <
functionObjects::fieldValues::faceSource
> faceSourceFunctionObject;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -27,33 +27,32 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::fieldValues::faceSource::sourceType& inline const Foam::functionObjects::fieldValues::faceSource::sourceType&
Foam::fieldValues::faceSource::source() const Foam::functionObjects::fieldValues::faceSource::source() const
{ {
return source_; return source_;
} }
inline const Foam::labelList& inline const Foam::labelList&
Foam::fieldValues::faceSource::faceId() const Foam::functionObjects::fieldValues::faceSource::faceId() const
{ {
return faceId_; return faceId_;
} }
inline const Foam::labelList& inline const Foam::labelList&
Foam::fieldValues::faceSource::facePatch() const Foam::functionObjects::fieldValues::faceSource::facePatch() const
{ {
return facePatchId_; return facePatchId_;
} }
inline const Foam::labelList& inline const Foam::labelList&
Foam::fieldValues::faceSource::faceSign() const Foam::functionObjects::fieldValues::faceSource::faceSign() const
{ {
return faceSign_; return faceSign_;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -32,7 +32,10 @@ License
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type> template<class Type>
bool Foam::fieldValues::faceSource::validField(const word& fieldName) const bool Foam::functionObjects::fieldValues::faceSource::validField
(
const word& fieldName
) const
{ {
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf; typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
typedef GeometricField<Type, fvPatchField, volMesh> vf; typedef GeometricField<Type, fvPatchField, volMesh> vf;
@ -51,7 +54,8 @@ bool Foam::fieldValues::faceSource::validField(const word& fieldName) const
template<class Type> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::fieldValues::faceSource::getFieldValues Foam::tmp<Foam::Field<Type>>
Foam::functionObjects::fieldValues::faceSource::getFieldValues
( (
const word& fieldName, const word& fieldName,
const bool mustGet, const bool mustGet,
@ -120,7 +124,7 @@ Foam::tmp<Foam::Field<Type>> Foam::fieldValues::faceSource::getFieldValues
template<class Type> template<class Type>
Type Foam::fieldValues::faceSource::processSameTypeValues Type Foam::functionObjects::fieldValues::faceSource::processSameTypeValues
( (
const Field<Type>& values, const Field<Type>& values,
const vectorField& Sf, const vectorField& Sf,
@ -236,10 +240,12 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
break; break;
} }
default: case opAreaNormalAverage:
{ {}
// Do nothing case opAreaNormalIntegrate:
} {}
case opNone:
{}
} }
return result; return result;
@ -247,7 +253,7 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
template<class Type> template<class Type>
Type Foam::fieldValues::faceSource::processValues Type Foam::functionObjects::fieldValues::faceSource::processValues
( (
const Field<Type>& values, const Field<Type>& values,
const vectorField& Sf, const vectorField& Sf,
@ -262,7 +268,7 @@ Type Foam::fieldValues::faceSource::processValues
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
bool Foam::fieldValues::faceSource::writeValues bool Foam::functionObjects::fieldValues::faceSource::writeValues
( (
const word& fieldName, const word& fieldName,
const scalarField& weightField, const scalarField& weightField,
@ -348,7 +354,8 @@ bool Foam::fieldValues::faceSource::writeValues
template<class Type> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::fieldValues::faceSource::filterField Foam::tmp<Foam::Field<Type>>
Foam::functionObjects::fieldValues::faceSource::filterField
( (
const GeometricField<Type, fvPatchField, volMesh>& field, const GeometricField<Type, fvPatchField, volMesh>& field,
const bool applyOrientation const bool applyOrientation
@ -389,7 +396,8 @@ Foam::tmp<Foam::Field<Type>> Foam::fieldValues::faceSource::filterField
template<class Type> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::fieldValues::faceSource::filterField Foam::tmp<Foam::Field<Type>>
Foam::functionObjects::fieldValues::faceSource::filterField
( (
const GeometricField<Type, fvsPatchField, surfaceMesh>& field, const GeometricField<Type, fvsPatchField, surfaceMesh>& field,
const bool applyOrientation const bool applyOrientation

View File

@ -40,8 +40,6 @@ namespace Foam
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::fieldValue::read(const dictionary& dict) void Foam::fieldValue::read(const dictionary& dict)
{
if (active_)
{ {
dict_ = dict; dict_ = dict;
@ -49,18 +47,14 @@ void Foam::fieldValue::read(const dictionary& dict)
dict.lookup("fields") >> fields_; dict.lookup("fields") >> fields_;
dict.lookup("valueOutput") >> valueOutput_; dict.lookup("valueOutput") >> valueOutput_;
} }
}
void Foam::fieldValue::write() void Foam::fieldValue::write()
{
if (active_)
{ {
functionObjectFiles::write(); functionObjectFiles::write();
if (log_) Info<< type() << " " << name_ << " output:" << nl; if (log_) Info<< type() << " " << name_ << " output:" << nl;
} }
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -78,26 +72,14 @@ Foam::fieldValue::fieldValue
name_(name), name_(name),
obr_(obr), obr_(obr),
dict_(dict), dict_(dict),
active_(true),
log_(true), log_(true),
sourceName_(word::null), sourceName_(word::null),
fields_(dict.lookup("fields")), fields_(dict.lookup("fields")),
valueOutput_(dict.lookup("valueOutput")), valueOutput_(dict.lookup("valueOutput")),
resultDict_(fileName("name"), dictionary::null) resultDict_(fileName("name"), dictionary::null)
{
// Only active if obr is an fvMesh
if (isA<fvMesh>(obr_))
{ {
read(dict); read(dict);
} }
else
{
WarningInFunction
<< "No fvMesh available, deactivating " << name << nl
<< endl;
active_ = false;
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -109,33 +91,23 @@ Foam::fieldValue::~fieldValue()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fieldValue::execute() void Foam::fieldValue::execute()
{ {}
// Do nothing
}
void Foam::fieldValue::end() void Foam::fieldValue::end()
{ {}
// Do nothing
}
void Foam::fieldValue::timeSet() void Foam::fieldValue::timeSet()
{ {}
// Do nothing
}
void Foam::fieldValue::updateMesh(const mapPolyMesh&) void Foam::fieldValue::updateMesh(const mapPolyMesh&)
{ {}
// Do nothing
}
void Foam::fieldValue::movePoints(const polyMesh&) void Foam::fieldValue::movePoints(const polyMesh&)
{ {}
// Do nothing
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -78,9 +78,6 @@ protected:
//- Construction dictionary //- Construction dictionary
dictionary dict_; dictionary dict_;
//- Active flag
bool active_;
//- Switch to send output to Info as well as to file //- Switch to send output to Info as well as to file
Switch log_; Switch log_;
@ -155,9 +152,6 @@ public:
//- Return the reference to the construction dictionary //- Return the reference to the construction dictionary
inline const dictionary& dict() const; inline const dictionary& dict() const;
//- Return the active flag
inline bool active() const;
//- Return the switch to send output to Info as well as to file //- Return the switch to send output to Info as well as to file
inline const Switch& log() const; inline const Switch& log() const;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,12 +46,6 @@ inline const Foam::dictionary& Foam::fieldValue::dict() const
} }
inline bool Foam::fieldValue::active() const
{
return active_;
}
inline const Foam::Switch& Foam::fieldValue::log() const inline const Foam::Switch& Foam::fieldValue::log() const
{ {
return log_; return log_;

View File

@ -33,14 +33,21 @@ License
namespace Foam namespace Foam
{ {
namespace functionObjects
{
namespace fieldValues namespace fieldValues
{ {
defineTypeNameAndDebug(fieldValueDelta, 0); defineTypeNameAndDebug(fieldValueDelta, 0);
} }
}
}
template<> template<>
const char* const char* Foam::NamedEnum
NamedEnum<fieldValues::fieldValueDelta::operationType, 5>::names[] = <
Foam::functionObjects::fieldValues::fieldValueDelta::operationType,
5
>::names[] =
{ {
"add", "add",
"subtract", "subtract",
@ -49,35 +56,19 @@ namespace Foam
"average" "average"
}; };
const NamedEnum<fieldValues::fieldValueDelta::operationType, 5> const Foam::NamedEnum
fieldValues::fieldValueDelta::operationTypeNames_; <
} Foam::functionObjects::fieldValues::fieldValueDelta::operationType,
5
> Foam::functionObjects::fieldValues::fieldValueDelta::operationTypeNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::fieldValues::fieldValueDelta::fieldValueDelta void Foam::functionObjects::fieldValues::fieldValueDelta::writeFileHeader
( (
const word& name, const label i
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
) )
:
functionObjectFiles(obr, name, typeName),
name_(name),
obr_(obr),
loadFromFiles_(loadFromFiles),
log_(true),
operation_(opSubtract),
source1Ptr_(NULL),
source2Ptr_(NULL)
{
read(dict);
}
void Foam::fieldValues::fieldValueDelta::writeFileHeader(const label i)
{ {
const wordList& fields1 = source1Ptr_->fields(); const wordList& fields1 = source1Ptr_->fields();
const wordList& fields2 = source2Ptr_->fields(); const wordList& fields2 = source2Ptr_->fields();
@ -108,15 +99,54 @@ void Foam::fieldValues::fieldValueDelta::writeFileHeader(const label i)
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::fieldValues::fieldValueDelta::fieldValueDelta
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
:
functionObjectFiles(obr, name, typeName),
name_(name),
obr_(obr),
loadFromFiles_(loadFromFiles),
log_(true),
operation_(opSubtract),
source1Ptr_(NULL),
source2Ptr_(NULL)
{
read(dict);
}
bool Foam::functionObjects::fieldValues::fieldValueDelta::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
// Construction is viable if the available mesh is an fvMesh
return isA<fvMesh>(obr);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fieldValues::fieldValueDelta::~fieldValueDelta() Foam::functionObjects::fieldValues::fieldValueDelta::~fieldValueDelta()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fieldValues::fieldValueDelta::read(const dictionary& dict) void Foam::functionObjects::fieldValues::fieldValueDelta::read
(
const dictionary& dict
)
{ {
log_ = dict.lookupOrDefault<Switch>("log", true); log_ = dict.lookupOrDefault<Switch>("log", true);
source1Ptr_.reset source1Ptr_.reset
@ -146,7 +176,7 @@ void Foam::fieldValues::fieldValueDelta::read(const dictionary& dict)
} }
void Foam::fieldValues::fieldValueDelta::write() void Foam::functionObjects::fieldValues::fieldValueDelta::write()
{ {
functionObjectFiles::write(); functionObjectFiles::write();
@ -186,34 +216,30 @@ void Foam::fieldValues::fieldValueDelta::write()
} }
void Foam::fieldValues::fieldValueDelta::execute() void Foam::functionObjects::fieldValues::fieldValueDelta::execute()
{ {}
// Do nothing
}
void Foam::fieldValues::fieldValueDelta::end() void Foam::functionObjects::fieldValues::fieldValueDelta::end()
{ {}
// Do nothing
}
void Foam::fieldValues::fieldValueDelta::timeSet() void Foam::functionObjects::fieldValues::fieldValueDelta::timeSet()
{ {}
// Do nothing
}
void Foam::fieldValues::fieldValueDelta::updateMesh(const mapPolyMesh&) void Foam::functionObjects::fieldValues::fieldValueDelta::updateMesh
{ (
// Do nothing const mapPolyMesh&
} )
{}
void Foam::fieldValues::fieldValueDelta::movePoints(const polyMesh&) void Foam::functionObjects::fieldValues::fieldValueDelta::movePoints
{ (
// Do nothing const polyMesh&
} )
{}
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::fieldValues::fieldValueDelta Foam::functionObjects::fieldValues::fieldValueDelta
Group Group
grpFieldFunctionObjects grpFieldFunctionObjects
@ -84,7 +84,8 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace functionObjects
{
namespace fieldValues namespace fieldValues
{ {
@ -162,6 +163,8 @@ public:
TypeName("fieldValueDelta"); TypeName("fieldValueDelta");
// Constructors
//- Construct from components //- Construct from components
fieldValueDelta fieldValueDelta
( (
@ -171,6 +174,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~fieldValueDelta(); virtual ~fieldValueDelta();
@ -206,6 +219,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fieldValues } // End namespace fieldValues
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,8 +43,10 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<fieldValues::fieldValueDelta> typedef OutputFilterFunctionObject
fieldValueDeltaFunctionObject; <
functionObjects::fieldValues::fieldValueDelta
> fieldValueDeltaFunctionObject;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -30,7 +30,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
Type Foam::fieldValues::fieldValueDelta::applyOperation Type Foam::functionObjects::fieldValues::fieldValueDelta::applyOperation
( (
const Type& value1, const Type& value1,
const Type& value2 const Type& value2
@ -79,7 +79,10 @@ Type Foam::fieldValues::fieldValueDelta::applyOperation
template<class Type> template<class Type>
void Foam::fieldValues::fieldValueDelta::processFields(bool& found) void Foam::functionObjects::fieldValues::fieldValueDelta::processFields
(
bool& found
)
{ {
typedef GeometricField<Type, fvPatchField, volMesh> vf; typedef GeometricField<Type, fvPatchField, volMesh> vf;
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf; typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;

View File

@ -75,26 +75,13 @@ Foam::functionObjects::histogram::histogram
) )
: :
functionObjectFile(obr, typeName), functionObjectFile(obr, typeName),
name_(name), name_(name)
active_(true)
{
// Check if the available mesh is an fvMesh, otherwise deactivate
if (isA<fvMesh>(obr_))
{ {
read(dict); read(dict);
} }
else
{
active_ = false;
WarningInFunction
<< "No fvMesh available, deactivating " << name_ << nl
<< endl;
}
}
Foam::autoPtr<Foam::functionObjects::histogram> bool Foam::functionObjects::histogram::viable
Foam::functionObjects::histogram::New
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -102,17 +89,8 @@ Foam::functionObjects::histogram::New
const bool loadFromFiles const bool loadFromFiles
) )
{ {
if (isA<fvMesh>(obr)) // Construction is viable if the available mesh is an fvMesh
{ return isA<fvMesh>(obr);
return autoPtr<histogram>
(
new histogram(name, obr, dict, loadFromFiles)
);
}
else
{
return autoPtr<histogram>();
}
} }
@ -125,8 +103,6 @@ Foam::functionObjects::histogram::~histogram()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::functionObjects::histogram::read(const dictionary& dict) void Foam::functionObjects::histogram::read(const dictionary& dict)
{
if (active_)
{ {
dict.lookup("field") >> fieldName_; dict.lookup("field") >> fieldName_;
dict.lookup("max") >> max_; dict.lookup("max") >> max_;
@ -136,7 +112,6 @@ void Foam::functionObjects::histogram::read(const dictionary& dict)
word format(dict.lookup("setFormat")); word format(dict.lookup("setFormat"));
formatterPtr_ = writer<scalar>::New(format); formatterPtr_ = writer<scalar>::New(format);
} }
}
void Foam::functionObjects::histogram::execute() void Foam::functionObjects::histogram::execute()
@ -152,8 +127,6 @@ void Foam::functionObjects::histogram::timeSet()
void Foam::functionObjects::histogram::write() void Foam::functionObjects::histogram::write()
{
if (active_)
{ {
Info<< type() << " " << name_ << " output:" << nl; Info<< type() << " " << name_ << " output:" << nl;
@ -236,7 +209,6 @@ void Foam::functionObjects::histogram::write()
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -99,9 +99,6 @@ class histogram
//- Name of this histogram //- Name of this histogram
word name_; word name_;
//- on/off switch
bool active_;
//- Name of field //- Name of field
word fieldName_; word fieldName_;
@ -152,9 +149,9 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Construct on free-store and return pointer if successful //- Return true if the construction of this functionObject is viable
// otherwise return a null-pointer // i.e. the prerequisites for construction are available
static autoPtr<histogram> New static bool viable
( (
const word& name, const word& name,
const objectRegistry&, const objectRegistry&,

View File

@ -32,14 +32,17 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{
namespace functionObjects
{ {
defineTypeNameAndDebug(nearWallFields, 0); defineTypeNameAndDebug(nearWallFields, 0);
} }
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::nearWallFields::calcAddressing() void Foam::functionObjects::nearWallFields::calcAddressing()
{ {
const fvMesh& mesh = refCast<const fvMesh>(obr_); const fvMesh& mesh = refCast<const fvMesh>(obr_);
@ -218,7 +221,7 @@ void Foam::nearWallFields::calcAddressing()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::nearWallFields::nearWallFields Foam::functionObjects::nearWallFields::nearWallFields
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -228,28 +231,28 @@ Foam::nearWallFields::nearWallFields
: :
name_(name), name_(name),
obr_(obr), obr_(obr),
active_(true),
fieldSet_() fieldSet_()
{
// Check if the available mesh is an fvMesh otherise deactivate
if (isA<fvMesh>(obr_))
{ {
read(dict); read(dict);
} }
else
{
active_ = false;
WarningInFunction
<< "No fvMesh available, deactivating " << name_
<< endl;
}
bool Foam::functionObjects::nearWallFields::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
// Construction is viable if the available mesh is an fvMesh
return isA<fvMesh>(obr);
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::nearWallFields::~nearWallFields() Foam::functionObjects::nearWallFields::~nearWallFields()
{ {
if (debug) if (debug)
{ {
@ -260,15 +263,13 @@ Foam::nearWallFields::~nearWallFields()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::nearWallFields::read(const dictionary& dict) void Foam::functionObjects::nearWallFields::read(const dictionary& dict)
{ {
if (debug) if (debug)
{ {
InfoInFunction << endl; InfoInFunction << endl;
} }
if (active_)
{
const fvMesh& mesh = refCast<const fvMesh>(obr_); const fvMesh& mesh = refCast<const fvMesh>(obr_);
dict.lookup("fields") >> fieldSet_; dict.lookup("fields") >> fieldSet_;
@ -307,19 +308,15 @@ void Foam::nearWallFields::read(const dictionary& dict)
// Do analysis // Do analysis
calcAddressing(); calcAddressing();
} }
}
void Foam::nearWallFields::execute() void Foam::functionObjects::nearWallFields::execute()
{ {
if (debug) if (debug)
{ {
InfoInFunction << endl; InfoInFunction << endl;
} }
if (active_)
{
if if
( (
fieldMap_.size() fieldMap_.size()
@ -353,38 +350,30 @@ void Foam::nearWallFields::execute()
sampleFields(vSymmtf_); sampleFields(vSymmtf_);
sampleFields(vtf_); sampleFields(vtf_);
} }
}
void Foam::nearWallFields::end() void Foam::functionObjects::nearWallFields::end()
{ {
if (debug) if (debug)
{ {
InfoInFunction << endl; InfoInFunction << endl;
} }
if (active_)
{
execute(); execute();
} }
}
void Foam::nearWallFields::timeSet() void Foam::functionObjects::nearWallFields::timeSet()
{ {}
// Do nothing
}
void Foam::nearWallFields::write() void Foam::functionObjects::nearWallFields::write()
{ {
if (debug) if (debug)
{ {
InfoInFunction << endl; InfoInFunction << endl;
} }
if (active_)
{
Info<< " Writing sampled fields to " << obr_.time().timeName() Info<< " Writing sampled fields to " << obr_.time().timeName()
<< endl; << endl;
@ -411,7 +400,6 @@ void Foam::nearWallFields::write()
Info<< endl; Info<< endl;
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::nearWallFields Foam::functionObjects::nearWallFields
Group Group
grpFieldFunctionObjects grpFieldFunctionObjects
@ -88,6 +88,9 @@ class objectRegistry;
class dictionary; class dictionary;
class mapPolyMesh; class mapPolyMesh;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class nearWallFields Declaration Class nearWallFields Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -103,9 +106,6 @@ protected:
const objectRegistry& obr_; const objectRegistry& obr_;
//- on/off switch
bool active_;
// Read from dictionary // Read from dictionary
//- Fields to process //- Fields to process
@ -197,6 +197,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~nearWallFields(); virtual ~nearWallFields();
@ -237,6 +247,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,7 +43,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<nearWallFields> typedef OutputFilterFunctionObject<functionObjects::nearWallFields>
nearWallFieldsFunctionObject; nearWallFieldsFunctionObject;
} }

View File

@ -28,7 +28,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::nearWallFields::createFields void Foam::functionObjects::nearWallFields::createFields
( (
PtrList<GeometricField<Type, fvPatchField, volMesh>>& sflds PtrList<GeometricField<Type, fvPatchField, volMesh>>& sflds
) const ) const
@ -72,7 +72,7 @@ void Foam::nearWallFields::createFields
template<class Type> template<class Type>
void Foam::nearWallFields::sampleBoundaryField void Foam::functionObjects::nearWallFields::sampleBoundaryField
( (
const interpolationCellPoint<Type>& interpolator, const interpolationCellPoint<Type>& interpolator,
GeometricField<Type, fvPatchField, volMesh>& fld GeometricField<Type, fvPatchField, volMesh>& fld
@ -122,7 +122,7 @@ void Foam::nearWallFields::sampleBoundaryField
template<class Type> template<class Type>
void Foam::nearWallFields::sampleFields void Foam::functionObjects::nearWallFields::sampleFields
( (
PtrList<GeometricField<Type, fvPatchField, volMesh>>& sflds PtrList<GeometricField<Type, fvPatchField, volMesh>>& sflds
) const ) const

View File

@ -30,14 +30,17 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{
namespace functionObjects
{ {
defineTypeNameAndDebug(processorField, 0); defineTypeNameAndDebug(processorField, 0);
} }
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::processorField::processorField Foam::functionObjects::processorField::processorField
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -46,11 +49,7 @@ Foam::processorField::processorField
) )
: :
name_(name), name_(name),
obr_(obr), obr_(obr)
active_(true)
{
// Check if the available mesh is an fvMesh otherise deactivate
if (isA<fvMesh>(obr_))
{ {
read(dict); read(dict);
@ -75,33 +74,35 @@ Foam::processorField::processorField
mesh.objectRegistry::store(procFieldPtr); mesh.objectRegistry::store(procFieldPtr);
} }
else
bool Foam::functionObjects::processorField::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{ {
active_ = false; // Construction is viable if the available mesh is an fvMesh
WarningInFunction return isA<fvMesh>(obr);
<< "No fvMesh available, deactivating " << name_
<< endl;
}
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::processorField::~processorField() Foam::functionObjects::processorField::~processorField()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::processorField::read(const dictionary& dict) void Foam::functionObjects::processorField::read(const dictionary& dict)
{ {}
// do nothing
}
void Foam::processorField::execute() void Foam::functionObjects::processorField::execute()
{
if (active_)
{ {
const volScalarField& procField = const volScalarField& procField =
obr_.lookupObject<volScalarField>("processorID"); obr_.lookupObject<volScalarField>("processorID");
@ -109,34 +110,25 @@ void Foam::processorField::execute()
const_cast<volScalarField&>(procField) == const_cast<volScalarField&>(procField) ==
dimensionedScalar("proci", dimless, Pstream::myProcNo()); dimensionedScalar("proci", dimless, Pstream::myProcNo());
} }
}
void Foam::processorField::end() void Foam::functionObjects::processorField::end()
{
if (active_)
{ {
execute(); execute();
} }
}
void Foam::processorField::timeSet() void Foam::functionObjects::processorField::timeSet()
{ {}
// Do nothing
}
void Foam::processorField::write() void Foam::functionObjects::processorField::write()
{
if (active_)
{ {
const volScalarField& procField = const volScalarField& procField =
obr_.lookupObject<volScalarField>("processorID"); obr_.lookupObject<volScalarField>("processorID");
procField.write(); procField.write();
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::processorField Foam::functionObjects::processorField
Group Group
grpFieldFunctionObjects grpFieldFunctionObjects
@ -76,6 +76,9 @@ class objectRegistry;
class dictionary; class dictionary;
class mapPolyMesh; class mapPolyMesh;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class processorField Declaration Class processorField Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -92,9 +95,6 @@ protected:
//- Reference to the database //- Reference to the database
const objectRegistry& obr_; const objectRegistry& obr_;
//- on/off switch
bool active_;
private: private:
@ -125,6 +125,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~processorField(); virtual ~processorField();
@ -165,6 +175,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,7 +43,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<processorField> typedef OutputFilterFunctionObject<functionObjects::processorField>
processorFieldFunctionObject; processorFieldFunctionObject;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,14 +29,17 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{
namespace functionObjects
{ {
defineTypeNameAndDebug(readFields, 0); defineTypeNameAndDebug(readFields, 0);
} }
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::readFields::readFields Foam::functionObjects::readFields::readFields
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -46,44 +49,40 @@ Foam::readFields::readFields
: :
name_(name), name_(name),
obr_(obr), obr_(obr),
active_(true),
fieldSet_() fieldSet_()
{
// Check if the available mesh is an fvMesh otherise deactivate
if (isA<fvMesh>(obr_))
{ {
read(dict); read(dict);
} }
else
bool Foam::functionObjects::readFields::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{ {
active_ = false; // Construction is viable if the available mesh is an fvMesh
WarningInFunction return isA<fvMesh>(obr);
<< "No fvMesh available, deactivating " << name_
<< endl;
}
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::readFields::~readFields() Foam::functionObjects::readFields::~readFields()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::readFields::read(const dictionary& dict) void Foam::functionObjects::readFields::read(const dictionary& dict)
{
if (active_)
{ {
dict.lookup("fields") >> fieldSet_; dict.lookup("fields") >> fieldSet_;
} }
}
void Foam::readFields::execute() void Foam::functionObjects::readFields::execute()
{
if (active_)
{ {
// Clear out any previously loaded fields // Clear out any previously loaded fields
vsf_.clear(); vsf_.clear();
@ -110,28 +109,20 @@ void Foam::readFields::execute()
loadField<tensor>(fieldName, vtf_, stf_); loadField<tensor>(fieldName, vtf_, stf_);
} }
} }
}
void Foam::readFields::end() void Foam::functionObjects::readFields::end()
{
if (active_)
{ {
execute(); execute();
} }
}
void Foam::readFields::timeSet() void Foam::functionObjects::readFields::timeSet()
{ {}
// Do nothing
}
void Foam::readFields::write() void Foam::functionObjects::readFields::write()
{ {}
// Do nothing
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::readFields Foam::functionObjects::readFields
Group Group
grpFieldFunctionObjects grpFieldFunctionObjects
@ -81,6 +81,9 @@ class objectRegistry;
class dictionary; class dictionary;
class mapPolyMesh; class mapPolyMesh;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class readFields Declaration Class readFields Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -96,9 +99,6 @@ protected:
const objectRegistry& obr_; const objectRegistry& obr_;
//- on/off switch
bool active_;
//- Fields to load //- Fields to load
wordList fieldSet_; wordList fieldSet_;
@ -156,6 +156,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~readFields(); virtual ~readFields();
@ -196,6 +206,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,7 +43,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<readFields> typedef OutputFilterFunctionObject<functionObjects::readFields>
readFieldsFunctionObject; readFieldsFunctionObject;
} }

View File

@ -31,7 +31,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::readFields::loadField void Foam::functionObjects::readFields::loadField
( (
const word& fieldName, const word& fieldName,
PtrList<GeometricField<Type, fvPatchField, volMesh>>& vflds, PtrList<GeometricField<Type, fvPatchField, volMesh>>& vflds,

View File

@ -33,8 +33,11 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{
namespace functionObjects
{ {
defineTypeNameAndDebug(regionSizeDistribution, 0); defineTypeNameAndDebug(regionSizeDistribution, 0);
}
//- Plus op for FixedList<scalar> //- Plus op for FixedList<scalar>
template<class T, unsigned Size> template<class T, unsigned Size>
@ -58,7 +61,7 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::regionSizeDistribution::writeGraph void Foam::functionObjects::regionSizeDistribution::writeGraph
( (
const coordSet& coords, const coordSet& coords,
const word& valueName, const word& valueName,
@ -81,7 +84,7 @@ void Foam::regionSizeDistribution::writeGraph
} }
void Foam::regionSizeDistribution::writeAlphaFields void Foam::functionObjects::regionSizeDistribution::writeAlphaFields
( (
const regionSplit& regions, const regionSplit& regions,
const Map<label>& patchRegions, const Map<label>& patchRegions,
@ -163,7 +166,8 @@ void Foam::regionSizeDistribution::writeAlphaFields
} }
Foam::Map<Foam::label> Foam::regionSizeDistribution::findPatchRegions Foam::Map<Foam::label>
Foam::functionObjects::regionSizeDistribution::findPatchRegions
( (
const polyMesh& mesh, const polyMesh& mesh,
const regionSplit& regions const regionSplit& regions
@ -209,7 +213,8 @@ Foam::Map<Foam::label> Foam::regionSizeDistribution::findPatchRegions
} }
Foam::tmp<Foam::scalarField> Foam::regionSizeDistribution::divide Foam::tmp<Foam::scalarField>
Foam::functionObjects::regionSizeDistribution::divide
( (
const scalarField& num, const scalarField& num,
const scalarField& denom const scalarField& denom
@ -233,7 +238,7 @@ Foam::tmp<Foam::scalarField> Foam::regionSizeDistribution::divide
} }
void Foam::regionSizeDistribution::writeGraphs void Foam::functionObjects::regionSizeDistribution::writeGraphs
( (
const word& fieldName, // name of field const word& fieldName, // name of field
const labelList& indices, // index of bin for each region const labelList& indices, // index of bin for each region
@ -274,7 +279,7 @@ void Foam::regionSizeDistribution::writeGraphs
} }
void Foam::regionSizeDistribution::writeGraphs void Foam::functionObjects::regionSizeDistribution::writeGraphs
( (
const word& fieldName, // name of field const word& fieldName, // name of field
const scalarField& cellField, // per cell field data const scalarField& cellField, // per cell field data
@ -314,7 +319,7 @@ void Foam::regionSizeDistribution::writeGraphs
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::regionSizeDistribution::regionSizeDistribution Foam::functionObjects::regionSizeDistribution::regionSizeDistribution
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -325,36 +330,35 @@ Foam::regionSizeDistribution::regionSizeDistribution
functionObjectFiles(obr, name, typeName), functionObjectFiles(obr, name, typeName),
name_(name), name_(name),
obr_(obr), obr_(obr),
active_(true),
alphaName_(dict.lookup("field")), alphaName_(dict.lookup("field")),
patchNames_(dict.lookup("patches")) patchNames_(dict.lookup("patches"))
{
// Check if the available mesh is an fvMesh, otherwise deactivate
if (isA<fvMesh>(obr_))
{ {
read(dict); read(dict);
} }
else
bool Foam::functionObjects::regionSizeDistribution::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{ {
active_ = false; // Construction is viable if the available mesh is an fvMesh
WarningInFunction return isA<fvMesh>(obr);
<< "No fvMesh available, deactivating " << name_ << nl
<< endl;
}
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::regionSizeDistribution::~regionSizeDistribution() Foam::functionObjects::regionSizeDistribution::~regionSizeDistribution()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::regionSizeDistribution::read(const dictionary& dict) void Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict)
{
if (active_)
{ {
dict.lookup("field") >> alphaName_; dict.lookup("field") >> alphaName_;
dict.lookup("patches") >> patchNames_; dict.lookup("patches") >> patchNames_;
@ -376,30 +380,21 @@ void Foam::regionSizeDistribution::read(const dictionary& dict)
<< coordSysPtr_().name() << endl; << coordSysPtr_().name() << endl;
} }
} }
}
void Foam::regionSizeDistribution::execute() void Foam::functionObjects::regionSizeDistribution::execute()
{ {}
// Do nothing - only valid on write
}
void Foam::regionSizeDistribution::end() void Foam::functionObjects::regionSizeDistribution::end()
{ {}
// Do nothing - only valid on write
}
void Foam::regionSizeDistribution::timeSet() void Foam::functionObjects::regionSizeDistribution::timeSet()
{ {}
// Do nothing - only valid on write
}
void Foam::regionSizeDistribution::write() void Foam::functionObjects::regionSizeDistribution::write()
{
if (active_)
{ {
Info<< type() << " " << name_ << " output:" << nl; Info<< type() << " " << name_ << " output:" << nl;
@ -859,7 +854,6 @@ void Foam::regionSizeDistribution::write()
} }
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::regionSizeDistribution Foam::functionObjects::regionSizeDistribution
Group Group
grpFieldFunctionObjects grpFieldFunctionObjects
@ -126,6 +126,9 @@ class mapPolyMesh;
class regionSplit; class regionSplit;
class polyMesh; class polyMesh;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class regionSizeDistribution Declaration Class regionSizeDistribution Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -141,9 +144,6 @@ class regionSizeDistribution
const objectRegistry& obr_; const objectRegistry& obr_;
//- on/off switch
bool active_;
//- Name of field //- Name of field
word alphaName_; word alphaName_;
@ -255,6 +255,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
// Destructor // Destructor
@ -296,6 +306,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,7 +43,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<regionSizeDistribution> typedef OutputFilterFunctionObject<functionObjects::regionSizeDistribution>
regionSizeDistributionFunctionObject; regionSizeDistributionFunctionObject;
} }

View File

@ -30,7 +30,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::Map<Type> Foam::regionSizeDistribution::regionSum Foam::Map<Type> Foam::functionObjects::regionSizeDistribution::regionSum
( (
const regionSplit& regions, const regionSplit& regions,
const Field<Type>& fld const Field<Type>& fld
@ -60,9 +60,8 @@ Foam::Map<Type> Foam::regionSizeDistribution::regionSum
} }
// Get data in sortedToc order
template<class Type> template<class Type>
Foam::List<Type> Foam::regionSizeDistribution::extractData Foam::List<Type> Foam::functionObjects::regionSizeDistribution::extractData
( (
const UList<label>& keys, const UList<label>& keys,
const Map<Type>& regionData const Map<Type>& regionData

View File

@ -39,15 +39,18 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{
namespace functionObjects
{ {
defineTypeNameAndDebug(streamLine, 0); defineTypeNameAndDebug(streamLine, 0);
} }
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::autoPtr<Foam::indirectPrimitivePatch> Foam::autoPtr<Foam::indirectPrimitivePatch>
Foam::streamLine::wallPatch() const Foam::functionObjects::streamLine::wallPatch() const
{ {
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
@ -57,7 +60,6 @@ Foam::streamLine::wallPatch() const
forAll(patches, patchi) forAll(patches, patchi)
{ {
//if (!polyPatch::constraintType(patches[patchi].type()))
if (isA<wallPolyPatch>(patches[patchi])) if (isA<wallPolyPatch>(patches[patchi]))
{ {
nFaces += patches[patchi].size(); nFaces += patches[patchi].size();
@ -70,7 +72,6 @@ Foam::streamLine::wallPatch() const
forAll(patches, patchi) forAll(patches, patchi)
{ {
//if (!polyPatch::constraintType(patches[patchi].type()))
if (isA<wallPolyPatch>(patches[patchi])) if (isA<wallPolyPatch>(patches[patchi]))
{ {
const polyPatch& pp = patches[patchi]; const polyPatch& pp = patches[patchi];
@ -97,7 +98,7 @@ Foam::streamLine::wallPatch() const
} }
void Foam::streamLine::track() void Foam::functionObjects::streamLine::track()
{ {
const Time& runTime = obr_.time(); const Time& runTime = obr_.time();
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
@ -121,7 +122,7 @@ void Foam::streamLine::track()
mesh, mesh,
seedPoints[i], seedPoints[i],
seedPoints.cells()[i], seedPoints.cells()[i],
lifeTime_ // lifetime lifeTime_
) )
); );
} }
@ -294,7 +295,7 @@ void Foam::streamLine::track()
} }
// additional particle info // Additional particle info
streamLineParticle::trackingData td streamLineParticle::trackingData td
( (
particles, particles,
@ -322,7 +323,7 @@ void Foam::streamLine::track()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::streamLine::streamLine Foam::functionObjects::streamLine::streamLine
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -334,39 +335,37 @@ Foam::streamLine::streamLine
name_(name), name_(name),
obr_(obr), obr_(obr),
loadFromFiles_(loadFromFiles), loadFromFiles_(loadFromFiles),
active_(true),
nSubCycle_(0) nSubCycle_(0)
{
// Only active if a fvMesh is available
if (isA<fvMesh>(obr_))
{ {
read(dict_); read(dict_);
} }
else
bool Foam::functionObjects::streamLine::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{ {
active_ = false; // Construction is viable if the available mesh is an fvMesh
WarningInFunction return isA<fvMesh>(obr);
<< "No fvMesh available, deactivating."
<< nl << endl;
}
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::streamLine::~streamLine() Foam::functionObjects::streamLine::~streamLine()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::streamLine::read(const dictionary& dict) void Foam::functionObjects::streamLine::read(const dictionary& dict)
{
if (active_)
{ {
Info<< type() << " " << name_ << ":" << nl; Info<< type() << " " << name_ << ":" << nl;
//dict_ = dict;
dict.lookup("fields") >> fields_; dict.lookup("fields") >> fields_;
if (dict.found("UName")) if (dict.found("UName"))
{ {
@ -443,9 +442,6 @@ void Foam::streamLine::read(const dictionary& dict)
interpolationCellPoint<scalar>::typeName interpolationCellPoint<scalar>::typeName
); );
//Info<< " using interpolation " << interpolationScheme_
// << endl;
cloudName_ = dict.lookupOrDefault<word>("cloudName", "streamLine"); cloudName_ = dict.lookupOrDefault<word>("cloudName", "streamLine");
dict.lookup("seedSampleSet") >> seedSet_; dict.lookup("seedSampleSet") >> seedSet_;
@ -466,56 +462,21 @@ void Foam::streamLine::read(const dictionary& dict)
scalarFormatterPtr_ = writer<scalar>::New(dict.lookup("setFormat")); scalarFormatterPtr_ = writer<scalar>::New(dict.lookup("setFormat"));
vectorFormatterPtr_ = writer<vector>::New(dict.lookup("setFormat")); vectorFormatterPtr_ = writer<vector>::New(dict.lookup("setFormat"));
} }
}
void Foam::streamLine::execute() void Foam::functionObjects::streamLine::execute()
{
// const Time& runTime = obr_.time();
// Pout<< "**streamLine::execute : time:" << runTime.timeName() << endl;
//
// bool isOutputTime = false;
//
// const functionObjectList& fobs = runTime.functionObjects();
//
// forAll(fobs, i)
// {
// if (isA<streamLineFunctionObject>(fobs[i]))
// {
// const streamLineFunctionObject& fo =
// dynamic_cast<const streamLineFunctionObject&>(fobs[i]);
//
// if (fo.name() == name_)
// {
// Pout<< "found me:" << i << endl;
// if (fo.outputControl().output())
// {
// isOutputTime = true;
// break;
// }
// }
// }
// }
//
//
// if (active_ && isOutputTime)
// {
// track();
// }
}
void Foam::streamLine::end()
{} {}
void Foam::streamLine::timeSet() void Foam::functionObjects::streamLine::end()
{} {}
void Foam::streamLine::write() void Foam::functionObjects::streamLine::timeSet()
{ {}
if (active_)
void Foam::functionObjects::streamLine::write()
{ {
Info<< type() << " " << name_ << " output:" << nl; Info<< type() << " " << name_ << " output:" << nl;
@ -730,8 +691,6 @@ void Foam::streamLine::write()
) )
); );
//Info<< " Writing vector data to " << vtkFile << endl;
vectorFormatterPtr_().write vectorFormatterPtr_().write
( (
true, // writeTracks true, // writeTracks
@ -743,29 +702,19 @@ void Foam::streamLine::write()
} }
} }
} }
}
void Foam::streamLine::updateMesh(const mapPolyMesh&) void Foam::functionObjects::streamLine::updateMesh(const mapPolyMesh&)
{ {
read(dict_); read(dict_);
} }
void Foam::streamLine::movePoints(const polyMesh&) void Foam::functionObjects::streamLine::movePoints(const polyMesh&)
{ {
// Moving mesh affects the search tree // Moving mesh affects the search tree
read(dict_); read(dict_);
} }
//void Foam::streamLine::readUpdate(const polyMesh::readUpdateState state)
//{
// if (state != UNCHANGED)
// {
// read(dict_);
// }
//}
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::streamLine Foam::functionObjects::streamLine
Group Group
grpFieldFunctionObjects grpFieldFunctionObjects
@ -125,6 +125,9 @@ class mapPolyMesh;
class meshSearch; class meshSearch;
class sampledSet; class sampledSet;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class streamLine Declaration Class streamLine Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -145,9 +148,6 @@ class streamLine
//- Load fields from files (not from objectRegistry) //- Load fields from files (not from objectRegistry)
bool loadFromFiles_; bool loadFromFiles_;
//- On/off switch
bool active_;
//- List of fields to sample //- List of fields to sample
wordList fields_; wordList fields_;
@ -182,7 +182,6 @@ class streamLine
wordList vectorNames_; wordList vectorNames_;
// Demand driven // Demand driven
//- Mesh searching enigne //- Mesh searching enigne
@ -244,6 +243,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~streamLine(); virtual ~streamLine();
@ -277,14 +286,12 @@ public:
//- Update for mesh point-motion //- Update for mesh point-motion
virtual void movePoints(const polyMesh&); virtual void movePoints(const polyMesh&);
////- Update for changes of mesh due to readUpdate
//virtual void readUpdate(const polyMesh::readUpdateState state);
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,7 +43,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<streamLine> typedef OutputFilterFunctionObject<functionObjects::streamLine>
streamLineFunctionObject; streamLineFunctionObject;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -28,14 +28,17 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{
namespace functionObjects
{ {
defineTypeNameAndDebug(surfaceInterpolateFields, 0); defineTypeNameAndDebug(surfaceInterpolateFields, 0);
} }
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceInterpolateFields::surfaceInterpolateFields Foam::functionObjects::surfaceInterpolateFields::surfaceInterpolateFields
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -45,44 +48,43 @@ Foam::surfaceInterpolateFields::surfaceInterpolateFields
: :
name_(name), name_(name),
obr_(obr), obr_(obr),
active_(true),
fieldSet_() fieldSet_()
{
// Check if the available mesh is an fvMesh otherise deactivate
if (isA<fvMesh>(obr_))
{ {
read(dict); read(dict);
} }
else
bool Foam::functionObjects::surfaceInterpolateFields::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{ {
active_ = false; // Construction is viable if the available mesh is an fvMesh
WarningInFunction return isA<fvMesh>(obr);
<< "No fvMesh available, deactivating " << name_
<< endl;
}
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceInterpolateFields::~surfaceInterpolateFields() Foam::functionObjects::surfaceInterpolateFields::~surfaceInterpolateFields()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfaceInterpolateFields::read(const dictionary& dict) void Foam::functionObjects::surfaceInterpolateFields::read
{ (
if (active_) const dictionary& dict
)
{ {
dict.lookup("fields") >> fieldSet_; dict.lookup("fields") >> fieldSet_;
} }
}
void Foam::surfaceInterpolateFields::execute() void Foam::functionObjects::surfaceInterpolateFields::execute()
{
if (active_)
{ {
Info<< type() << " " << name_ << " output:" << nl; Info<< type() << " " << name_ << " output:" << nl;
@ -101,27 +103,19 @@ void Foam::surfaceInterpolateFields::execute()
Info<< endl; Info<< endl;
} }
}
void Foam::surfaceInterpolateFields::end() void Foam::functionObjects::surfaceInterpolateFields::end()
{
if (active_)
{ {
execute(); execute();
} }
}
void Foam::surfaceInterpolateFields::timeSet() void Foam::functionObjects::surfaceInterpolateFields::timeSet()
{ {}
// Do nothing
}
void Foam::surfaceInterpolateFields::write() void Foam::functionObjects::surfaceInterpolateFields::write()
{
if (active_)
{ {
Info<< type() << " " << name_ << " output:" << nl; Info<< type() << " " << name_ << " output:" << nl;
@ -149,7 +143,6 @@ void Foam::surfaceInterpolateFields::write()
stf_[i].write(); stf_[i].write();
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -84,6 +84,9 @@ class objectRegistry;
class dictionary; class dictionary;
class mapPolyMesh; class mapPolyMesh;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class surfaceInterpolateFields Declaration Class surfaceInterpolateFields Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -99,9 +102,6 @@ protected:
const objectRegistry& obr_; const objectRegistry& obr_;
//- on/off switch
bool active_;
//- Fields to process //- Fields to process
//wordList fieldSet_; //wordList fieldSet_;
List<Tuple2<word, word>> fieldSet_; List<Tuple2<word, word>> fieldSet_;
@ -152,6 +152,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~surfaceInterpolateFields(); virtual ~surfaceInterpolateFields();
@ -192,6 +202,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,8 +43,10 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<surfaceInterpolateFields> typedef OutputFilterFunctionObject
surfaceInterpolateFieldsFunctionObject; <
functionObjects::surfaceInterpolateFields
> surfaceInterpolateFieldsFunctionObject;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -30,7 +30,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::surfaceInterpolateFields::interpolateFields void Foam::functionObjects::surfaceInterpolateFields::interpolateFields
( (
PtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>& sflds PtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>& sflds
) const ) const

View File

@ -41,15 +41,18 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{
namespace functionObjects
{ {
defineTypeNameAndDebug(wallBoundedStreamLine, 0); defineTypeNameAndDebug(wallBoundedStreamLine, 0);
} }
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::autoPtr<Foam::indirectPrimitivePatch> Foam::autoPtr<Foam::indirectPrimitivePatch>
Foam::wallBoundedStreamLine::wallPatch() const Foam::functionObjects::wallBoundedStreamLine::wallPatch() const
{ {
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
@ -99,7 +102,7 @@ Foam::wallBoundedStreamLine::wallPatch() const
} }
Foam::tetIndices Foam::wallBoundedStreamLine::findNearestTet Foam::tetIndices Foam::functionObjects::wallBoundedStreamLine::findNearestTet
( (
const PackedBoolList& isWallPatch, const PackedBoolList& isWallPatch,
const point& seedPt, const point& seedPt,
@ -156,7 +159,7 @@ Foam::tetIndices Foam::wallBoundedStreamLine::findNearestTet
} }
void Foam::wallBoundedStreamLine::track() void Foam::functionObjects::wallBoundedStreamLine::track()
{ {
const Time& runTime = obr_.time(); const Time& runTime = obr_.time();
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
@ -432,7 +435,7 @@ void Foam::wallBoundedStreamLine::track()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::wallBoundedStreamLine::wallBoundedStreamLine Foam::functionObjects::wallBoundedStreamLine::wallBoundedStreamLine
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -443,35 +446,34 @@ Foam::wallBoundedStreamLine::wallBoundedStreamLine
dict_(dict), dict_(dict),
name_(name), name_(name),
obr_(obr), obr_(obr),
loadFromFiles_(loadFromFiles), loadFromFiles_(loadFromFiles)
active_(true)
{
// Only active if a fvMesh is available
if (isA<fvMesh>(obr_))
{ {
read(dict_); read(dict_);
} }
else
bool Foam::functionObjects::wallBoundedStreamLine::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{ {
active_ = false; // Construction is viable if the available mesh is an fvMesh
WarningInFunction return isA<fvMesh>(obr);
<< "No fvMesh available, deactivating " << name_
<< nl << endl;
}
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::wallBoundedStreamLine::~wallBoundedStreamLine() Foam::functionObjects::wallBoundedStreamLine::~wallBoundedStreamLine()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::wallBoundedStreamLine::read(const dictionary& dict) void Foam::functionObjects::wallBoundedStreamLine::read(const dictionary& dict)
{
if (active_)
{ {
//dict_ = dict; //dict_ = dict;
dict.lookup("fields") >> fields_; dict.lookup("fields") >> fields_;
@ -529,9 +531,6 @@ void Foam::wallBoundedStreamLine::read(const dictionary& dict)
interpolationCellPoint<scalar>::typeName interpolationCellPoint<scalar>::typeName
); );
//Info<< typeName << " using interpolation " << interpolationScheme_
// << endl;
cloudName_ = dict.lookupOrDefault<word> cloudName_ = dict.lookupOrDefault<word>
( (
"cloudName", "cloudName",
@ -621,24 +620,21 @@ void Foam::wallBoundedStreamLine::read(const dictionary& dict)
} }
} }
} }
}
void Foam::wallBoundedStreamLine::execute() void Foam::functionObjects::wallBoundedStreamLine::execute()
{} {}
void Foam::wallBoundedStreamLine::end() void Foam::functionObjects::wallBoundedStreamLine::end()
{} {}
void Foam::wallBoundedStreamLine::timeSet() void Foam::functionObjects::wallBoundedStreamLine::timeSet()
{} {}
void Foam::wallBoundedStreamLine::write() void Foam::functionObjects::wallBoundedStreamLine::write()
{
if (active_)
{ {
const Time& runTime = obr_.time(); const Time& runTime = obr_.time();
const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_);
@ -850,8 +846,6 @@ void Foam::wallBoundedStreamLine::write()
) )
); );
//Info<< "Writing vector data to " << vtkFile << endl;
vectorFormatterPtr_().write vectorFormatterPtr_().write
( (
true, // writeTracks true, // writeTracks
@ -863,30 +857,22 @@ void Foam::wallBoundedStreamLine::write()
} }
} }
} }
}
void Foam::wallBoundedStreamLine::updateMesh(const mapPolyMesh&) void Foam::functionObjects::wallBoundedStreamLine::updateMesh
(
const mapPolyMesh&
)
{ {
read(dict_); read(dict_);
} }
void Foam::wallBoundedStreamLine::movePoints(const polyMesh&) void Foam::functionObjects::wallBoundedStreamLine::movePoints(const polyMesh&)
{ {
// Moving mesh affects the search tree // Moving mesh affects the search tree
read(dict_); read(dict_);
} }
//void Foam::wallBoundedStreamLine::readUpdate
//(const polyMesh::readUpdateState state)
//{
// if (state != UNCHANGED)
// {
// read(dict_);
// }
//}
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::wallBoundedStreamLine Foam::functionObjects::wallBoundedStreamLine
Group Group
grpFieldFunctionObjects grpFieldFunctionObjects
@ -127,6 +127,9 @@ class mapPolyMesh;
class meshSearch; class meshSearch;
class sampledSet; class sampledSet;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class wallBoundedStreamLine Declaration Class wallBoundedStreamLine Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -147,10 +150,6 @@ class wallBoundedStreamLine
//- Load fields from files (not from objectRegistry) //- Load fields from files (not from objectRegistry)
bool loadFromFiles_; bool loadFromFiles_;
//- On/off switch
bool active_;
//- List of fields to sample //- List of fields to sample
wordList fields_; wordList fields_;
@ -250,6 +249,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~wallBoundedStreamLine(); virtual ~wallBoundedStreamLine();
@ -283,14 +292,12 @@ public:
//- Update for mesh point-motion //- Update for mesh point-motion
virtual void movePoints(const polyMesh&); virtual void movePoints(const polyMesh&);
////- Update for changes of mesh due to readUpdate
//virtual void readUpdate(const polyMesh::readUpdateState state);
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -44,7 +44,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<wallBoundedStreamLine> typedef OutputFilterFunctionObject<functionObjects::wallBoundedStreamLine>
wallBoundedStreamLineFunctionObject; wallBoundedStreamLineFunctionObject;
} }

View File

@ -140,13 +140,11 @@ Foam::functionObjects::forceCoeffs::forceCoeffs
Aref_(0.0) Aref_(0.0)
{ {
read(dict); read(dict);
Info<< endl; Info<< endl;
} }
Foam::autoPtr<Foam::functionObjects::forceCoeffs> bool Foam::functionObjects::forceCoeffs::viable
Foam::functionObjects::forceCoeffs::New
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -154,17 +152,8 @@ Foam::functionObjects::forceCoeffs::New
const bool loadFromFiles const bool loadFromFiles
) )
{ {
if (isA<fvMesh>(obr)) // Construction is viable if the available mesh is an fvMesh
{ return isA<fvMesh>(obr);
return autoPtr<forceCoeffs>
(
new forceCoeffs(name, obr, dict, loadFromFiles)
);
}
else
{
return autoPtr<forceCoeffs>();
}
} }
@ -177,8 +166,6 @@ Foam::functionObjects::forceCoeffs::~forceCoeffs()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::functionObjects::forceCoeffs::read(const dictionary& dict) void Foam::functionObjects::forceCoeffs::read(const dictionary& dict)
{
if (active_)
{ {
forces::read(dict); forces::read(dict);
@ -194,7 +181,6 @@ void Foam::functionObjects::forceCoeffs::read(const dictionary& dict)
dict.lookup("lRef") >> lRef_; dict.lookup("lRef") >> lRef_;
dict.lookup("Aref") >> Aref_; dict.lookup("Aref") >> Aref_;
} }
}
void Foam::functionObjects::forceCoeffs::execute() void Foam::functionObjects::forceCoeffs::execute()
@ -213,11 +199,6 @@ void Foam::functionObjects::forceCoeffs::write()
{ {
forces::calcForcesMoment(); forces::calcForcesMoment();
if (!active_)
{
return;
}
if (Pstream::master()) if (Pstream::master())
{ {
functionObjectFiles::write(); functionObjectFiles::write();

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::forceCoeffs Foam::functionObjects::forceCoeffs
Group Group
grpForcesFunctionObjects grpForcesFunctionObjects
@ -172,9 +172,9 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Construct on free-store and return pointer if successful //- Return true if the construction of this functionObject is viable
// otherwise return a null-pointer // i.e. the prerequisites for construction are available
static autoPtr<forceCoeffs> New static bool viable
( (
const word& name, const word& name,
const objectRegistry&, const objectRegistry&,

View File

@ -161,7 +161,7 @@ void Foam::functionObjects::forces::writeFileHeader(const label i)
void Foam::functionObjects::forces::initialise() void Foam::functionObjects::forces::initialise()
{ {
if (initialised_ || !active_) if (initialised_)
{ {
return; return;
} }
@ -170,11 +170,9 @@ void Foam::functionObjects::forces::initialise()
{ {
if (!obr_.foundObject<volVectorField>(fDName_)) if (!obr_.foundObject<volVectorField>(fDName_))
{ {
active_ = false; FatalErrorInFunction
WarningInFunction << "Could not find " << fDName_ << " in database."
<< "Could not find " << fDName_ << " in database." << nl << exit(FatalError);
<< " De-activating forces."
<< endl;
} }
} }
else else
@ -189,10 +187,9 @@ void Foam::functionObjects::forces::initialise()
) )
) )
{ {
active_ = false; FatalErrorInFunction
<< "Could not find " << UName_ << ", " << pName_
WarningInFunction << exit(FatalError);
<< "Could not find " << UName_ << ", " << pName_;
if (rhoName_ != "rhoInf") if (rhoName_ != "rhoInf")
{ {
@ -534,7 +531,6 @@ Foam::functionObjects::forces::forces
functionObjectFiles(obr, name, createFileNames(dict)), functionObjectFiles(obr, name, createFileNames(dict)),
name_(name), name_(name),
obr_(obr), obr_(obr),
active_(true),
log_(true), log_(true),
force_(3), force_(3),
moment_(3), moment_(3),
@ -556,9 +552,6 @@ Foam::functionObjects::forces::forces
binPoints_(), binPoints_(),
binCumulative_(true), binCumulative_(true),
initialised_(false) initialised_(false)
{
// Check if the available mesh is an fvMesh otherise deactivate
if (isA<fvMesh>(obr_))
{ {
if (readFields) if (readFields)
{ {
@ -566,19 +559,9 @@ Foam::functionObjects::forces::forces
Info<< endl; Info<< endl;
} }
} }
else
{
active_ = false;
WarningInFunction
<< "No fvMesh available, deactivating " << name_
<< endl;
}
}
Foam::autoPtr<Foam::functionObjects::forces> bool Foam::functionObjects::forces::viable
Foam::functionObjects::forces::New
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -586,17 +569,8 @@ Foam::functionObjects::forces::New
const bool loadFromFiles const bool loadFromFiles
) )
{ {
if (isA<fvMesh>(obr)) // Construction is viable if the available mesh is an fvMesh
{ return isA<fvMesh>(obr);
return autoPtr<forces>
(
new forces(name, obr, dict, loadFromFiles)
);
}
else
{
return autoPtr<forces>();
}
} }
@ -616,7 +590,6 @@ Foam::functionObjects::forces::forces
functionObjectFiles(obr, name, typeName), functionObjectFiles(obr, name, typeName),
name_(name), name_(name),
obr_(obr), obr_(obr),
active_(true),
log_(true), log_(true),
force_(3), force_(3),
moment_(3), moment_(3),
@ -656,8 +629,6 @@ Foam::functionObjects::forces::~forces()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::functionObjects::forces::read(const dictionary& dict) void Foam::functionObjects::forces::read(const dictionary& dict)
{
if (active_)
{ {
initialised_ = false; initialised_ = false;
@ -785,7 +756,6 @@ void Foam::functionObjects::forces::read(const dictionary& dict)
moment_[2].setSize(1); moment_[2].setSize(1);
} }
} }
}
void Foam::functionObjects::forces::execute() void Foam::functionObjects::forces::execute()
@ -804,11 +774,6 @@ void Foam::functionObjects::forces::write()
{ {
calcForcesMoment(); calcForcesMoment();
if (!active_)
{
return;
}
if (Pstream::master()) if (Pstream::master())
{ {
functionObjectFiles::write(); functionObjectFiles::write();
@ -826,11 +791,6 @@ void Foam::functionObjects::forces::calcForcesMoment()
{ {
initialise(); initialise();
if (!active_)
{
return;
}
force_[0] = Zero; force_[0] = Zero;
force_[1] = Zero; force_[1] = Zero;
force_[2] = Zero; force_[2] = Zero;

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::forces Foam::functionObjects::forces
Group Group
grpForcesFunctionObjects grpForcesFunctionObjects
@ -156,9 +156,6 @@ protected:
const objectRegistry& obr_; const objectRegistry& obr_;
//- On/off switch
bool active_;
//- Switch to send output to Info as well as to file //- Switch to send output to Info as well as to file
Switch log_; Switch log_;
@ -296,9 +293,9 @@ public:
const bool readFields = true const bool readFields = true
); );
//- Construct on free-store and return pointer if successful //- Return true if the construction of this functionObject is viable
// otherwise return a null-pointer // i.e. the prerequisites for construction are available
static autoPtr<forces> New static bool viable
( (
const word& name, const word& name,
const objectRegistry&, const objectRegistry&,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -31,14 +31,17 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{
namespace functionObjects
{ {
defineTypeNameAndDebug(calcFvcDiv, 0); defineTypeNameAndDebug(calcFvcDiv, 0);
} }
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::volScalarField& Foam::calcFvcDiv::divField Foam::volScalarField& Foam::functionObjects::calcFvcDiv::divField
( (
const word& divName, const word& divName,
const dimensionSet& dims const dimensionSet& dims
@ -76,7 +79,7 @@ Foam::volScalarField& Foam::calcFvcDiv::divField
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::calcFvcDiv::calcFvcDiv Foam::functionObjects::calcFvcDiv::calcFvcDiv
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -86,34 +89,35 @@ Foam::calcFvcDiv::calcFvcDiv
: :
name_(name), name_(name),
obr_(obr), obr_(obr),
active_(true),
fieldName_("undefined-fieldName"), fieldName_("undefined-fieldName"),
resultName_("undefined-resultName") resultName_("undefined-resultName")
{ {
// Check if the available mesh is an fvMesh, otherwise deactivate read(dict);
if (!isA<fvMesh>(obr_))
{
active_ = false;
WarningInFunction
<< "No fvMesh available, deactivating." << nl
<< endl;
} }
read(dict);
bool Foam::functionObjects::calcFvcDiv::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
// Construction is viable if the available mesh is an fvMesh
return isA<fvMesh>(obr);
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::calcFvcDiv::~calcFvcDiv() Foam::functionObjects::calcFvcDiv::~calcFvcDiv()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::calcFvcDiv::read(const dictionary& dict) void Foam::functionObjects::calcFvcDiv::read(const dictionary& dict)
{
if (active_)
{ {
dict.lookup("fieldName") >> fieldName_; dict.lookup("fieldName") >> fieldName_;
dict.lookup("resultName") >> resultName_; dict.lookup("resultName") >> resultName_;
@ -123,12 +127,9 @@ void Foam::calcFvcDiv::read(const dictionary& dict)
resultName_ = "fvc::div(" + fieldName_ + ")"; resultName_ = "fvc::div(" + fieldName_ + ")";
} }
} }
}
void Foam::calcFvcDiv::execute() void Foam::functionObjects::calcFvcDiv::execute()
{
if (active_)
{ {
bool processed = false; bool processed = false;
@ -141,27 +142,19 @@ void Foam::calcFvcDiv::execute()
<< "Unprocessed field " << fieldName_ << endl; << "Unprocessed field " << fieldName_ << endl;
} }
} }
}
void Foam::calcFvcDiv::end() void Foam::functionObjects::calcFvcDiv::end()
{
if (active_)
{ {
execute(); execute();
} }
}
void Foam::calcFvcDiv::timeSet() void Foam::functionObjects::calcFvcDiv::timeSet()
{ {}
// Do nothing
}
void Foam::calcFvcDiv::write() void Foam::functionObjects::calcFvcDiv::write()
{
if (active_)
{ {
if (obr_.foundObject<regIOobject>(resultName_)) if (obr_.foundObject<regIOobject>(resultName_))
{ {
@ -174,7 +167,6 @@ void Foam::calcFvcDiv::write()
field.write(); field.write();
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::calcFvcDiv Foam::functionObjects::calcFvcDiv
Group Group
grpFVFunctionObjects grpFVFunctionObjects
@ -59,6 +59,9 @@ class polyMesh;
class mapPolyMesh; class mapPolyMesh;
class dimensionSet; class dimensionSet;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class calcFvcDiv Declaration Class calcFvcDiv Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -73,9 +76,6 @@ class calcFvcDiv
//- Reference to the database //- Reference to the database
const objectRegistry& obr_; const objectRegistry& obr_;
//- On/off switch
bool active_;
//- Name of field to process //- Name of field to process
word fieldName_; word fieldName_;
@ -126,6 +126,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~calcFvcDiv(); virtual ~calcFvcDiv();
@ -166,6 +176,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,7 +43,8 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<calcFvcDiv> calcFvcDivFunctionObject; typedef OutputFilterFunctionObject<functionObjects::calcFvcDiv>
calcFvcDivFunctionObject;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,7 +29,7 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class FieldType> template<class FieldType>
void Foam::calcFvcDiv::calcDiv void Foam::functionObjects::calcFvcDiv::calcDiv
( (
const word& fieldName, const word& fieldName,
const word& resultName, const word& resultName,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -31,14 +31,17 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{
namespace functionObjects
{ {
defineTypeNameAndDebug(calcFvcGrad, 0); defineTypeNameAndDebug(calcFvcGrad, 0);
} }
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::calcFvcGrad::calcFvcGrad Foam::functionObjects::calcFvcGrad::calcFvcGrad
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -48,34 +51,35 @@ Foam::calcFvcGrad::calcFvcGrad
: :
name_(name), name_(name),
obr_(obr), obr_(obr),
active_(true),
fieldName_("undefined-fieldName"), fieldName_("undefined-fieldName"),
resultName_("undefined-resultName") resultName_("undefined-resultName")
{ {
// Check if the available mesh is an fvMesh, otherwise deactivate read(dict);
if (!isA<fvMesh>(obr_))
{
active_ = false;
WarningInFunction
<< "No fvMesh available, deactivating." << nl
<< endl;
} }
read(dict);
bool Foam::functionObjects::calcFvcGrad::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
// Construction is viable if the available mesh is an fvMesh
return isA<fvMesh>(obr);
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::calcFvcGrad::~calcFvcGrad() Foam::functionObjects::calcFvcGrad::~calcFvcGrad()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::calcFvcGrad::read(const dictionary& dict) void Foam::functionObjects::calcFvcGrad::read(const dictionary& dict)
{
if (active_)
{ {
dict.lookup("fieldName") >> fieldName_; dict.lookup("fieldName") >> fieldName_;
dict.lookup("resultName") >> resultName_; dict.lookup("resultName") >> resultName_;
@ -85,12 +89,9 @@ void Foam::calcFvcGrad::read(const dictionary& dict)
resultName_ = "fvc::grad(" + fieldName_ + ")"; resultName_ = "fvc::grad(" + fieldName_ + ")";
} }
} }
}
void Foam::calcFvcGrad::execute() void Foam::functionObjects::calcFvcGrad::execute()
{
if (active_)
{ {
bool processed = false; bool processed = false;
@ -103,27 +104,19 @@ void Foam::calcFvcGrad::execute()
<< "Unprocessed field " << fieldName_ << endl; << "Unprocessed field " << fieldName_ << endl;
} }
} }
}
void Foam::calcFvcGrad::end() void Foam::functionObjects::calcFvcGrad::end()
{
if (active_)
{ {
execute(); execute();
} }
}
void Foam::calcFvcGrad::timeSet() void Foam::functionObjects::calcFvcGrad::timeSet()
{ {}
// Do nothing
}
void Foam::calcFvcGrad::write() void Foam::functionObjects::calcFvcGrad::write()
{
if (active_)
{ {
if (obr_.foundObject<regIOobject>(resultName_)) if (obr_.foundObject<regIOobject>(resultName_))
{ {
@ -136,7 +129,6 @@ void Foam::calcFvcGrad::write()
field.write(); field.write();
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::calcFvcGrad Foam::functionObjects::calcFvcGrad
Group Group
grpFVFunctionObjects grpFVFunctionObjects
@ -59,6 +59,9 @@ class polyMesh;
class mapPolyMesh; class mapPolyMesh;
class dimensionSet; class dimensionSet;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class calcFvcGrad Declaration Class calcFvcGrad Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -73,9 +76,6 @@ class calcFvcGrad
//- Reference to the database //- Reference to the database
const objectRegistry& obr_; const objectRegistry& obr_;
//- On/off switch
bool active_;
//- Name of field to process //- Name of field to process
word fieldName_; word fieldName_;
@ -129,6 +129,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~calcFvcGrad(); virtual ~calcFvcGrad();
@ -169,6 +179,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,7 +43,8 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<calcFvcGrad> calcFvcGradFunctionObject; typedef OutputFilterFunctionObject<functionObjects::calcFvcGrad>
calcFvcGradFunctionObject;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -35,7 +35,11 @@ Foam::GeometricField
Foam::fvPatchField, Foam::fvPatchField,
Foam::volMesh Foam::volMesh
>& >&
Foam::calcFvcGrad::gradField(const word& gradName, const dimensionSet& dims) Foam::functionObjects::calcFvcGrad::gradField
(
const word& gradName,
const dimensionSet& dims
)
{ {
Info<< "gradField" << endl; Info<< "gradField" << endl;
@ -78,7 +82,7 @@ Foam::calcFvcGrad::gradField(const word& gradName, const dimensionSet& dims)
template<class Type> template<class Type>
void Foam::calcFvcGrad::calcGrad void Foam::functionObjects::calcFvcGrad::calcGrad
( (
const word& fieldName, const word& fieldName,
const word& resultName, const word& resultName,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -31,14 +31,17 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{
namespace functionObjects
{ {
defineTypeNameAndDebug(calcMag, 0); defineTypeNameAndDebug(calcMag, 0);
} }
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::calcMag::calcMag Foam::functionObjects::calcMag::calcMag
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -48,34 +51,35 @@ Foam::calcMag::calcMag
: :
name_(name), name_(name),
obr_(obr), obr_(obr),
active_(true),
fieldName_("undefined-fieldName"), fieldName_("undefined-fieldName"),
resultName_("undefined-resultName") resultName_("undefined-resultName")
{ {
// Check if the available mesh is an fvMesh, otherwise deactivate read(dict);
if (!isA<fvMesh>(obr_))
{
active_ = false;
WarningInFunction
<< "No fvMesh available, deactivating." << nl
<< endl;
} }
read(dict);
bool Foam::functionObjects::calcMag::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
// Construction is viable if the available mesh is an fvMesh
return isA<fvMesh>(obr);
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::calcMag::~calcMag() Foam::functionObjects::calcMag::~calcMag()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::calcMag::read(const dictionary& dict) void Foam::functionObjects::calcMag::read(const dictionary& dict)
{
if (active_)
{ {
dict.lookup("fieldName") >> fieldName_; dict.lookup("fieldName") >> fieldName_;
dict.lookup("resultName") >> resultName_; dict.lookup("resultName") >> resultName_;
@ -85,12 +89,9 @@ void Foam::calcMag::read(const dictionary& dict)
resultName_ = "mag(" + fieldName_ + ")"; resultName_ = "mag(" + fieldName_ + ")";
} }
} }
}
void Foam::calcMag::execute() void Foam::functionObjects::calcMag::execute()
{
if (active_)
{ {
bool processed = false; bool processed = false;
@ -106,27 +107,19 @@ void Foam::calcMag::execute()
<< "Unprocessed field " << fieldName_ << endl; << "Unprocessed field " << fieldName_ << endl;
} }
} }
}
void Foam::calcMag::end() void Foam::functionObjects::calcMag::end()
{
if (active_)
{ {
execute(); execute();
} }
}
void Foam::calcMag::timeSet() void Foam::functionObjects::calcMag::timeSet()
{ {}
// Do nothing
}
void Foam::calcMag::write() void Foam::functionObjects::calcMag::write()
{
if (active_)
{ {
if (obr_.foundObject<regIOobject>(resultName_)) if (obr_.foundObject<regIOobject>(resultName_))
{ {
@ -139,7 +132,6 @@ void Foam::calcMag::write()
field.write(); field.write();
} }
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::calcMag Foam::functionObjects::calcMag
Group Group
grpFVFunctionObjects grpFVFunctionObjects
@ -59,6 +59,9 @@ class polyMesh;
class mapPolyMesh; class mapPolyMesh;
class dimensionSet; class dimensionSet;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class calcMag Declaration Class calcMag Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -73,9 +76,6 @@ class calcMag
//- Reference to the database //- Reference to the database
const objectRegistry& obr_; const objectRegistry& obr_;
//- On/off switch
bool active_;
//- Name of field to process //- Name of field to process
word fieldName_; word fieldName_;
@ -123,6 +123,16 @@ public:
const bool loadFromFiles = false const bool loadFromFiles = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~calcMag(); virtual ~calcMag();
@ -163,6 +173,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,7 +43,8 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<calcMag> calcMagFunctionObject; typedef OutputFilterFunctionObject<functionObjects::calcMag>
calcMagFunctionObject;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,7 +29,7 @@ License
#include "surfaceFields.H" #include "surfaceFields.H"
template<class FieldType> template<class FieldType>
FieldType& Foam::calcMag::magField FieldType& Foam::functionObjects::calcMag::magField
( (
const word& magName, const word& magName,
const dimensionSet& dims const dimensionSet& dims
@ -68,7 +68,7 @@ FieldType& Foam::calcMag::magField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::calcMag::calc void Foam::functionObjects::calcMag::calc
( (
const word& fieldName, const word& fieldName,
const word& resultName, const word& resultName,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -33,19 +33,17 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{
namespace functionObjects
{ {
defineTypeNameAndDebug(abortCalculation, 0); defineTypeNameAndDebug(abortCalculation, 0);
} }
}
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
template<> template<>
const char* Foam::NamedEnum const char* Foam::NamedEnum
< <
Foam::abortCalculation::actionType, Foam::functionObjects::abortCalculation::actionType,
3 3
>::names[] = >::names[] =
{ {
@ -53,16 +51,17 @@ namespace Foam
"writeNow", "writeNow",
"nextWrite" "nextWrite"
}; };
}
const Foam::NamedEnum
const Foam::NamedEnum<Foam::abortCalculation::actionType, 3> <
Foam::abortCalculation::actionTypeNames_; Foam::functionObjects::abortCalculation::actionType,
3
> Foam::functionObjects::abortCalculation::actionTypeNames_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::abortCalculation::removeFile() const void Foam::functionObjects::abortCalculation::removeFile() const
{ {
bool hasAbort = isFile(abortFile_); bool hasAbort = isFile(abortFile_);
reduce(hasAbort, orOp<bool>()); reduce(hasAbort, orOp<bool>());
@ -77,7 +76,7 @@ void Foam::abortCalculation::removeFile() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::abortCalculation::abortCalculation Foam::functionObjects::abortCalculation::abortCalculation
( (
const word& name, const word& name,
const objectRegistry& obr, const objectRegistry& obr,
@ -98,15 +97,28 @@ Foam::abortCalculation::abortCalculation
} }
bool Foam::functionObjects::abortCalculation::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
return true;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::abortCalculation::~abortCalculation() Foam::functionObjects::abortCalculation::~abortCalculation()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::abortCalculation::read(const dictionary& dict) void Foam::functionObjects::abortCalculation::read(const dictionary& dict)
{ {
if (dict.found("action")) if (dict.found("action"))
{ {
@ -124,7 +136,7 @@ void Foam::abortCalculation::read(const dictionary& dict)
} }
void Foam::abortCalculation::execute() void Foam::functionObjects::abortCalculation::execute()
{ {
bool hasAbort = isFile(abortFile_); bool hasAbort = isFile(abortFile_);
reduce(hasAbort, orOp<bool>()); reduce(hasAbort, orOp<bool>());
@ -173,22 +185,18 @@ void Foam::abortCalculation::execute()
} }
void Foam::abortCalculation::end() void Foam::functionObjects::abortCalculation::end()
{ {
removeFile(); removeFile();
} }
void Foam::abortCalculation::timeSet() void Foam::functionObjects::abortCalculation::timeSet()
{ {}
// Do nothing - only valid on execute
}
void Foam::abortCalculation::write() void Foam::functionObjects::abortCalculation::write()
{ {}
// Do nothing - only valid on execute
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::abortCalculation Foam::functionObjects::abortCalculation
Group Group
grpJobControlFunctionObjects grpJobControlFunctionObjects
@ -58,6 +58,9 @@ class dictionary;
class polyMesh; class polyMesh;
class mapPolyMesh; class mapPolyMesh;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class abortCalculation Declaration Class abortCalculation Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -124,6 +127,16 @@ public:
const bool loadFromFilesUnused = false const bool loadFromFilesUnused = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~abortCalculation(); virtual ~abortCalculation();
@ -164,6 +177,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,7 +43,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
typedef OutputFilterFunctionObject<abortCalculation> typedef OutputFilterFunctionObject<functionObjects::abortCalculation>
abortCalculationFunctionObject; abortCalculationFunctionObject;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -30,14 +30,17 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{
namespace functionObjects
{ {
defineTypeNameAndDebug(systemCall, 0); defineTypeNameAndDebug(systemCall, 0);
} }
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::systemCall::systemCall Foam::functionObjects::systemCall::systemCall
( (
const word& name, const word& name,
const objectRegistry&, const objectRegistry&,
@ -54,15 +57,27 @@ Foam::systemCall::systemCall
} }
bool Foam::functionObjects::systemCall::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
return true;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::systemCall::~systemCall() Foam::functionObjects::systemCall::~systemCall()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::systemCall::read(const dictionary& dict) void Foam::functionObjects::systemCall::read(const dictionary& dict)
{ {
dict.readIfPresent("executeCalls", executeCalls_); dict.readIfPresent("executeCalls", executeCalls_);
dict.readIfPresent("endCalls", endCalls_); dict.readIfPresent("endCalls", endCalls_);
@ -93,7 +108,7 @@ void Foam::systemCall::read(const dictionary& dict)
} }
void Foam::systemCall::execute() void Foam::functionObjects::systemCall::execute()
{ {
forAll(executeCalls_, callI) forAll(executeCalls_, callI)
{ {
@ -102,7 +117,7 @@ void Foam::systemCall::execute()
} }
void Foam::systemCall::end() void Foam::functionObjects::systemCall::end()
{ {
forAll(endCalls_, callI) forAll(endCalls_, callI)
{ {
@ -111,13 +126,11 @@ void Foam::systemCall::end()
} }
void Foam::systemCall::timeSet() void Foam::functionObjects::systemCall::timeSet()
{ {}
// Do nothing
}
void Foam::systemCall::write() void Foam::functionObjects::systemCall::write()
{ {
forAll(writeCalls_, callI) forAll(writeCalls_, callI)
{ {

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::systemCall Foam::functionObjects::systemCall
Group Group
grpFunctionObjects grpFunctionObjects
@ -100,6 +100,9 @@ class dictionary;
class polyMesh; class polyMesh;
class mapPolyMesh; class mapPolyMesh;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class systemCall Declaration Class systemCall Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -152,6 +155,16 @@ public:
const bool loadFromFilesUnused = false const bool loadFromFilesUnused = false
); );
//- Return true if the construction of this functionObject is viable
// i.e. the prerequisites for construction are available
static bool viable
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor //- Destructor
virtual ~systemCall(); virtual ~systemCall();
@ -192,6 +205,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Some files were not shown because too many files have changed in this diff Show More