STYLE: use globalPath() instead of path()/".." for parallel

This commit is contained in:
Mark Olesen 2018-12-05 22:54:50 +01:00
parent d3a2544bfa
commit a199fef957
7 changed files with 53 additions and 89 deletions

View File

@ -46,18 +46,14 @@ void Foam::functionObjects::writeFile::initStream(Ostream& os) const
Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const
{
fileName baseDir = fileObr_.time().path();
// Put in undecomposed case
// (Note: gives problems for distributed data running)
if (Pstream::parRun())
{
// Put in undecomposed case (Note: gives problems for
// distributed data running)
baseDir = baseDir/".."/functionObject::outputPrefix;
}
else
{
baseDir = baseDir/functionObject::outputPrefix;
}
fileName baseDir =
(
fileObr_.time().globalPath()
/ functionObject::outputPrefix
);
// Append mesh name if not default region
if (isA<polyMesh>(fileObr_))
@ -65,12 +61,11 @@ Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const
const polyMesh& mesh = refCast<const polyMesh>(fileObr_);
if (mesh.name() != polyMesh::defaultRegion)
{
baseDir = baseDir/mesh.name();
baseDir /= mesh.name();
}
}
// Remove any ".."
baseDir.clean();
baseDir.clean(); // Remove unneeded ".."
return baseDir;
}

View File

@ -968,15 +968,11 @@ void Foam::isoAdvection::writeIsoFaces
if (!writeIsoFacesToFile_ || !mesh_.time().writeTime()) return;
// Writing isofaces to obj file for inspection, e.g. in paraview
const fileName dirName
const fileName outputFile
(
Pstream::parRun() ?
mesh_.time().path()/".."/"isoFaces"
: mesh_.time().path()/"isoFaces"
);
const word fName
(
word::printf("isoFaces_%012d", mesh_.time().timeIndex())
mesh_.time().globalPath()
/ "isoFaces"
/ word::printf("isoFaces_%012d.obj", mesh_.time().timeIndex())
);
if (Pstream::parRun())
@ -988,8 +984,8 @@ void Foam::isoAdvection::writeIsoFaces
if (Pstream::master())
{
mkDir(dirName);
OBJstream os(dirName/fName + ".obj");
mkDir(outputFile.path());
OBJstream os(outputFile);
Info<< nl << "isoAdvection: writing iso faces to file: "
<< os.name() << nl << endl;
@ -1015,8 +1011,8 @@ void Foam::isoAdvection::writeIsoFaces
}
else
{
mkDir(dirName);
OBJstream os(dirName/fName + ".obj");
mkDir(outputFile.path());
OBJstream os(outputFile);
Info<< nl << "isoAdvection: writing iso faces to file: "
<< os.name() << nl << endl;

View File

@ -646,9 +646,7 @@ bool Foam::functionObjects::streamLineBase::writeToFile()
fileName vtkPath
(
Pstream::parRun()
? time_.path()/".."/functionObject::outputPrefix/"sets"/name()
: time_.path()/functionObject::outputPrefix/"sets"/name()
time_.globalPath()/functionObject::outputPrefix/"sets"/name()
);
if (mesh_.name() != fvMesh::defaultRegion)
{

View File

@ -389,16 +389,12 @@ void Foam::functionObjects::runTimePostPro::scene::saveImage
const Time& runTime = obr_.time();
const fileName relPath
const fileName prefix
(
functionObject::outputPrefix/name_/obr_.time().timeName()
);
fileName prefix
(
Pstream::parRun() ?
runTime.path()/".."/relPath
: runTime.path()/relPath
runTime.globalPath()
/ functionObject::outputPrefix
/ name_
/ runTime.timeName()
);
mkDir(prefix);

View File

@ -55,28 +55,21 @@ Foam::CloudFunctionObject<CloudType>::CloudFunctionObject
)
:
CloudSubModelBase<CloudType>(modelName, owner, dict, typeName, objectType),
outputDir_(owner.mesh().time().path())
outputDir_()
{
const fileName relPath
// Put in undecomposed case
// (Note: gives problems for distributed data running)
outputDir_ =
(
functionObject::outputPrefix
/cloud::prefix
/owner.name()
/this->modelName()
owner.mesh().time().globalPath()
/ functionObject::outputPrefix
/ 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_.clean(); // Remove unneeded ".."
}

View File

@ -195,26 +195,24 @@ Foam::label Foam::probes::prepare()
<< endl;
fileName probeDir;
fileName probeSubDir = name();
if (mesh_.name() != polyMesh::defaultRegion)
{
probeSubDir = probeSubDir/mesh_.name();
}
probeSubDir =
functionObject::outputPrefix/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;
}
// Put in undecomposed case
// (Note: gives problems for distributed data running)
fileName probeDir =
(
mesh_.time().globalPath()
/ functionObject::outputPrefix
/ probeSubDir
/ mesh_.time().timeName()
);
probeDir.clean(); // Remove unneeded ".."
// ignore known fields, close streams for fields that no longer exist

View File

@ -97,16 +97,10 @@ Foam::sampledSets::sampledSets
interpolationScheme_(word::null),
writeFormat_(word::null)
{
const fileName relPath(functionObject::outputPrefix/name);
if (Pstream::parRun())
{
outputPath_ = mesh_.time().path()/".."/relPath;
}
else
{
outputPath_ = mesh_.time().path()/relPath;
}
outputPath_ =
(
mesh_.time().globalPath()/functionObject::outputPrefix/name
);
if (mesh_.name() != fvMesh::defaultRegion)
{
@ -136,16 +130,10 @@ Foam::sampledSets::sampledSets
interpolationScheme_(word::null),
writeFormat_(word::null)
{
const fileName relPath(functionObject::outputPrefix/name);
if (Pstream::parRun())
{
outputPath_ = mesh_.time().path()/".."/relPath;
}
else
{
outputPath_ = mesh_.time().path()/relPath;
}
outputPath_ =
(
mesh_.time().globalPath()/functionObject::outputPrefix/name
);
if (mesh_.name() != fvMesh::defaultRegion)
{