diff --git a/applications/utilities/mesh/generation/PDRblockMesh/PDRblockMesh.C b/applications/utilities/mesh/generation/PDRblockMesh/PDRblockMesh.C index 20efaae0d24391fc09b641ef2af76292c6ecd45c..8f040f93d2ae5a147cd55d7ffbb4085a43dbd47c 100644 --- a/applications/utilities/mesh/generation/PDRblockMesh/PDRblockMesh.C +++ b/applications/utilities/mesh/generation/PDRblockMesh/PDRblockMesh.C @@ -111,6 +111,9 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" + // Remove old files, unless disabled + const bool removeOldFiles = !args.found("noClean"); + // Instance for resulting mesh bool useTime = false; word meshInstance(runTime.constant()); @@ -159,7 +162,7 @@ int main(int argc, char *argv[]) runTime.setTime(instant(meshInstance), 0); } - if (!args.found("noClean")) + if (removeOldFiles) { const fileName polyMeshPath ( diff --git a/applications/utilities/mesh/generation/blockMesh/blockMesh.C b/applications/utilities/mesh/generation/blockMesh/blockMesh.C index 02a59d6c13d07da30c9fc075859ac9a5537a65fb..431f7000ef5784eb2079535b56b85b2898dbb61b 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-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,6 +46,9 @@ Usage - \par -blockTopology Write the topology as a set of edges in OBJ format and exit. + - \par -merge-geometric + Use geometric instead of topological merging + - \par -region \<name\> Specify alternative mesh region. @@ -118,6 +121,13 @@ int main(int argc, char *argv[]) "Write block edges and centres as obj files and exit" ); argList::addBoolOption + ( + "merge-geometric", + "Use geometric (point) merging instead of topological merging " + "(slower, fails with high-aspect cells. default for 1912 and earlier)", + true // mark as an advanced option + ); + argList::addBoolOption ( "noClean", "Do not remove any existing polyMesh/ directory or files" @@ -144,7 +154,18 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" - word regionName = polyMesh::defaultRegion; + // Remove old files, unless disabled + const bool removeOldFiles = !args.found("noClean"); + + // Topological merge, unless otherwise specified + blockMesh::mergeStrategy strategy(blockMesh::TOPOLOGICAL); + + if (args.found("merge-geometric")) + { + strategy = blockMesh::GEOMETRIC; + } + + word regionName(polyMesh::defaultRegion); word regionPath; // Check if the region is specified otherwise mesh the default region @@ -183,7 +204,7 @@ int main(int argc, char *argv[]) // Locate appropriate blockMeshDict #include "findBlockMeshDict.H" - blockMesh blocks(meshDict, regionName); + blockMesh blocks(meshDict, regionName, strategy); if (!blocks.valid()) { @@ -243,7 +264,7 @@ int main(int argc, char *argv[]) runTime.setTime(instant(meshInstance), 0); } - if (!args.found("noClean")) + if (removeOldFiles) { const fileName polyMeshPath ( diff --git a/src/mesh/blockMesh/Make/files b/src/mesh/blockMesh/Make/files index 8193f56e1a1242aac540ce062fb6da9eb052adc6..2f88d0e1e3aaa8324a2e29ae3dcc57d24a47ea1d 100644 --- a/src/mesh/blockMesh/Make/files +++ b/src/mesh/blockMesh/Make/files @@ -34,8 +34,8 @@ blockMesh/blockMesh.C blockMesh/blockMeshCreate.C blockMesh/blockMeshTopology.C blockMesh/blockMeshCheck.C -blockMesh/blockMeshMerge.C -blockMesh/blockMeshMergeFast.C +blockMesh/blockMeshMergeGeometrical.C +blockMesh/blockMeshMergeTopological.C blockMeshTools/blockMeshTools.C diff --git a/src/mesh/blockMesh/blockMesh/blockMesh.C b/src/mesh/blockMesh/blockMesh/blockMesh.C index cc2f51a64e8b05be142a8eeb0dea53669b9a1f2f..0b52d4daa83f90674c8af01244fd1b1765849808 100644 --- a/src/mesh/blockMesh/blockMesh/blockMesh.C +++ b/src/mesh/blockMesh/blockMesh/blockMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,13 +39,18 @@ namespace Foam // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::blockMesh::blockMesh(const IOdictionary& dict, const word& regionName) +Foam::blockMesh::blockMesh +( + const IOdictionary& dict, + const word& regionName, + const mergeStrategy strategy +) : meshDict_(dict), - verboseOutput(meshDict_.lookupOrDefault("verbose", true)), + verboseOutput(meshDict_.getOrDefault("verbose", true)), checkFaceCorrespondence_ ( - meshDict_.lookupOrDefault("checkFaceCorrespondence", true) + meshDict_.getOrDefault("checkFaceCorrespondence", true) ), geometry_ ( @@ -63,7 +68,7 @@ Foam::blockMesh::blockMesh(const IOdictionary& dict, const word& regionName) : dictionary(), true ), - scaleFactor_(1.0), + scaleFactor_(1), blockVertices_ ( meshDict_.lookup("vertices"), @@ -72,13 +77,17 @@ Foam::blockMesh::blockMesh(const IOdictionary& dict, const word& regionName) vertices_(Foam::vertices(blockVertices_)), topologyPtr_(createTopology(meshDict_, regionName)) { - if (meshDict_.lookupOrDefault("fastMerge", false)) + // TODO - extend with Enum + + bool useTopoMerge = (strategy == mergeStrategy::TOPOLOGICAL); + + if (meshDict_.getOrDefault("fastMerge", useTopoMerge)) { - calcMergeInfoFast(); + calcTopologicalMerge(); } else { - calcMergeInfo(); + calcGeometricalMerge(); } } diff --git a/src/mesh/blockMesh/blockMesh/blockMesh.H b/src/mesh/blockMesh/blockMesh/blockMesh.H index 0f6747d6ff3b749f01d936aa69fcc2531c4c3f7f..d89bbf95a2671f63f540f5bb78061a4369b66392 100644 --- a/src/mesh/blockMesh/blockMesh/blockMesh.H +++ b/src/mesh/blockMesh/blockMesh/blockMesh.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,7 +66,7 @@ class blockMesh : public blockList { - // Private data + // Private Data //- Reference to mesh dictionary const IOdictionary& meshDict_; @@ -155,11 +155,13 @@ class blockMesh void check(const polyMesh& bm, const dictionary& dict) const; - //- Determine the merge info and the final number of cells/points - void calcMergeInfo(); + //- Determine merge info and final number of cells/points + //- based on point distances + void calcGeometricalMerge(); - //- Determine the merge info and the final number of cells/points - void calcMergeInfoFast(); + //- Determine merge info and final number of cells/points + //- based on block topology + void calcTopologicalMerge(); faceList createPatchFaces(const polyPatch& patchTopologyFaces) const; @@ -177,15 +179,31 @@ class blockMesh public: - // Static data members + // Data Types + + //- The block merging strategy + enum mergeStrategy + { + TOPOLOGICAL, //!< Merge using block topology + GEOMETRIC //!< Merge using point geometry + }; + + + // Static Data Members ClassName("blockMesh"); // Constructors - //- Construct from IOdictionary - blockMesh(const IOdictionary& dict, const word& regionName); + //- Construct from IOdictionary for given region + // Default is topological merging. + blockMesh + ( + const IOdictionary& dict, + const word& regionName, + const mergeStrategy strategy = TOPOLOGICAL + ); //- Destructor diff --git a/src/mesh/blockMesh/blockMesh/blockMeshMerge.C b/src/mesh/blockMesh/blockMesh/blockMeshMergeGeometrical.C similarity index 99% rename from src/mesh/blockMesh/blockMesh/blockMeshMerge.C rename to src/mesh/blockMesh/blockMesh/blockMeshMergeGeometrical.C index 87771f846ca72be2b5d15bb98b37d5732ea8b91c..c5936f7bf0705c445b7344c9cddaaf8fabe4255b 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshMerge.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshMergeGeometrical.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,7 +30,7 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::blockMesh::calcMergeInfo() +void Foam::blockMesh::calcGeometricalMerge() { const blockList& blocks = *this; diff --git a/src/mesh/blockMesh/blockMesh/blockMeshMergeFast.C b/src/mesh/blockMesh/blockMesh/blockMeshMergeTopological.C similarity index 99% rename from src/mesh/blockMesh/blockMesh/blockMeshMergeFast.C rename to src/mesh/blockMesh/blockMesh/blockMeshMergeTopological.C index 15d23219bf890865829616ba3ea098d483807543..42a0c80354a26932274290ad8e3c302586adb94f 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshMergeFast.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshMergeTopological.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -301,7 +301,7 @@ inline label facePointN // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::blockMesh::calcMergeInfoFast() +void Foam::blockMesh::calcTopologicalMerge() { // Generate the static face-face map genFaceFaceRotMap();