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

@ -661,13 +661,10 @@ bool Foam::functionObjects::streamLineBase::writeToFile()
fileName vtkPath
(
time_.globalPath()/functionObject::outputPrefix/"sets"/name()
time_.globalPath()/functionObject::outputPrefix/"sets"
/ name()/mesh_.regionName()
/ mesh_.time().timeName()
);
if (mesh_.name() != polyMesh::defaultRegion)
{
vtkPath = vtkPath/mesh_.name();
}
vtkPath = vtkPath/mesh_.time().timeName();
mkDir(vtkPath);

View File

@ -87,9 +87,9 @@ void Foam::functionObjects::hydrostaticPressure::calculateAndWrite()
auto& p = thermo.p();
Info<< "Performing hydrostatic pressure initialisation";
if (mesh_.name() != polyMesh::defaultRegion)
if (!mesh_.regionName().empty())
{
Info<< "for region " << mesh_.name();
Info<< " region=" << mesh_.name();
}

View File

@ -280,10 +280,7 @@ bool Foam::functionObjects::vtkWrite::write()
label regioni = 0;
for (const word& regionName : meshes_.sortedToc())
{
const word& regionDir =
(
regionName == polyMesh::defaultRegion ? word::null : regionName
);
const word& regionDir = polyMesh::regionName(regionName);
auto& meshProxy = meshSubsets_[regioni];
auto& vtuMeshCells = vtuMappings_[regioni];