mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: respond to externalCoupled lock file contents
- waitForSlave now return a Time::stopAtControls enumeration:
unknown: when lockfile has no specially recognized content.
endTime: when lockfile contains "status=done"
writeNow: when lockfile contains "action=writeNow"
nextWrite: when lockfile contains "action=nextWrite"
noWriteNow: when lockfile contains "action=noWriteNow"
These values can be used by the caller to terminate the master
(OpenFOAM) as desired in response to information placed there by the
slave process.
This commit is contained in:
@ -460,6 +460,42 @@ void Foam::functionObjects::externalCoupled::initCoupling()
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::externalCoupled::performCoupling()
|
||||
{
|
||||
// Ensure coupling has been initialised
|
||||
initCoupling();
|
||||
|
||||
// Write data for external source
|
||||
writeDataMaster();
|
||||
|
||||
// Signal external source to execute (by removing lock file)
|
||||
// - Wait for slave to provide data
|
||||
useSlave();
|
||||
|
||||
// Wait for response - and catch any abort information sent from slave
|
||||
const auto action = waitForSlave();
|
||||
|
||||
// Remove old data files from OpenFOAM
|
||||
removeDataMaster();
|
||||
|
||||
// Read data passed back from external source
|
||||
readDataMaster();
|
||||
|
||||
// Signal external source to wait (by creating the lock file)
|
||||
useMaster();
|
||||
|
||||
// Process any abort information sent from slave
|
||||
if
|
||||
(
|
||||
action != time_.stopAt()
|
||||
&& action != Time::stopAtControls::saUnknown
|
||||
)
|
||||
{
|
||||
time_.stopAt(action);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::externalCoupled::externalCoupled
|
||||
@ -483,46 +519,16 @@ Foam::functionObjects::externalCoupled::externalCoupled
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::externalCoupled::~externalCoupled()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::externalCoupled::execute()
|
||||
{
|
||||
if (!initialisedCoupling_ || time_.timeIndex() % calcFrequency_ == 0)
|
||||
{
|
||||
// Initialise the coupling
|
||||
initCoupling();
|
||||
|
||||
// Write data for external source
|
||||
writeDataMaster();
|
||||
|
||||
// Signal external source to execute (by removing lock file)
|
||||
// - Wait for slave to provide data
|
||||
useSlave();
|
||||
|
||||
// Wait for response
|
||||
waitForSlave();
|
||||
|
||||
// Remove old data files from OpenFOAM
|
||||
removeDataMaster();
|
||||
|
||||
// Read data passed back from external source
|
||||
readDataMaster();
|
||||
|
||||
// Signal external source to wait (by creating the lock file)
|
||||
useMaster();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
performCoupling();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -282,6 +282,9 @@ private:
|
||||
|
||||
static void checkOrder(const wordList& regionNames);
|
||||
|
||||
//- Perform the coupling with necessary initialization etc.
|
||||
void performCoupling();
|
||||
|
||||
//- Disallow default bitwise copy constructor
|
||||
externalCoupled(const externalCoupled&) = delete;
|
||||
|
||||
@ -313,7 +316,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~externalCoupled();
|
||||
virtual ~externalCoupled() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
Reference in New Issue
Block a user