ENH: add 'filtered' polyMesh regionName() method

- in various situations with mesh regions it is also useful to
  filter out or remove the defaultRegion name (ie, "region0").

  Can now do that conveniently from the polyMesh itself or as a static
  function. Simply use this

      const word& regionDir = polyMesh::regionName(regionName);

  OR  mesh.regionName()

  instead of

      const word& regionDir =
      (
           regionName != polyMesh::defaultRegion
         ? regionName
         : word::null
      );

  Additionally, since the string '/' join operator filters out empty
  strings, the following will work correctly:

      (polyMesh::regionName(regionName)/polyMesh::meshSubDir)

      (mesh.regionName()/polyMesh::meshSubDir)
This commit is contained in:
Mark Olesen
2022-05-20 11:02:49 +02:00
parent f00f236cb3
commit ba10afea77
50 changed files with 347 additions and 357 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -76,17 +76,11 @@ void Foam::probes::createProbeFiles(const wordList& fieldNames)
// Put in undecomposed case
// (Note: gives problems for distributed data running)
fileName probeSubDir = name();
if (mesh_.name() != polyMesh::defaultRegion)
{
probeSubDir = probeSubDir/mesh_.name();
}
fileName probeDir
(
mesh_.time().globalPath()
/ functionObject::outputPrefix
/ probeSubDir
/ name()/mesh_.regionName()
// Use startTime as the instance for output files
/ mesh_.time().timeName(mesh_.time().startTime().value())
);

View File

@ -88,17 +88,11 @@ Foam::OFstream* Foam::sampledSets::createProbeFile(const word& fieldName)
// Put in undecomposed case
// (Note: gives problems for distributed data running)
fileName probeSubDir = name();
if (mesh_.name() != polyMesh::defaultRegion)
{
probeSubDir = probeSubDir/mesh_.name();
}
fileName probeDir
(
mesh_.time().globalPath()
/ functionObject::outputPrefix
/ probeSubDir
/ name()/mesh_.regionName()
// Use startTime as the instance for output files
/ mesh_.time().timeName(mesh_.time().startTime().value())
);
@ -446,7 +440,8 @@ Foam::sampledSets::sampledSets
writeAsProbes_(false),
outputPath_
(
time_.globalPath()/functionObject::outputPrefix/name
time_.globalPath()/functionObject::outputPrefix
/ name/mesh_.regionName()
),
searchEngine_(mesh_),
samplePointScheme_(),
@ -459,10 +454,6 @@ Foam::sampledSets::sampledSets
gatheredSorting_(),
globalIndices_()
{
if (mesh_.name() != polyMesh::defaultRegion)
{
outputPath_ /= mesh_.name();
}
outputPath_.clean(); // Remove unneeded ".."
read(dict);
@ -487,7 +478,8 @@ Foam::sampledSets::sampledSets
writeAsProbes_(false),
outputPath_
(
time_.globalPath()/functionObject::outputPrefix/name
time_.globalPath()/functionObject::outputPrefix
/ name/mesh_.regionName()
),
searchEngine_(mesh_),
samplePointScheme_(),
@ -500,10 +492,6 @@ Foam::sampledSets::sampledSets
gatheredSorting_(),
globalIndices_()
{
if (mesh_.name() != polyMesh::defaultRegion)
{
outputPath_ /= mesh_.name();
}
outputPath_.clean(); // Remove unneeded ".."
read(dict);