STYLE: use 'statusDone' keyword for coupling (#1243)

This commit is contained in:
Mark Olesen
2019-03-22 08:00:01 +01:00
committed by Andrew Heather
parent ac646d48b7
commit 6301866a9c
3 changed files with 11 additions and 10 deletions

View File

@ -94,7 +94,7 @@ Foam::externalFileCoupler::externalFileCoupler()
: :
runState_(NONE), runState_(NONE),
commsDir_("<case>/comms"), commsDir_("<case>/comms"),
statusEnd_("done"), statusDone_("done"),
waitInterval_(1u), waitInterval_(1u),
timeOut_(100u), timeOut_(100u),
slaveFirst_(false), slaveFirst_(false),
@ -109,7 +109,7 @@ Foam::externalFileCoupler::externalFileCoupler(const fileName& commsDir)
: :
runState_(NONE), runState_(NONE),
commsDir_(commsDir), commsDir_(commsDir),
statusEnd_("done"), statusDone_("done"),
waitInterval_(1u), waitInterval_(1u),
timeOut_(100u), timeOut_(100u),
slaveFirst_(false), slaveFirst_(false),
@ -157,7 +157,7 @@ bool Foam::externalFileCoupler::readDict(const dictionary& dict)
dict.readEntry("commsDir", commsDir_); dict.readEntry("commsDir", commsDir_);
commsDir_.expand(); commsDir_.expand();
commsDir_.clean(); commsDir_.clean();
statusEnd_ = dict.lookupOrDefault<word>("shutdown", "done"); statusDone_ = dict.lookupOrDefault<word>("statusDone", "done");
slaveFirst_ = dict.lookupOrDefault("initByExternal", false); slaveFirst_ = dict.lookupOrDefault("initByExternal", false);
Info<< type() << ": initialize" << nl Info<< type() << ": initialize" << nl
@ -360,10 +360,10 @@ void Foam::externalFileCoupler::shutdown() const
{ {
if (Pstream::master() && runState_ == MASTER && Foam::isDir(commsDir_)) if (Pstream::master() && runState_ == MASTER && Foam::isDir(commsDir_))
{ {
Log << type() << ": lock file status=" << statusEnd_ << endl; Log << type() << ": lock file status=" << statusDone_ << endl;
std::ofstream os(lockFile()); std::ofstream os(lockFile());
os << "status=" << statusEnd_ << nl; os << "status=" << statusDone_ << nl;
} }
runState_ = DONE; // Avoid re-triggering in destructor runState_ = DONE; // Avoid re-triggering in destructor

View File

@ -8,7 +8,7 @@
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify i OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
@ -54,7 +54,7 @@ Description
waitInterval 1; waitInterval 1;
timeOut 100; timeOut 100;
initByExternal no; initByExternal no;
shutdown done; statusDone done;
} }
\endverbatim \endverbatim
@ -129,7 +129,7 @@ private:
fileName commsDir_; fileName commsDir_;
//- Value for "status=..." on termination //- Value for "status=..." on termination
word statusEnd_; word statusDone_;
//- Interval time between checking for return data [s] //- Interval time between checking for return data [s]
unsigned waitInterval_; unsigned waitInterval_;
@ -283,6 +283,7 @@ public:
//- Generate \c status=done in lock (only when run-state = master) //- Generate \c status=done in lock (only when run-state = master)
// The exact text can be specified via the statusDone keyword
void shutdown() const; void shutdown() const;
//- Remove files written by OpenFOAM //- Remove files written by OpenFOAM

View File

@ -88,7 +88,7 @@ Usage
log yes; log yes;
commsDir "<case>/comms"; commsDir "<case>/comms";
initByExternal yes; initByExternal yes;
shutdown done; // Any arbitrary status=... value statusDone done; // Any arbitrary status=... value
regions regions
{ {
@ -129,7 +129,7 @@ Usage
commsDir | Communication directory | yes | commsDir | Communication directory | yes |
waitInterval | wait interval in (s) | no | 1 waitInterval | wait interval in (s) | no | 1
timeOut | timeout in (s) | no | 100*waitInterval timeOut | timeout in (s) | no | 100*waitInterval
shutdown | Lockfile status=... on termination | no | done statusDone | Lockfile status=... on termination | no | done
initByExternal | Initialization values supplied by external app | yes initByExternal | Initialization values supplied by external app | yes
calcFrequency | Calculation frequency | no | 1 calcFrequency | Calculation frequency | no | 1
regions | The regions to couple | yes | regions | The regions to couple | yes |