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:
Mark Olesen
2022-05-20 11:02:49 +02:00
parent f00f236cb3
commit ba10afea77
50 changed files with 347 additions and 357 deletions

View File

@ -1,22 +1,52 @@
Info<< "Create dynamic mesh for time = " /*---------------------------------------------------------------------------*\
<< runTime.timeName() << nl << endl; ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
autoPtr<dynamicFvMesh> meshPtr Description
Create a dynamicFvMesh, with init()
Required Variables
- runTime [Time]
Provided Variables
- mesh [dynamicFvMesh], meshPtr
\*---------------------------------------------------------------------------*/
Foam::autoPtr<Foam::dynamicFvMesh> meshPtr;
{
Foam::Info << "Create dynamic mesh for time = "
<< runTime.timeName() << Foam::nl;
meshPtr = dynamicFvMesh::New
( (
dynamicFvMesh::New IOobject
( (
IOobject polyMesh::defaultRegion,
( runTime.timeName(),
polyMesh::defaultRegion, runTime,
runTime.timeName(), IOobject::MUST_READ
runTime,
IOobject::MUST_READ
)
) )
); );
}
dynamicFvMesh& mesh = meshPtr();
// Calculate initial mesh-to-mesh mapping. Note that this should be dynamicFvMesh& mesh = meshPtr();
// done under the hood, e.g. as a MeshObject
mesh.update(); // Calculate initial mesh-to-mesh mapping. Note that this should be
// done under the hood, e.g. as a MeshObject
mesh.update();
Foam::Info << Foam::endl;
// ************************************************************************* //

View File

@ -1,22 +1,52 @@
Info<< "Create dynamic mesh for time = " /*---------------------------------------------------------------------------*\
<< runTime.timeName() << nl << endl; ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
autoPtr<dynamicFvMesh> meshPtr Description
Create a dynamicFvMesh, with init()
Required Variables
- runTime [Time]
Provided Variables
- mesh [dynamicFvMesh], meshPtr
\*---------------------------------------------------------------------------*/
Foam::autoPtr<Foam::dynamicFvMesh> meshPtr;
{
Foam::Info << "Create dynamic mesh for time = "
<< runTime.timeName() << Foam::nl;
meshPtr = dynamicFvMesh::New
( (
dynamicFvMesh::New IOobject
( (
IOobject polyMesh::defaultRegion,
( runTime.timeName(),
polyMesh::defaultRegion, runTime,
runTime.timeName(), IOobject::MUST_READ
runTime,
IOobject::MUST_READ
)
) )
); );
}
dynamicFvMesh& mesh = meshPtr();
// Calculate initial mesh-to-mesh mapping. Note that this should be dynamicFvMesh& mesh = meshPtr();
// done under the hood, e.g. as a MeshObject
mesh.update(); // Calculate initial mesh-to-mesh mapping. Note that this should be
// done under the hood, e.g. as a MeshObject
mesh.update();
Foam::Info << Foam::endl;
// ************************************************************************* //

View File

