mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -130,7 +130,6 @@ int main(int argc, char *argv[])
|
||||
const bool noOuterRegion = args.found("no-outer");
|
||||
|
||||
const word regionName(polyMesh::defaultRegion);
|
||||
const word regionPath;
|
||||
|
||||
|
||||
// Instance for resulting mesh
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -18,10 +18,11 @@ Description
|
||||
{
|
||||
// Shadows enclosing parameter (dictName)
|
||||
const word blockMeshDictName("blockMeshDict");
|
||||
const word& regionDir = polyMesh::regionName(regionName);
|
||||
|
||||
const fileName polyMeshPath
|
||||
(
|
||||
runTime.path()/meshInstance/regionPath/polyMesh::meshSubDir
|
||||
runTime.path()/meshInstance/regionDir/polyMesh::meshSubDir
|
||||
);
|
||||
|
||||
if (exists(polyMeshPath))
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -184,16 +184,13 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
word regionName(polyMesh::defaultRegion);
|
||||
word regionPath;
|
||||
|
||||
// Check if the region is specified otherwise mesh the default region
|
||||
if (args.readIfPresent("region", regionName))
|
||||
{
|
||||
Info<< nl << "Generating mesh for region " << regionName << endl;
|
||||
regionPath = regionName;
|
||||
}
|
||||
|
||||
|
||||
// Instance for resulting mesh
|
||||
bool useTime = false;
|
||||
word meshInstance(runTime.constant());
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -18,10 +18,11 @@ Description
|
||||
{
|
||||
// Shadows enclosing parameter (dictName)
|
||||
const word blockMeshDictName("blockMeshDict");
|
||||
const word& regionDir = polyMesh::regionName(regionName);
|
||||
|
||||
const fileName polyMeshPath
|
||||
(
|
||||
runTime.path()/meshInstance/regionPath/polyMesh::meshSubDir
|
||||
runTime.path()/meshInstance/regionDir/polyMesh::meshSubDir
|
||||
);
|
||||
|
||||
if (exists(polyMeshPath))
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -22,6 +22,7 @@ autoPtr<IOdictionary> meshDictPtr;
|
||||
|
||||
{
|
||||
fileName dictPath;
|
||||
const word& regionDir = polyMesh::regionName(regionName);
|
||||
|
||||
if (args.readIfPresent("dict", dictPath))
|
||||
{
|
||||
@ -37,15 +38,17 @@ autoPtr<IOdictionary> meshDictPtr;
|
||||
exists
|
||||
(
|
||||
runTime.path()/runTime.constant()
|
||||
/regionPath/polyMesh::meshSubDir/dictName
|
||||
/ regionDir/polyMesh::meshSubDir/dictName
|
||||
)
|
||||
)
|
||||
{
|
||||
// Dictionary present in constant polyMesh directory (old-style)
|
||||
|
||||
dictPath =
|
||||
(
|
||||
runTime.constant()
|
||||
/regionPath/polyMesh::meshSubDir/dictName;
|
||||
/ regionDir/polyMesh::meshSubDir/dictName
|
||||
);
|
||||
|
||||
|
||||
// Warn that constant/polyMesh/blockMeshDict was used
|
||||
@ -54,14 +57,14 @@ autoPtr<IOdictionary> meshDictPtr;
|
||||
<< "Using the old blockMeshDict location: "
|
||||
<< dictPath << nl
|
||||
<< " instead of the default location: "
|
||||
<< runTime.system()/regionPath/dictName << nl
|
||||
<< runTime.system()/regionDir/dictName << nl
|
||||
<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume dictionary is to be found in the system directory
|
||||
|
||||
dictPath = runTime.system()/regionPath/dictName;
|
||||
dictPath = runTime.system()/regionDir/dictName;
|
||||
}
|
||||
|
||||
IOobject meshDictIO
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -256,21 +256,19 @@ int main(int argc, char *argv[])
|
||||
#include "createTimeExtruded.H"
|
||||
|
||||
// Get optional regionName
|
||||
word regionName;
|
||||
word regionDir;
|
||||
word regionName(polyMesh::defaultRegion);
|
||||
if (args.readIfPresent("region", regionName))
|
||||
{
|
||||
regionDir = regionName;
|
||||
Info<< "Create mesh " << regionName << " for time = "
|
||||
<< runTimeExtruded.timeName() << nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
regionName = fvMesh::defaultRegion;
|
||||
Info<< "Create mesh for time = "
|
||||
<< runTimeExtruded.timeName() << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
const IOdictionary dict
|
||||
(
|
||||
IOobject::selectIO
|
||||
@ -755,7 +753,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
// Create dummy fvSchemes, fvSolution
|
||||
fvMeshTools::createDummyFvMeshFiles(mesh, regionDir, true);
|
||||
fvMeshTools::createDummyFvMeshFiles
|
||||
(
|
||||
mesh,
|
||||
polyMesh::regionName(regionName),
|
||||
true
|
||||
);
|
||||
|
||||
// Create actual mesh from polyTopoChange container
|
||||
autoPtr<mapPolyMesh> map = meshMod().makeMesh
|
||||
|
||||
@ -234,12 +234,12 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
mesh = autoPtr<polyMesh>::New
|
||||
(
|
||||
Foam::IOobject
|
||||
IOobject
|
||||
(
|
||||
Foam::polyMesh::defaultRegion,
|
||||
polyMesh::defaultRegion,
|
||||
runTimeExtruded.timeName(),
|
||||
runTimeExtruded,
|
||||
Foam::IOobject::MUST_READ
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
|
||||
// (
|
||||
// IOobject
|
||||
// (
|
||||
// Foam::polyMesh::defaultRegion,
|
||||
// polyMesh::defaultRegion,
|
||||
// instance,
|
||||
// runTime_,
|
||||
// IOobject::MUST_READ
|
||||
|
||||
Reference in New Issue
Block a user