ENH: minor simplifications for handling region meshes

- static version of polyMesh::meshDir(), which takes a region name

      polyMesh::meshDir(regionName)
  vs
      polyMesh::regionName(regionName)/polyMesh::meshSubDir

STYLE: use polyMesh::regionName(..) instead of comparing to defaultRegion

STYLE: use getOrDefault when retrieving various -region options

FIX: polyMesh::dbDir() now checks registry name, not full path (#3033)
This commit is contained in:
Mark Olesen
2023-11-22 15:28:49 +01:00
parent f377875bc8
commit ca25929372
49 changed files with 453 additions and 147 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1317,11 +1317,12 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
#include "createTime.H"
word regionName(polyMesh::defaultRegion);
// Specified region or default region
#include "getRegionOption.H"
if (args.readIfPresent("region", regionName))
if (!polyMesh::regionName(regionName).empty())
{
Info<< "Creating polyMesh for region " << regionName << endl;
Info<< "Creating polyMesh for region " << regionName << nl;
}
const bool keepOrientation = args.found("keepOrientation");

View File

@ -18,11 +18,10 @@ Description
{
// Shadows enclosing parameter (dictName)
const word blockMeshDictName("blockMeshDict");
const word& regionDir = polyMesh::regionName(regionName);
const fileName polyMeshPath
(
runTime.path()/meshInstance/regionDir/polyMesh::meshSubDir
runTime.path()/meshInstance/polyMesh::meshDir(regionName)
);
if (exists(polyMeshPath))

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -183,12 +183,12 @@ int main(int argc, char *argv[])
: blockMesh::DEFAULT_MERGE
);
word regionName(polyMesh::defaultRegion);
// Specified region or default region
#include "getRegionOption.H"
// Check if the region is specified otherwise mesh the default region
if (args.readIfPresent("region", regionName))
if (!polyMesh::regionName(regionName).empty())
{
Info<< nl << "Generating mesh for region " << regionName << endl;
Info<< nl << "Generating mesh for region " << regionName << nl;
}
// Instance for resulting mesh

View File

@ -18,11 +18,10 @@ Description
{
// Shadows enclosing parameter (dictName)
const word blockMeshDictName("blockMeshDict");
const word& regionDir = polyMesh::regionName(regionName);
const fileName polyMeshPath
(
runTime.path()/meshInstance/regionDir/polyMesh::meshSubDir
runTime.path()/meshInstance/polyMesh::meshDir(regionName)
);
if (exists(polyMeshPath))

View File

@ -38,7 +38,7 @@ autoPtr<IOdictionary> meshDictPtr;
exists
(
runTime.path()/runTime.constant()
/ regionDir/polyMesh::meshSubDir/dictName
/ polyMesh::meshDir(regionName)/dictName
)
)
{
@ -47,7 +47,7 @@ autoPtr<IOdictionary> meshDictPtr;
dictPath =
(
runTime.constant()
/ regionDir/polyMesh::meshSubDir/dictName
/ polyMesh::meshDir(regionName)/dictName
);

View File

@ -255,19 +255,17 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
#include "createTimeExtruded.H"
// Get optional regionName
word regionName(polyMesh::defaultRegion);
if (args.readIfPresent("region", regionName))
{
Info<< "Create mesh " << regionName << " for time = "
<< runTimeExtruded.timeName() << nl << endl;
}
else
{
Info<< "Create mesh for time = "
<< runTimeExtruded.timeName() << nl << endl;
}
// Specified region or default region
#include "getRegionOption.H"
{
Info<< "Create mesh";
if (!polyMesh::regionName(regionName).empty())
{
Info<< ' ' << regionName;
}
Info<< " for time = " << runTimeExtruded.timeName() << nl << nl;
}
const IOdictionary dict
(

View File

@ -1210,7 +1210,7 @@ void extrudeGeometricProperties
(
"patchFaceCentres",
mesh.pointsInstance(),
mesh.meshSubDir,
polyMesh::meshSubDir,
mesh,
IOobject::MUST_READ
)
@ -1222,7 +1222,7 @@ void extrudeGeometricProperties
(
"patchEdgeCentres",
mesh.pointsInstance(),
mesh.meshSubDir,
polyMesh::meshSubDir,
mesh,
IOobject::MUST_READ
)
@ -1268,7 +1268,7 @@ void extrudeGeometricProperties
(
"faceCentres",
regionMesh.pointsInstance(),
regionMesh.meshSubDir,
polyMesh::meshSubDir,
regionMesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
@ -1352,7 +1352,7 @@ void extrudeGeometricProperties
(
"cellCentres",
regionMesh.pointsInstance(),
regionMesh.meshSubDir,
polyMesh::meshSubDir,
regionMesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
@ -2555,7 +2555,7 @@ int main(int argc, char *argv[])
(
"cellToPatchFaceAddressing",
regionMesh.facesInstance(),
regionMesh.meshSubDir,
polyMesh::meshSubDir,
regionMesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
@ -2571,7 +2571,7 @@ int main(int argc, char *argv[])
(
"faceToPatchFaceAddressing",
regionMesh.facesInstance(),
regionMesh.meshSubDir,
polyMesh::meshSubDir,
regionMesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
@ -2588,7 +2588,7 @@ int main(int argc, char *argv[])
(
"faceToPatchEdgeAddressing",
regionMesh.facesInstance(),
regionMesh.meshSubDir,
polyMesh::meshSubDir,
regionMesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
@ -2605,7 +2605,7 @@ int main(int argc, char *argv[])
(
"pointToPatchPointAddressing",
regionMesh.facesInstance(),
regionMesh.meshSubDir,
polyMesh::meshSubDir,
regionMesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
@ -2647,7 +2647,7 @@ int main(int argc, char *argv[])
(
"patchFaceCentres",
mesh.pointsInstance(),
mesh.meshSubDir,
polyMesh::meshSubDir,
mesh,
IOobject::MUST_READ
);

View File

@ -296,7 +296,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
// (
// "pointDualAddressing",
// instance,
// "tetDualMesh"/polyMesh::meshSubDir,
// polyMesh::meshDir("tetDualMesh"),
// runTime_,
// IOobject::NO_READ,
// IOobject::NO_WRITE,
@ -343,7 +343,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
// (
// "dualPoints",
// instance,
// "tetDualMesh"/polyMesh::meshSubDir,
// polyMesh::meshDir("tetDualMesh"),
// runTime_,
// IOobject::NO_READ,
// IOobject::NO_WRITE,

View File

@ -129,7 +129,7 @@ int main(int argc, char *argv[])
const word& regionName = regionNames[regioni];
const fileName meshDir
(
polyMesh::regionName(regionName)/polyMesh::meshSubDir
polyMesh::meshDir(regionName)
);
if (regionNames.size() > 1)

View File

@ -86,7 +86,7 @@ int main(int argc, char *argv[])
#include "createNamedPolyMesh.H"
const fileName setsSubPath(mesh.dbDir()/polyMesh::meshSubDir/"sets");
const fileName setsSubPath(mesh.meshDir()/"sets");
// Search for list of objects for the time of the mesh
word setsInstance = runTime.findInstance

View File

@ -894,7 +894,7 @@ void createAndWriteRegion
(
"pointRegionAddressing",
newMesh().facesInstance(),
newMesh().meshSubDir,
polyMesh::meshSubDir,
newMesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
@ -913,7 +913,7 @@ void createAndWriteRegion
(
"faceRegionAddressing",
newMesh().facesInstance(),
newMesh().meshSubDir,
polyMesh::meshSubDir,
newMesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
@ -951,7 +951,7 @@ void createAndWriteRegion
(
"cellRegionAddressing",
newMesh().facesInstance(),
newMesh().meshSubDir,
polyMesh::meshSubDir,
newMesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
@ -970,7 +970,7 @@ void createAndWriteRegion
(
"boundaryRegionAddressing",
newMesh().facesInstance(),
newMesh().meshSubDir,
polyMesh::meshSubDir,
newMesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -22,12 +22,14 @@ Provided Variables
\*---------------------------------------------------------------------------*/
Foam::Info << "Create mesh";
if (regionName != Foam::polyMesh::defaultRegion)
{
Foam::Info << ' ' << regionName;
Foam::Info << "Create mesh";
if (!Foam::polyMesh::regionName(regionName).empty())
{
Foam::Info << ' ' << regionName;
}
Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
}
Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
Foam::fvMesh mesh
(

View File

@ -396,7 +396,7 @@ int main(int argc, char *argv[])
const word& regionName = regionNames[regioni];
const fileName meshDir
(
polyMesh::regionName(regionName)/polyMesh::meshSubDir
polyMesh::meshDir(regionName)
);
if (regionNames.size() > 1)