mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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
This commit is contained in:
@ -43,11 +43,11 @@ Usage
|
|||||||
\b blockMesh [OPTION]
|
\b blockMesh [OPTION]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
- \par -blockTopology
|
- \par -write-obj
|
||||||
Write the topology as a set of edges in OBJ format and exit.
|
Write topology as a set of edges in OBJ format and exit.
|
||||||
|
|
||||||
- \par -merge-geometric
|
- \par -merge-points
|
||||||
Use geometric instead of topological merging
|
Merge points instead of default topological merge
|
||||||
|
|
||||||
- \par -region \<name\>
|
- \par -region \<name\>
|
||||||
Specify alternative mesh region.
|
Specify alternative mesh region.
|
||||||
@ -117,13 +117,15 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
argList::addBoolOption
|
argList::addBoolOption
|
||||||
(
|
(
|
||||||
"blockTopology",
|
"write-obj",
|
||||||
"Write block edges and centres as obj files and exit"
|
"Write block edges and centres as obj files and exit"
|
||||||
);
|
);
|
||||||
|
argList::addOptionCompat("write-obj", {"blockTopology", 1912});
|
||||||
|
|
||||||
argList::addBoolOption
|
argList::addBoolOption
|
||||||
(
|
(
|
||||||
"merge-geometric",
|
"merge-points",
|
||||||
"Use geometric (point) merging instead of topological merging "
|
"Geometric (point) merging instead of topological merging "
|
||||||
"(slower, fails with high-aspect cells. default for 1912 and earlier)",
|
"(slower, fails with high-aspect cells. default for 1912 and earlier)",
|
||||||
true // mark as an advanced option
|
true // mark as an advanced option
|
||||||
);
|
);
|
||||||
@ -157,12 +159,12 @@ int main(int argc, char *argv[])
|
|||||||
// Remove old files, unless disabled
|
// Remove old files, unless disabled
|
||||||
const bool removeOldFiles = !args.found("noClean");
|
const bool removeOldFiles = !args.found("noClean");
|
||||||
|
|
||||||
// Topological merge, unless otherwise specified
|
// Default merge (topology), unless otherwise specified
|
||||||
blockMesh::mergeStrategy strategy(blockMesh::TOPOLOGICAL);
|
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);
|
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;
|
Info<< nl;
|
||||||
|
|
||||||
// Write mesh as edges.
|
// Write mesh as edges
|
||||||
{
|
{
|
||||||
OFstream os(runTime.path()/"blockTopology.obj");
|
OFstream os(runTime.path()/"blockTopology.obj");
|
||||||
|
|
||||||
@ -238,21 +244,21 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "Writing block centres as obj format: "
|
Info<< "Writing block centres as obj format: "
|
||||||
<< os.name().name() << endl;
|
<< os.name().name() << endl;
|
||||||
|
|
||||||
const polyMesh& topo = blocks.topology();
|
for (const point& cc : blocks.topology().cellCentres())
|
||||||
|
|
||||||
for (const point& cc : topo.cellCentres())
|
|
||||||
{
|
{
|
||||||
os << "v " << cc.x() << ' ' << cc.y() << ' ' << cc.z() << nl;
|
os << "v " << cc.x() << ' ' << cc.y() << ' ' << cc.z() << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quickExit)
|
||||||
|
{
|
||||||
Info<< "\nEnd\n" << endl;
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Instance for resulting mesh
|
// Instance for resulting mesh
|
||||||
if (useTime)
|
if (useTime)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -37,13 +37,21 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::Enum<Foam::blockMesh::mergeStrategy>
|
||||||
|
Foam::blockMesh::strategyNames_
|
||||||
|
({
|
||||||
|
{ mergeStrategy::MERGE_TOPOLOGY, "topology" },
|
||||||
|
{ mergeStrategy::MERGE_POINTS, "points" },
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::blockMesh::blockMesh
|
Foam::blockMesh::blockMesh
|
||||||
(
|
(
|
||||||
const IOdictionary& dict,
|
const IOdictionary& dict,
|
||||||
const word& regionName,
|
const word& regionName,
|
||||||
const mergeStrategy strategy
|
mergeStrategy strategy
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
meshDict_(dict),
|
meshDict_(dict),
|
||||||
@ -77,17 +85,24 @@ Foam::blockMesh::blockMesh
|
|||||||
vertices_(Foam::vertices(blockVertices_)),
|
vertices_(Foam::vertices(blockVertices_)),
|
||||||
topologyPtr_(createTopology(meshDict_, regionName))
|
topologyPtr_(createTopology(meshDict_, regionName))
|
||||||
{
|
{
|
||||||
// TODO - extend with Enum
|
// Command-line option has precedence over dictionary setting
|
||||||
|
|
||||||
bool useTopoMerge = (strategy == mergeStrategy::TOPOLOGICAL);
|
if (strategy == mergeStrategy::DEFAULT_MERGE)
|
||||||
|
|
||||||
if (meshDict_.getOrDefault("fastMerge", useTopoMerge))
|
|
||||||
{
|
{
|
||||||
calcTopologicalMerge();
|
strategyNames_.readIfPresent("mergeType", meshDict_, strategy);
|
||||||
|
|
||||||
|
// Warn about fairly obscure old "fastMerge" option?
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strategy == mergeStrategy::MERGE_POINTS)
|
||||||
|
{
|
||||||
|
// MERGE_POINTS
|
||||||
|
calcGeometricalMerge();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
calcGeometricalMerge();
|
// MERGE_TOPOLOGY
|
||||||
|
calcTopologicalMerge();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +111,7 @@ Foam::blockMesh::blockMesh
|
|||||||
|
|
||||||
bool Foam::blockMesh::valid() const
|
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
|
void Foam::blockMesh::writeTopology(Ostream& os) const
|
||||||
{
|
{
|
||||||
const pointField& pts = topology().points();
|
for (const point& p : topology().points())
|
||||||
|
|
||||||
for (const point& pt : pts)
|
|
||||||
{
|
{
|
||||||
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 : topology().edges())
|
||||||
|
|
||||||
for (const edge& e : 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
|
Description
|
||||||
A multi-block mesh generator
|
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
|
Note
|
||||||
The vertices, cells and patches for filling the blocks are demand-driven.
|
The vertices, cells and patches for filling the blocks are demand-driven.
|
||||||
|
|
||||||
@ -45,6 +62,7 @@ SourceFiles
|
|||||||
#ifndef blockMesh_H
|
#ifndef blockMesh_H
|
||||||
#define blockMesh_H
|
#define blockMesh_H
|
||||||
|
|
||||||
|
#include "Enum.H"
|
||||||
#include "blockList.H"
|
#include "blockList.H"
|
||||||
#include "searchableSurfaces.H"
|
#include "searchableSurfaces.H"
|
||||||
#include "polyMesh.H"
|
#include "polyMesh.H"
|
||||||
@ -66,6 +84,27 @@ class blockMesh
|
|||||||
:
|
:
|
||||||
public blockList
|
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
|
// Private Data
|
||||||
|
|
||||||
//- Reference to mesh dictionary
|
//- Reference to mesh dictionary
|
||||||
@ -179,19 +218,8 @@ class blockMesh
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Data Types
|
//- Runtime type information
|
||||||
|
ClassName("blockMesh");
|
||||||
//- The block merging strategy
|
|
||||||
enum mergeStrategy
|
|
||||||
{
|
|
||||||
TOPOLOGICAL, //!< Merge using block topology
|
|
||||||
GEOMETRIC //!< Merge using point geometry
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Static Data Members
|
|
||||||
|
|
||||||
ClassName("blockMesh");
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
@ -202,7 +230,7 @@ public:
|
|||||||
(
|
(
|
||||||
const IOdictionary& dict,
|
const IOdictionary& dict,
|
||||||
const word& regionName,
|
const word& regionName,
|
||||||
const mergeStrategy strategy = TOPOLOGICAL
|
mergeStrategy strategy = mergeStrategy::DEFAULT_MERGE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -55,7 +55,7 @@ void Foam::blockMesh::calcGeometricalMerge()
|
|||||||
|
|
||||||
if (verboseOutput)
|
if (verboseOutput)
|
||||||
{
|
{
|
||||||
Info<< "Creating merge list.." << flush;
|
Info<< "Creating merge list (geometric search).." << flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set unused to -1
|
// set unused to -1
|
||||||
|
|||||||
@ -328,7 +328,7 @@ void Foam::blockMesh::calcTopologicalMerge()
|
|||||||
|
|
||||||
if (verboseOutput)
|
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
|
// Size merge list and initialize to -1
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------*- C++ -*----------------------------------*\
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
| ========= | |
|
| ========= | |
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
| \\ / O peration | Version: v1912 |
|
| \\ / O peration | Version: v2006 |
|
||||||
| \\ / A nd | Website: www.openfoam.com |
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -14,7 +14,7 @@ FoamFile
|
|||||||
}
|
}
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
fastMerge true; // Use fast topological search
|
mergeType topology; // Point merging is very slow
|
||||||
|
|
||||||
scale 1;
|
scale 1;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------*- C++ -*----------------------------------*\
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
| ========= | |
|
| ========= | |
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
| \\ / O peration | Version: v1912 |
|
| \\ / O peration | Version: v2006 |
|
||||||
| \\ / A nd | Website: www.openfoam.com |
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -14,6 +14,8 @@ FoamFile
|
|||||||
}
|
}
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
mergeType points; // Merge points instead of topology
|
||||||
|
|
||||||
scale 1;
|
scale 1;
|
||||||
|
|
||||||
//- Half angle of wedge in degrees
|
//- Half angle of wedge in degrees
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*--------------------------------*- C++ -*----------------------------------*\
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
| ========= | |
|
| ========= | |
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
| \\ / O peration | Version: v1912 |
|
| \\ / O peration | Version: v2006 |
|
||||||
| \\ / A nd | Website: www.openfoam.com |
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -14,6 +14,8 @@ FoamFile
|
|||||||
}
|
}
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
mergeType points; // Merge points instead of topology
|
||||||
|
|
||||||
scale 1e-6;
|
scale 1e-6;
|
||||||
|
|
||||||
vertices
|
vertices
|
||||||
|
|||||||
Reference in New Issue
Block a user