Commit 4fad84b6 authored by Henry Weller's avatar Henry Weller
Browse files

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
parent 19dcf83b
......@@ -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 blockFrac = gd[sectioni].blockFraction();
scalar nDivFrac = gd[sectioni].nDivFraction();
scalar expRatio = gd[sectioni].expansionRatio();
secnDivs[sectioni] = label(nDivFrac*nDiv + 0.5);
sumSecnDivs += secnDivs[sectioni];
label secnDiv = label(nDivFrac*nDiv + 0.5);
if (sectioni == gd.size() - 1)
// Find the section with the largest number of divisions
if (nDivFrac > gd[secnMaxDivs].nDivFraction())
{
secnDiv = nDiv - secnStart + 1;
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 expRatio = gd[sectioni].expansionRatio();
label secnDiv = secnDivs[sectioni];
label secnEnd = secnStart + secnDiv;
// Calculate the spacing
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment