diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index 59d09611e5f07cd15e91766d47158a0f82e73073..b1a67daf3088a0acaaa0e452db4a554f07475462 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -468,6 +468,7 @@ Foam::Time::Time ( args.parRunControl().parRun(), args.rootPath(), + args.distributed(), args.globalCaseName(), args.caseName(), systemName, diff --git a/src/OpenFOAM/db/Time/TimePaths.C b/src/OpenFOAM/db/Time/TimePaths.C index ae5b5d182f9ba19f7107730c5429ac50ab7b92d5..05126252c6d3943f347a7a718a92d74c3f6f815e 100644 --- a/src/OpenFOAM/db/Time/TimePaths.C +++ b/src/OpenFOAM/db/Time/TimePaths.C @@ -70,6 +70,7 @@ Foam::TimePaths::TimePaths : processorCase_(false), rootPath_(rootPath), + distributed_(false), globalCaseName_(caseName), case_(caseName), system_(systemName), @@ -84,6 +85,7 @@ Foam::TimePaths::TimePaths ( const bool processorCase, const fileName& rootPath, + const bool distributed, const fileName& globalCaseName, const fileName& caseName, const word& systemName, @@ -92,6 +94,7 @@ Foam::TimePaths::TimePaths : processorCase_(processorCase), rootPath_(rootPath), + distributed_(distributed), globalCaseName_(globalCaseName), case_(caseName), system_(systemName), diff --git a/src/OpenFOAM/db/Time/TimePaths.H b/src/OpenFOAM/db/Time/TimePaths.H index f7bbc25d2956b6f1a9f41ef5790061f8c2d27f7c..32674008b2382d39b083b56172046c97125a41ff 100644 --- a/src/OpenFOAM/db/Time/TimePaths.H +++ b/src/OpenFOAM/db/Time/TimePaths.H @@ -53,6 +53,7 @@ class TimePaths bool processorCase_; const fileName rootPath_; + bool distributed_; fileName globalCaseName_; fileName case_; const word system_; @@ -84,6 +85,7 @@ public: ( const bool processorCase, const fileName& rootPath, + const bool distributed, const fileName& globalCaseName, const fileName& caseName, const word& systemName, @@ -139,6 +141,13 @@ public: return constant_; } + //- Is case running with parallel distributed directories + // (i.e. not NFS mounted) + bool distributed() const + { + return distributed_; + } + //- Return constant name for the case // which for parallel runs returns ../constant() fileName caseConstant() const; diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 1139bbb8f163d9d931f6eeb67c94950e9f72e56e..264d75d2e10c20bcb5b3b3a8fe9c2bea4e3c58b8 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -429,7 +429,8 @@ Foam::argList::argList ) : args_(argc), - options_(argc) + options_(argc), + distributed_(false) { // Check if this run is a parallel run by searching for any parallel option // If found call runPar which might filter argv @@ -669,6 +670,7 @@ void Foam::argList::parse label dictNProcs = -1; if (options_.found("roots")) { + distributed_ = true; source = "-roots"; IStringStream is(options_["roots"]); roots = readList<fileName>(is); @@ -700,7 +702,7 @@ void Foam::argList::parse decompDict.lookup("numberOfSubdomains") ); - if (decompDict.lookupOrDefault("distributed", false)) + if (decompDict.lookupOrDefault("distributed", distributed_)) { decompDict.lookup("roots") >> roots; } @@ -771,7 +773,7 @@ void Foam::argList::parse options_.set("case", roots[slave-1]/globalCase_); OPstream toSlave(Pstream::scheduled, slave); - toSlave << args_ << options_; + toSlave << args_ << options_ << roots.size(); } options_.erase("case"); @@ -818,7 +820,7 @@ void Foam::argList::parse ) { OPstream toSlave(Pstream::scheduled, slave); - toSlave << args_ << options_; + toSlave << args_ << options_ << roots.size(); } } } @@ -826,7 +828,7 @@ void Foam::argList::parse { // Collect the master's argument list IPstream fromMaster(Pstream::scheduled, Pstream::masterNo()); - fromMaster >> args_ >> options_; + fromMaster >> args_ >> options_ >> distributed_; // Establish rootPath_/globalCase_/case_ for slave getRootCase(); diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index f2635744536ebd549396349718072010a139345f..8ff04458c4d5ea5d0aac0bbe87bad80313d8c715 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -109,6 +109,7 @@ class argList word executable_; fileName rootPath_; + bool distributed_; fileName globalCase_; fileName case_; string argListStr_; @@ -221,6 +222,10 @@ public: //- Return root path inline const fileName& rootPath() const; + //- Return distributed flag (i.e. are rootPaths different on + // different machines) + inline bool distributed() const; + //- Return case name (parallel run) or global case (serial run) inline const fileName& caseName() const; diff --git a/src/OpenFOAM/global/argList/argListI.H b/src/OpenFOAM/global/argList/argListI.H index 47ad29a58eb208a5c21b44b6e2ade8336b5e2fd4..28caff6acbcd561a0928471a13fae7aa6c59e364 100644 --- a/src/OpenFOAM/global/argList/argListI.H +++ b/src/OpenFOAM/global/argList/argListI.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,6 +39,12 @@ inline const Foam::fileName& Foam::argList::rootPath() const } +inline bool Foam::argList::distributed() const +{ + return distributed_; +} + + inline const Foam::fileName& Foam::argList::caseName() const { return case_; diff --git a/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C b/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C index cd74fc9ae10cbd42a34b63f906a16702d3ab873a..ed48e24fcf45620d36a88ab4cdfdc6e0b151780c 100644 --- a/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C +++ b/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C @@ -67,11 +67,14 @@ void Foam::functionObjects::timeActivatedFileUpdate::updateFile() Log << nl << type() << ": copying file" << nl << timeVsFile_[i].second() << nl << "to:" << nl << fileToUpdate_ << nl << endl; - fileName destFile(fileToUpdate_ + Foam::name(pid())); - cp(timeVsFile_[i].second(), destFile); - mv(destFile, fileToUpdate_); + if (Pstream::master() || time_.distributed()) + { + // Slaves do not copy if running non-distributed + fileName destFile(fileToUpdate_ + Foam::name(pid())); + cp(timeVsFile_[i].second(), destFile); + mv(destFile, fileToUpdate_); + } lastIndex_ = i; - modified_ = true; } }