mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
COMP: Multiple changes - first clean build after latest merge - UNTESTED
This commit is contained in:
@ -1,147 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IOOutputFilter.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class OutputFilter>
|
||||
Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
|
||||
(
|
||||
const word& outputFilterName,
|
||||
const IOobject& ioDict,
|
||||
const bool readFromFiles
|
||||
)
|
||||
:
|
||||
IOdictionary(ioDict),
|
||||
OutputFilter(outputFilterName, ioDict.db(), *this, readFromFiles)
|
||||
{}
|
||||
|
||||
|
||||
template<class OutputFilter>
|
||||
Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
|
||||
(
|
||||
const word& outputFilterName,
|
||||
const objectRegistry& obr,
|
||||
const word& dictName,
|
||||
const IOobject::readOption rOpt,
|
||||
const bool readFromFiles
|
||||
)
|
||||
:
|
||||
IOdictionary
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
dictName,
|
||||
obr.time().system(),
|
||||
obr,
|
||||
rOpt,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
),
|
||||
OutputFilter(outputFilterName, obr, *this, readFromFiles)
|
||||
{}
|
||||
|
||||
|
||||
template<class OutputFilter>
|
||||
Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
|
||||
(
|
||||
const word& outputFilterName,
|
||||
const objectRegistry& obr,
|
||||
const fileName& dictName,
|
||||
const IOobject::readOption rOpt,
|
||||
const bool readFromFiles
|
||||
)
|
||||
:
|
||||
IOdictionary
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
dictName,
|
||||
obr,
|
||||
rOpt,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
),
|
||||
OutputFilter(outputFilterName, obr, *this, readFromFiles)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class OutputFilter>
|
||||
Foam::IOOutputFilter<OutputFilter>::~IOOutputFilter()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class OutputFilter>
|
||||
const Foam::word& Foam::IOOutputFilter<OutputFilter>::name() const
|
||||
{
|
||||
return IOdictionary::name();
|
||||
}
|
||||
|
||||
|
||||
template<class OutputFilter>
|
||||
bool Foam::IOOutputFilter<OutputFilter>::read()
|
||||
{
|
||||
if (regIOobject::read())
|
||||
{
|
||||
OutputFilter::read(*this);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class OutputFilter>
|
||||
bool Foam::IOOutputFilter<OutputFilter>::write()
|
||||
{
|
||||
return 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);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,153 +0,0 @@
|
||||
/*---------------------------------------------------------------------------* \
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::IOOutputFilter
|
||||
|
||||
Description
|
||||
IOdictionary wrapper around OutputFilter to allow them to read from
|
||||
their associated dictionaries.
|
||||
|
||||
Note
|
||||
The IOobject or the objectRegistry will normally have to be
|
||||
derived from a fvMesh for a subsequent cast (within OutputFilter)
|
||||
to work correctly.
|
||||
|
||||
SourceFiles
|
||||
IOOutputFilter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOOutputFilter_H
|
||||
#define IOOutputFilter_H
|
||||
|
||||
#include "IOdictionary.H"
|
||||
#include "pointFieldFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class IOOutputFilter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class OutputFilter>
|
||||
class IOOutputFilter
|
||||
:
|
||||
public IOdictionary,
|
||||
public OutputFilter
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
// Disallow default bitwise copy construct and assignment
|
||||
IOOutputFilter(const IOOutputFilter&);
|
||||
void operator=(const IOOutputFilter&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from an IOobject for IOdictionary
|
||||
// Allow the possibility to load fields from files
|
||||
IOOutputFilter
|
||||
(
|
||||
const word& outputFilterName,
|
||||
const IOobject& ioDict,
|
||||
const bool loadFromFile = false
|
||||
);
|
||||
|
||||
//- Construct for given objectRegistry and dictionary
|
||||
// Allow dictionary to be optional
|
||||
// Allow the possibility to load fields from files
|
||||
IOOutputFilter
|
||||
(
|
||||
const word& outputFilterName,
|
||||
const objectRegistry&,
|
||||
const word& dictName = OutputFilter::typeName() + "Dict",
|
||||
const IOobject::readOption rOpt = IOobject::MUST_READ_IF_MODIFIED,
|
||||
const bool loadFromFile = false
|
||||
);
|
||||
|
||||
//- Construct for given objectRegistry and dictionary
|
||||
// Dictionary read from full path.
|
||||
// Allow the possibility to load fields from files
|
||||
IOOutputFilter
|
||||
(
|
||||
const word& outputFilterName,
|
||||
const objectRegistry&,
|
||||
const fileName& dictName,
|
||||
const IOobject::readOption rOpt = IOobject::MUST_READ_IF_MODIFIED,
|
||||
const bool loadFromFile = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~IOOutputFilter();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name
|
||||
virtual const word& name() const;
|
||||
|
||||
//- Inherit read from OutputFilter
|
||||
using OutputFilter::read;
|
||||
|
||||
//- Read output filter properties
|
||||
virtual bool read();
|
||||
|
||||
//- Inherit write from regIOobject
|
||||
using regIOobject::write;
|
||||
|
||||
//- Sample and write
|
||||
virtual bool write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh& mpm);
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh& mesh);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "IOOutputFilter.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -520,11 +520,6 @@ bool Foam::functionObjectList::execute()
|
||||
|
||||
if (execution_)
|
||||
{
|
||||
if (forceWrite)
|
||||
{
|
||||
resetState();
|
||||
}
|
||||
|
||||
if (!updated_)
|
||||
{
|
||||
read();
|
||||
@ -532,21 +527,18 @@ bool Foam::functionObjectList::execute()
|
||||
|
||||
forAll(*this, objectI)
|
||||
{
|
||||
addProfiling
|
||||
(
|
||||
fo,
|
||||
"functionObject::" + operator[](objectI).name() + "::execute"
|
||||
);
|
||||
const word& objName = operator[](objectI).name();
|
||||
{
|
||||
addProfiling(fo, "functionObject::" + objName + "::execute");
|
||||
|
||||
ok = operator[](objectI).execute() && ok;
|
||||
ok = operator[](objectI).execute() && ok;
|
||||
}
|
||||
|
||||
addProfiling
|
||||
(
|
||||
fo,
|
||||
"functionObject::" + operator[](objectI).name() + "::write"
|
||||
);
|
||||
{
|
||||
addProfiling(fo, "functionObject::" + objName + "::write");
|
||||
|
||||
ok = operator[](objectI).write() && ok;
|
||||
ok = operator[](objectI).write() && ok;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -583,11 +575,9 @@ bool Foam::functionObjectList::end()
|
||||
|
||||
forAll(*this, objectI)
|
||||
{
|
||||
addProfiling
|
||||
(
|
||||
fo,
|
||||
"functionObject::" + operator[](objectI).name() + "::end"
|
||||
);
|
||||
const word& objName = operator[](objectI).name();
|
||||
|
||||
addProfiling(fo, "functionObject::" + objName + "::end");
|
||||
|
||||
ok = operator[](objectI).end() && ok;
|
||||
}
|
||||
@ -610,12 +600,9 @@ bool Foam::functionObjectList::adjustTimeStep()
|
||||
|
||||
forAll(*this, objectI)
|
||||
{
|
||||
addProfiling
|
||||
(
|
||||
fo,
|
||||
"functionObject::" + operator[](objectI).name()
|
||||
+ "::adjustTimeStep"
|
||||
);
|
||||
const word& objName = operator[](objectI).name();
|
||||
|
||||
addProfiling(fo, "functionObject::" + objName + "::adjustTimeStep");
|
||||
|
||||
ok = operator[](objectI).adjustTimeStep() && ok;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -40,7 +40,7 @@ void Foam::functionObjects::logFiles::createFiles()
|
||||
{
|
||||
if (!filePtrs_.set(i))
|
||||
{
|
||||
filePtrs_.set(i, createFile(names_[i]);
|
||||
filePtrs_.set(i, createFile(names_[i]));
|
||||
|
||||
initStream(filePtrs_[i]);
|
||||
}
|
||||
@ -67,7 +67,7 @@ void Foam::functionObjects::logFiles::resetName(const word& name)
|
||||
names_.clear();
|
||||
names_.append(name);
|
||||
|
||||
resetFile(name);
|
||||
writeFile::resetFile(name);
|
||||
}
|
||||
|
||||
|
||||
@ -85,6 +85,21 @@ Foam::functionObjects::logFiles::logFiles
|
||||
{}
|
||||
|
||||
|
||||
Foam::functionObjects::logFiles::logFiles
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const word& prefix,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
writeFile(obr, prefix),
|
||||
names_(),
|
||||
filePtrs_()
|
||||
{
|
||||
writeFile::read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::logFiles::~logFiles()
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -41,7 +41,6 @@ SourceFiles
|
||||
#define functionObjects_logFiles_H
|
||||
|
||||
#include "writeFile.H"
|
||||
#include "OFstream.H"
|
||||
#include "PtrList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -82,9 +81,6 @@ protected:
|
||||
//- Reset the list of names to a single name entry
|
||||
virtual void resetName(const word& name);
|
||||
|
||||
//- File header information
|
||||
virtual void writeFileHeader(const label i = 0) = 0;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -109,6 +105,16 @@ public:
|
||||
);
|
||||
|
||||
|
||||
//- Construct from objectRegistry and prefix, and read options
|
||||
// from dictionary
|
||||
logFiles
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const word& prefix,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~logFiles();
|
||||
|
||||
|
||||
@ -97,8 +97,7 @@ Foam::functionObjects::regionFunctionObject::regionFunctionObject
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
time_(runTime),
|
||||
stateFunctionObject(name, runTime),
|
||||
obr_
|
||||
(
|
||||
runTime.lookupObject<objectRegistry>
|
||||
@ -116,8 +115,7 @@ Foam::functionObjects::regionFunctionObject::regionFunctionObject
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
time_(obr.time()),
|
||||
stateFunctionObject(name, obr.time()),
|
||||
obr_(obr)
|
||||
{}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,7 +29,7 @@ Description
|
||||
reference to the region Foam::objectRegistry.
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::stateFunctionObject
|
||||
|
||||
SourceFiles
|
||||
regionFunctionObject.C
|
||||
@ -39,7 +39,7 @@ SourceFiles
|
||||
#ifndef functionObjects_regionFunctionObject_H
|
||||
#define functionObjects_regionFunctionObject_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "stateFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -53,21 +53,18 @@ namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class regionFunctionObject Declaration
|
||||
Class regionFunctionObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class regionFunctionObject
|
||||
:
|
||||
public functionObject
|
||||
public stateFunctionObject
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected member data
|
||||
|
||||
//- Reference to the Time
|
||||
const Time& time_;
|
||||
|
||||
//- Reference to the region objectRegistry
|
||||
const objectRegistry& obr_;
|
||||
|
||||
@ -86,7 +83,7 @@ protected:
|
||||
template<class ObjectType>
|
||||
bool store
|
||||
(
|
||||
word& fieldName,
|
||||
const word& fieldName,
|
||||
const tmp<ObjectType>& tfield,
|
||||
bool cacheable = false
|
||||
);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -51,7 +51,7 @@ const ObjectType& Foam::functionObjects::regionFunctionObject::lookupObject
|
||||
template<class ObjectType>
|
||||
bool Foam::functionObjects::regionFunctionObject::store
|
||||
(
|
||||
word& fieldName,
|
||||
const word& fieldName,
|
||||
const tmp<ObjectType>& tfield,
|
||||
bool cacheable
|
||||
)
|
||||
@ -68,16 +68,9 @@ bool Foam::functionObjects::regionFunctionObject::store
|
||||
return false;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
fieldName.size()
|
||||
&& obr_.foundObject<ObjectType>(fieldName)
|
||||
)
|
||||
if (fieldName.size() && foundObject<ObjectType>(fieldName))
|
||||
{
|
||||
const ObjectType& field =
|
||||
(
|
||||
obr_.lookupObject<ObjectType>(fieldName)
|
||||
);
|
||||
const ObjectType& field = lookupObject<ObjectType>(fieldName);
|
||||
|
||||
// If there is a result field already registered assign to the new
|
||||
// result field otherwise transfer ownership of the new result field to
|
||||
@ -97,10 +90,6 @@ bool Foam::functionObjects::regionFunctionObject::store
|
||||
{
|
||||
tfield.ref().rename(fieldName);
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldName = tfield().name();
|
||||
}
|
||||
|
||||
obr_.objectRegistry::store(tfield.ptr());
|
||||
}
|
||||
|
||||
@ -23,79 +23,71 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "functionObjectState.H"
|
||||
#include "stateFunctionObject.H"
|
||||
#include "Time.H"
|
||||
|
||||
const Foam::word Foam::functionObjectState::resultsName_ = "results";
|
||||
const Foam::word Foam::functionObjects::stateFunctionObject::resultsName_ =
|
||||
"results";
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
const Foam::IOdictionary& Foam::functionObjectState::stateDict() const
|
||||
const Foam::IOdictionary&
|
||||
Foam::functionObjects::stateFunctionObject::stateDict() const
|
||||
{
|
||||
return obr_.time().functionObjects().stateDict();
|
||||
return time_.functionObjects().stateDict();
|
||||
}
|
||||
|
||||
|
||||
Foam::IOdictionary& Foam::functionObjectState::stateDict()
|
||||
Foam::IOdictionary& Foam::functionObjects::stateFunctionObject::stateDict()
|
||||
{
|
||||
return const_cast<IOdictionary&>(obr_.time().functionObjects().stateDict());
|
||||
return const_cast<IOdictionary&>(time_.functionObjects().stateDict());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjectState::functionObjectState
|
||||
Foam::functionObjects::stateFunctionObject::stateFunctionObject
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const word& name
|
||||
const word& name,
|
||||
const Time& runTime
|
||||
)
|
||||
:
|
||||
obr_(obr),
|
||||
name_(name),
|
||||
active_(true)
|
||||
functionObject(name),
|
||||
time_(runTime)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjectState::~functionObjectState()
|
||||
Foam::functionObjects::stateFunctionObject::~stateFunctionObject()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::word& Foam::functionObjectState::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjectState::active() const
|
||||
{
|
||||
return active_;
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary& Foam::functionObjectState::propertyDict()
|
||||
Foam::dictionary& Foam::functionObjects::stateFunctionObject::propertyDict()
|
||||
{
|
||||
IOdictionary& stateDict = this->stateDict();
|
||||
|
||||
if (!stateDict.found(name_))
|
||||
if (!stateDict.found(name()))
|
||||
{
|
||||
stateDict.add(name_, dictionary());
|
||||
stateDict.add(name(), dictionary());
|
||||
}
|
||||
|
||||
return stateDict.subDict(name_);
|
||||
return stateDict.subDict(name());
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjectState::foundProperty(const word& entryName) const
|
||||
bool Foam::functionObjects::stateFunctionObject::foundProperty
|
||||
(
|
||||
const word& entryName
|
||||
) const
|
||||
{
|
||||
const IOdictionary& stateDict = this->stateDict();
|
||||
|
||||
if (stateDict.found(name_))
|
||||
if (stateDict.found(name()))
|
||||
{
|
||||
const dictionary& baseDict = stateDict.subDict(name_);
|
||||
const dictionary& baseDict = stateDict.subDict(name());
|
||||
return baseDict.found(entryName);
|
||||
}
|
||||
|
||||
@ -103,13 +95,16 @@ bool Foam::functionObjectState::foundProperty(const word& entryName) const
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::functionObjectState::resultType(const word& entryName) const
|
||||
Foam::word Foam::functionObjects::stateFunctionObject::resultType
|
||||
(
|
||||
const word& entryName
|
||||
) const
|
||||
{
|
||||
return objectResultType(name_, entryName);
|
||||
return objectResultType(name(), entryName);
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::functionObjectState::objectResultType
|
||||
Foam::word Foam::functionObjects::stateFunctionObject::objectResultType
|
||||
(
|
||||
const word& objectName,
|
||||
const word& entryName
|
||||
@ -142,13 +137,15 @@ Foam::word Foam::functionObjectState::objectResultType
|
||||
}
|
||||
|
||||
|
||||
Foam::List<Foam::word> Foam::functionObjectState::objectResultEntries() const
|
||||
Foam::List<Foam::word>
|
||||
Foam::functionObjects::stateFunctionObject::objectResultEntries() const
|
||||
{
|
||||
return objectResultEntries(name_);
|
||||
return objectResultEntries(name());
|
||||
}
|
||||
|
||||
|
||||
Foam::List<Foam::word> Foam::functionObjectState::objectResultEntries
|
||||
Foam::List<Foam::word> Foam::functionObjects::stateFunctionObject::
|
||||
objectResultEntries
|
||||
(
|
||||
const word& objectName
|
||||
) const
|
||||
@ -29,60 +29,67 @@ Description
|
||||
information (data required for smooth restart behaviour) and results
|
||||
to/from the state dictionary
|
||||
|
||||
See Also
|
||||
Note: cannot access the state dictionary until after construction of the
|
||||
function objects, since the owner container functionObjectList is owned
|
||||
by time, and time owns the state dictionary. I.e. need to wait for time
|
||||
to be fully consttucted.
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
|
||||
SourceFiles
|
||||
functionObjectState.C
|
||||
stateFunctionObject.C
|
||||
stateFunctionObjectTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjectState_H
|
||||
#define functionObjectState_H
|
||||
#ifndef functionObjects_stateFunctionObject_H
|
||||
#define functionObjects_stateFunctionObject_H
|
||||
|
||||
#include "objectRegistry.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "functionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class IOdictionary;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class functionObjectState Declaration
|
||||
Class stateFunctionObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class functionObjectState
|
||||
class stateFunctionObject
|
||||
:
|
||||
public functionObject
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
// Private member data
|
||||
|
||||
//- Name of the results dictionary
|
||||
static const word resultsName_;
|
||||
|
||||
//- Reference to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
functionObjectState(const functionObjectState&);
|
||||
stateFunctionObject(const stateFunctionObject&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const functionObjectState&);
|
||||
void operator=(const stateFunctionObject&) = delete;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
// Protected Member Data
|
||||
|
||||
//- Name of model
|
||||
const word name_;
|
||||
|
||||
//- Flag to indicate whether the object is active
|
||||
bool active_;
|
||||
//- Reference to the time database
|
||||
const Time& time_;
|
||||
|
||||
|
||||
// Protacted Member Functions
|
||||
@ -100,29 +107,18 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
functionObjectState(const objectRegistry& obr, const word& name);
|
||||
stateFunctionObject(const word& name, const Time& runTime);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~functionObjectState();
|
||||
~stateFunctionObject();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the name
|
||||
const word& name() const;
|
||||
|
||||
//- Return the active flag
|
||||
bool active() const;
|
||||
|
||||
//- Return access to the property dictionary
|
||||
dictionary& propertyDict();
|
||||
|
||||
//- Set the active status by querying objectRegistry type
|
||||
// returns new active status
|
||||
template<class Type>
|
||||
bool setActive();
|
||||
|
||||
|
||||
// Properties
|
||||
|
||||
@ -238,12 +234,13 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "functionObjectStateTemplates.C"
|
||||
#include "stateFunctionObjectTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -23,28 +23,12 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IOdictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::functionObjectState::setActive()
|
||||
{
|
||||
active_ = true;
|
||||
|
||||
if (!isA<Type>(obr_))
|
||||
{
|
||||
WarningInFunction
|
||||
<< "No " << Type::typeName << " available, deactivating " << name_
|
||||
<< endl;
|
||||
|
||||
active_ = false;
|
||||
}
|
||||
|
||||
return active_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::functionObjectState::getProperty
|
||||
Type Foam::functionObjects::stateFunctionObject::getProperty
|
||||
(
|
||||
const word& entryName,
|
||||
const Type& defaultValue
|
||||
@ -57,29 +41,29 @@ Type Foam::functionObjectState::getProperty
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjectState::getProperty
|
||||
void Foam::functionObjects::stateFunctionObject::getProperty
|
||||
(
|
||||
const word& entryName,
|
||||
Type& value
|
||||
) const
|
||||
{
|
||||
getObjectProperty(name_, entryName, value);
|
||||
getObjectProperty(name(), entryName, value);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjectState::setProperty
|
||||
void Foam::functionObjects::stateFunctionObject::setProperty
|
||||
(
|
||||
const word& entryName,
|
||||
const Type& value
|
||||
)
|
||||
{
|
||||
setObjectProperty(name_, entryName, value);
|
||||
setObjectProperty(name(), entryName, value);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::functionObjectState::getObjectProperty
|
||||
Type Foam::functionObjects::stateFunctionObject::getObjectProperty
|
||||
(
|
||||
const word& objectName,
|
||||
const word& entryName,
|
||||
@ -93,7 +77,7 @@ Type Foam::functionObjectState::getObjectProperty
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjectState::getObjectProperty
|
||||
void Foam::functionObjects::stateFunctionObject::getObjectProperty
|
||||
(
|
||||
const word& objectName,
|
||||
const word& entryName,
|
||||
@ -121,7 +105,7 @@ void Foam::functionObjectState::getObjectProperty
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjectState::setObjectProperty
|
||||
void Foam::functionObjects::stateFunctionObject::setObjectProperty
|
||||
(
|
||||
const word& objectName,
|
||||
const word& entryName,
|
||||
@ -141,18 +125,18 @@ void Foam::functionObjectState::setObjectProperty
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjectState::setResult
|
||||
void Foam::functionObjects::stateFunctionObject::setResult
|
||||
(
|
||||
const word& entryName,
|
||||
const Type& value
|
||||
)
|
||||
{
|
||||
setObjectResult(name_, entryName, value);
|
||||
setObjectResult(name(), entryName, value);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjectState::setObjectResult
|
||||
void Foam::functionObjects::stateFunctionObject::setObjectResult
|
||||
(
|
||||
const word& objectName,
|
||||
const word& entryName,
|
||||
@ -170,7 +154,7 @@ void Foam::functionObjectState::setObjectResult
|
||||
|
||||
if (!resultsDict.found(objectName))
|
||||
{
|
||||
resultsDict.add(name_, dictionary());
|
||||
resultsDict.add(name(), dictionary());
|
||||
}
|
||||
|
||||
dictionary& objectDict = resultsDict.subDict(objectName);
|
||||
@ -189,18 +173,18 @@ void Foam::functionObjectState::setObjectResult
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::functionObjectState::getResult
|
||||
Type Foam::functionObjects::stateFunctionObject::getResult
|
||||
(
|
||||
const word& entryName,
|
||||
const Type& defaultValue
|
||||
) const
|
||||
{
|
||||
return getObjectResult(name_, entryName, defaultValue);
|
||||
return getObjectResult(name(), entryName, defaultValue);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::functionObjectState::getObjectResult
|
||||
Type Foam::functionObjects::stateFunctionObject::getObjectResult
|
||||
(
|
||||
const word& objectName,
|
||||
const word& entryName,
|
||||
@ -214,7 +198,7 @@ Type Foam::functionObjectState::getObjectResult
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjectState::getObjectResult
|
||||
void Foam::functionObjects::stateFunctionObject::getObjectResult
|
||||
(
|
||||
const word& objectName,
|
||||
const word& entryName,
|
||||
@ -60,6 +60,7 @@ public:
|
||||
ocAdjustableRunTime, //!< Adjust time step for execution
|
||||
ocRunTime, //!< run time for execution
|
||||
ocClockTime, //!< clock time for execution
|
||||
ocCpuTime, //!< CPU time for execution
|
||||
ocOnEnd, //!< on end of run
|
||||
ocNone //!< no execution
|
||||
};
|
||||
|
||||
@ -93,7 +93,7 @@ Foam::autoPtr<Foam::OFstream> Foam::functionObjects::writeFile::createFile
|
||||
if (Pstream::master() && writeToFile_)
|
||||
{
|
||||
const word startTimeName =
|
||||
obr_.time().timeName(obr_.time().startTime().value());
|
||||
fileObr_.time().timeName(fileObr_.time().startTime().value());
|
||||
|
||||
fileName outputDir(baseFileDir()/prefix_/startTimeName);
|
||||
|
||||
@ -105,7 +105,7 @@ Foam::autoPtr<Foam::OFstream> Foam::functionObjects::writeFile::createFile
|
||||
IFstream is(outputDir/(fName + ".dat"));
|
||||
if (is.good())
|
||||
{
|
||||
fName = fName + "_" + obr_.time().timeName();
|
||||
fName = fName + "_" + fileObr_.time().timeName();
|
||||
}
|
||||
|
||||
osPtr.set(new OFstream(outputDir/(fName + ".dat")));
|
||||
|
||||
@ -40,6 +40,7 @@ SourceFiles
|
||||
#define functionObjects_writeFile_H
|
||||
|
||||
#include "objectRegistry.H"
|
||||
#include "OFstream.H"
|
||||
#include "IOmanip.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -129,7 +130,8 @@ public:
|
||||
const word& prefix
|
||||
);
|
||||
|
||||
//- Construct from components and read options from dictionary
|
||||
//- Construct from objectRegistry and prefix, and read options
|
||||
// from dictionary
|
||||
writeFile
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
@ -151,6 +153,12 @@ public:
|
||||
//- Return access to the file (if only 1)
|
||||
OFstream& file();
|
||||
|
||||
//- Flag to allow writing to file
|
||||
bool writeToFile() const;
|
||||
|
||||
//- Return width of character stream output
|
||||
label charWidth() const;
|
||||
|
||||
//- Write a commented string to stream
|
||||
void writeCommented(Ostream& os, const string& str) const;
|
||||
|
||||
@ -171,9 +179,6 @@ public:
|
||||
const string& property,
|
||||
const Type& value
|
||||
) const;
|
||||
|
||||
//- Return width of character stream output
|
||||
label charWidth() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user