Commit 44b22560 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: add blockMeshDict "mergeType" keyword (#1589)

- enumerated values are (points | topology) which can be optionally
  specified in the blockMeshDict. Default is 'topology'.

  If the command-line option `blockMesh -merge-points` is specified,
  this has absolute priority over any blockMeshDict entry.

STYLE: changed blockMesh "-blockTopology" option to "-write-obj"

- this is more specific to what it does. Potentially wish to add a
  "-write-vtk" option in the future.

TUT: adjust tutorials to use preferred or necessary merge strategies:

  * channel395DFSEM - topology
  * nozzleFlow2D - points
  * pipeCyclic - points
parent 5999125c
......@@ -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)
{
......
......@@ -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
......
......@@ -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;
}
}
......
......@@ -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
);
......
......@@ -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
......
......@@ -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
......
/*--------------------------------*- 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;
......
/*--------------------------------*- 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
......
/*--------------------------------*- 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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment