From a8f61f210f984c4f1e591f9d1eb975d704658757 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sun, 12 Jul 2015 20:32:25 +0100 Subject: [PATCH] blockMesh: added experimental fast-merge algorithm The standard merge-algorithm is N^2 over the face-points and uses a geometric proximity test for the merge. These are both choices for implementation simplicity and are rather inefficient for large meshes. I have now implemented an experimental linear topological merge algorithm which is VERY fast and effective for meshes of any size. Currently it will merge internal faces on meshes of arbitrary complexity but does not yet handle edge or face collapse needed for wedges and other degenerate blocks. The new fast-merge algorithm may be selected using the optional "fastMerge" entry: fastMerge yes; and if not present the standard N^2 algorithm will be used. Henry G. Weller CFD Direct --- src/mesh/blockMesh/Make/files | 1 + src/mesh/blockMesh/block/block.C | 2 +- src/mesh/blockMesh/block/block.H | 13 +- src/mesh/blockMesh/block/blockCreate.C | 13 +- src/mesh/blockMesh/block/blockI.H | 47 ++ .../blockDescriptor/blockDescriptor.H | 6 + .../blockDescriptor/blockDescriptorEdges.C | 2 +- src/mesh/blockMesh/blockMesh/blockMesh.C | 19 +- src/mesh/blockMesh/blockMesh/blockMesh.H | 22 +- src/mesh/blockMesh/blockMesh/blockMeshMerge.C | 2 +- .../blockMesh/blockMesh/blockMeshMergeFast.C | 590 ++++++++++++++++++ 11 files changed, 688 insertions(+), 29 deletions(-) create mode 100644 src/mesh/blockMesh/block/blockI.H create mode 100644 src/mesh/blockMesh/blockMesh/blockMeshMergeFast.C diff --git a/src/mesh/blockMesh/Make/files b/src/mesh/blockMesh/Make/files index 123b6510b..37bbe7ba1 100644 --- a/src/mesh/blockMesh/Make/files +++ b/src/mesh/blockMesh/Make/files @@ -24,5 +24,6 @@ blockMesh/blockMeshCreate.C blockMesh/blockMeshTopology.C blockMesh/blockMeshCheck.C blockMesh/blockMeshMerge.C +blockMesh/blockMeshMergeFast.C LIB = $(FOAM_LIBBIN)/libblockMesh diff --git a/src/mesh/blockMesh/block/block.C b/src/mesh/blockMesh/block/block.C index 74b7eb38b..3130bcef9 100644 --- a/src/mesh/blockMesh/block/block.C +++ b/src/mesh/blockMesh/block/block.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/mesh/blockMesh/block/block.H b/src/mesh/blockMesh/block/block.H index 05f41b92a..fba8517c0 100644 --- a/src/mesh/blockMesh/block/block.H +++ b/src/mesh/blockMesh/block/block.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -126,13 +126,10 @@ public: // Access //- Return the block definition - inline const blockDescriptor& blockDef() const - { - return *this; - } + inline const blockDescriptor& blockDef() const; //- Vertex label offset for a particular i,j,k position - label vtxLabel(label i, label j, label k) const; + inline label vtxLabel(label i, label j, label k) const; //- Return the points for filling the block const pointField& points() const; @@ -161,6 +158,10 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "blockI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/mesh/blockMesh/block/blockCreate.C b/src/mesh/blockMesh/block/blockCreate.C index 038f278ce..c5d1c5356 100644 --- a/src/mesh/blockMesh/block/blockCreate.C +++ b/src/mesh/blockMesh/block/blockCreate.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,17 +28,6 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::label Foam::block::vtxLabel(label i, label j, label k) const -{ - return - ( - i - + j * (meshDensity().x() + 1) - + k * (meshDensity().x() + 1) * (meshDensity().y() + 1) - ); -} - - void Foam::block::createPoints() const { // set local variables for mesh specification diff --git a/src/mesh/blockMesh/block/blockI.H b/src/mesh/blockMesh/block/blockI.H new file mode 100644 index 000000000..2d9136b72 --- /dev/null +++ b/src/mesh/blockMesh/block/blockI.H @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +inline Foam::label Foam::block::vtxLabel(label i, label j, label k) const +{ + return + ( + i + + j * (meshDensity().x() + 1) + + k * (meshDensity().x() + 1) * (meshDensity().y() + 1) + ); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline const Foam::blockDescriptor& Foam::block::blockDef() const +{ + return *this; +} + + +// ************************************************************************* // diff --git a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.H b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.H index 323e61160..ac5964ecc 100644 --- a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.H +++ b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.H @@ -142,6 +142,12 @@ public: // Access + //- Return the number of cells in the i,j,k directions + const Vector