mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
- 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)
96 lines
2.5 KiB
C
96 lines
2.5 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | www.openfoam.com
|
|
\\/ M anipulation |
|
|
-------------------------------------------------------------------------------
|
|
Copyright (C) 2021-2022 OpenCFD Ltd.
|
|
-------------------------------------------------------------------------------
|
|
License
|
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
|
|
|
Description
|
|
Search for the appropriate blockMeshDict dictionary...
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
// Search for the appropriate blockMesh dictionary....
|
|
const word dictName("blockMeshDict");
|
|
|
|
autoPtr<IOdictionary> meshDictPtr;
|
|
|
|
{
|
|
fileName dictPath;
|
|
const word& regionDir = polyMesh::regionName(regionName);
|
|
|
|
if (args.readIfPresent("dict", dictPath))
|
|
{
|
|
// Dictionary specified on the command-line ...
|
|
|
|
if (isDir(dictPath))
|
|
{
|
|
dictPath /= dictName;
|
|
}
|
|
}
|
|
else if
|
|
(
|
|
exists
|
|
(
|
|
runTime.path()/runTime.constant()
|
|
/ regionDir/polyMesh::meshSubDir/dictName
|
|
)
|
|
)
|
|
{
|
|
// Dictionary present in constant polyMesh directory (old-style)
|
|
|
|
dictPath =
|
|
(
|
|
runTime.constant()
|
|
/ regionDir/polyMesh::meshSubDir/dictName
|
|
);
|
|
|
|
|
|
// Warn that constant/polyMesh/blockMeshDict was used
|
|
// instead of system/blockMeshDict
|
|
WarningIn(args.executable())
|
|
<< "Using the old blockMeshDict location: "
|
|
<< dictPath << nl
|
|
<< " instead of the default location: "
|
|
<< runTime.system()/regionDir/dictName << nl
|
|
<< endl;
|
|
}
|
|
else
|
|
{
|
|
// Assume dictionary is to be found in the system directory
|
|
|
|
dictPath = runTime.system()/regionDir/dictName;
|
|
}
|
|
|
|
IOobject meshDictIO
|
|
(
|
|
dictPath,
|
|
runTime,
|
|
IOobject::MUST_READ,
|
|
IOobject::NO_WRITE,
|
|
false
|
|
);
|
|
|
|
if (!meshDictIO.typeHeaderOk<IOdictionary>(true))
|
|
{
|
|
FatalErrorInFunction
|
|
<< meshDictIO.objectPath() << nl
|
|
<< exit(FatalError);
|
|
}
|
|
|
|
Info<< "Creating block mesh from "
|
|
<< meshDictIO.objectRelPath() << endl;
|
|
|
|
meshDictPtr = autoPtr<IOdictionary>::New(meshDictIO);
|
|
}
|
|
|
|
const IOdictionary& meshDict = *meshDictPtr;
|
|
|
|
|
|
// ************************************************************************* //
|