mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -13,6 +13,19 @@ License
|
||||
Description
|
||||
Search for the appropriate faMeshDefinition dictionary...
|
||||
|
||||
Required Classes
|
||||
- Foam::polyMesh
|
||||
- Foam::IOdictionary
|
||||
|
||||
Required Variables
|
||||
- regionName [word]
|
||||
- args [argList]
|
||||
- runTime [Time]
|
||||
|
||||
Provided Variables
|
||||
- meshDefDict [IOdictionary]
|
||||
- meshDictPtr [autoPtr<IOdictionary>]
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
const word dictName("faMeshDefinition");
|
||||
@ -21,7 +34,7 @@ autoPtr<IOdictionary> meshDictPtr;
|
||||
|
||||
{
|
||||
fileName dictPath;
|
||||
const word& regionDir = polyMesh::regionName(regionName);
|
||||
const word& regionDir = Foam::polyMesh::regionName(regionName);
|
||||
|
||||
if (args.readIfPresent("dict", dictPath))
|
||||
{
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -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
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
(
|
||||
|
||||
@ -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
|
||||
);
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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
|
||||
(
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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.
|
||||
@ -296,15 +296,16 @@ int main(int argc, char *argv[])
|
||||
IOobject::fileModificationChecking = IOobject::timeStamp;
|
||||
|
||||
|
||||
word regionName(polyMesh::defaultRegion);
|
||||
if (args.readIfPresent("region", regionName))
|
||||
// Specified region or default region
|
||||
#include "getRegionOption.H"
|
||||
if (!polyMesh::regionName(regionName).empty())
|
||||
{
|
||||
Info<< "Using region " << regionName << nl << endl;
|
||||
}
|
||||
|
||||
const fileName meshDir
|
||||
(
|
||||
polyMesh::regionName(regionName)/polyMesh::meshSubDir
|
||||
polyMesh::meshDir(regionName)
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -813,11 +813,7 @@ int main(int argc, char *argv[])
|
||||
IOobject io
|
||||
(
|
||||
"faBoundary",
|
||||
mesh.time().findInstance
|
||||
(
|
||||
mesh.dbDir()/polyMesh::meshSubDir,
|
||||
"boundary"
|
||||
),
|
||||
mesh.time().findInstance(mesh.meshDir(), "boundary"),
|
||||
faMesh::meshSubDir,
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
|
||||
@ -305,7 +305,7 @@ autoPtr<mapPolyMesh> mergeSharedPoints
|
||||
boundBox procBounds
|
||||
(
|
||||
const PtrList<Time>& databases,
|
||||
const word& regionDir
|
||||
const word& regionName
|
||||
)
|
||||
{
|
||||
boundBox bb;
|
||||
@ -316,7 +316,7 @@ boundBox procBounds
|
||||
(
|
||||
procDb.findInstance
|
||||
(
|
||||
regionDir/polyMesh::meshSubDir,
|
||||
polyMesh::meshDir(regionName),
|
||||
"points"
|
||||
)
|
||||
);
|
||||
@ -345,10 +345,10 @@ boundBox procBounds
|
||||
"points",
|
||||
procDb.findInstance
|
||||
(
|
||||
regionDir/polyMesh::meshSubDir,
|
||||
polyMesh::meshDir(regionName),
|
||||
"points"
|
||||
),
|
||||
regionDir/polyMesh::meshSubDir,
|
||||
polyMesh::meshDir(regionName),
|
||||
procDb,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
@ -771,7 +771,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
"faces",
|
||||
databases[0].timeName(),
|
||||
polyMesh::regionName(regionName)/polyMesh::meshSubDir,
|
||||
polyMesh::meshDir(regionName),
|
||||
databases[0],
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
|
||||
@ -275,7 +275,7 @@ void Foam::masterMeshInstance
|
||||
{
|
||||
const fileName meshSubDir
|
||||
(
|
||||
polyMesh::regionName(io.name()) / polyMesh::meshSubDir
|
||||
polyMesh::meshDir(io.name())
|
||||
);
|
||||
|
||||
if (UPstream::master())
|
||||
|
||||
@ -1577,14 +1577,20 @@ int main(int argc, char *argv[])
|
||||
forAll(regionNames, regioni)
|
||||
{
|
||||
const word& regionName = regionNames[regioni];
|
||||
const word& regionDir = polyMesh::regionName(regionName);
|
||||
|
||||
const fileName volMeshSubDir(regionDir/polyMesh::meshSubDir);
|
||||
const fileName areaMeshSubDir(regionDir/faMesh::meshSubDir);
|
||||
const fileName volMeshSubDir
|
||||
(
|
||||
polyMesh::meshDir(regionName)
|
||||
);
|
||||
const fileName areaMeshSubDir
|
||||
(
|
||||
polyMesh::regionName(regionName) / faMesh::meshSubDir
|
||||
);
|
||||
|
||||
InfoOrPout
|
||||
<< nl
|
||||
<< "Reconstructing mesh " << regionDir << nl << endl;
|
||||
<< "Reconstructing mesh:"
|
||||
<< polyMesh::regionName(regionName) << nl << endl;
|
||||
|
||||
bool areaMeshDetected = false;
|
||||
|
||||
@ -2474,15 +2480,20 @@ int main(int argc, char *argv[])
|
||||
forAll(regionNames, regioni)
|
||||
{
|
||||
const word& regionName = regionNames[regioni];
|
||||
const word& regionDir = polyMesh::regionName(regionName);
|
||||
|
||||
const fileName volMeshSubDir(regionDir/polyMesh::meshSubDir);
|
||||
const fileName areaMeshSubDir(regionDir/faMesh::meshSubDir);
|
||||
const fileName volMeshSubDir
|
||||
(
|
||||
polyMesh::meshDir(regionName)
|
||||
);
|
||||
const fileName areaMeshSubDir
|
||||
(
|
||||
polyMesh::regionName(regionName) / faMesh::meshSubDir
|
||||
);
|
||||
|
||||
InfoOrPout
|
||||
<< nl << nl
|
||||
<< (decompose ? "Decomposing" : "Redistributing")
|
||||
<< " mesh " << regionDir << nl << endl;
|
||||
<< " mesh:" << polyMesh::regionName(regionName) << nl << endl;
|
||||
|
||||
|
||||
// Get time instance directory
|
||||
|
||||
@ -184,7 +184,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
"pointDualAddressing",
|
||||
tetDualMesh.facesInstance(),
|
||||
tetDualMesh.meshSubDir,
|
||||
polyMesh::meshSubDir,
|
||||
tetDualMesh,
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
|
||||
@ -540,7 +540,7 @@ int main(int argc, char *argv[])
|
||||
"boundary",
|
||||
runTime.findInstance
|
||||
(
|
||||
polyMesh::regionName(regionName)/polyMesh::meshSubDir,
|
||||
polyMesh::meshDir(regionName),
|
||||
"boundary",
|
||||
IOobject::READ_IF_PRESENT
|
||||
),
|
||||
|
||||
@ -54,8 +54,8 @@ Foam::IOPtrList<Foam::entry> Foam::boundaryInfo::readBoundaryDict
|
||||
IOobject
|
||||
(
|
||||
"boundary",
|
||||
runTime.findInstance(regionName/polyMesh::meshSubDir, "boundary"),
|
||||
regionName/polyMesh::meshSubDir,
|
||||
runTime.findInstance(polyMesh::meshDir(regionName), "boundary"),
|
||||
polyMesh::meshDir(regionName),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
|
||||
@ -409,15 +409,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
const bool enableEntries = args.found("enableFunctionEntries");
|
||||
|
||||
const word regionName =
|
||||
args.getOrDefault<word>("region", polyMesh::defaultRegion);
|
||||
|
||||
fileName regionPrefix;
|
||||
if (regionName != polyMesh::defaultRegion)
|
||||
{
|
||||
regionPrefix = regionName;
|
||||
}
|
||||
// Specified region or default region
|
||||
#include "getRegionOption.H"
|
||||
|
||||
regionPrefix = polyMesh::regionName(regionName);
|
||||
}
|
||||
|
||||
// Per cyclic patch the new name for this side and the other side
|
||||
HashTable<word> thisNames;
|
||||
|
||||
Reference in New Issue
Block a user