ENH: stricter handling of missing timeActivatedFileUpdate files (#2573)

- previously threw FatalError, which downgrades to a Warning only when
  loading the functionObject. Now throw a FatalIOError so that missing
  control files are treated as a critical error.
This commit is contained in:
Mark Olesen
2022-09-05 16:17:49 +02:00
parent 2a9e68c2bf
commit c624590e26
2 changed files with 19 additions and 13 deletions

View File

@ -77,7 +77,7 @@ void Foam::functionObjects::timeActivatedFileUpdate::updateFile()
if (Pstream::master() || time_.distributed()) if (Pstream::master() || time_.distributed())
{ {
// Slaves do not copy if running non-distributed // Copy on master only for non-distributed
fileName tmpFile(fileToUpdate_ + Foam::name(pid())); fileName tmpFile(fileToUpdate_ + Foam::name(pid()));
Foam::cp(srcFile, tmpFile); Foam::cp(srcFile, tmpFile);
Foam::mv(tmpFile, fileToUpdate_); Foam::mv(tmpFile, fileToUpdate_);
@ -98,7 +98,7 @@ Foam::functionObjects::timeActivatedFileUpdate::timeActivatedFileUpdate
) )
: :
timeFunctionObject(name, runTime), timeFunctionObject(name, runTime),
fileToUpdate_("unknown-fileToUpdate"), fileToUpdate_(),
timeVsFile_(), timeVsFile_(),
lastIndex_(-1), lastIndex_(-1),
modified_(false) modified_(false)
@ -122,26 +122,33 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read
lastIndex_ = -1; lastIndex_ = -1;
fileToUpdate_.expand(); fileToUpdate_.expand();
Info<< type() << " " << name() << " output:" << nl if (fileToUpdate_.empty() || timeVsFile_.empty())
<< " time vs file list:" << endl;
forAll(timeVsFile_, i)
{ {
timeVsFile_[i].second().expand(); FatalIOErrorInFunction(dict)
const fileName& srcFile = timeVsFile_[i].second(); << "Bad entries for fileToUpdate and/or timeVsFile" << endl
<< exit(FatalIOError);
}
Info<< type() << " " << name() << " output:" << nl
<< " time vs file list:" << nl;
for (auto& tuple : timeVsFile_)
{
fileName& srcFile = tuple.second();
srcFile.expand();
// Report case-relative path for information // Report case-relative path for information
Info<< " " << timeVsFile_[i].first() << tab Info<< " " << tuple.first() << tab
<< time_.relativePath(srcFile, true) << endl; << time_.relativePath(srcFile, true) << nl;
if (Pstream::master() || time_.distributed()) if (Pstream::master() || time_.distributed())
{ {
if (!Foam::isFile(srcFile)) if (!Foam::isFile(srcFile))
{ {
// Report full path on error // Report full path on error
FatalErrorInFunction FatalIOErrorInFunction(dict)
<< "File not found: " << srcFile << endl << "File not found: " << srcFile << endl
<< exit(FatalError); << exit(FatalIOError);
} }
} }
} }

View File

@ -74,7 +74,6 @@ SourceFiles
#include "timeFunctionObject.H" #include "timeFunctionObject.H"
#include "Tuple2.H" #include "Tuple2.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //