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

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,14 +31,17 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(timeActivatedFileUpdate, 0);
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::timeActivatedFileUpdate::updateFile()
void Foam::functionObjects::timeActivatedFileUpdate::updateFile()
{
label i = lastIndex_;
while
@ -63,7 +66,7 @@ void Foam::timeActivatedFileUpdate::updateFile()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::timeActivatedFileUpdate::timeActivatedFileUpdate
Foam::functionObjects::timeActivatedFileUpdate::timeActivatedFileUpdate
(
const word& name,
const objectRegistry& obr,
@ -73,7 +76,6 @@ Foam::timeActivatedFileUpdate::timeActivatedFileUpdate
:
name_(name),
obr_(obr),
active_(true),
fileToUpdate_(dict.lookup("fileToUpdate")),
timeVsFile_(),
lastIndex_(-1)
@ -82,73 +84,75 @@ Foam::timeActivatedFileUpdate::timeActivatedFileUpdate
}
bool Foam::functionObjects::timeActivatedFileUpdate::viable
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
{
return true;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::timeActivatedFileUpdate::~timeActivatedFileUpdate()
Foam::functionObjects::timeActivatedFileUpdate::~timeActivatedFileUpdate()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::timeActivatedFileUpdate::read(const dictionary& dict)
void Foam::functionObjects::timeActivatedFileUpdate::read
(
const dictionary& dict
)
{
if (active_)
dict.lookup("fileToUpdate") >> fileToUpdate_;
dict.lookup("timeVsFile") >> timeVsFile_;
lastIndex_ = -1;
fileToUpdate_.expand();
Info<< type() << ": time vs file list:" << nl;
forAll(timeVsFile_, i)
{
dict.lookup("fileToUpdate") >> fileToUpdate_;
dict.lookup("timeVsFile") >> timeVsFile_;
lastIndex_ = -1;
fileToUpdate_.expand();
Info<< type() << ": time vs file list:" << nl;
forAll(timeVsFile_, i)
timeVsFile_[i].second() = timeVsFile_[i].second().expand();
if (!isFile(timeVsFile_[i].second()))
{
timeVsFile_[i].second() = timeVsFile_[i].second().expand();
if (!isFile(timeVsFile_[i].second()))
{
FatalErrorInFunction
<< "File: " << timeVsFile_[i].second() << " not found"
<< nl << exit(FatalError);
}
Info<< " " << timeVsFile_[i].first() << tab
<< timeVsFile_[i].second() << endl;
FatalErrorInFunction
<< "File: " << timeVsFile_[i].second() << " not found"
<< nl << exit(FatalError);
}
Info<< endl;
updateFile();
Info<< " " << timeVsFile_[i].first() << tab
<< timeVsFile_[i].second() << endl;
}
Info<< endl;
updateFile();
}
void Foam::timeActivatedFileUpdate::execute()
void Foam::functionObjects::timeActivatedFileUpdate::execute()
{
if (active_)
{
updateFile();
}
updateFile();
}
void Foam::timeActivatedFileUpdate::end()
void Foam::functionObjects::timeActivatedFileUpdate::end()
{
if (active_)
{
execute();
}
execute();
}
void Foam::timeActivatedFileUpdate::timeSet()
{
// Do nothing
}
void Foam::functionObjects::timeActivatedFileUpdate::timeSet()
{}
void Foam::timeActivatedFileUpdate::write()
{
// Do nothing
}
void Foam::functionObjects::timeActivatedFileUpdate::write()
{}
// ************************************************************************* //