mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
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:
@ -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()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user