TimePaths: Rationalised path methods

This commit is contained in:
Will Bainbridge
2021-06-24 12:03:16 +01:00
parent 77213b62d1
commit dae463dbd8
14 changed files with 82 additions and 164 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -116,7 +116,7 @@ int main(int argc, char *argv[])
pointField pointsWedge(nPointsij*2, Zero); pointField pointsWedge(nPointsij*2, Zero);
fileName pointsFile(runTime.constantPath()/"points.tmp"); fileName pointsFile(runTime.path()/runTime.constant()/"points.tmp");
OFstream pFile(pointsFile); OFstream pFile(pointsFile);
scalar a(degToRad(0.1)); scalar a(degToRad(0.1));

View File

@ -516,17 +516,10 @@ void extractSurface
MeshedSurface<face> sortedFace(unsortedFace); MeshedSurface<face> sortedFace(unsortedFace);
fileName globalCasePath Info<< "Writing merged surface to "
( << runTime.globalPath()/outFileName << endl;
runTime.processorCase()
? runTime.path()/".."/outFileName
: runTime.path()/outFileName
);
globalCasePath.clean();
Info<< "Writing merged surface to " << globalCasePath << endl; sortedFace.write(runTime.globalPath()/outFileName);
sortedFace.write(globalCasePath);
} }
} }

View File

@ -41,6 +41,7 @@ License
#include "syncTools.H" #include "syncTools.H"
#include "globalIndex.H" #include "globalIndex.H"
#include "PatchTools.H" #include "PatchTools.H"
#include "writeFile.H"
void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology) void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
@ -270,13 +271,11 @@ void Foam::mergeAndWrite
fileName outputDir fileName outputDir
( (
set.time().path() set.time().globalPath()
/ (Pstream::parRun() ? ".." : "") /functionObjects::writeFile::outputPrefix
/ "postProcessing" /mesh.pointsInstance()
/ mesh.pointsInstance() /set.name()
/ set.name()
); );
outputDir.clean();
mergeAndWrite(mesh, writer, set.name(), setPatch, outputDir); mergeAndWrite(mesh, writer, set.name(), setPatch, outputDir);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -1248,10 +1248,10 @@ int main(int argc, char *argv[])
if (Pstream::parRun() && doLinks) if (Pstream::parRun() && doLinks)
{ {
mkDir(runTime.path()/".."/"VTK"); mkDir(runTime.globalPath()/"VTK");
chDir(runTime.path()/".."/"VTK"); chDir(runTime.globalPath()/"VTK");
Info<< "Linking all processor files to " << runTime.path()/".."/"VTK" Info<< "Linking all processor files to " << runTime.globalPath()/"VTK"
<< endl; << endl;
// Get list of vtk files // Get list of vtk files
@ -1277,21 +1277,14 @@ int main(int argc, char *argv[])
if (exists(procFile)) if (exists(procFile))
{ {
string cmd ln
( (
"ln -s " procFile,
+ procFile "processor"
+ " "
+ "processor"
+ name(Pstream::myProcNo()) + name(Pstream::myProcNo())
+ "_" + "_"
+ procFile.name() + procFile.name()
); );
if (system(cmd.c_str()) == -1)
{
WarningInFunction
<< "Could not execute command " << cmd << endl;
}
} }
} }
} }

View File

