diff --git a/applications/utilities/mesh/generation/blockMesh/blockMesh.C b/applications/utilities/mesh/generation/blockMesh/blockMesh.C index 431f7000ef5784eb2079535b56b85b2898dbb61b..35ba6ed12d688f740fa5e80892a8da78828590df 100644 --- a/applications/utilities/mesh/generation/blockMesh/blockMesh.C +++ b/applications/utilities/mesh/generation/blockMesh/blockMesh.C @@ -43,11 +43,11 @@ Usage \b blockMesh [OPTION] Options: - - \par -blockTopology - Write the topology as a set of edges in OBJ format and exit. + - \par -write-obj + Write topology as a set of edges in OBJ format and exit. - - \par -merge-geometric - Use geometric instead of topological merging + - \par -merge-points + Merge points instead of default topological merge - \par -region \<name\> Specify alternative mesh region. @@ -117,13 +117,15 @@ int main(int argc, char *argv[]) argList::addBoolOption ( - "blockTopology", + "write-obj", "Write block edges and centres as obj files and exit" ); + argList::addOptionCompat("write-obj", {"blockTopology", 1912}); + argList::addBoolOption ( - "merge-geometric", - "Use geometric (point) merging instead of topological merging " + "merge-points", + "Geometric (point) merging instead of topological merging " "(slower, fails with high-aspect cells. default for 1912 and earlier)", true // mark as an advanced option ); @@ -157,12 +159,12 @@ int main(int argc, char *argv[]) // Remove old files, unless disabled const bool removeOldFiles = !args.found("noClean"); - // Topological merge, unless otherwise specified - blockMesh::mergeStrategy strategy(blockMesh::TOPOLOGICAL); + // Default merge (topology), unless otherwise specified + blockMesh::mergeStrategy strategy(blockMesh::DEFAULT_MERGE); - if (args.found("merge-geometric")) + if (args.found("merge-points")) { - strategy = blockMesh::GEOMETRIC; + strategy = blockMesh::MERGE_POINTS; } word regionName(polyMesh::defaultRegion); @@ -217,11 +219,15 @@ int main(int argc, char *argv[]) } - if (args.found("blockTopology")) + bool quickExit = false; + + if (args.found("write-obj")) { + quickExit = true; + Info<< nl; - // Write mesh as edges. + // Write mesh as edges { OFstream os(runTime.path()/"blockTopology.obj"); @@ -238,21 +244,21 @@ int main(int argc, char *argv[]) Info<< "Writing block centres as obj format: " << os.name().name() << endl; - const polyMesh& topo = blocks.topology(); - - for (const point& cc : topo.cellCentres()) + for (const point& cc : blocks.topology().cellCentres()) { os << "v " << cc.x() << ' ' << cc.y() << ' ' << cc.z() << nl; } } + } + if (quickExit) + { Info<< "\nEnd\n" << endl; return 0; } - // Instance for resulting mesh if (useTime) { diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C index 40a7c5ad8526d6ea303ce275ba2fa0028fa8647a..a76401ca41dfc52b38c5d2614a105f83c33db384 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C @@ -336,7 +336,7 @@ void Foam::polyMesh::setTopology // an error or explicitly desired (e.g. duplicate // baffles or acmi). We could have a special 7-faced // hex shape instead so we can have additional patches - // but that would be unworkable. + // but that would be unworkable. // So now either // - exit with error // - or warn and append face to addressing diff --git a/src/mesh/blockMesh/blockMesh/blockMesh.C b/src/mesh/blockMesh/blockMesh/blockMesh.C index 0b52d4daa83f90674c8af01244fd1b1765849808..3df87de8d24bd93fa837de119dd71ee0e232c3ed 100644 --- a/src/mesh/blockMesh/blockMesh/blockMesh.C +++ b/src/mesh/blockMesh/blockMesh/blockMesh.C @@ -37,13 +37,21 @@ namespace Foam } +const Foam::Enum<Foam::blockMesh::mergeStrategy> +Foam::blockMesh::strategyNames_ +({ + { mergeStrategy::MERGE_TOPOLOGY, "topology" }, + { mergeStrategy::MERGE_POINTS, "points" }, +}); + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::blockMesh::blockMesh ( const IOdictionary& dict, const word& regionName, - const mergeStrategy strategy + mergeStrategy strategy ) : meshDict_(dict), @@ -77,17 +85,24 @@ Foam::blockMesh::blockMesh vertices_(Foam::vertices(blockVertices_)), topologyPtr_(createTopology(meshDict_, regionName)) { - // TODO - extend with Enum + // Command-line option has precedence over dictionary setting + + if (strategy == mergeStrategy::DEFAULT_MERGE) + { + strategyNames_.readIfPresent("mergeType", meshDict_, strategy); - bool useTopoMerge = (strategy == mergeStrategy::TOPOLOGICAL); + // Warn about fairly obscure old "fastMerge" option? + } - if (meshDict_.getOrDefault("fastMerge", useTopoMerge)) + if (strategy == mergeStrategy::MERGE_POINTS) { - calcTopologicalMerge(); + // MERGE_POINTS + calcGeometricalMerge(); } else { - calcGeometricalMerge(); + // MERGE_TOPOLOGY + calcTopologicalMerge(); } } @@ -96,7 +111,7 @@ Foam::blockMesh::blockMesh bool Foam::blockMesh::valid() const { - return topologyPtr_.valid(); + return bool(topologyPtr_); } @@ -219,18 +234,14 @@ Foam::label Foam::blockMesh::numZonedBlocks() const void Foam::blockMesh::writeTopology(Ostream& os) const { - const pointField& pts = topology().points(); - - for (const point& pt : pts) + for (const point& p : topology().points()) { - os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl; + os << "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl; } - const edgeList& edges = topology().edges(); - - for (const edge& e : edges) + for (const edge& e : topology().edges()) { - os << "l " << e.start() + 1 << ' ' << e.end() + 1 << endl; + os << "l " << e.start() + 1 << ' ' << e.end() + 1 << nl; } } diff --git a/src/mesh/blockMesh/blockMesh/blockMesh.H b/src/mesh/blockMesh/blockMesh/blockMesh.H index d89bbf95a2671f63f540f5bb78061a4369b66392..4227b3de0674212ba458e48f769e324d2e7ff61d 100644 --- a/src/mesh/blockMesh/blockMesh/blockMesh.H +++ b/src/mesh/blockMesh/blockMesh/blockMesh.H @@ -30,6 +30,23 @@ Class Description A multi-block mesh generator + Dictionary controls + \table + Property | Description | Required | Default + scale | Point scaling | no | 1.0 + vertices | | yes | + blocks | | yes | + edges | | no | + faces | | no | + boundary | Boundary definition | no | + patches | Alternate version for "boundary" | no | + namedBlocks | | no | + namedVertices | | no | + mergeType | Merging "points" or "topology" | no | topology + checkFaceCorrespondence | | no | true + verbose | | no | true + \endtable + Note The vertices, cells and patches for filling the blocks are demand-driven. @@ -45,6 +62,7 @@ SourceFiles #ifndef blockMesh_H #define blockMesh_H +#include "Enum.H" #include "blockList.H" #include "searchableSurfaces.H" #include "polyMesh.H" @@ -66,6 +84,27 @@ class blockMesh : public blockList { +public: + + // Data Types + + //- The block merging strategy + enum mergeStrategy + { + DEFAULT_MERGE, //!< Default (TOPOLOGY), not selectable + MERGE_TOPOLOGY, //!< "topology" merge by block topology (default) + MERGE_POINTS //!< "points" merge by point geometry + }; + + +private: + + // Static Data + + //- Names corresponding to the mergeStrategy + static const Enum<mergeStrategy> strategyNames_; + + // Private Data //- Reference to mesh dictionary @@ -179,19 +218,8 @@ class blockMesh public: - // Data Types - - //- The block merging strategy - enum mergeStrategy - { - TOPOLOGICAL, //!< Merge using block topology - GEOMETRIC //!< Merge using point geometry - }; - - - // Static Data Members - - ClassName("blockMesh"); + //- Runtime type information + ClassName("blockMesh"); // Constructors @@ -202,7 +230,7 @@ public: ( const IOdictionary& dict, const word& regionName, - const mergeStrategy strategy = TOPOLOGICAL + mergeStrategy strategy = mergeStrategy::DEFAULT_MERGE ); diff --git a/src/mesh/blockMesh/blockMesh/blockMeshMergeGeometrical.C b/src/mesh/blockMesh/blockMesh/blockMeshMergeGeometrical.C index c5936f7bf0705c445b7344c9cddaaf8fabe4255b..fe59b12d449459305168a1a3e71cd8a180bc5022 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshMergeGeometrical.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshMergeGeometrical.C @@ -55,7 +55,7 @@ void Foam::blockMesh::calcGeometricalMerge() if (verboseOutput) { - Info<< "Creating merge list.." << flush; + Info<< "Creating merge list (geometric search).." << flush; } // set unused to -1 diff --git a/src/mesh/blockMesh/blockMesh/blockMeshMergeTopological.C b/src/mesh/blockMesh/blockMesh/blockMeshMergeTopological.C index 42a0c80354a26932274290ad8e3c302586adb94f..743877a77c7c329770f7fe110475e28b840e954e 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshMergeTopological.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshMergeTopological.C @@ -328,7 +328,7 @@ void Foam::blockMesh::calcTopologicalMerge() if (verboseOutput) { - Info<< "Creating merge list with fast topological search.." << flush; + Info<< "Creating merge list (topological search).." << flush; } // Size merge list and initialize to -1 diff --git a/tutorials/incompressible/pimpleFoam/LES/channel395DFSEM/system/blockMeshDict b/tutorials/incompressible/pimpleFoam/LES/channel395DFSEM/system/blockMeshDict index 12565155709185f6a9ffe99bb15319281ed9f13d..4d23114ec0a8a41979dbd403860c099032d80aa3 100644 --- a/tutorials/incompressible/pimpleFoam/LES/channel395DFSEM/system/blockMeshDict +++ b/tutorials/incompressible/pimpleFoam/LES/channel395DFSEM/system/blockMeshDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v1912 | +| \\ / O peration | Version: v2006 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -14,7 +14,7 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -fastMerge true; // Use fast topological search +mergeType topology; // Point merging is very slow scale 1; diff --git a/tutorials/incompressible/simpleFoam/pipeCyclic/system/blockMeshDict b/tutorials/incompressible/simpleFoam/pipeCyclic/system/blockMeshDict index d5e0248eaa23acf933a43965c066fa4e3b614fdd..bdbbf798dd014343b2182b3453d7bf87a90d525e 100644 --- a/tutorials/incompressible/simpleFoam/pipeCyclic/system/blockMeshDict +++ b/tutorials/incompressible/simpleFoam/pipeCyclic/system/blockMeshDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v1912 | +| \\ / O peration | Version: v2006 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -14,6 +14,8 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +mergeType points; // Merge points instead of topology + scale 1; //- Half angle of wedge in degrees diff --git a/tutorials/multiphase/interFoam/LES/nozzleFlow2D/system/blockMeshDict b/tutorials/multiphase/interFoam/LES/nozzleFlow2D/system/blockMeshDict index ac8223027f4dc21bcfa53fdfc6402b8750a3f18d..74f114b540c4b21ead91e768c334a645a6dcd794 100644 --- a/tutorials/multiphase/interFoam/LES/nozzleFlow2D/system/blockMeshDict +++ b/tutorials/multiphase/interFoam/LES/nozzleFlow2D/system/blockMeshDict @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v1912 | +| \\ / O peration | Version: v2006 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -14,6 +14,8 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +mergeType points; // Merge points instead of topology + scale 1e-6; vertices