diff --git a/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/createUpdatedDynamicFvMesh.H b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/createUpdatedDynamicFvMesh.H index ea5823cc1c3a9c0a1f8d8a6b80a59ad8d2145bff..66d37d170f04f965b6356fd5b06755907a3a7667 100644 --- a/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/createUpdatedDynamicFvMesh.H +++ b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/createUpdatedDynamicFvMesh.H @@ -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(), - runTime, - IOobject::MUST_READ - ) + polyMesh::defaultRegion, + runTime.timeName(), + runTime, + IOobject::MUST_READ ) ); +} + + +dynamicFvMesh& mesh = meshPtr(); + +// 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; - dynamicFvMesh& mesh = meshPtr(); - // Calculate initial mesh-to-mesh mapping. Note that this should be - // done under the hood, e.g. as a MeshObject - mesh.update(); +// ************************************************************************* // diff --git a/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createUpdatedDynamicFvMesh.H b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createUpdatedDynamicFvMesh.H index ea5823cc1c3a9c0a1f8d8a6b80a59ad8d2145bff..66d37d170f04f965b6356fd5b06755907a3a7667 100644 --- a/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createUpdatedDynamicFvMesh.H +++ b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createUpdatedDynamicFvMesh.H @@ -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(), - runTime, - IOobject::MUST_READ - ) + polyMesh::defaultRegion, + runTime.timeName(), + runTime, + IOobject::MUST_READ ) ); +} + + +dynamicFvMesh& mesh = meshPtr(); + +// 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; - dynamicFvMesh& mesh = meshPtr(); - // Calculate initial mesh-to-mesh mapping. Note that this should be - // done under the hood, e.g. as a MeshObject - mesh.update(); +// ************************************************************************* // diff --git a/applications/test/checkDecomposePar/Test-checkDecomposePar.C b/applications/test/checkDecomposePar/Test-checkDecomposePar.C index 3987a7d21e9f903dccc3e85261ef63fdacca29ae..5cc6bb231178ac305fe51d015a3c05cc13d907f7 100644 --- a/applications/test/checkDecomposePar/Test-checkDecomposePar.C +++ b/applications/test/checkDecomposePar/Test-checkDecomposePar.C @@ -89,12 +89,7 @@ int main(int argc, char *argv[]) forAll(regionNames, regioni) { const word& regionName = regionNames[regioni]; - // const word& regionDir = - // ( - // regionName != polyMesh::defaultRegion - // ? regionName - // : word::null - // ); + // const word& regionDir = polyMesh::regionName(regionName); Info<< "\n\nDecomposing mesh " << regionName << nl << endl; Info<< "Create mesh..." << flush; diff --git a/applications/utilities/finiteArea/makeFaMesh/findMeshDefinitionDict.H b/applications/utilities/finiteArea/makeFaMesh/findMeshDefinitionDict.H index 5385d38f370970df3fb593ac273e1b1befad9686..a5697ea69e3a83aa3796aae19b92829a9355fec0 100644 --- a/applications/utilities/finiteArea/makeFaMesh/findMeshDefinitionDict.H +++ b/applications/utilities/finiteArea/makeFaMesh/findMeshDefinitionDict.H @@ -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. @@ -21,9 +21,7 @@ autoPtr<IOdictionary> meshDictPtr; { fileName dictPath; - - const word& regionDir = - (regionName == polyMesh::defaultRegion ? word::null : regionName); + const word& regionDir = polyMesh::regionName(regionName); if (args.readIfPresent("dict", dictPath)) { @@ -40,15 +38,17 @@ autoPtr<IOdictionary> meshDictPtr; exists ( runTime.path()/runTime.caseConstant() - /regionDir/faMesh::meshSubDir/dictName + / regionDir/faMesh::meshSubDir/dictName ) ) { // Dictionary present in constant faMesh directory (old-style) dictPath = + ( runTime.constant() - /regionDir/faMesh::meshSubDir/dictName; + / regionDir/faMesh::meshSubDir/dictName + ); // Warn that constant/faMesh/faMeshDefinition was used // instead of system/faMeshDefinition diff --git a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C index 83685328e704d7007adb048c5d35980a8d098592..fec3b4bed8d6f145693dd791a168ac6e1d05d5d7 100644 --- a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C +++ b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C @@ -1317,7 +1317,7 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" - word regionName = polyMesh::defaultRegion; + word regionName(polyMesh::defaultRegion); if (args.readIfPresent("region", regionName)) { diff --git a/applications/utilities/mesh/generation/PDRblockMesh/PDRblockMesh.C b/applications/utilities/mesh/generation/PDRblockMesh/PDRblockMesh.C index 32d304c6b4caaefdf4a23d4f45f10797464f7b94..75fbbe7016adae2e5b89f089582dd0108bc4ee7e 100644 --- a/applications/utilities/mesh/generation/PDRblockMesh/PDRblockMesh.C +++ b/applications/utilities/mesh/generation/PDRblockMesh/PDRblockMesh.C @@ -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 diff --git a/applications/utilities/mesh/generation/PDRblockMesh/cleanMeshDirectory.H b/applications/utilities/mesh/generation/PDRblockMesh/cleanMeshDirectory.H index 46f017fb196001152cd4c47ef0bbf48b0a050e93..9b0d60bebd66b7b4e74268e28787bdc4583fec15 100644 --- a/applications/utilities/mesh/generation/PDRblockMesh/cleanMeshDirectory.H +++ b/applications/utilities/mesh/generation/PDRblockMesh/cleanMeshDirectory.H @@ -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)) diff --git a/applications/utilities/mesh/generation/blockMesh/blockMesh.C b/applications/utilities/mesh/generation/blockMesh/blockMesh.C index dae940888c49e372a95d9af3021e16e078360c6e..52942def33d983a5d0c5219ce7896bd9bb737157 100644 --- a/applications/utilities/mesh/generation/blockMesh/blockMesh.C +++ b/applications/utilities/mesh/generation/blockMesh/blockMesh.C @@ -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()); diff --git a/applications/utilities/mesh/generation/blockMesh/cleanMeshDirectory.H b/applications/utilities/mesh/generation/blockMesh/cleanMeshDirectory.H index 46f017fb196001152cd4c47ef0bbf48b0a050e93..9b0d60bebd66b7b4e74268e28787bdc4583fec15 100644 --- a/applications/utilities/mesh/generation/blockMesh/cleanMeshDirectory.H +++ b/applications/utilities/mesh/generation/blockMesh/cleanMeshDirectory.H @@ -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)) diff --git a/applications/utilities/mesh/generation/blockMesh/findBlockMeshDict.H b/applications/utilities/mesh/generation/blockMesh/findBlockMeshDict.H index 4f81c74ccc9719d81d75ca6ca10fcd041c00ede8..43f4ffecb6e072a865bdbec1ef7f4e80d6d4be5a 100644 --- a/applications/utilities/mesh/generation/blockMesh/findBlockMeshDict.H +++ b/applications/utilities/mesh/generation/blockMesh/findBlockMeshDict.H @@ -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 diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index bc5fba6e60093e975f3ed4cafc01dd3742841e37..f93e6f03afa7f51ade687353fa182ab43d4fa32b 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -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 diff --git a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMeshApp.C b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMeshApp.C index 92d91f25a91a6dbd7537f0b42ba99cc87e988692..7b235d8c48522f9bf09db9bbc33180b058d8e290 100644 --- a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMeshApp.C +++ b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMeshApp.C @@ -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 ) ); } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C index 37c3a3c528e6f24b8280d14739b72367f7e19c5e..bad6f988a0300a1ec72e085d1de3a6b4bbde0523 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C @@ -331,7 +331,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance) // ( // IOobject // ( -// Foam::polyMesh::defaultRegion, +// polyMesh::defaultRegion, // instance, // runTime_, // IOobject::MUST_READ diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C index ce2c8f83ce11d6f4a4ce623945f7f536ee2d9276..482acaaff37fb38d41bac2ea849532c36f5af815 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C @@ -1015,10 +1015,8 @@ Foam::label Foam::checkGeometry const fileName outputDir ( - mesh.time().globalPath() - /functionObject::outputPrefix - /(mesh.name() == polyMesh::defaultRegion ? word::null : mesh.name()) - /"checkMesh" + mesh.time().globalPath()/functionObject::outputPrefix + / mesh.regionName()/"checkMesh" ); forAll(pbm, patchi) diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C index 7e461b37a9270980ad36c252c3e4f5832488cf4b..1b29212518987f76603ee73018ee5fe11d524ab3 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C @@ -52,15 +52,8 @@ License void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology) { - if (mesh.name() == Foam::polyMesh::defaultRegion) - { - Info<< "Mesh stats" << nl; - } - else - { - Info<< "Mesh " << mesh.name() << " stats" << nl; - } - Info<< " points: " + Info<< "Mesh stats " << mesh.regionName() << nl + << " points: " << returnReduce(mesh.points().size(), sumOp<label>()) << nl; diff --git a/applications/utilities/mesh/manipulation/rotateMesh/rotateMesh.C b/applications/utilities/mesh/manipulation/rotateMesh/rotateMesh.C index 9950dc0e69b43b5f62a02431c3c93a2e6ecdb8b9..d2e53138ea1e2fa1cb5069d8bb78475e524a0717 100644 --- a/applications/utilities/mesh/manipulation/rotateMesh/rotateMesh.C +++ b/applications/utilities/mesh/manipulation/rotateMesh/rotateMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -130,11 +130,10 @@ int main(int argc, char *argv[]) forAll(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) { diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C index 2fdcf6edd0e059d7a495307b96de06f3574c2ad0..dd82546f4e9f3ef53154d3a09f74d7b030e931f2 100644 --- a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C +++ b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C @@ -369,11 +369,10 @@ int main(int argc, char *argv[]) forAll(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) { diff --git a/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C b/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C index 518e2510c6468942888984c895c9b527034503cc..44ef3d3f7c610a36b4aba87eccd63f976572ca6a 100644 --- a/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C +++ b/applications/utilities/miscellaneous/foamFormatConvert/foamFormatConvert.C @@ -297,16 +297,18 @@ int main(int argc, char *argv[]) IOobject::fileModificationChecking = IOobject::timeStamp; - fileName meshDir = polyMesh::meshSubDir; - fileName regionPrefix = ""; - word regionName = polyMesh::defaultRegion; + word regionName(polyMesh::defaultRegion); if (args.readIfPresent("region", regionName)) { 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); forAll(timeDirs, timeI) @@ -349,7 +351,7 @@ int main(int argc, char *argv[]) writeMeshObject<pointIOField> ( "internalDelaunayVertices", - regionPrefix, + polyMesh::regionName(regionName), runTime ); @@ -365,7 +367,12 @@ int main(int argc, char *argv[]) } // Get list of objects from the database - IOobjectList objects(runTime, runTime.timeName(), regionPrefix); + IOobjectList objects + ( + runTime, + runTime.timeName(), + polyMesh::regionName(regionName) + ); forAllConstIters(objects, iter) { @@ -417,7 +424,7 @@ int main(int argc, char *argv[]) fileHandler().filePath ( runTime.timePath() - / regionPrefix + / polyMesh::regionName(regionName) / cloud::prefix ) ); diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 7157fa89dd4fe70216a7bdd83bd519f41e9a8e30..a2510f3086766de3a7d7705005420d8916bd349b 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -274,7 +274,7 @@ void decomposeUniform // Link with relative paths string parentPath = string("..")/".."; - if (regionDir != word::null) + if (!regionDir.empty()) { parentPath = parentPath/".."; } @@ -479,10 +479,7 @@ int main(int argc, char *argv[]) forAll(regionNames, regioni) { const word& regionName = regionNames[regioni]; - const word& regionDir = - ( - regionName == polyMesh::defaultRegion ? word::null : regionName - ); + const word& regionDir = polyMesh::regionName(regionName); if (args.dryRun()) { diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C index 5ea758d254894b6beebebcd1e6638bdbc01f3114..4e3968cd3312a8821bc8bd195827d572a645d8bf 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C @@ -294,12 +294,7 @@ int main(int argc, char *argv[]) forAll(regionNames, regioni) { const word& regionName = regionNames[regioni]; - const word& regionDir = - ( - regionName != polyMesh::defaultRegion - ? regionName - : word::null - ); + const word& regionDir = polyMesh::regionName(regionName); Info<< "\n\nReconstructing fields" << nl << "region=" << regionName << nl << endl; @@ -925,7 +920,7 @@ int main(int argc, char *argv[]) // For the first region of a multi-region case additionally // copy the "uniform" directory in the time directory - if (regioni == 0 && regionDir != word::null) + if (regioni == 0 && !regionDir.empty()) { fileName uniformDir0 ( diff --git a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C index 7679e08ed3d533a61b8ed1b7e962cd9e8b382514..4b57c890dca1097aae0949353b2993589d3758ea 100644 --- a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C +++ b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -450,18 +450,11 @@ void writeMesh const labelListList& cellProcAddressing ) { - const word& regionDir = - ( - mesh.name() == polyMesh::defaultRegion - ? word::null - : mesh.name() - ); - const fileName outputDir ( mesh.time().path() / mesh.time().timeName() - / regionDir + / mesh.regionName() / polyMesh::meshSubDir ); @@ -489,18 +482,11 @@ void writeMaps const labelUList& boundProcAddressing ) { - const word& regionDir = - ( - procMesh.name() == polyMesh::defaultRegion - ? word::null - : procMesh.name() - ); - const fileName outputDir ( procMesh.time().caseName() / procMesh.facesInstance() - / regionDir + / procMesh.regionName() / polyMesh::meshSubDir ); @@ -775,18 +761,12 @@ int main(int argc, char *argv[]) forAll(regionNames, regioni) { const word& regionName = regionNames[regioni]; - const word& regionDir = - ( - regionName == polyMesh::defaultRegion - ? word::null - : regionName - ); IOobject facesIO ( "faces", databases[0].timeName(), - regionDir/polyMesh::meshSubDir, + polyMesh::regionName(regionName)/polyMesh::meshSubDir, databases[0], IOobject::NO_READ, IOobject::NO_WRITE @@ -817,12 +797,7 @@ int main(int argc, char *argv[]) forAll(regionNames, regioni) { const word& regionName = regionNames[regioni]; - const word& regionDir = - ( - regionName == polyMesh::defaultRegion - ? word::null - : regionName - ); + const word& regionDir = polyMesh::regionName(regionName); if (!hasRegionMesh[regioni]) { diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index 36643487d66ad73b36b436e8ed836558190faf6e..9010cd6db23aa9931343eec5a7a145892fe660ca 100644 --- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -1313,10 +1313,7 @@ int main(int argc, char *argv[]) forAll(regionNames, regioni) { const word& regionName = regionNames[regioni]; - const word& regionDir = - ( - regionName == polyMesh::defaultRegion ? word::null : regionName - ); + const word& regionDir = polyMesh::regionName(regionName); const fileName volMeshSubDir(regionDir/polyMesh::meshSubDir); const fileName areaMeshSubDir(regionDir/faMesh::meshSubDir); @@ -2087,10 +2084,8 @@ int main(int argc, char *argv[]) forAll(regionNames, regioni) { const word& regionName = regionNames[regioni]; - const word& regionDir = - ( - regionName == polyMesh::defaultRegion ? word::null : regionName - ); + const word& regionDir = polyMesh::regionName(regionName); + const fileName volMeshSubDir(regionDir/polyMesh::meshSubDir); const fileName areaMeshSubDir(regionDir/faMesh::meshSubDir); diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/createMeshAccounting.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/createMeshAccounting.H index 7d33588a56993343190ceccd9eb395e09bebfbe6..43c274ebfca4750bcffa9d3c9b79e8d073b28467 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/createMeshAccounting.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/createMeshAccounting.H @@ -28,12 +28,7 @@ PtrList<ensightFaMesh> ensightMeshesFa(regionNames.size()); const fvMesh& mesh = meshes[regioni]; const word& regionName = regionNames[regioni]; - const word& regionDir = - ( - regionName != polyMesh::defaultRegion - ? regionName - : word::null - ); + const word& regionDir = polyMesh::regionName(regionName); fileName ensCasePath(outputDir); word ensCaseName(args.globalCaseName()); diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/findCloudFields.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/findCloudFields.H index debff3288a00f83689c34b0b3c77e7ca3e1ea9be..30adf8ed22f5537bee500504da14d00ee4145941 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/findCloudFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/findCloudFields.H @@ -29,15 +29,12 @@ if (timeDirs.size() && doLagrangian) auto& cloudFields = regionCloudFields[regioni]; const word& regionName = regionNames[regioni]; - const word& regionDir = + + const fileName cloudPrefix ( - regionName != polyMesh::defaultRegion - ? regionName - : word::null + polyMesh::regionName(regionName)/cloud::prefix ); - const fileName cloudPrefix(regionDir/cloud::prefix); - for (const instant& inst : timeDirs) { const word& timeName = inst.name(); diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C index 12b4891c3df4ffa342f8959abd804a9945f526f1..fab7b60eb8500d82df48d07b98a17e6fc709e9e1 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C @@ -512,12 +512,7 @@ int main(int argc, char *argv[]) forAll(regionNames, regioni) { const word& regionName = regionNames[regioni]; - const word& regionDir = - ( - regionName != polyMesh::defaultRegion - ? regionName - : word::null - ); + const word& regionDir = polyMesh::regionName(regionName); if (regionNames.size() > 1) { diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index 9f02a529bccdbb48d9b42ee3d9e24a97918da4ef..a14329a0be887d403fc1364fe499dec27124e1ed 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -697,21 +697,16 @@ int main(int argc, char *argv[]) for (const word& regionName : regionNames) { - const word& regionDir = - ( - regionName == polyMesh::defaultRegion ? word::null : regionName - ); - - fileName regionalDir(outputDir/regionDir); + fileName regionOutDir(outputDir/polyMesh::regionName(regionName)); - if (args.found("overwrite") && Foam::isDir(regionalDir)) + if (args.found("overwrite") && Foam::isDir(regionOutDir)) { Info<< "Removing old directory " - << args.relativePath(regionalDir) + << args.relativePath(regionOutDir) << 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) { const word& regionName = regionNames[regioni]; - const word& regionDir = - ( - regionName == polyMesh::defaultRegion ? word::null : regionName - ); - if (regionNames.size() > 1 || !regionDir.empty()) + const word& regionDir = polyMesh::regionName(regionName); + + if (regionNames.size() > 1) { Info<< "region = " << regionName << nl; } diff --git a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C index 458dc61e8ad2ed5c76a54ab11cb6457186f6a7e8..b28e45f8313339eeb5c40667acf65b40b0910239 100644 --- a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C +++ b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License 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 // fields (different per processor) as dictionaries. IOobject::fileModificationChecking = IOobject::timeStamp; @@ -547,7 +540,7 @@ int main(int argc, char *argv[]) "boundary", runTime.findInstance ( - regionPrefix/polyMesh::meshSubDir, + polyMesh::regionName(regionName)/polyMesh::meshSubDir, "boundary", IOobject::READ_IF_PRESENT ), diff --git a/applications/utilities/preProcessing/createZeroDirectory/createZeroDirectory.C b/applications/utilities/preProcessing/createZeroDirectory/createZeroDirectory.C index 5c09e1bbd67d66612cbbeeff4a0fb53e7412ed02..3cdc15bff73265f2975f62cd43283f32c33d9357 100644 --- a/applications/utilities/preProcessing/createZeroDirectory/createZeroDirectory.C +++ b/applications/utilities/preProcessing/createZeroDirectory/createZeroDirectory.C @@ -145,7 +145,7 @@ void createFieldFiles fileName regionPath = "/"; - if (regionName != word::null) + if (!regionName.empty()) { regionPath += regionName + '/'; } @@ -294,7 +294,7 @@ int main(int argc, char *argv[]) { const word& regionName = solver.regionName(regionI); - if (regionName == word::null) + if (regionName.empty()) { Info<< "Region: " << polyMesh::defaultRegion << " (default)" << endl; diff --git a/applications/utilities/preProcessing/createZeroDirectory/solverTemplate.C b/applications/utilities/preProcessing/createZeroDirectory/solverTemplate.C index aa1a5cf9bc6a766b45ba65a4c8790f162c04f7cf..deeaec638247b0e357d9b32a1961a0406268d783 100644 --- a/applications/utilities/preProcessing/createZeroDirectory/solverTemplate.C +++ b/applications/utilities/preProcessing/createZeroDirectory/solverTemplate.C @@ -78,14 +78,11 @@ Foam::dictionary Foam::solverTemplate::readFluidFieldTemplates { Info<< " Reading fluid field templates"; - if (regionName == word::null) + if (!regionName.empty()) { - Info<< endl; - } - else - { - Info<< " for region " << regionName << endl; + Info<< " for region " << regionName; } + Info<< endl; dictionary fieldTemplates = solverDict.subDict("fluidFields"); diff --git a/applications/utilities/preProcessing/mapFields/mapFields.C b/applications/utilities/preProcessing/mapFields/mapFields.C index 047e61320925321075c99c58ba1203c7e0eb64bd..8b5b24dd294db4d0db861f82d6a5ad7f57de6891 100644 --- a/applications/utilities/preProcessing/mapFields/mapFields.C +++ b/applications/utilities/preProcessing/mapFields/mapFields.C @@ -290,21 +290,21 @@ int main(int argc, char *argv[]) const fileName rootDirSource = casePath.path().toAbsolute(); const fileName caseDirSource = casePath.name(); - Info<< "Source: " << rootDirSource << " " << caseDirSource << endl; - word sourceRegion = polyMesh::defaultRegion; - if (args.found("sourceRegion")) + Info<< "Source: " << rootDirSource << ' ' << caseDirSource; + word sourceRegion(polyMesh::defaultRegion); + if (args.readIfPresent("sourceRegion", sourceRegion)) { - sourceRegion = args["sourceRegion"]; - Info<< "Source region: " << sourceRegion << endl; + Info<< " (region " << sourceRegion << ')'; } + Info<< endl; - Info<< "Target: " << rootDirTarget << " " << caseDirTarget << endl; - word targetRegion = polyMesh::defaultRegion; - if (args.found("targetRegion")) + Info<< "Target: " << rootDirTarget << ' ' << caseDirTarget; + word targetRegion(polyMesh::defaultRegion); + if (args.readIfPresent("targetRegion", targetRegion)) { - targetRegion = args["targetRegion"]; - Info<< "Target region: " << targetRegion << endl; + Info<< " (region " << targetRegion << ')'; } + Info<< endl; const bool parallelSource = args.found("parallelSource"); const bool parallelTarget = args.found("parallelTarget"); diff --git a/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C b/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C index 8b494325f25613f67a9663d5499c4b36c70e3184..cb610d4549ad47208be62b37f02ec601df9df36b 100644 --- a/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C +++ b/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C @@ -220,19 +220,21 @@ int main(int argc, char *argv[]) const fileName rootDirSource = casePath.path(); const fileName caseDirSource = casePath.name(); - Info<< "Source: " << rootDirSource << " " << caseDirSource << endl; - word sourceRegion = polyMesh::defaultRegion; + Info<< "Source: " << rootDirSource << ' ' << caseDirSource; + word sourceRegion(polyMesh::defaultRegion); if (args.readIfPresent("sourceRegion", sourceRegion)) { - Info<< "Source region: " << sourceRegion << endl; + Info<< " (region " << sourceRegion << ')'; } + Info<< endl; - Info<< "Target: " << rootDirTarget << " " << caseDirTarget << endl; - word targetRegion = polyMesh::defaultRegion; + Info<< "Target: " << rootDirTarget << ' ' << caseDirTarget; + word targetRegion(polyMesh::defaultRegion); if (args.readIfPresent("targetRegion", targetRegion)) { - Info<< "Target region: " << targetRegion << endl; + Info<< " (region " << targetRegion << ')'; } + Info<< endl; const bool consistent = args.found("consistent"); diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C index 51be217fda8cf1d7b88023b01ecbae1a016ac207..8c2d9f2cc4658a9a344d54539c1c20a879a0a760 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2018 OpenFOAM Foundation - Copyright (C) 2015-2020 OpenCFD Ltd. + Copyright (C) 2015-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,14 +58,11 @@ Foam::fileName Foam::functionObjects::writeFile::baseFileDir() const / functionObject::outputPrefix ); - // Append mesh name if not default region - if (isA<polyMesh>(fileObr_)) + // Append mesh region name if not default region + const auto* meshPtr = isA<polyMesh>(fileObr_); + if (meshPtr) { - const polyMesh& mesh = refCast<const polyMesh>(fileObr_); - if (mesh.name() != polyMesh::defaultRegion) - { - baseDir /= mesh.name(); - } + baseDir /= meshPtr->regionName(); } baseDir.clean(); // Remove unneeded ".." diff --git a/src/OpenFOAM/include/createNamedMeshes.H b/src/OpenFOAM/include/createNamedMeshes.H index a1d1512939de5283c0a75a91d1c5835ba5fae317..64af72a3de9078a5d6642372aad5551ca2a0eda1 100644 --- a/src/OpenFOAM/include/createNamedMeshes.H +++ b/src/OpenFOAM/include/createNamedMeshes.H @@ -34,11 +34,7 @@ Foam::PtrList<Foam::fvMesh> meshes(regionNames.size()); const Foam::word& regionName = regionNames[regioni]; Foam::Info<< "Create mesh"; - if - ( - regionNames.size() > 1 - || regionName != Foam::polyMesh::defaultRegion - ) + if (regionNames.size() > 1) { Foam::Info<< ' ' << regionName; } diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 466c82fde1aee2cbe61c19b82cf64314b6818506..f7fb0e115cedee85f9cee1e5ce3cadcf9d8a3ed4 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -44,11 +44,11 @@ License namespace Foam { 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 * * * * * * * * * * * // @@ -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 * * * * * * * * * * * * * // 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 { return points_.instance(); diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H index b5512d75fb4945f567d0d718bf827fe903553d4a..f0cdcf83c9c8dfde698d9357b7f23aedd6bfc324 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017, 2020 OpenFOAM Foundation - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,8 +41,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef polyMesh_H -#define polyMesh_H +#ifndef Foam_polyMesh_H +#define Foam_polyMesh_H #include "objectRegistry.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 //- Return raw points diff --git a/src/dynamicFaMesh/interfaceTrackingFvMesh/functionObjects/pointHistory/pointHistory.C b/src/dynamicFaMesh/interfaceTrackingFvMesh/functionObjects/pointHistory/pointHistory.C index d1060b286f3a5a62d9f58b20a83e8cd5655f41de..4cb7288cc627af0cd0d57374e31ae4955d4d1d5f 100644 --- a/src/dynamicFaMesh/interfaceTrackingFvMesh/functionObjects/pointHistory/pointHistory.C +++ b/src/dynamicFaMesh/interfaceTrackingFvMesh/functionObjects/pointHistory/pointHistory.C @@ -48,8 +48,7 @@ namespace Foam bool Foam::pointHistory::writeData() { - const fvMesh& mesh = - time_.lookupObject<fvMesh>(polyMesh::defaultRegion); + const fvMesh& mesh = time_.lookupObject<fvMesh>(polyMesh::defaultRegion); vector position(Zero); @@ -98,8 +97,7 @@ Foam::pointHistory::pointHistory dict.readIfPresent("region", regionName_); dict.readIfPresent("historyPointID", historyPointID_); - const fvMesh& mesh = - time_.lookupObject<fvMesh>(regionName_); + const fvMesh& mesh = time_.lookupObject<fvMesh>(regionName_); const vectorField& points = mesh.points(); diff --git a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C index ea6a5d9a020e4cbcebf4542db442c5337b772a3e..35643811290df5d391a31d909bbdf39ee0c3c174 100644 --- a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C +++ b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,7 +43,7 @@ Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io) ( "dynamicMeshDict", io.time().constant(), - (io.name() == polyMesh::defaultRegion ? "" : io.name()), + polyMesh::regionName(io.name()), io.db(), IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE, @@ -124,6 +124,14 @@ Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New const Time& runTime ) { + const IOobject meshIO + ( + polyMesh::defaultRegion, + runTime.timeName(), + runTime, + IOobject::MUST_READ + ); + if (args.dryRun() || args.found("dry-run-write")) { Info @@ -148,32 +156,10 @@ Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New functionObject::outputPrefix = "postProcessing-dry-run"; - return - 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 simplifiedMeshes::simplifiedDynamicFvMeshBase::New(meshIO); } + + return New(meshIO); } diff --git a/src/dynamicFvMesh/include/createNamedDynamicFvMesh.H b/src/dynamicFvMesh/include/createNamedDynamicFvMesh.H index 6cb1444055df5d73abf47e101debb3b037f667f0..dd659f2481fb4d80230ee6e456ea45f40fafedfc 100644 --- a/src/dynamicFvMesh/include/createNamedDynamicFvMesh.H +++ b/src/dynamicFvMesh/include/createNamedDynamicFvMesh.H @@ -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)) { - Foam::Info - << "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 << ' ' << regionName; } + Foam::Info << " for time = " << runTime.timeName() << Foam::nl; - autoPtr<dynamicFvMesh> meshPtr + meshPtr = dynamicFvMesh::New ( - dynamicFvMesh::New + IOobject ( - IOobject - ( - regionName, - runTime.timeName(), - runTime, - IOobject::MUST_READ - ) + regionName, + runTime.timeName(), + runTime, + IOobject::MUST_READ ) ); +} + + +dynamicFvMesh& mesh = meshPtr(); + +Foam::Info << Foam::endl; + - dynamicFvMesh& mesh = meshPtr(); +// ************************************************************************* // diff --git a/src/dynamicFvMesh/simplifiedDynamicFvMesh/simplifiedDynamicFvMesh.C b/src/dynamicFvMesh/simplifiedDynamicFvMesh/simplifiedDynamicFvMesh.C index 92403dedf1bd2283617e9002512b6af469e71c7c..c7db30f8af2f34226c9e91d8cc19ccdc12496fe8 100644 --- a/src/dynamicFvMesh/simplifiedDynamicFvMesh/simplifiedDynamicFvMesh.C +++ b/src/dynamicFvMesh/simplifiedDynamicFvMesh/simplifiedDynamicFvMesh.C @@ -51,7 +51,7 @@ Foam::simplifiedMeshes::simplifiedDynamicFvMeshBase::New ( "dynamicMeshDict", io.time().constant(), - (io.name() == polyMesh::defaultRegion ? "" : io.name()), + polyMesh::regionName(io.name()), io.db(), IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE, diff --git a/src/finiteArea/faMesh/faMesh.C b/src/finiteArea/faMesh/faMesh.C index 32de35d34a6362d9ad3fb227535debf967bb617d..eeda85f1d5fb92e426fa8adee5d4b58dfe3e411c 100644 --- a/src/finiteArea/faMesh/faMesh.C +++ b/src/finiteArea/faMesh/faMesh.C @@ -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 { fileName meshFilesPath = thisDb().time().path()/instanceDir/meshDir(); diff --git a/src/finiteArea/faMesh/faMesh.H b/src/finiteArea/faMesh/faMesh.H index 4d59b4ac7963ca3190d83b1eb3ab790d9f6e454a..633ecd56fc29e9ba2f11e3bcfc44fe97c1e9ebf4 100644 --- a/src/finiteArea/faMesh/faMesh.H +++ b/src/finiteArea/faMesh/faMesh.H @@ -665,20 +665,26 @@ public: inline bool hasInternalEdgeLabels() const noexcept; - // Access + // Database - //- Return true if thisDb() is a valid DB - virtual bool hasDb() const; + //- Return true if thisDb() is a valid DB + virtual bool hasDb() const; - //- Return reference to the mesh database - virtual const objectRegistry& thisDb() 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(); - } + //- 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 //- Return constant reference to boundary mesh inline const faBoundaryMesh& boundary() const noexcept; diff --git a/src/finiteArea/faMesh/faMeshTools/faMeshTools.C b/src/finiteArea/faMesh/faMeshTools/faMeshTools.C index 24b46edf5e162eae5fd35d95bbb502cc2725fb6e..b7bbf8b90d3a8e87d7bbedf1fd232003b34768de 100644 --- a/src/finiteArea/faMesh/faMeshTools/faMeshTools.C +++ b/src/finiteArea/faMesh/faMeshTools/faMeshTools.C @@ -77,8 +77,7 @@ Foam::autoPtr<Foam::faMesh> Foam::faMeshTools::newMesh const fileName meshSubDir ( - (pMesh.name() == polyMesh::defaultRegion ? word::null : pMesh.name()) - / faMesh::meshSubDir + pMesh.regionName() / faMesh::meshSubDir ); @@ -260,8 +259,7 @@ Foam::autoPtr<Foam::faMesh> Foam::faMeshTools::loadOrCreateMesh const fileName meshSubDir ( - (pMesh.name() == polyMesh::defaultRegion ? word::null : pMesh.name()) - / faMesh::meshSubDir + pMesh.regionName() / faMesh::meshSubDir ); diff --git a/src/finiteVolume/fvMesh/fvMeshTools/fvMeshTools.C b/src/finiteVolume/fvMesh/fvMeshTools/fvMeshTools.C index 719aea05fd3fa6643d00a065edc6aeac688281b3..565c8a9223e2446a6ccb54582516da5bf1d8604c 100644 --- a/src/finiteVolume/fvMesh/fvMeshTools/fvMeshTools.C +++ b/src/finiteVolume/fvMesh/fvMeshTools/fvMeshTools.C @@ -459,8 +459,7 @@ Foam::fvMeshTools::newMesh const fileName meshSubDir ( - (io.name() == polyMesh::defaultRegion ? word::null : io.name()) - / polyMesh::meshSubDir + polyMesh::regionName(io.name()) / polyMesh::meshSubDir ); @@ -744,8 +743,7 @@ Foam::fvMeshTools::loadOrCreateMesh const fileName meshSubDir ( - (io.name() == polyMesh::defaultRegion ? word::null : io.name()) - / polyMesh::meshSubDir + polyMesh::regionName(io.name()) / polyMesh::meshSubDir ); diff --git a/src/finiteVolume/fvMesh/simplifiedFvMesh/columnFvMesh/columnFvMesh.C b/src/finiteVolume/fvMesh/simplifiedFvMesh/columnFvMesh/columnFvMesh.C index c373ab314b3ef650f51bb3bef5257834280af46f..7a242f9525f05fb45919a7693ecca06f8b2a669d 100644 --- a/src/finiteVolume/fvMesh/simplifiedFvMesh/columnFvMesh/columnFvMesh.C +++ b/src/finiteVolume/fvMesh/simplifiedFvMesh/columnFvMesh/columnFvMesh.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -64,7 +64,7 @@ bool Foam::simplifiedMeshes::columnFvMeshInfo::setPatchEntries ( "boundary", localInstance_, - regionPrefix_ + polyMesh::meshSubDir, + polyMesh::regionName(regionName_)/polyMesh::meshSubDir, runTime, IOobject::MUST_READ, IOobject::NO_WRITE, @@ -103,7 +103,7 @@ bool Foam::simplifiedMeshes::columnFvMeshInfo::setPatchEntries ( runTime, runTime.timeName(), - (regionName_ == polyMesh::defaultRegion ? "" : regionName_) + polyMesh::regionName(regionName_) ); if (objects.empty()) @@ -209,7 +209,7 @@ void Foam::simplifiedMeshes::columnFvMeshInfo::initialise(const Time& runTime) ( "points", localInstance_, - regionPrefix_ + polyMesh::meshSubDir, + polyMesh::regionName(regionName_)/polyMesh::meshSubDir, runTime, IOobject::MUST_READ, IOobject::NO_WRITE, @@ -409,17 +409,11 @@ Foam::simplifiedMeshes::columnFvMeshInfo::columnFvMeshInfo ) : regionName_(regionName), - regionPrefix_ - ( - regionName_ == polyMesh::defaultRegion - ? "" - : regionName_ + '/' - ), localInstance_ ( runTime.findInstance ( - regionPrefix_ + polyMesh::meshSubDir, + polyMesh::regionName(regionName_)/polyMesh::meshSubDir, "boundary", IOobject::READ_IF_PRESENT ) diff --git a/src/finiteVolume/fvMesh/simplifiedFvMesh/columnFvMesh/columnFvMesh.H b/src/finiteVolume/fvMesh/simplifiedFvMesh/columnFvMesh/columnFvMesh.H index 4e345ac3acfcd787a742d10f9462074b50ae6396..6096bca444dbd770d7f24953381d23219ad56b45 100644 --- a/src/finiteVolume/fvMesh/simplifiedFvMesh/columnFvMesh/columnFvMesh.H +++ b/src/finiteVolume/fvMesh/simplifiedFvMesh/columnFvMesh/columnFvMesh.H @@ -73,14 +73,11 @@ class columnFvMeshInfo protected: - // Protected data + // Protected Data //- Region of existing mesh const word regionName_; - //- Additional prefix for region. Empty if default region - const fileName regionPrefix_; - //- Location of existing mesh (if present) const word localInstance_; @@ -111,6 +108,7 @@ protected: //- Number of patches with at least 1 local face label nPatchWithFace_; + // Protected Member Functions //- Add the patches to the mesh diff --git a/src/functionObjects/field/streamLine/streamLineBase.C b/src/functionObjects/field/streamLine/streamLineBase.C index 67cf07f6faf40fbd962406fdfe9ee4f69bb2aa94..2540476981d3dbb45e77a8aa8443bd7ca9a6059d 100644 --- a/src/functionObjects/field/streamLine/streamLineBase.C +++ b/src/functionObjects/field/streamLine/streamLineBase.C @@ -661,13 +661,10 @@ bool Foam::functionObjects::streamLineBase::writeToFile() 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); diff --git a/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C b/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C index 2edb8e74a2d5d55b953e14a55495c12b14a741b0..53b387008163336116a626a51c11141a992419b2 100644 --- a/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C +++ b/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C @@ -87,9 +87,9 @@ void Foam::functionObjects::hydrostaticPressure::calculateAndWrite() auto& p = thermo.p(); Info<< "Performing hydrostatic pressure initialisation"; - if (mesh_.name() != polyMesh::defaultRegion) + if (!mesh_.regionName().empty()) { - Info<< "for region " << mesh_.name(); + Info<< " region=" << mesh_.name(); } diff --git a/src/functionObjects/utilities/vtkWrite/vtkWrite.C b/src/functionObjects/utilities/vtkWrite/vtkWrite.C index 5f92c2a7cdc970bafe06d14fd804ffad0046e360..84e49ab664f014956ff912a60a4e17a0d22d746c 100644 --- a/src/functionObjects/utilities/vtkWrite/vtkWrite.C +++ b/src/functionObjects/utilities/vtkWrite/vtkWrite.C @@ -280,10 +280,7 @@ bool Foam::functionObjects::vtkWrite::write() label regioni = 0; for (const word& regionName : meshes_.sortedToc()) { - const word& regionDir = - ( - regionName == polyMesh::defaultRegion ? word::null : regionName - ); + const word& regionDir = polyMesh::regionName(regionName); auto& meshProxy = meshSubsets_[regioni]; auto& vtuMeshCells = vtuMappings_[regioni]; diff --git a/src/sampling/probes/probes.C b/src/sampling/probes/probes.C index 849803e57a91bffd522b0a3c4d32520ec54ca352..bf2e91f9e638a3c2acbf083c23facad4fff0c2db 100644 --- a/src/sampling/probes/probes.C +++ b/src/sampling/probes/probes.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2021 OpenCFD Ltd. + Copyright (C) 2015-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -76,17 +76,11 @@ void Foam::probes::createProbeFiles(const wordList& fieldNames) // Put in undecomposed case // (Note: gives problems for distributed data running) - fileName probeSubDir = name(); - if (mesh_.name() != polyMesh::defaultRegion) - { - probeSubDir = probeSubDir/mesh_.name(); - } - fileName probeDir ( mesh_.time().globalPath() / functionObject::outputPrefix - / probeSubDir + / name()/mesh_.regionName() // Use startTime as the instance for output files / mesh_.time().timeName(mesh_.time().startTime().value()) ); diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.C b/src/sampling/sampledSet/sampledSets/sampledSets.C index 22a103472d4dc3ffaa3950bf7de60e01059395b7..63248a47aebcb74d40a2804a270846b53047d370 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.C +++ b/src/sampling/sampledSet/sampledSets/sampledSets.C @@ -88,17 +88,11 @@ Foam::OFstream* Foam::sampledSets::createProbeFile(const word& fieldName) // Put in undecomposed case // (Note: gives problems for distributed data running) - fileName probeSubDir = name(); - if (mesh_.name() != polyMesh::defaultRegion) - { - probeSubDir = probeSubDir/mesh_.name(); - } - fileName probeDir ( mesh_.time().globalPath() / functionObject::outputPrefix - / probeSubDir + / name()/mesh_.regionName() // Use startTime as the instance for output files / mesh_.time().timeName(mesh_.time().startTime().value()) ); @@ -446,7 +440,8 @@ Foam::sampledSets::sampledSets writeAsProbes_(false), outputPath_ ( - time_.globalPath()/functionObject::outputPrefix/name + time_.globalPath()/functionObject::outputPrefix + / name/mesh_.regionName() ), searchEngine_(mesh_), samplePointScheme_(), @@ -459,10 +454,6 @@ Foam::sampledSets::sampledSets gatheredSorting_(), globalIndices_() { - if (mesh_.name() != polyMesh::defaultRegion) - { - outputPath_ /= mesh_.name(); - } outputPath_.clean(); // Remove unneeded ".." read(dict); @@ -487,7 +478,8 @@ Foam::sampledSets::sampledSets writeAsProbes_(false), outputPath_ ( - time_.globalPath()/functionObject::outputPrefix/name + time_.globalPath()/functionObject::outputPrefix + / name/mesh_.regionName() ), searchEngine_(mesh_), samplePointScheme_(), @@ -500,10 +492,6 @@ Foam::sampledSets::sampledSets gatheredSorting_(), globalIndices_() { - if (mesh_.name() != polyMesh::defaultRegion) - { - outputPath_ /= mesh_.name(); - } outputPath_.clean(); // Remove unneeded ".." read(dict);