diff --git a/applications/utilities/mesh/generation/blockMesh/blockMesh.C b/applications/utilities/mesh/generation/blockMesh/blockMesh.C index 431f7000ef..35ba6ed12d 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 \ 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 40a7c5ad85..a76401ca41 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 0b52d4daa8..3df87de8d2 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::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 - bool useTopoMerge = (strategy == mergeStrategy::TOPOLOGICAL); - - if (meshDict_.getOrDefault("fastMerge", useTopoMerge)) + if (strategy == mergeStrategy::DEFAULT_MERGE) { - calcTopologicalMerge(); + strategyNames_.readIfPresent("mergeType", meshDict_, strategy); + + // Warn about fairly obscure old "fastMerge" option? + } + + if (strategy == mergeStrategy::MERGE_POINTS) + { + // 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 d89bbf95a2..4227b3de06 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 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 c5936f7bf0..fe59b12d44 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 42a0c80354..743877a77c 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 1256515570..4d23114ec0 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 d5e0248eaa..bdbbf798dd 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 ac8223027f..74f114b540 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