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

View File

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

View File

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

View File

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

View File

@ -55,28 +55,21 @@ 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 // Put in undecomposed case
// (Note: gives problems for distributed data running)
outputDir_ =
( (
functionObject::outputPrefix owner.mesh().time().globalPath()
/cloud::prefix / functionObject::outputPrefix
/owner.name() / cloud::prefix
/this->modelName() / owner.name()
/ this->modelName()
); );
outputDir_.clean(); // Remove unneeded ".."
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

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

View File

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