mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: enable 'status=done' when finishing an externalCoupled FO
- This provides a mechanism for the external code to detect when OpenFOAM is done. - Adjust tutorial to use the mechanism. Also test in parallel.
This commit is contained in:
@ -82,6 +82,7 @@ Description
|
||||
log yes;
|
||||
commsDir "${FOAM_CASE}/comms";
|
||||
initByExternal yes;
|
||||
stateEnd remove; // (remove | done)
|
||||
|
||||
regions
|
||||
{
|
||||
@ -122,9 +123,11 @@ SourceFiles
|
||||
#include "DynamicList.H"
|
||||
#include "wordReList.H"
|
||||
#include "scalarField.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "Switch.H"
|
||||
#include "UPtrList.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -145,6 +148,23 @@ class externalCoupledFunctionObject
|
||||
:
|
||||
public functionObject
|
||||
{
|
||||
public:
|
||||
|
||||
// Public data types
|
||||
|
||||
//- Lockfile state on termination
|
||||
enum stateEnd
|
||||
{
|
||||
REMOVE, //!< Remove lock file on end
|
||||
DONE //!< Lock file contains status=done on end
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
//- State end names
|
||||
static const NamedEnum<stateEnd, 2> stateEndNames_;
|
||||
|
||||
|
||||
// Private data
|
||||
|
||||
//- Reference to the time database
|
||||
@ -168,6 +188,9 @@ class externalCoupledFunctionObject
|
||||
//- Flag to indicate values are initialised by external application
|
||||
bool initByExternal_;
|
||||
|
||||
//- Lockfile state on termination
|
||||
stateEnd stateEnd_;
|
||||
|
||||
//- Log flag
|
||||
bool log_;
|
||||
|
||||
@ -209,11 +232,15 @@ class externalCoupledFunctionObject
|
||||
//- Return the file path to the lock file
|
||||
fileName lockFile() const;
|
||||
|
||||
//- Create lock file
|
||||
void createLockFile() const;
|
||||
|
||||
//- Remove lock file
|
||||
void removeLockFile() const;
|
||||
//- Create lock file to indicate that OpenFOAM is in charge
|
||||
void useMaster() const;
|
||||
|
||||
//- Remove lock file to indicate that the external program is in charge
|
||||
void useSlave() const;
|
||||
|
||||
//- Remove lock file or status=done in lock.
|
||||
void cleanup() const;
|
||||
|
||||
//- Remove files written by OpenFOAM
|
||||
void removeWriteFiles() const;
|
||||
@ -221,8 +248,9 @@ class externalCoupledFunctionObject
|
||||
//- Remove files written by external code
|
||||
void removeReadFiles() const;
|
||||
|
||||
//- Wait for response from external source
|
||||
void wait() const;
|
||||
//- Wait for indication that the external program has supplied input
|
||||
// (ie, for the lock file to reappear).
|
||||
void waitForSlave() const;
|
||||
|
||||
|
||||
//- Read data for a single region, single field
|
||||
|
||||
Reference in New Issue
Block a user