diff --git a/applications/utilities/mesh/conversion/datToFoam/datToFoam.C b/applications/utilities/mesh/conversion/datToFoam/datToFoam.C index d79aa2b3b2..eff8da938f 100644 --- a/applications/utilities/mesh/conversion/datToFoam/datToFoam.C +++ b/applications/utilities/mesh/conversion/datToFoam/datToFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -116,7 +116,7 @@ int main(int argc, char *argv[]) pointField pointsWedge(nPointsij*2, Zero); - fileName pointsFile(runTime.constantPath()/"points.tmp"); + fileName pointsFile(runTime.path()/runTime.constant()/"points.tmp"); OFstream pFile(pointsFile); scalar a(degToRad(0.1)); diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 18d22cc1a3..de46509c74 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -516,17 +516,10 @@ void extractSurface MeshedSurface sortedFace(unsortedFace); - fileName globalCasePath - ( - runTime.processorCase() - ? runTime.path()/".."/outFileName - : runTime.path()/outFileName - ); - globalCasePath.clean(); + Info<< "Writing merged surface to " + << runTime.globalPath()/outFileName << endl; - Info<< "Writing merged surface to " << globalCasePath << endl; - - sortedFace.write(globalCasePath); + sortedFace.write(runTime.globalPath()/outFileName); } } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C index 87b1931c62..827ac5dea0 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C @@ -41,6 +41,7 @@ License #include "syncTools.H" #include "globalIndex.H" #include "PatchTools.H" +#include "writeFile.H" void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology) @@ -270,13 +271,11 @@ void Foam::mergeAndWrite fileName outputDir ( - set.time().path() - / (Pstream::parRun() ? ".." : "") - / "postProcessing" - / mesh.pointsInstance() - / set.name() + set.time().globalPath() + /functionObjects::writeFile::outputPrefix + /mesh.pointsInstance() + /set.name() ); - outputDir.clean(); mergeAndWrite(mesh, writer, set.name(), setPatch, outputDir); } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index e30bdced0d..7381ddc221 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -1248,10 +1248,10 @@ int main(int argc, char *argv[]) if (Pstream::parRun() && doLinks) { - mkDir(runTime.path()/".."/"VTK"); - chDir(runTime.path()/".."/"VTK"); + mkDir(runTime.globalPath()/"VTK"); + chDir(runTime.globalPath()/"VTK"); - Info<< "Linking all processor files to " << runTime.path()/".."/"VTK" + Info<< "Linking all processor files to " << runTime.globalPath()/"VTK" << endl; // Get list of vtk files @@ -1277,21 +1277,14 @@ int main(int argc, char *argv[]) if (exists(procFile)) { - string cmd + ln ( - "ln -s " - + procFile - + " " - + "processor" + procFile, + "processor" + name(Pstream::myProcNo()) + "_" + procFile.name() ); - if (system(cmd.c_str()) == -1) - { - WarningInFunction - << "Could not execute command " << cmd << endl; - } } } } diff --git a/applications/utilities/surface/surfaceFeatures/surfaceFeatures.C b/applications/utilities/surface/surfaceFeatures/surfaceFeatures.C index 610b12b90e..ed5dd9e264 100644 --- a/applications/utilities/surface/surfaceFeatures/surfaceFeatures.C +++ b/applications/utilities/surface/surfaceFeatures/surfaceFeatures.C @@ -182,7 +182,8 @@ namespace Foam triSurface surf ( - runTime.constantPath() + runTime.path() + /runTime.constant() /searchableSurface::geometryDir(runTime) /surfaceFileName ); @@ -493,7 +494,8 @@ namespace Foam vtkSurfaceWriter(runTime.writeFormat()).write ( - runTime.constantPath() + runTime.path() + /runTime.constant() /searchableSurface::geometryDir(runTime), searchSurf.objectRegistry::name(), searchSurf.points(), @@ -505,7 +507,8 @@ namespace Foam vtkSurfaceWriter(runTime.writeFormat()).write ( - runTime.constantPath() + runTime.path() + /runTime.constant() /searchableSurface::geometryDir(runTime), searchSurf.objectRegistry::name(), searchSurf.points(), @@ -561,7 +564,8 @@ namespace Foam vtkSurfaceWriter(runTime.writeFormat()).write ( - runTime.constantPath() + runTime.path() + /runTime.constant() /searchableSurface::geometryDir(runTime), searchSurf.objectRegistry::name(), searchSurf.points(), @@ -573,7 +577,8 @@ namespace Foam vtkSurfaceWriter(runTime.writeFormat()).write ( - runTime.constantPath() + runTime.path() + /runTime.constant() /searchableSurface::geometryDir(runTime), searchSurf.objectRegistry::name(), searchSurf.points(), @@ -612,7 +617,8 @@ namespace Foam { vtkSurfaceWriter(runTime.writeFormat()).write ( - runTime.constantPath() + runTime.path() + /runTime.constant() /searchableSurface::geometryDir(runTime), sFeatFileName, surf.points(), @@ -685,7 +691,8 @@ namespace Foam { vtkSurfaceWriter(runTime.writeFormat()).write ( - runTime.constantPath() + runTime.path() + /runTime.constant() /searchableSurface::geometryDir(runTime), sFeatFileName, surf.points(), diff --git a/applications/utilities/surface/surfaceMeshTriangulate/surfaceMeshTriangulate.C b/applications/utilities/surface/surfaceMeshTriangulate/surfaceMeshTriangulate.C index dcf9fbf10f..8f0058652e 100644 --- a/applications/utilities/surface/surfaceMeshTriangulate/surfaceMeshTriangulate.C +++ b/applications/utilities/surface/surfaceMeshTriangulate/surfaceMeshTriangulate.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -356,17 +356,10 @@ int main(int argc, char *argv[]) MeshedSurface sortedFace(unsortedFace); - fileName globalCasePath - ( - runTime.processorCase() - ? runTime.path()/".."/outFileName - : runTime.path()/outFileName - ); - globalCasePath.clean(); + Info<< "Writing merged surface to " + << runTime.globalPath()/outFileName << endl; - Info<< "Writing merged surface to " << globalCasePath << endl; - - sortedFace.write(globalCasePath); + sortedFace.write(runTime.globalPath()/outFileName); } Info<< "End\n" << endl; diff --git a/src/OpenFOAM/db/Time/Time.H b/src/OpenFOAM/db/Time/Time.H index 1aee1edb32..b37951e8f3 100644 --- a/src/OpenFOAM/db/Time/Time.H +++ b/src/OpenFOAM/db/Time/Time.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -252,29 +252,25 @@ public: // Database functions - //- Return root path - const fileName& rootPath() const - { - return TimePaths::rootPath(); - } + //- Explicitly inherit rootPath from TimePaths to disambiguate from + // the corresponding method in objectRegistry + using TimePaths::rootPath; - //- Return case name - const fileName& caseName() const - { - return TimePaths::caseName(); - } + //- Explicitly inherit caseName from TimePaths to disambiguate from + // the corresponding method in objectRegistry + using TimePaths::caseName; - //- Return path - fileName path() const - { - return rootPath()/caseName(); - } + //- Explicitly inherit path from TimePaths to disambiguate from + // the corresponding method in objectRegistry + using TimePaths::path; + //- Return the control dict const dictionary& controlDict() const { return controlDict_; } + //- Local directory path of this objectRegistry relative to time virtual const fileName& dbDir() const { return fileName::null; diff --git a/src/OpenFOAM/db/Time/TimePaths.H b/src/OpenFOAM/db/Time/TimePaths.H index b4950520e7..65c4536a67 100644 --- a/src/OpenFOAM/db/Time/TimePaths.H +++ b/src/OpenFOAM/db/Time/TimePaths.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,7 +46,6 @@ namespace Foam Class TimePaths Declaration \*---------------------------------------------------------------------------*/ - class TimePaths { // Private Data @@ -131,23 +130,17 @@ public: // which for parallel runs returns ../constant() fileName caseConstant() const; + //- Return the global path + fileName globalPath() const + { + return rootPath()/globalCaseName(); + } + //- Return path fileName path() const { return rootPath()/caseName(); } - - //- Return system path - fileName systemPath() const - { - return path()/system(); - } - - //- Return constant path - fileName constantPath() const - { - return path()/constant(); - } }; diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C index 42f07eca7b..55be78fc55 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -48,18 +48,7 @@ void Foam::functionObjects::writeFile::initStream(Ostream& os) const Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const { - fileName baseDir = fileObr_.time().path(); - - if (Pstream::parRun()) - { - // Put in undecomposed case (Note: gives problems for - // distributed data running) - baseDir = baseDir/".."/outputPrefix; - } - else - { - baseDir = baseDir/outputPrefix; - } + fileName baseDir = fileObr_.time().globalPath()/outputPrefix; // Append mesh name if not default region if (isA(fileObr_)) @@ -71,9 +60,6 @@ Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const } } - // Remove any ".." - baseDir.clean(); - return baseDir; } diff --git a/src/functionObjects/field/streamLine/streamLine.C b/src/functionObjects/field/streamLine/streamLine.C index 91b22a15bb..66904017f8 100644 --- a/src/functionObjects/field/streamLine/streamLine.C +++ b/src/functionObjects/field/streamLine/streamLine.C @@ -35,6 +35,7 @@ License #include "interpolationCellPoint.H" #include "PatchTools.H" #include "mapPolyMesh.H" +#include "writeFile.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -575,16 +576,13 @@ bool Foam::functionObjects::streamLine::write() fileName vtkPath ( - Pstream::parRun() - ? runTime.path()/".."/"postProcessing"/"sets"/name() - : runTime.path()/"postProcessing"/"sets"/name() + runTime.globalPath()/writeFile::outputPrefix/"sets"/name() ); if (mesh_.name() != fvMesh::defaultRegion) { vtkPath = vtkPath/mesh_.name(); } vtkPath = vtkPath/mesh_.time().timeName(); - vtkPath.clean(); mkDir(vtkPath); // Convert track positions diff --git a/src/lagrangian/parcel/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.C b/src/lagrangian/parcel/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.C index 6181fb7f03..4519dc785b 100644 --- a/src/lagrangian/parcel/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.C +++ b/src/lagrangian/parcel/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -54,23 +54,12 @@ Foam::CloudFunctionObject::CloudFunctionObject ) : CloudSubModelBase(modelName, owner, dict, typeName, objectType), - outputDir_(owner.mesh().time().path()) + outputDir_() { const fileName relPath = "postProcessing"/cloud::prefix/owner.name()/this->modelName(); - - if (Pstream::parRun()) - { - // Put in undecomposed case (Note: gives problems for - // distributed data running) - outputDir_ = outputDir_/".."/relPath; - } - else - { - outputDir_ = outputDir_/relPath; - } - outputDir_.clean(); + outputDir_ = owner.mesh().time().globalPath()/relPath; } diff --git a/src/sampling/probes/probes.C b/src/sampling/probes/probes.C index df668ad347..14c3001212 100644 --- a/src/sampling/probes/probes.C +++ b/src/sampling/probes/probes.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -201,18 +201,7 @@ Foam::label Foam::probes::prepare() } probeSubDir = "postProcessing"/probeSubDir/mesh_.time().timeName(); - if (Pstream::parRun()) - { - // Put in undecomposed case - // (Note: gives problems for distributed data running) - probeDir = mesh_.time().path()/".."/probeSubDir; - } - else - { - probeDir = mesh_.time().path()/probeSubDir; - } - // Remove ".." - probeDir.clean(); + probeDir = mesh_.time().globalPath()/probeSubDir; // ignore known fields, close streams for fields that no longer exist forAllIter(HashPtrTable, probeFilePtrs_, iter) diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.C b/src/sampling/sampledSet/sampledSets/sampledSets.C index f0fedea551..a70f27a7bb 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.C +++ b/src/sampling/sampledSet/sampledSets/sampledSets.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,6 +31,7 @@ License #include "SortableList.H" #include "volPointInterpolation.H" #include "mapPolyMesh.H" +#include "writeFile.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -163,20 +164,13 @@ Foam::sampledSets::sampledSets interpolationScheme_(word::null), writeFormat_(word::null) { - if (Pstream::parRun()) - { - outputPath_ = mesh_.time().path()/".."/"postProcessing"/name; - } - else - { - outputPath_ = mesh_.time().path()/"postProcessing"/name; - } + outputPath_ = + mesh_.time().globalPath()/functionObjects::writeFile::outputPrefix/name; + if (mesh_.name() != fvMesh::defaultRegion) { outputPath_ = outputPath_/mesh_.name(); } - // Remove ".." - outputPath_.clean(); read(dict); } @@ -199,20 +193,13 @@ Foam::sampledSets::sampledSets interpolationScheme_(word::null), writeFormat_(word::null) { - if (Pstream::parRun()) - { - outputPath_ = mesh_.time().path()/".."/"postProcessing"/name; - } - else - { - outputPath_ = mesh_.time().path()/"postProcessing"/name; - } + outputPath_ = + mesh_.time().globalPath()/functionObjects::writeFile::outputPrefix/name; + if (mesh_.name() != fvMesh::defaultRegion) { outputPath_ = outputPath_/mesh_.name(); } - // Remove ".." - outputPath_.clean(); read(dict); } diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index 5b8b0fc724..e43f09b709 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -27,6 +27,7 @@ License #include "PatchTools.H" #include "mapPolyMesh.H" #include "OSspecific.H" +#include "writeFile.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -118,16 +119,13 @@ Foam::functionObjects::sampledSurfaces::sampledSurfaces mergeList_(), formatter_(nullptr) { - if (Pstream::parRun()) + outputPath_ = + mesh_.time().globalPath()/functionObjects::writeFile::outputPrefix/name; + + if (mesh_.name() != fvMesh::defaultRegion) { - outputPath_ = mesh_.time().path()/".."/"postProcessing"/name; + outputPath_ = outputPath_/mesh_.name(); } - else - { - outputPath_ = mesh_.time().path()/"postProcessing"/name; - } - // Remove ".." - outputPath_.clean(); read(dict); } @@ -151,16 +149,13 @@ Foam::functionObjects::sampledSurfaces::sampledSurfaces mergeList_(), formatter_(nullptr) { - if (Pstream::parRun()) + outputPath_ = + mesh_.time().globalPath()/functionObjects::writeFile::outputPrefix/name; + + if (mesh_.name() != fvMesh::defaultRegion) { - outputPath_ = mesh_.time().path()/".."/"postProcessing"/name; + outputPath_ = outputPath_/mesh_.name(); } - else - { - outputPath_ = mesh_.time().path()/"postProcessing"/name; - } - // Remove ".." - outputPath_.clean(); read(dict); }