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
\\ / 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));

View File

@ -516,17 +516,10 @@ void extractSurface
MeshedSurface<face> 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);
}
}

View File

@ -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);
}

View File

@ -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;
}
}
}
}

View File

@ -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(),

View File

@ -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<face> 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;

View File

@ -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;

View File

@ -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();
}
};

View File

@ -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<polyMesh>(fileObr_))
@ -71,9 +60,6 @@ Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const
}
}
// Remove any ".."
baseDir.clean();
return baseDir;
}

View File

@ -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

View File

@ -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<CloudType>::CloudFunctionObject
)
:
CloudSubModelBase<CloudType>(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;
}

View File

@ -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<OFstream>, probeFilePtrs_, iter)

View File

@ -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);
}

View File

@ -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);
}