diff --git a/applications/test/externalFileCoupler/Allclean b/applications/test/externalFileCoupler/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..ad4e6f330131860a9e55f5bc048d38d7e3e853a5 --- /dev/null +++ b/applications/test/externalFileCoupler/Allclean @@ -0,0 +1,10 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +#------------------------------------------------------------------------------ + +# Remove old junk +rm -f comms/OpenFOAM.lock + +rmdir comms + +#------------------------------------------------------------------------------ diff --git a/applications/test/externalFileCoupler/Allrun b/applications/test/externalFileCoupler/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..e5557cc1581ba2984630d71ca5c308e50ba15923 --- /dev/null +++ b/applications/test/externalFileCoupler/Allrun @@ -0,0 +1,20 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +#------------------------------------------------------------------------------ + +# Cleanup old junk that may prevent things from starting +rm -f comms/OpenFOAM.lock + +# If this exits prematurely, trigger the external solver to stop +trap '[ -e comms/OpenFOAM.lock ] && echo "status=done" > comms/OpenFOAM.lock' EXIT TERM INT + +Test-externalFileCoupler -slave -max 50 & + +Test-externalFileCoupler -max 25 + +# Give some time for the slave to find updated file +sleep 2 + +[ -d comms ] && echo "status=done" > comms/OpenFOAM.lock + +#------------------------------------------------------------------------------ diff --git a/applications/test/externalFileCoupler/Make/options b/applications/test/externalFileCoupler/Make/options index fa15f124528ebfcaf279a88a73a0d7954f2e9dc1..54c035b8f55d183c1ad02bc372398feceaf31718 100644 --- a/applications/test/externalFileCoupler/Make/options +++ b/applications/test/externalFileCoupler/Make/options @@ -1,5 +1,5 @@ EXE_INC = \ - -I$(LIB_SRC)/finiteVolume/lnInclude + -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = \ - -lfiniteVolume + -lmeshTools diff --git a/applications/test/externalFileCoupler/Test-externalFileCoupler.C b/applications/test/externalFileCoupler/Test-externalFileCoupler.C index c90e766aacb65591c7da7c0e48d14be18fe2a136..65edbddeb09818eefd021945e1e2ff80a8f8b669 100644 --- a/applications/test/externalFileCoupler/Test-externalFileCoupler.C +++ b/applications/test/externalFileCoupler/Test-externalFileCoupler.C @@ -28,6 +28,7 @@ Application Description Test of master/slave communication etc. + \*---------------------------------------------------------------------------*/ #include "argList.H" @@ -41,55 +42,78 @@ using namespace Foam; int main(int argc, char *argv[]) { + argList::noBanner(); argList::noParallel(); + argList::addOption("sleep", "N", "sleep to add between calls"); argList::addOption("max", "N", "max number of calls (default: 1000)"); argList::addBoolOption("slave", "run as slave"); #include "setRootCase.H" const label maxCount = args.getOrDefault<label>("max", 1000); + const label sleeping = args.getOrDefault<label>("sleep", 0); externalFileCoupler coupler; if (args.found("slave")) { const word role = "slave"; - Info<< "Running as " << role << " max=" << maxCount << endl; + const word other = "master"; + Info<< "Running as " << role << " max=" << maxCount + << " (sleep " << sleeping << ')' << endl; for (label count = 0; count < maxCount; ++count) { // Wait for master, but stop if status=done was seen + Info<< role << '[' << count << "] wait for " << other << endl; - Info<< role << ": waiting for master" << endl; if (!coupler.waitForMaster()) { Info<< role << ": stopping. status=done was detected" << endl; break; } - Info<< role << ": switch to master" << endl; + if (sleeping) + { + sleep(sleeping); + } + + // Info<< role << ": switch to " << other << endl; coupler.useMaster(); } + + Info<< role << ": exiting" << endl; } else { const word role = "master"; - Info<< "Running as " << role << " max=" << maxCount << endl; + const word other = "slave"; + Info<< "Running as " << role << " max=" << maxCount + << " (sleep " << sleeping << ')' << endl; for (label count = 0; count < maxCount; ++count) { // Wait for slave, but stop if status=done was seen - Info<< role << ": waiting for slave" << endl; + Info<< role << '[' << count << "] wait for " << other << endl; + if (!coupler.waitForSlave()) { Info<< role << ": stopping. status=done was detected" << endl; break; } - Info<< role << ": switch to slave" << endl; + if (sleeping) + { + sleep(sleeping); + } + + // Info<< role << ": switch to " << other << endl; coupler.useSlave(); } + + // shudown - slave should notice and terminate + Info<< role << ": exiting" << endl; } return 0; diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 6a0bf5c8fa791c11e0ff223eab504b82fb343f96..7ef61600d63173dee88bae7766a4b22f01d6c03e 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -471,9 +471,6 @@ $(general)/pressureControl/pressureControl.C $(general)/levelSet/levelSet.C $(general)/meshObjects/gravity/gravityMeshObject.C -coupling = $(general)/coupling -$(coupling)/externalFileCoupler.C - solutionControl = $(general)/solutionControl $(solutionControl)/solutionControl/solutionControl.C $(solutionControl)/loopControl/loopControl.C diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index 1203f2e448feb4b71068111181aa893bad75ed80..a5f1aa4cd3979d731be74c07d227a960994cac5f 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -301,6 +301,8 @@ PatchFunction1/CodedField/makeCodedFields.C meshStructure/meshStructure.C +coupling/externalFileCoupler.C + output/foamVtkIndPatchWriter.C output/foamVtkInternalMeshWriter.C output/foamVtkPatchMeshWriter.C diff --git a/src/finiteVolume/cfdTools/general/coupling/externalFileCoupler.C b/src/meshTools/coupling/externalFileCoupler.C similarity index 100% rename from src/finiteVolume/cfdTools/general/coupling/externalFileCoupler.C rename to src/meshTools/coupling/externalFileCoupler.C diff --git a/src/finiteVolume/cfdTools/general/coupling/externalFileCoupler.H b/src/meshTools/coupling/externalFileCoupler.H similarity index 99% rename from src/finiteVolume/cfdTools/general/coupling/externalFileCoupler.H rename to src/meshTools/coupling/externalFileCoupler.H index c6008105f7bd009ab9dc235a62e1379b5cac18e6..599c0804b2dad1a1cb78ca8fae8538594bc837f3 100644 --- a/src/finiteVolume/cfdTools/general/coupling/externalFileCoupler.H +++ b/src/meshTools/coupling/externalFileCoupler.H @@ -290,7 +290,6 @@ public: //- Remove files written by OpenFOAM void removeDirectory() const; - }; diff --git a/src/finiteVolume/cfdTools/general/coupling/externalFileCouplerI.H b/src/meshTools/coupling/externalFileCouplerI.H similarity index 100% rename from src/finiteVolume/cfdTools/general/coupling/externalFileCouplerI.H rename to src/meshTools/coupling/externalFileCouplerI.H