ENH: use topological merge as default for blockMesh (closes #1589)

- faster and fewer issues with high aspect ratio cells.

- `blockMesh -merge-geometric` for old behaviour
This commit is contained in:
Mark Olesen
2020-05-04 16:19:03 +02:00
parent 8d29896fca
commit 8756791b00
7 changed files with 79 additions and 27 deletions

View File

@ -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
(

View File

@ -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
(

View File

@ -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

View File

@ -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();
}
}

View File

@ -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

View File

@ -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;

View File

@ -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();