functionObjects: Standardised file paths for functions applied to regions

Function objects now write to the following path when applied to a
non-default region of a multi-region case:

    postProcessing/<regionName>/<functionName>/<time>/

Previously the order of <regionName> and <functionName> was not
consistent between the various function objects.

Resolves bug report https://bugs.openfoam.org/view.php?id=3907
This commit is contained in:
Will Bainbridge
2022-10-13 11:19:27 +01:00
parent 2fc1f0b138
commit 5b11f5a833
7 changed files with 49 additions and 55 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) 2015-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -364,11 +364,10 @@ 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();

View File

@ -33,6 +33,7 @@ License
#include "polyTopoChangeMap.H"
#include "polyMeshMap.H"
#include "polyDistributionMap.H"
#include "OSspecific.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -310,17 +311,18 @@ bool Foam::functionObjects::layerAverage::write()
#undef CollapseTypeFields
}
// Output directory
fileName outputPath =
mesh_.time().globalPath()/writeFile::outputPrefix/name();
if (mesh_.name() != fvMesh::defaultRegion)
{
outputPath = outputPath/mesh_.name();
}
// Write
if (Pstream::master() && layerCentre_.size())
{
// Make output directory
const fileName outputPath =
mesh_.time().globalPath()
/writeFile::outputPrefix
/(mesh_.name() != polyMesh::defaultRegion ? mesh_.name() : word())
/name()
/mesh_.time().timeName();
mkDir(outputPath);
scalarField layerDistance(layerCentre_.size(), 0);
for (label i = 1; i < layerCentre_.size(); ++ i)
{
@ -330,7 +332,7 @@ bool Foam::functionObjects::layerAverage::write()
formatter_->write
(
outputPath/mesh_.time().timeName(),
outputPath,
typeName,
coordSet
(

View File

@ -533,15 +533,12 @@ bool Foam::functionObjects::streamlines::write()
if (Pstream::master() && allPositions.size())
{
// Make output directory
fileName outputPath
(
mesh_.time().globalPath()/writeFile::outputPrefix/name()
);
if (mesh_.name() != fvMesh::defaultRegion)
{
outputPath = outputPath/mesh_.name();
}
outputPath = outputPath/mesh_.time().timeName();
const fileName outputPath =
mesh_.time().globalPath()
/writeFile::outputPrefix
/(mesh_.name() != polyMesh::defaultRegion ? mesh_.name() : word())
/name()
/mesh_.time().timeName();
mkDir(outputPath);
// Pass data to the formatter to write

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-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "CloudFunctionObject.H"
#include "writeFile.H"
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
@ -57,7 +58,10 @@ Foam::CloudFunctionObject<CloudType>::CloudFunctionObject
outputDir_()
{
const fileName relPath =
"postProcessing"/cloud::prefix/owner.name()/this->modelName();
functionObjects::writeFile::outputPrefix
/cloud::prefix
/owner.name()
/this->modelName();
outputDir_ = owner.mesh().time().globalPath()/relPath;
}

View File

@ -27,6 +27,7 @@ License
#include "volFields.H"
#include "polyTopoChangeMap.H"
#include "OSspecific.H"
#include "writeFile.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -191,17 +192,12 @@ Foam::label Foam::probes::prepare()
<< endl;
}
fileName probeDir;
fileName probeSubDir = name();
if (mesh_.name() != polyMesh::defaultRegion)
{
probeSubDir = probeSubDir/mesh_.name();
}
probeSubDir = "postProcessing"/probeSubDir/mesh_.time().timeName();
probeDir = mesh_.time().globalPath()/probeSubDir;
const fileName probeDir =
mesh_.time().globalPath()
/functionObjects::writeFile::outputPrefix
/(mesh_.name() != polyMesh::defaultRegion ? mesh_.name() : word())
/name()
/mesh_.time().timeName();
// ignore known fields, close streams for fields that no longer exist
forAllIter(HashPtrTable<OFstream>, probeFilePtrs_, iter)

View File

@ -111,19 +111,17 @@ Foam::functionObjects::sampledSets::sampledSets
:
fvMeshFunctionObject(name, t, dict),
PtrList<sampledSet>(),
outputPath_(fileName::null),
outputPath_
(
mesh_.time().globalPath()
/writeFile::outputPrefix
/(mesh_.name() != polyMesh::defaultRegion ? mesh_.name() : word())
/name
),
searchEngine_(mesh_),
interpolationScheme_(word::null),
formatter_(nullptr)
{
outputPath_ =
mesh_.time().globalPath()/functionObjects::writeFile::outputPrefix/name;
if (mesh_.name() != fvMesh::defaultRegion)
{
outputPath_ = outputPath_/mesh_.name();
}
read(dict);
}

View File

@ -165,21 +165,19 @@ Foam::functionObjects::sampledSurfaces::sampledSurfaces
:
fvMeshFunctionObject(name, t, dict),
PtrList<sampledSurface>(),
outputPath_(fileName::null),
outputPath_
(
mesh_.time().globalPath()
/writeFile::outputPrefix
/(mesh_.name() != polyMesh::defaultRegion ? mesh_.name() : word())
/name
),
fields_(),
interpolationScheme_(word::null),
writeEmpty_(false),
mergeList_(),
formatter_(nullptr)
{
outputPath_ =
mesh_.time().globalPath()/functionObjects::writeFile::outputPrefix/name;
if (mesh_.name() != fvMesh::defaultRegion)
{
outputPath_ = outputPath_/mesh_.name();
}
read(dict);
}