@ -182,7 +182,8 @@ namespace Foam
triSurface surf triSurface surf
( (
runTime.constantPath() runTime.path()
/runTime.constant()
/searchableSurface::geometryDir(runTime) /searchableSurface::geometryDir(runTime)
/surfaceFileName /surfaceFileName
); );
@ -493,7 +494,8 @@ namespace Foam
vtkSurfaceWriter(runTime.writeFormat()).write vtkSurfaceWriter(runTime.writeFormat()).write
( (
runTime.constantPath() runTime.path()
/runTime.constant()
/searchableSurface::geometryDir(runTime), /searchableSurface::geometryDir(runTime),
searchSurf.objectRegistry::name(), searchSurf.objectRegistry::name(),
searchSurf.points(), searchSurf.points(),
@ -505,7 +507,8 @@ namespace Foam
vtkSurfaceWriter(runTime.writeFormat()).write vtkSurfaceWriter(runTime.writeFormat()).write
( (
runTime.constantPath() runTime.path()
/runTime.constant()
/searchableSurface::geometryDir(runTime), /searchableSurface::geometryDir(runTime),
searchSurf.objectRegistry::name(), searchSurf.objectRegistry::name(),
searchSurf.points(), searchSurf.points(),
@ -561,7 +564,8 @@ namespace Foam
vtkSurfaceWriter(runTime.writeFormat()).write vtkSurfaceWriter(runTime.writeFormat()).write
( (
runTime.constantPath() runTime.path()
/runTime.constant()
/searchableSurface::geometryDir(runTime), /searchableSurface::geometryDir(runTime),
searchSurf.objectRegistry::name(), searchSurf.objectRegistry::name(),
searchSurf.points(), searchSurf.points(),
@ -573,7 +577,8 @@ namespace Foam
vtkSurfaceWriter(runTime.writeFormat()).write vtkSurfaceWriter(runTime.writeFormat()).write
( (
runTime.constantPath() runTime.path()
/runTime.constant()
/searchableSurface::geometryDir(runTime), /searchableSurface::geometryDir(runTime),
searchSurf.objectRegistry::name(), searchSurf.objectRegistry::name(),
searchSurf.points(), searchSurf.points(),
@ -612,7 +617,8 @@ namespace Foam
{ {
vtkSurfaceWriter(runTime.writeFormat()).write vtkSurfaceWriter(runTime.writeFormat()).write
( (
runTime.constantPath() runTime.path()
/runTime.constant()
/searchableSurface::geometryDir(runTime), /searchableSurface::geometryDir(runTime),
sFeatFileName, sFeatFileName,
surf.points(), surf.points(),
@ -685,7 +691,8 @@ namespace Foam
{ {
vtkSurfaceWriter(runTime.writeFormat()).write vtkSurfaceWriter(runTime.writeFormat()).write
( (
runTime.constantPath() runTime.path()
/runTime.constant()
/searchableSurface::geometryDir(runTime), /searchableSurface::geometryDir(runTime),
sFeatFileName, sFeatFileName,
surf.points(), surf.points(),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -356,17 +356,10 @@ int main(int argc, char *argv[])
MeshedSurface<face> sortedFace(unsortedFace); MeshedSurface<face> sortedFace(unsortedFace);
fileName globalCasePath Info<< "Writing merged surface to "
( << runTime.globalPath()/outFileName << endl;
runTime.processorCase()
? runTime.path()/".."/outFileName
: runTime.path()/outFileName
);
globalCasePath.clean();
Info<< "Writing merged surface to " << globalCasePath << endl; sortedFace.write(runTime.globalPath()/outFileName);
sortedFace.write(globalCasePath);
} }
Info<< "End\n" << endl; Info<< "End\n" << endl;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -252,29 +252,25 @@ public:
// Database functions // Database functions
//- Return root path //- Explicitly inherit rootPath from TimePaths to disambiguate from
const fileName& rootPath() const // the corresponding method in objectRegistry
{ using TimePaths::rootPath;
return TimePaths::rootPath();
}
//- Return case name //- Explicitly inherit caseName from TimePaths to disambiguate from
const fileName& caseName() const // the corresponding method in objectRegistry
{ using TimePaths::caseName;
return TimePaths::caseName();
}
//- Return path //- Explicitly inherit path from TimePaths to disambiguate from
fileName path() const // the corresponding method in objectRegistry
{ using TimePaths::path;
return rootPath()/caseName();
}
//- Return the control dict
const dictionary& controlDict() const const dictionary& controlDict() const
{ {
return controlDict_; return controlDict_;
} }
//- Local directory path of this objectRegistry relative to time
virtual const fileName& dbDir() const virtual const fileName& dbDir() const
{ {
return fileName::null; return fileName::null;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,7 +46,6 @@ namespace Foam
Class TimePaths Declaration Class TimePaths Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class TimePaths class TimePaths
{ {
// Private Data // Private Data
@ -131,23 +130,17 @@ public:
// which for parallel runs returns ../constant() // which for parallel runs returns ../constant()
fileName caseConstant() const; fileName caseConstant() const;
//- Return the global path
fileName globalPath() const
{
return rootPath()/globalCaseName();
}
//- Return path //- Return path
fileName path() const fileName path() const
{ {
return rootPath()/caseName(); return rootPath()/caseName();
} }
//- Return system path
fileName systemPath() const
{
return path()/system();
}
//- Return constant path
fileName constantPath() const
{
return path()/constant();
}
}; };

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -48,18 +48,7 @@ void Foam::functionObjects::writeFile::initStream(Ostream& os) const
Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const
{ {
fileName baseDir = fileObr_.time().path(); fileName baseDir = fileObr_.time().globalPath()/outputPrefix;
if (Pstream::parRun())
{
// Put in undecomposed case (Note: gives problems for
// distributed data running)
baseDir = baseDir/".."/outputPrefix;
}
else
{
baseDir = baseDir/outputPrefix;
}
// Append mesh name if not default region // Append mesh name if not default region
if (isA<polyMesh>(fileObr_)) if (isA<polyMesh>(fileObr_))
@ -71,9 +60,6 @@ Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const
} }
} }
// Remove any ".."
baseDir.clean();
return baseDir; return baseDir;
} }

View File

@ -35,6 +35,7 @@ License
#include "interpolationCellPoint.H" #include "interpolationCellPoint.H"
#include "PatchTools.H" #include "PatchTools.H"
#include "mapPolyMesh.H" #include "mapPolyMesh.H"
#include "writeFile.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -575,16 +576,13 @@ bool Foam::functionObjects::streamLine::write()
fileName vtkPath fileName vtkPath
( (
Pstream::parRun() runTime.globalPath()/writeFile::outputPrefix/"sets"/name()
? runTime.path()/".."/"postProcessing"/"sets"/name()
: runTime.path()/"postProcessing"/"sets"/name()
); );
if (mesh_.name() != fvMesh::defaultRegion) if (mesh_.name() != fvMesh::defaultRegion)
{ {
vtkPath = vtkPath/mesh_.name(); vtkPath = vtkPath/mesh_.name();
} }
vtkPath = vtkPath/mesh_.time().timeName(); vtkPath = vtkPath/mesh_.time().timeName();
vtkPath.clean();
mkDir(vtkPath); mkDir(vtkPath);
// Convert track positions // Convert track positions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -54,23 +54,12 @@ Foam::CloudFunctionObject<CloudType>::CloudFunctionObject
) )
: :
CloudSubModelBase<CloudType>(modelName, owner, dict, typeName, objectType), CloudSubModelBase<CloudType>(modelName, owner, dict, typeName, objectType),
outputDir_(owner.mesh().time().path()) outputDir_()
{ {
const fileName relPath = const fileName relPath =
"postProcessing"/cloud::prefix/owner.name()/this->modelName(); "postProcessing"/cloud::prefix/owner.name()/this->modelName();
outputDir_ = owner.mesh().time().globalPath()/relPath;
if (Pstream::parRun())
{
// Put in undecomposed case (Note: gives problems for
// distributed data running)
outputDir_ = outputDir_/".."/relPath;
}
else
{
outputDir_ = outputDir_/relPath;
}
outputDir_.clean();
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -201,18 +201,7 @@ Foam::label Foam::probes::prepare()
} }
probeSubDir = "postProcessing"/probeSubDir/mesh_.time().timeName(); probeSubDir = "postProcessing"/probeSubDir/mesh_.time().timeName();
if (Pstream::parRun()) probeDir = mesh_.time().globalPath()/probeSubDir;
{
// 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();
// ignore known fields, close streams for fields that no longer exist // ignore known fields, close streams for fields that no longer exist
forAllIter(HashPtrTable<OFstream>, probeFilePtrs_, iter) forAllIter(HashPtrTable<OFstream>, probeFilePtrs_, iter)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -31,6 +31,7 @@ License
#include "SortableList.H" #include "SortableList.H"
#include "volPointInterpolation.H" #include "volPointInterpolation.H"
#include "mapPolyMesh.H" #include "mapPolyMesh.H"
#include "writeFile.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -163,20 +164,13 @@ Foam::sampledSets::sampledSets
interpolationScheme_(word::null), interpolationScheme_(word::null),
writeFormat_(word::null) writeFormat_(word::null)
{ {
if (Pstream::parRun()) outputPath_ =
{ mesh_.time().globalPath()/functionObjects::writeFile::outputPrefix/name;
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name;
}
else
{
outputPath_ = mesh_.time().path()/"postProcessing"/name;
}
if (mesh_.name() != fvMesh::defaultRegion) if (mesh_.name() != fvMesh::defaultRegion)
{ {
outputPath_ = outputPath_/mesh_.name(); outputPath_ = outputPath_/mesh_.name();
} }
// Remove ".."
outputPath_.clean();
read(dict); read(dict);
} }
@ -199,20 +193,13 @@ Foam::sampledSets::sampledSets
interpolationScheme_(word::null), interpolationScheme_(word::null),
writeFormat_(word::null) writeFormat_(word::null)
{ {
if (Pstream::parRun()) outputPath_ =
{ mesh_.time().globalPath()/functionObjects::writeFile::outputPrefix/name;
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name;
}
else
{
outputPath_ = mesh_.time().path()/"postProcessing"/name;
}
if (mesh_.name() != fvMesh::defaultRegion) if (mesh_.name() != fvMesh::defaultRegion)
{ {
outputPath_ = outputPath_/mesh_.name(); outputPath_ = outputPath_/mesh_.name();
} }
// Remove ".."
outputPath_.clean();
read(dict); read(dict);
} }

View File

@ -27,6 +27,7 @@ License
#include "PatchTools.H" #include "PatchTools.H"
#include "mapPolyMesh.H" #include "mapPolyMesh.H"
#include "OSspecific.H" #include "OSspecific.H"
#include "writeFile.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -118,16 +119,13 @@ Foam::functionObjects::sampledSurfaces::sampledSurfaces
mergeList_(), mergeList_(),
formatter_(nullptr) 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); read(dict);
} }
@ -151,16 +149,13 @@ Foam::functionObjects::sampledSurfaces::sampledSurfaces
mergeList_(), mergeList_(),
formatter_(nullptr) 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); read(dict);
} }