From dfcf5d948ebd8398a2097a0d75a2558c21677991 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Thu, 6 Aug 2015 09:08:58 +0100 Subject: [PATCH] blockMesh: Updated to latest version from OpenFOAM-dev: Improved multi-grading so that the divisions are independent of section ordering. Corrected multi-grading support for polyLine. Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1809 Changed default location of blockMeshDict from constant/polyMesh to system For multi-region cases the default location of blockMeshDict is now system/ If the blockMeshDict is not found in system then the constant directory is also checked providing backward-compatibility 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 | 57 +- src/mesh/blockMesh/block/blockI.H | 47 ++ .../blockDescriptor/blockDescriptor.C | 12 +- .../blockDescriptor/blockDescriptor.H | 6 + .../blockDescriptor/blockDescriptorEdges.C | 2 +- src/mesh/blockMesh/blockMesh/blockMesh.C | 19 +- src/mesh/blockMesh/blockMesh/blockMesh.H | 26 +- src/mesh/blockMesh/blockMesh/blockMeshMerge.C | 17 +- .../blockMesh/blockMesh/blockMeshMergeFast.C | 590 ++++++++++++++++++ src/mesh/blockMesh/curvedEdges/curvedEdge.C | 6 +- src/mesh/blockMesh/curvedEdges/lineDivide.C | 34 +- src/mesh/blockMesh/curvedEdges/polyLine.C | 32 +- .../gradingDescriptor/gradingDescriptors.C | 2 +- 16 files changed, 767 insertions(+), 99 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 123b6510..37bbe7ba 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 74b7eb38..3130bcef 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 05f41b92..fba8517c 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 038f278c..85c6c583 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,20 +28,9 @@ 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 + // Set local variables for mesh specification const label ni = meshDensity().x(); const label nj = meshDensity().y(); const label nk = meshDensity().z(); @@ -57,12 +46,12 @@ void Foam::block::createPoints() const const point& p011 = blockPoint(7); - // list of edge point and weighting factors + // List of edge point and weighting factors const List< List >& p = blockEdgePoints(); const scalarListList& w = blockEdgeWeights(); // - // generate vertices + // Generate vertices // vertices_.clear(); vertices_.setSize(nPoints()); @@ -75,7 +64,7 @@ void Foam::block::createPoints() const { const label vertexNo = vtxLabel(i, j, k); - // points on edges + // Points on edges vector edgex1 = p000 + (p100 - p000)*w[0][i]; vector edgex2 = p010 + (p110 - p010)*w[1][i]; vector edgex3 = p011 + (p111 - p011)*w[2][i]; @@ -92,7 +81,7 @@ void Foam::block::createPoints() const vector edgez4 = p010 + (p011 - p010)*w[11][k]; - // calculate the importance factors for all edges + // Calculate the importance factors for all edges // x-direction scalar impx1 = @@ -190,7 +179,7 @@ void Foam::block::createPoints() const impz4 /= magImpz; - // calculate the correction vectors + // Calculate the correction vectors vector corx1 = impx1*(p[0][i] - edgex1); vector corx2 = impx2*(p[1][i] - edgex2); vector corx3 = impx3*(p[2][i] - edgex3); @@ -207,7 +196,7 @@ void Foam::block::createPoints() const vector corz4 = impz4*(p[11][k] - edgez4); - // multiply by the importance factor + // Multiply by the importance factor // x-direction edgex1 *= impx1; @@ -228,7 +217,7 @@ void Foam::block::createPoints() const edgez4 *= impz4; - // add the contributions + // Add the contributions vertices_[vertexNo] = ( edgex1 + edgex2 + edgex3 + edgex4 @@ -255,7 +244,7 @@ void Foam::block::createCells() const const label nk = meshDensity().z(); // - // generate cells + // Generate cells // cells_.clear(); cells_.setSize(nCells()); @@ -292,7 +281,7 @@ void Foam::block::createBoundary() const const label nk = meshDensity().z(); // - // generate boundaries on each side of the hex + // Generate boundaries on each side of the hex // boundaryPatches_.clear(); boundaryPatches_.setSize(6); @@ -311,7 +300,7 @@ void Foam::block::createBoundary() const { boundaryPatches_[wallLabel][wallCellLabel].setSize(4); - // set the points + // Set the points boundaryPatches_[wallLabel][wallCellLabel][0] = vtxLabel(0, j, k); boundaryPatches_[wallLabel][wallCellLabel][1] = @@ -321,7 +310,7 @@ void Foam::block::createBoundary() const boundaryPatches_[wallLabel][wallCellLabel][3] = vtxLabel(0, j + 1, k); - // update the counter + // Update the counter wallCellLabel++; } } @@ -338,7 +327,7 @@ void Foam::block::createBoundary() const { boundaryPatches_[wallLabel][wallCellLabel].setSize(4); - // set the points + // Set the points boundaryPatches_[wallLabel][wallCellLabel][0] = vtxLabel(ni, j, k); boundaryPatches_[wallLabel][wallCellLabel][1] = @@ -348,7 +337,7 @@ void Foam::block::createBoundary() const boundaryPatches_[wallLabel][wallCellLabel][3] = vtxLabel(ni, j, k+1); - // update the counter + // Update the counter wallCellLabel++; } } @@ -366,7 +355,7 @@ void Foam::block::createBoundary() const { boundaryPatches_[wallLabel][wallCellLabel].setSize(4); - // set the points + // Set the points boundaryPatches_[wallLabel][wallCellLabel][0] = vtxLabel(i, 0, k); boundaryPatches_[wallLabel][wallCellLabel][1] = @@ -376,7 +365,7 @@ void Foam::block::createBoundary() const boundaryPatches_[wallLabel][wallCellLabel][3] = vtxLabel(i, 0, k + 1); - // update the counter + // Update the counter wallCellLabel++; } } @@ -393,7 +382,7 @@ void Foam::block::createBoundary() const { boundaryPatches_[wallLabel][wallCellLabel].setSize(4); - // set the points + // Set the points boundaryPatches_[wallLabel][wallCellLabel][0] = vtxLabel(i, nj, k); boundaryPatches_[wallLabel][wallCellLabel][1] = @@ -403,7 +392,7 @@ void Foam::block::createBoundary() const boundaryPatches_[wallLabel][wallCellLabel][3] = vtxLabel(i + 1, nj, k); - // update the counter + // Update the counter wallCellLabel++; } } @@ -422,7 +411,7 @@ void Foam::block::createBoundary() const { boundaryPatches_[wallLabel][wallCellLabel].setSize(4); - // set the points + // Set the points boundaryPatches_[wallLabel][wallCellLabel][0] = vtxLabel(i, j, 0); boundaryPatches_[wallLabel][wallCellLabel][1] = @@ -432,7 +421,7 @@ void Foam::block::createBoundary() const boundaryPatches_[wallLabel][wallCellLabel][3] = vtxLabel(i + 1, j, 0); - // update the counter + // Update the counter wallCellLabel++; } } @@ -449,7 +438,7 @@ void Foam::block::createBoundary() const { boundaryPatches_[wallLabel][wallCellLabel].setSize(4); - // set the points + // Set the points boundaryPatches_[wallLabel][wallCellLabel][0] = vtxLabel(i, j, nk); boundaryPatches_[wallLabel][wallCellLabel][1] = @@ -459,7 +448,7 @@ void Foam::block::createBoundary() const boundaryPatches_[wallLabel][wallCellLabel][3] = vtxLabel(i, j + 1, nk); - // update the counter + // Update the counter wallCellLabel++; } } diff --git a/src/mesh/blockMesh/block/blockI.H b/src/mesh/blockMesh/block/blockI.H new file mode 100644 index 00000000..2d9136b7 --- /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.C b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C index bafbc065..fad60ea2 100644 --- a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C +++ b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C @@ -59,7 +59,7 @@ Foam::blockDescriptor::blockDescriptor << exit(FatalError); } - // create a list of edges + // Create a list of edges makeBlockEdges(); } @@ -99,7 +99,7 @@ Foam::blockDescriptor::blockDescriptor if (t.isPunctuation()) { - // new-style: read a list of 3 values + // New-style: read a list of 3 values if (t.pToken() == token::BEGIN_LIST) { is >> meshDensity_; @@ -118,7 +118,7 @@ Foam::blockDescriptor::blockDescriptor } else { - // old-style: read three labels + // Old-style: read three labels is >> meshDensity_.x() >> meshDensity_.y() >> meshDensity_.z(); @@ -134,7 +134,7 @@ Foam::blockDescriptor::blockDescriptor if (expRatios.size() == 1) { - // identical in x/y/z-directions + // Identical in x/y/z-directions expand_ = expRatios[0]; } else if (expRatios.size() == 3) @@ -171,7 +171,7 @@ Foam::blockDescriptor::blockDescriptor << exit(FatalError); } - // create a list of edges + // Create a list of edges makeBlockEdges(); } @@ -279,7 +279,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const blockDescriptor& bd) const List& expand = bd.expand_; - // can we use a compact notation? + // Can we use a compact notation? if ( // x-direction diff --git a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.H b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.H index 323e6116..ac5964ec 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