@ -89,12 +89,7 @@ int main(int argc, char *argv[])
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
// const word& regionDir = // const word& regionDir = polyMesh::regionName(regionName);
// (
// regionName != polyMesh::defaultRegion
// ? regionName
// : word::null
// );
Info<< "\n\nDecomposing mesh " << regionName << nl << endl; Info<< "\n\nDecomposing mesh " << regionName << nl << endl;
Info<< "Create mesh..." << flush; Info<< "Create mesh..." << flush;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd. Copyright (C) 2021-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later. This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -21,9 +21,7 @@ autoPtr<IOdictionary> meshDictPtr;
{ {
fileName dictPath; fileName dictPath;
const word& regionDir = polyMesh::regionName(regionName);
const word& regionDir =
(regionName == polyMesh::defaultRegion ? word::null : regionName);
if (args.readIfPresent("dict", dictPath)) if (args.readIfPresent("dict", dictPath))
{ {
@ -40,15 +38,17 @@ autoPtr<IOdictionary> meshDictPtr;
exists exists
( (
runTime.path()/runTime.caseConstant() runTime.path()/runTime.caseConstant()
/regionDir/faMesh::meshSubDir/dictName / regionDir/faMesh::meshSubDir/dictName
) )
) )
{ {
// Dictionary present in constant faMesh directory (old-style) // Dictionary present in constant faMesh directory (old-style)
dictPath = dictPath =
(
runTime.constant() runTime.constant()
/regionDir/faMesh::meshSubDir/dictName; / regionDir/faMesh::meshSubDir/dictName
);
// Warn that constant/faMesh/faMeshDefinition was used // Warn that constant/faMesh/faMeshDefinition was used
// instead of system/faMeshDefinition // instead of system/faMeshDefinition

View File

@ -1317,7 +1317,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
word regionName = polyMesh::defaultRegion; word regionName(polyMesh::defaultRegion);
if (args.readIfPresent("region", regionName)) if (args.readIfPresent("region", regionName))
{ {

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -130,7 +130,6 @@ int main(int argc, char *argv[])
const bool noOuterRegion = args.found("no-outer"); const bool noOuterRegion = args.found("no-outer");
const word regionName(polyMesh::defaultRegion); const word regionName(polyMesh::defaultRegion);
const word regionPath;
// Instance for resulting mesh // Instance for resulting mesh

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later. This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -18,10 +18,11 @@ Description
{ {
// Shadows enclosing parameter (dictName) // Shadows enclosing parameter (dictName)
const word blockMeshDictName("blockMeshDict"); const word blockMeshDictName("blockMeshDict");
const word& regionDir = polyMesh::regionName(regionName);
const fileName polyMeshPath const fileName polyMeshPath
( (
runTime.path()/meshInstance/regionPath/polyMesh::meshSubDir runTime.path()/meshInstance/regionDir/polyMesh::meshSubDir
); );
if (exists(polyMeshPath)) if (exists(polyMeshPath))

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd. Copyright (C) 2016-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -184,16 +184,13 @@ int main(int argc, char *argv[])
); );
word regionName(polyMesh::defaultRegion); word regionName(polyMesh::defaultRegion);
word regionPath;
// Check if the region is specified otherwise mesh the default region // Check if the region is specified otherwise mesh the default region
if (args.readIfPresent("region", regionName)) if (args.readIfPresent("region", regionName))
{ {
Info<< nl << "Generating mesh for region " << regionName << endl; Info<< nl << "Generating mesh for region " << regionName << endl;
regionPath = regionName;
} }
// Instance for resulting mesh // Instance for resulting mesh
bool useTime = false; bool useTime = false;
word meshInstance(runTime.constant()); word meshInstance(runTime.constant());

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later. This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -18,10 +18,11 @@ Description
{ {
// Shadows enclosing parameter (dictName) // Shadows enclosing parameter (dictName)
const word blockMeshDictName("blockMeshDict"); const word blockMeshDictName("blockMeshDict");
const word& regionDir = polyMesh::regionName(regionName);
const fileName polyMeshPath const fileName polyMeshPath
( (
runTime.path()/meshInstance/regionPath/polyMesh::meshSubDir runTime.path()/meshInstance/regionDir/polyMesh::meshSubDir
); );
if (exists(polyMeshPath)) if (exists(polyMeshPath))

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd. Copyright (C) 2021-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later. This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -22,6 +22,7 @@ autoPtr<IOdictionary> meshDictPtr;
{ {
fileName dictPath; fileName dictPath;
const word& regionDir = polyMesh::regionName(regionName);
if (args.readIfPresent("dict", dictPath)) if (args.readIfPresent("dict", dictPath))
{ {
@ -37,15 +38,17 @@ autoPtr<IOdictionary> meshDictPtr;
exists exists
( (
runTime.path()/runTime.constant() runTime.path()/runTime.constant()
/regionPath/polyMesh::meshSubDir/dictName / regionDir/polyMesh::meshSubDir/dictName
) )
) )
{ {
// Dictionary present in constant polyMesh directory (old-style) // Dictionary present in constant polyMesh directory (old-style)
dictPath = dictPath =
(
runTime.constant() runTime.constant()
/regionPath/polyMesh::meshSubDir/dictName; / regionDir/polyMesh::meshSubDir/dictName
);
// Warn that constant/polyMesh/blockMeshDict was used // Warn that constant/polyMesh/blockMeshDict was used
@ -54,14 +57,14 @@ autoPtr<IOdictionary> meshDictPtr;
<< "Using the old blockMeshDict location: " << "Using the old blockMeshDict location: "
<< dictPath << nl << dictPath << nl
<< " instead of the default location: " << " instead of the default location: "
<< runTime.system()/regionPath/dictName << nl << runTime.system()/regionDir/dictName << nl
<< endl; << endl;
} }
else else
{ {
// Assume dictionary is to be found in the system directory // Assume dictionary is to be found in the system directory
dictPath = runTime.system()/regionPath/dictName; dictPath = runTime.system()/regionDir/dictName;
} }
IOobject meshDictIO IOobject meshDictIO

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd. Copyright (C) 2015-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -256,21 +256,19 @@ int main(int argc, char *argv[])
#include "createTimeExtruded.H" #include "createTimeExtruded.H"
// Get optional regionName // Get optional regionName
word regionName; word regionName(polyMesh::defaultRegion);
word regionDir;
if (args.readIfPresent("region", regionName)) if (args.readIfPresent("region", regionName))
{ {
regionDir = regionName;
Info<< "Create mesh " << regionName << " for time = " Info<< "Create mesh " << regionName << " for time = "
<< runTimeExtruded.timeName() << nl << endl; << runTimeExtruded.timeName() << nl << endl;
} }
else else
{ {
regionName = fvMesh::defaultRegion;
Info<< "Create mesh for time = " Info<< "Create mesh for time = "
<< runTimeExtruded.timeName() << nl << endl; << runTimeExtruded.timeName() << nl << endl;
} }
const IOdictionary dict const IOdictionary dict
( (
IOobject::selectIO IOobject::selectIO
@ -755,7 +753,12 @@ int main(int argc, char *argv[])
// Create dummy fvSchemes, fvSolution // Create dummy fvSchemes, fvSolution
fvMeshTools::createDummyFvMeshFiles(mesh, regionDir, true); fvMeshTools::createDummyFvMeshFiles
(
mesh,
polyMesh::regionName(regionName),
true
);
// Create actual mesh from polyTopoChange container // Create actual mesh from polyTopoChange container
autoPtr<mapPolyMesh> map = meshMod().makeMesh autoPtr<mapPolyMesh> map = meshMod().makeMesh

View File

@ -234,12 +234,12 @@ int main(int argc, char *argv[])
{ {
mesh = autoPtr<polyMesh>::New mesh = autoPtr<polyMesh>::New
( (
Foam::IOobject IOobject
( (
Foam::polyMesh::defaultRegion, polyMesh::defaultRegion,
runTimeExtruded.timeName(), runTimeExtruded.timeName(),
runTimeExtruded, runTimeExtruded,
Foam::IOobject::MUST_READ IOobject::MUST_READ
) )
); );
} }

View File

@ -331,7 +331,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
// ( // (
// IOobject // IOobject
// ( // (
// Foam::polyMesh::defaultRegion, // polyMesh::defaultRegion,
// instance, // instance,
// runTime_, // runTime_,
// IOobject::MUST_READ // IOobject::MUST_READ

View File

@ -1015,10 +1015,8 @@ Foam::label Foam::checkGeometry
const fileName outputDir const fileName outputDir
( (
mesh.time().globalPath() mesh.time().globalPath()/functionObject::outputPrefix
/functionObject::outputPrefix / mesh.regionName()/"checkMesh"
/(mesh.name() == polyMesh::defaultRegion ? word::null : mesh.name())
/"checkMesh"
); );
forAll(pbm, patchi) forAll(pbm, patchi)

View File

@ -52,15 +52,8 @@ License
void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology) void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
{ {
if (mesh.name() == Foam::polyMesh::defaultRegion) Info<< "Mesh stats " << mesh.regionName() << nl
{ << " points: "
Info<< "Mesh stats" << nl;
}
else
{
Info<< "Mesh " << mesh.name() << " stats" << nl;
}
Info<< " points: "
<< returnReduce(mesh.points().size(), sumOp<label>()) << nl; << returnReduce(mesh.points().size(), sumOp<label>()) << nl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -130,11 +130,10 @@ int main(int argc, char *argv[])
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word& regionDir = const fileName meshDir
( (
regionName == polyMesh::defaultRegion ? word::null : regionName polyMesh::regionName(regionName)/polyMesh::meshSubDir
); );
const fileName meshDir = regionDir/polyMesh::meshSubDir;
if (regionNames.size() > 1) if (regionNames.size() > 1)
{ {

View File

@ -369,11 +369,10 @@ int main(int argc, char *argv[])
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word& regionDir = const fileName meshDir
( (
regionName == polyMesh::defaultRegion ? word::null : regionName polyMesh::regionName(regionName)/polyMesh::meshSubDir
); );
const fileName meshDir = regionDir/polyMesh::meshSubDir;
if (regionNames.size() > 1) if (regionNames.size() > 1)
{ {

View File

@ -297,16 +297,18 @@ int main(int argc, char *argv[])
IOobject::fileModificationChecking = IOobject::timeStamp; IOobject::fileModificationChecking = IOobject::timeStamp;
fileName meshDir = polyMesh::meshSubDir; word regionName(polyMesh::defaultRegion);
fileName regionPrefix = "";
word regionName = polyMesh::defaultRegion;
if (args.readIfPresent("region", regionName)) if (args.readIfPresent("region", regionName))
{ {
Info<< "Using region " << regionName << nl << endl; Info<< "Using region " << regionName << nl << endl;
regionPrefix = regionName;
meshDir = regionName/polyMesh::meshSubDir;
} }
const fileName meshDir
(
polyMesh::regionName(regionName)/polyMesh::meshSubDir
);
Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);
forAll(timeDirs, timeI) forAll(timeDirs, timeI)
@ -349,7 +351,7 @@ int main(int argc, char *argv[])
writeMeshObject<pointIOField> writeMeshObject<pointIOField>
( (
"internalDelaunayVertices", "internalDelaunayVertices",
regionPrefix, polyMesh::regionName(regionName),
runTime runTime
); );
@ -365,7 +367,12 @@ int main(int argc, char *argv[])
} }
// Get list of objects from the database // Get list of objects from the database
IOobjectList objects(runTime, runTime.timeName(), regionPrefix); IOobjectList objects
(
runTime,
runTime.timeName(),
polyMesh::regionName(regionName)
);
forAllConstIters(objects, iter) forAllConstIters(objects, iter)
{ {
@ -417,7 +424,7 @@ int main(int argc, char *argv[])
fileHandler().filePath fileHandler().filePath
( (
runTime.timePath() runTime.timePath()
/ regionPrefix / polyMesh::regionName(regionName)
/ cloud::prefix / cloud::prefix
) )
); );

View File

@ -274,7 +274,7 @@ void decomposeUniform
// Link with relative paths // Link with relative paths
string parentPath = string("..")/".."; string parentPath = string("..")/"..";
if (regionDir != word::null) if (!regionDir.empty())
{ {
parentPath = parentPath/".."; parentPath = parentPath/"..";
} }
@ -479,10 +479,7 @@ int main(int argc, char *argv[])
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word& regionDir = const word& regionDir = polyMesh::regionName(regionName);
(
regionName == polyMesh::defaultRegion ? word::null : regionName
);
if (args.dryRun()) if (args.dryRun())
{ {

View File

@ -294,12 +294,7 @@ int main(int argc, char *argv[])
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word& regionDir = const word& regionDir = polyMesh::regionName(regionName);
(
regionName != polyMesh::defaultRegion
? regionName
: word::null
);
Info<< "\n\nReconstructing fields" << nl Info<< "\n\nReconstructing fields" << nl
<< "region=" << regionName << nl << endl; << "region=" << regionName << nl << endl;
@ -925,7 +920,7 @@ int main(int argc, char *argv[])
// For the first region of a multi-region case additionally // For the first region of a multi-region case additionally
// copy the "uniform" directory in the time directory // copy the "uniform" directory in the time directory
if (regioni == 0 && regionDir != word::null) if (regioni == 0 && !regionDir.empty())
{ {
fileName uniformDir0 fileName uniformDir0
( (

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd. Copyright (C) 2016-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -450,18 +450,11 @@ void writeMesh
const labelListList& cellProcAddressing const labelListList& cellProcAddressing
) )
{ {
const word& regionDir =
(
mesh.name() == polyMesh::defaultRegion
? word::null
: mesh.name()
);
const fileName outputDir const fileName outputDir
( (
mesh.time().path() mesh.time().path()
/ mesh.time().timeName() / mesh.time().timeName()
/ regionDir / mesh.regionName()
/ polyMesh::meshSubDir / polyMesh::meshSubDir
); );
@ -489,18 +482,11 @@ void writeMaps
const labelUList& boundProcAddressing const labelUList& boundProcAddressing
) )
{ {
const word& regionDir =
(
procMesh.name() == polyMesh::defaultRegion
? word::null
: procMesh.name()
);
const fileName outputDir const fileName outputDir
( (
procMesh.time().caseName() procMesh.time().caseName()
/ procMesh.facesInstance() / procMesh.facesInstance()
/ regionDir / procMesh.regionName()
/ polyMesh::meshSubDir / polyMesh::meshSubDir
); );
@ -775,18 +761,12 @@ int main(int argc, char *argv[])
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word& regionDir =
(
regionName == polyMesh::defaultRegion
? word::null
: regionName
);
IOobject facesIO IOobject facesIO
( (
"faces", "faces",
databases[0].timeName(), databases[0].timeName(),
regionDir/polyMesh::meshSubDir, polyMesh::regionName(regionName)/polyMesh::meshSubDir,
databases[0], databases[0],
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
@ -817,12 +797,7 @@ int main(int argc, char *argv[])
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word& regionDir = const word& regionDir = polyMesh::regionName(regionName);
(
regionName == polyMesh::defaultRegion
? word::null
: regionName
);
if (!hasRegionMesh[regioni]) if (!hasRegionMesh[regioni])
{ {

View File

@ -1313,10 +1313,7 @@ int main(int argc, char *argv[])
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word& regionDir = const word& regionDir = polyMesh::regionName(regionName);
(
regionName == polyMesh::defaultRegion ? word::null : regionName
);
const fileName volMeshSubDir(regionDir/polyMesh::meshSubDir); const fileName volMeshSubDir(regionDir/polyMesh::meshSubDir);
const fileName areaMeshSubDir(regionDir/faMesh::meshSubDir); const fileName areaMeshSubDir(regionDir/faMesh::meshSubDir);
@ -2087,10 +2084,8 @@ int main(int argc, char *argv[])
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word& regionDir = const word& regionDir = polyMesh::regionName(regionName);
(
regionName == polyMesh::defaultRegion ? word::null : regionName
);
const fileName volMeshSubDir(regionDir/polyMesh::meshSubDir); const fileName volMeshSubDir(regionDir/polyMesh::meshSubDir);
const fileName areaMeshSubDir(regionDir/faMesh::meshSubDir); const fileName areaMeshSubDir(regionDir/faMesh::meshSubDir);

View File

@ -28,12 +28,7 @@ PtrList<ensightFaMesh> ensightMeshesFa(regionNames.size());
const fvMesh& mesh = meshes[regioni]; const fvMesh& mesh = meshes[regioni];
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word& regionDir = const word& regionDir = polyMesh::regionName(regionName);
(
regionName != polyMesh::defaultRegion
? regionName
: word::null
);
fileName ensCasePath(outputDir); fileName ensCasePath(outputDir);
word ensCaseName(args.globalCaseName()); word ensCaseName(args.globalCaseName());

View File

@ -29,14 +29,11 @@ if (timeDirs.size() && doLagrangian)
auto& cloudFields = regionCloudFields[regioni]; auto& cloudFields = regionCloudFields[regioni];
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word& regionDir =
(
regionName != polyMesh::defaultRegion
? regionName
: word::null
);
const fileName cloudPrefix(regionDir/cloud::prefix); const fileName cloudPrefix
(
polyMesh::regionName(regionName)/cloud::prefix
);
for (const instant& inst : timeDirs) for (const instant& inst : timeDirs)
{ {

View File

@ -512,12 +512,7 @@ int main(int argc, char *argv[])
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word& regionDir = const word& regionDir = polyMesh::regionName(regionName);
(
regionName != polyMesh::defaultRegion
? regionName
: word::null
);
if (regionNames.size() > 1) if (regionNames.size() > 1)
{ {

View File

@ -697,21 +697,16 @@ int main(int argc, char *argv[])
for (const word& regionName : regionNames) for (const word& regionName : regionNames)
{ {
const word& regionDir = fileName regionOutDir(outputDir/polyMesh::regionName(regionName));
(
regionName == polyMesh::defaultRegion ? word::null : regionName
);
fileName regionalDir(outputDir/regionDir); if (args.found("overwrite") && Foam::isDir(regionOutDir))
if (args.found("overwrite") && Foam::isDir(regionalDir))
{ {
Info<< "Removing old directory " Info<< "Removing old directory "
<< args.relativePath(regionalDir) << args.relativePath(regionOutDir)
<< nl << endl; << nl << endl;
Foam::rmDir(regionalDir); Foam::rmDir(regionOutDir);
} }
Foam::mkDir(regionalDir); Foam::mkDir(regionOutDir);
} }
} }
@ -749,11 +744,9 @@ int main(int argc, char *argv[])
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word& regionDir = const word& regionDir = polyMesh::regionName(regionName);
(
regionName == polyMesh::defaultRegion ? word::null : regionName if (regionNames.size() > 1)
);
if (regionNames.size() > 1 || !regionDir.empty())
{ {
Info<< "region = " << regionName << nl; Info<< "region = " << regionName << nl;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd. Copyright (C) 2016-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -498,13 +498,6 @@ int main(int argc, char *argv[])
} }
fileName regionPrefix;
if (regionName != polyMesh::defaultRegion)
{
regionPrefix = regionName;
}
// Make sure we do not use the master-only reading since we read // Make sure we do not use the master-only reading since we read
// fields (different per processor) as dictionaries. // fields (different per processor) as dictionaries.
IOobject::fileModificationChecking = IOobject::timeStamp; IOobject::fileModificationChecking = IOobject::timeStamp;
@ -547,7 +540,7 @@ int main(int argc, char *argv[])
"boundary", "boundary",
runTime.findInstance runTime.findInstance
( (
regionPrefix/polyMesh::meshSubDir, polyMesh::regionName(regionName)/polyMesh::meshSubDir,
"boundary", "boundary",
IOobject::READ_IF_PRESENT IOobject::READ_IF_PRESENT
), ),

View File

@ -145,7 +145,7 @@ void createFieldFiles
fileName regionPath = "/"; fileName regionPath = "/";
if (regionName != word::null) if (!regionName.empty())
{ {
regionPath += regionName + '/'; regionPath += regionName + '/';
} }
@ -294,7 +294,7 @@ int main(int argc, char *argv[])
{ {
const word& regionName = solver.regionName(regionI); const word& regionName = solver.regionName(regionI);
if (regionName == word::null) if (regionName.empty())
{ {
Info<< "Region: " << polyMesh::defaultRegion << " (default)" Info<< "Region: " << polyMesh::defaultRegion << " (default)"
<< endl; << endl;

View File

@ -78,14 +78,11 @@ Foam::dictionary Foam::solverTemplate::readFluidFieldTemplates
{ {
Info<< " Reading fluid field templates"; Info<< " Reading fluid field templates";
if (regionName == word::null) if (!regionName.empty())
{ {
Info<< endl; Info<< " for region " << regionName;
}
else
{
Info<< " for region " << regionName << endl;
} }
Info<< endl;
dictionary fieldTemplates = solverDict.subDict("fluidFields"); dictionary fieldTemplates = solverDict.subDict("fluidFields");

View File

@ -290,21 +290,21 @@ int main(int argc, char *argv[])
const fileName rootDirSource = casePath.path().toAbsolute(); const fileName rootDirSource = casePath.path().toAbsolute();
const fileName caseDirSource = casePath.name(); const fileName caseDirSource = casePath.name();
Info<< "Source: " << rootDirSource << " " << caseDirSource << endl; Info<< "Source: " << rootDirSource << ' ' << caseDirSource;
word sourceRegion = polyMesh::defaultRegion; word sourceRegion(polyMesh::defaultRegion);
if (args.found("sourceRegion")) if (args.readIfPresent("sourceRegion", sourceRegion))
{ {
sourceRegion = args["sourceRegion"]; Info<< " (region " << sourceRegion << ')';
Info<< "Source region: " << sourceRegion << endl;
} }
Info<< endl;
Info<< "Target: " << rootDirTarget << " " << caseDirTarget << endl; Info<< "Target: " << rootDirTarget << ' ' << caseDirTarget;
word targetRegion = polyMesh::defaultRegion; word targetRegion(polyMesh::defaultRegion);
if (args.found("targetRegion")) if (args.readIfPresent("targetRegion", targetRegion))
{ {
targetRegion = args["targetRegion"]; Info<< " (region " << targetRegion << ')';
Info<< "Target region: " << targetRegion << endl;
} }
Info<< endl;
const bool parallelSource = args.found("parallelSource"); const bool parallelSource = args.found("parallelSource");
const bool parallelTarget = args.found("parallelTarget"); const bool parallelTarget = args.found("parallelTarget");

View File

@ -220,19 +220,21 @@ int main(int argc, char *argv[])
const fileName rootDirSource = casePath.path(); const fileName rootDirSource = casePath.path();
const fileName caseDirSource = casePath.name(); const fileName caseDirSource = casePath.name();
Info<< "Source: " << rootDirSource << " " << caseDirSource << endl; Info<< "Source: " << rootDirSource << ' ' << caseDirSource;
word sourceRegion = polyMesh::defaultRegion; word sourceRegion(polyMesh::defaultRegion);
if (args.readIfPresent("sourceRegion", sourceRegion)) if (args.readIfPresent("sourceRegion", sourceRegion))
{ {
Info<< "Source region: " << sourceRegion << endl; Info<< " (region " << sourceRegion << ')';
} }
Info<< endl;
Info<< "Target: " << rootDirTarget << " " << caseDirTarget << endl; Info<< "Target: " << rootDirTarget << ' ' << caseDirTarget;
word targetRegion = polyMesh::defaultRegion; word targetRegion(polyMesh::defaultRegion);
if (args.readIfPresent("targetRegion", targetRegion)) if (args.readIfPresent("targetRegion", targetRegion))
{ {
Info<< "Target region: " << targetRegion << endl; Info<< " (region " << targetRegion << ')';
} }
Info<< endl;
const bool consistent = args.found("consistent"); const bool consistent = args.found("consistent");

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2018 OpenFOAM Foundation Copyright (C) 2012-2018 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -58,14 +58,11 @@ Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const
/ functionObject::outputPrefix / functionObject::outputPrefix
); );
// Append mesh name if not default region // Append mesh region name if not default region
if (isA<polyMesh>(fileObr_)) const auto* meshPtr = isA<polyMesh>(fileObr_);
if (meshPtr)
{ {
const polyMesh& mesh = refCast<const polyMesh>(fileObr_); baseDir /= meshPtr->regionName();
if (mesh.name() != polyMesh::defaultRegion)
{
baseDir /= mesh.name();
}
} }
baseDir.clean(); // Remove unneeded ".." baseDir.clean(); // Remove unneeded ".."

View File

@ -34,11 +34,7 @@ Foam::PtrList<Foam::fvMesh> meshes(regionNames.size());
const Foam::word& regionName = regionNames[regioni]; const Foam::word& regionName = regionNames[regioni];
Foam::Info<< "Create mesh"; Foam::Info<< "Create mesh";
if if (regionNames.size() > 1)
(
regionNames.size() > 1
|| regionName != Foam::polyMesh::defaultRegion
)
{ {
Foam::Info<< ' ' << regionName; Foam::Info<< ' ' << regionName;
} }

View File

@ -44,11 +44,11 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(polyMesh, 0); defineTypeNameAndDebug(polyMesh, 0);
word polyMesh::defaultRegion = "region0";
word polyMesh::meshSubDir = "polyMesh";
} }
Foam::word Foam::polyMesh::defaultRegion = "region0";
Foam::word Foam::polyMesh::meshSubDir = "polyMesh";
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -824,6 +824,14 @@ Foam::polyMesh::~polyMesh()
} }
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
const Foam::word& Foam::polyMesh::regionName(const word& region)
{
return (region == polyMesh::defaultRegion ? word::null : region);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::fileName& Foam::polyMesh::dbDir() const const Foam::fileName& Foam::polyMesh::dbDir() const
@ -843,6 +851,12 @@ Foam::fileName Foam::polyMesh::meshDir() const
} }
const Foam::word& Foam::polyMesh::regionName() const
{
return polyMesh::regionName(objectRegistry::name());
}
const Foam::fileName& Foam::polyMesh::pointsInstance() const const Foam::fileName& Foam::polyMesh::pointsInstance() const
{ {
return points_.instance(); return points_.instance();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017, 2020 OpenFOAM Foundation Copyright (C) 2011-2017, 2020 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -41,8 +41,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef polyMesh_H #ifndef Foam_polyMesh_H
#define polyMesh_H #define Foam_polyMesh_H
#include "objectRegistry.H" #include "objectRegistry.H"
#include "primitiveMesh.H" #include "primitiveMesh.H"
@ -418,6 +418,15 @@ public:
); );
// Regions
//- The mesh region name or word::null if polyMesh::defaultRegion
static const word& regionName(const word& region);
//- The mesh region name or word::null if polyMesh::defaultRegion
const word& regionName() const;
// Access // Access
//- Return raw points //- Return raw points

View File

@ -48,8 +48,7 @@ namespace Foam
bool Foam::pointHistory::writeData() bool Foam::pointHistory::writeData()
{ {
const fvMesh& mesh = const fvMesh& mesh = time_.lookupObject<fvMesh>(polyMesh::defaultRegion);
time_.lookupObject<fvMesh>(polyMesh::defaultRegion);
vector position(Zero); vector position(Zero);
@ -98,8 +97,7 @@ Foam::pointHistory::pointHistory
dict.readIfPresent("region", regionName_); dict.readIfPresent("region", regionName_);
dict.readIfPresent("historyPointID", historyPointID_); dict.readIfPresent("historyPointID", historyPointID_);
const fvMesh& mesh = const fvMesh& mesh = time_.lookupObject<fvMesh>(regionName_);
time_.lookupObject<fvMesh>(regionName_);
const vectorField& points = mesh.points(); const vectorField& points = mesh.points();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -43,7 +43,7 @@ Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io)
( (
"dynamicMeshDict", "dynamicMeshDict",
io.time().constant(), io.time().constant(),
(io.name() == polyMesh::defaultRegion ? "" : io.name()), polyMesh::regionName(io.name()),
io.db(), io.db(),
IOobject::MUST_READ_IF_MODIFIED, IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE, IOobject::NO_WRITE,
@ -124,6 +124,14 @@ Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New
const Time& runTime const Time& runTime
) )
{ {
const IOobject meshIO
(
polyMesh::defaultRegion,
runTime.timeName(),
runTime,
IOobject::MUST_READ
);
if (args.dryRun() || args.found("dry-run-write")) if (args.dryRun() || args.found("dry-run-write"))
{ {
Info Info
@ -148,32 +156,10 @@ Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New
functionObject::outputPrefix = "postProcessing-dry-run"; functionObject::outputPrefix = "postProcessing-dry-run";
return return simplifiedMeshes::simplifiedDynamicFvMeshBase::New(meshIO);
simplifiedMeshes::simplifiedDynamicFvMeshBase::New
(
IOobject
(
polyMesh::defaultRegion,
runTime.timeName(),
runTime,
IOobject::MUST_READ
)
);
}
else
{
return
New
(
IOobject
(
polyMesh::defaultRegion,
runTime.timeName(),
runTime,
IOobject::MUST_READ
)
);
} }
return New(meshIO);
} }

View File

@ -1,30 +1,55 @@
Foam::word regionName = Foam::polyMesh::defaultRegion; /*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Create a dynamicFvMesh for a specified region, or the defaultRegion
Required Variables
- runTime [Time]
Provided Variables
- regionName [word]
- mesh [dynamicFvMesh], meshPtr
\*---------------------------------------------------------------------------*/
Foam::word regionName(Foam::polyMesh::defaultRegion);
Foam::autoPtr<Foam::dynamicFvMesh> meshPtr;
{
Foam::Info << "Create dynamic mesh";
if (args.readIfPresent("region", regionName)) if (args.readIfPresent("region", regionName))
{ {
Foam::Info Foam::Info << ' ' << regionName;
<< "Create mesh " << regionName << " for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
}
else
{
Foam::Info
<< "Create mesh for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
} }
Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
autoPtr<dynamicFvMesh> meshPtr meshPtr = dynamicFvMesh::New
( (
dynamicFvMesh::New IOobject
( (
IOobject regionName,
( runTime.timeName(),
regionName, runTime,
runTime.timeName(), IOobject::MUST_READ
runTime,
IOobject::MUST_READ
)
) )
); );
}
dynamicFvMesh& mesh = meshPtr();
dynamicFvMesh& mesh = meshPtr();
Foam::Info << Foam::endl;
// ************************************************************************* //

View File

@ -51,7 +51,7 @@ Foam::simplifiedMeshes::simplifiedDynamicFvMeshBase::New
( (
"dynamicMeshDict", "dynamicMeshDict",
io.time().constant(), io.time().constant(),
(io.name() == polyMesh::defaultRegion ? "" : io.name()), polyMesh::regionName(io.name()),
io.db(), io.db(),
IOobject::MUST_READ_IF_MODIFIED, IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE, IOobject::NO_WRITE,

View File

@ -601,6 +601,12 @@ const Foam::objectRegistry& Foam::faMesh::thisDb() const
} }
const Foam::word& Foam::faMesh::regionName() const
{
return polyMesh::regionName(thisDb().name());
}
void Foam::faMesh::removeFiles(const fileName& instanceDir) const void Foam::faMesh::removeFiles(const fileName& instanceDir) const
{ {
fileName meshFilesPath = thisDb().time().path()/instanceDir/meshDir(); fileName meshFilesPath = thisDb().time().path()/instanceDir/meshDir();

View File

@ -665,21 +665,27 @@ public:
inline bool hasInternalEdgeLabels() const noexcept; inline bool hasInternalEdgeLabels() const noexcept;
// Database
//- Return true if thisDb() is a valid DB
virtual bool hasDb() const;
//- Return reference to the mesh database
virtual const objectRegistry& thisDb() const;
//- Name function is needed to disambiguate those inherited
//- from base classes
const word& name() const
{
return thisDb().name();
}
//- The mesh region name or word::null if polyMesh::defaultRegion
const word& regionName() const;
// Access // Access
//- Return true if thisDb() is a valid DB
virtual bool hasDb() const;
//- Return reference to the mesh database
virtual const objectRegistry& thisDb() const;
//- Name function is needed to disambiguate those inherited
//- from base classes
const word& name() const
{
return thisDb().name();
}
//- Return constant reference to boundary mesh //- Return constant reference to boundary mesh
inline const faBoundaryMesh& boundary() const noexcept; inline const faBoundaryMesh& boundary() const noexcept;

View File

@ -77,8 +77,7 @@ Foam::autoPtr<Foam::faMesh> Foam::faMeshTools::newMesh
const fileName meshSubDir const fileName meshSubDir
( (
(pMesh.name() == polyMesh::defaultRegion ? word::null : pMesh.name()) pMesh.regionName() / faMesh::meshSubDir
/ faMesh::meshSubDir
); );
@ -260,8 +259,7 @@ Foam::autoPtr<Foam::faMesh> Foam::faMeshTools::loadOrCreateMesh
const fileName meshSubDir const fileName meshSubDir
( (
(pMesh.name() == polyMesh::defaultRegion ? word::null : pMesh.name()) pMesh.regionName() / faMesh::meshSubDir
/ faMesh::meshSubDir
); );

View File

@ -459,8 +459,7 @@ Foam::fvMeshTools::newMesh
const fileName meshSubDir const fileName meshSubDir
( (
(io.name() == polyMesh::defaultRegion ? word::null : io.name()) polyMesh::regionName(io.name()) / polyMesh::meshSubDir
/ polyMesh::meshSubDir
); );
@ -744,8 +743,7 @@ Foam::fvMeshTools::loadOrCreateMesh
const fileName meshSubDir const fileName meshSubDir
( (
(io.name() == polyMesh::defaultRegion ? word::null : io.name()) polyMesh::regionName(io.name()) / polyMesh::meshSubDir
/ polyMesh::meshSubDir
); );

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -64,7 +64,7 @@ bool Foam::simplifiedMeshes::columnFvMeshInfo::setPatchEntries
( (
"boundary", "boundary",
localInstance_, localInstance_,
regionPrefix_ + polyMesh::meshSubDir, polyMesh::regionName(regionName_)/polyMesh::meshSubDir,
runTime, runTime,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
@ -103,7 +103,7 @@ bool Foam::simplifiedMeshes::columnFvMeshInfo::setPatchEntries
( (
runTime, runTime,
runTime.timeName(), runTime.timeName(),
(regionName_ == polyMesh::defaultRegion ? "" : regionName_) polyMesh::regionName(regionName_)
); );
if (objects.empty()) if (objects.empty())
@ -209,7 +209,7 @@ void Foam::simplifiedMeshes::columnFvMeshInfo::initialise(const Time& runTime)
( (
"points", "points",
localInstance_, localInstance_,
regionPrefix_ + polyMesh::meshSubDir, polyMesh::regionName(regionName_)/polyMesh::meshSubDir,
runTime, runTime,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
@ -409,17 +409,11 @@ Foam::simplifiedMeshes::columnFvMeshInfo::columnFvMeshInfo
) )
: :
regionName_(regionName), regionName_(regionName),
regionPrefix_
(
regionName_ == polyMesh::defaultRegion
? ""
: regionName_ + '/'
),
localInstance_ localInstance_
( (
runTime.findInstance runTime.findInstance
( (
regionPrefix_ + polyMesh::meshSubDir, polyMesh::regionName(regionName_)/polyMesh::meshSubDir,
"boundary", "boundary",
IOobject::READ_IF_PRESENT IOobject::READ_IF_PRESENT
) )

View File

@ -73,14 +73,11 @@ class columnFvMeshInfo
protected: protected:
// Protected data // Protected Data
//- Region of existing mesh //- Region of existing mesh
const word regionName_; const word regionName_;
//- Additional prefix for region. Empty if default region
const fileName regionPrefix_;
//- Location of existing mesh (if present) //- Location of existing mesh (if present)
const word localInstance_; const word localInstance_;
@ -111,6 +108,7 @@ protected:
//- Number of patches with at least 1 local face //- Number of patches with at least 1 local face
label nPatchWithFace_; label nPatchWithFace_;
// Protected Member Functions // Protected Member Functions
//- Add the patches to the mesh //- Add the patches to the mesh

View File

@ -661,13 +661,10 @@ bool Foam::functionObjects::streamLineBase::writeToFile()
fileName vtkPath fileName vtkPath
( (
time_.globalPath()/functionObject::outputPrefix/"sets"/name() time_.globalPath()/functionObject::outputPrefix/"sets"
/ name()/mesh_.regionName()
/ mesh_.time().timeName()
); );
if (mesh_.name() != polyMesh::defaultRegion)
{
vtkPath = vtkPath/mesh_.name();
}
vtkPath = vtkPath/mesh_.time().timeName();
mkDir(vtkPath); mkDir(vtkPath);

View File

@ -87,9 +87,9 @@ void Foam::functionObjects::hydrostaticPressure::calculateAndWrite()
auto& p = thermo.p(); auto& p = thermo.p();
Info<< "Performing hydrostatic pressure initialisation"; Info<< "Performing hydrostatic pressure initialisation";
if (mesh_.name() != polyMesh::defaultRegion) if (!mesh_.regionName().empty())
{ {
Info<< "for region " << mesh_.name(); Info<< " region=" << mesh_.name();
} }

View File

@ -280,10 +280,7 @@ bool Foam::functionObjects::vtkWrite::write()
label regioni = 0; label regioni = 0;
for (const word& regionName : meshes_.sortedToc()) for (const word& regionName : meshes_.sortedToc())
{ {
const word& regionDir = const word& regionDir = polyMesh::regionName(regionName);
(
regionName == polyMesh::defaultRegion ? word::null : regionName
);
auto& meshProxy = meshSubsets_[regioni]; auto& meshProxy = meshSubsets_[regioni];
auto& vtuMeshCells = vtuMappings_[regioni]; auto& vtuMeshCells = vtuMappings_[regioni];

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd. Copyright (C) 2015-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -76,17 +76,11 @@ void Foam::probes::createProbeFiles(const wordList& fieldNames)
// Put in undecomposed case // Put in undecomposed case
// (Note: gives problems for distributed data running) // (Note: gives problems for distributed data running)
fileName probeSubDir = name();
if (mesh_.name() != polyMesh::defaultRegion)
{
probeSubDir = probeSubDir/mesh_.name();
}
fileName probeDir fileName probeDir
( (
mesh_.time().globalPath() mesh_.time().globalPath()
/ functionObject::outputPrefix / functionObject::outputPrefix
/ probeSubDir / name()/mesh_.regionName()
// Use startTime as the instance for output files // Use startTime as the instance for output files
/ mesh_.time().timeName(mesh_.time().startTime().value()) / mesh_.time().timeName(mesh_.time().startTime().value())
); );

View File

@ -88,17 +88,11 @@ Foam::OFstream* Foam::sampledSets::createProbeFile(const word& fieldName)
// Put in undecomposed case // Put in undecomposed case
// (Note: gives problems for distributed data running) // (Note: gives problems for distributed data running)
fileName probeSubDir = name();
if (mesh_.name() != polyMesh::defaultRegion)
{
probeSubDir = probeSubDir/mesh_.name();
}
fileName probeDir fileName probeDir
( (
mesh_.time().globalPath() mesh_.time().globalPath()
/ functionObject::outputPrefix / functionObject::outputPrefix
/ probeSubDir / name()/mesh_.regionName()
// Use startTime as the instance for output files // Use startTime as the instance for output files
/ mesh_.time().timeName(mesh_.time().startTime().value()) / mesh_.time().timeName(mesh_.time().startTime().value())
); );
@ -446,7 +440,8 @@ Foam::sampledSets::sampledSets
writeAsProbes_(false), writeAsProbes_(false),
outputPath_ outputPath_
( (
time_.globalPath()/functionObject::outputPrefix/name time_.globalPath()/functionObject::outputPrefix
/ name/mesh_.regionName()
), ),
searchEngine_(mesh_), searchEngine_(mesh_),
samplePointScheme_(), samplePointScheme_(),
@ -459,10 +454,6 @@ Foam::sampledSets::sampledSets
gatheredSorting_(), gatheredSorting_(),
globalIndices_() globalIndices_()
{ {
if (mesh_.name() != polyMesh::defaultRegion)
{
outputPath_ /= mesh_.name();
}
outputPath_.clean(); // Remove unneeded ".." outputPath_.clean(); // Remove unneeded ".."
read(dict); read(dict);
@ -487,7 +478,8 @@ Foam::sampledSets::sampledSets
writeAsProbes_(false), writeAsProbes_(false),
outputPath_ outputPath_
( (
time_.globalPath()/functionObject::outputPrefix/name time_.globalPath()/functionObject::outputPrefix
/ name/mesh_.regionName()
), ),
searchEngine_(mesh_), searchEngine_(mesh_),
samplePointScheme_(), samplePointScheme_(),
@ -500,10 +492,6 @@ Foam::sampledSets::sampledSets
gatheredSorting_(), gatheredSorting_(),
globalIndices_() globalIndices_()
{ {
if (mesh_.name() != polyMesh::defaultRegion)
{
outputPath_ /= mesh_.name();
}
outputPath_.clean(); // Remove unneeded ".." outputPath_.clean(); // Remove unneeded ".."
read(dict); read(dict);