openfoam/applications/utilities/mesh/generation/PDRblockMesh/cleanMeshDirectory.H
Mark Olesen ba10afea77 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)
2022-05-27 14:10:31 +02:00

47 lines
1.5 KiB
C

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Removal of polyMesh directory
\*---------------------------------------------------------------------------*/
{
// Shadows enclosing parameter (dictName)
const word blockMeshDictName("blockMeshDict");
const word& regionDir = polyMesh::regionName(regionName);
const fileName polyMeshPath
(
runTime.path()/meshInstance/regionDir/polyMesh::meshSubDir
);
if (exists(polyMeshPath))
{
if (exists(polyMeshPath/blockMeshDictName))
{
Info<< "Not deleting polyMesh directory "
<< runTime.relativePath(polyMeshPath) << nl
<< " because it contains " << blockMeshDictName << endl;
}
else
{
Info<< "Deleting polyMesh directory "
<< runTime.relativePath(polyMeshPath) << endl;
rmDir(polyMeshPath);
}
}
}
// ************************************************************************* //