From 18ac24b2caf7aff3c43b1dae8b52f74da2705ed3 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sun, 2 Aug 2015 22:14:26 +0100 Subject: [PATCH] blockMesh: Improve multi-grading so that the divisions are independent of section ordering Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1809 --- src/mesh/blockMesh/curvedEdges/lineDivide.C | 33 +++++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/mesh/blockMesh/curvedEdges/lineDivide.C b/src/mesh/blockMesh/curvedEdges/lineDivide.C index 7ac372c47..240097ed3 100644 --- a/src/mesh/blockMesh/curvedEdges/lineDivide.C +++ b/src/mesh/blockMesh/curvedEdges/lineDivide.C @@ -59,17 +59,38 @@ Foam::lineDivide::lineDivide // Check that there are more divisions than sections if (nDiv >= gd.size()) { + // Calculate distribution of divisions to be independent + // of the order of the sections + labelList secnDivs(gd.size()); + label sumSecnDivs = 0; + label secnMaxDivs = 0; + + forAll(gd, sectioni) + { + scalar nDivFrac = gd[sectioni].nDivFraction(); + secnDivs[sectioni] = label(nDivFrac*nDiv + 0.5); + sumSecnDivs += secnDivs[sectioni]; + + // Find the section with the largest number of divisions + if (nDivFrac > gd[secnMaxDivs].nDivFraction()) + { + secnMaxDivs = sectioni; + } + } + + // Adjust the number of divisions on the section with the largest + // number so that the total is nDiv + if (sumSecnDivs != nDiv) + { + secnDivs[secnMaxDivs] += (nDiv - sumSecnDivs); + } + forAll(gd, sectioni) { scalar blockFrac = gd[sectioni].blockFraction(); - scalar nDivFrac = gd[sectioni].nDivFraction(); scalar expRatio = gd[sectioni].expansionRatio(); - label secnDiv = label(nDivFrac*nDiv + 0.5); - if (sectioni == gd.size() - 1) - { - secnDiv = nDiv - secnStart + 1; - } + label secnDiv = secnDivs[sectioni]; label secnEnd = secnStart + secnDiv; // Calculate the spacing