From a8cf37a56c1a0d284ebe0441d8172ccc818d9709 Mon Sep 17 00:00:00 2001 From: Thomas Fetzer Date: Fri, 10 Mar 2017 08:42:13 +0100 Subject: [PATCH] [fix/gridcreatorFixRanges] All number can be used for ranges Simplified treatment of gradingFactor, so all numbers including -1 can be used. Replaced reverse by increasingCellSize, which is more descriptive. --- dumux/io/cakegridcreator.hh | 36 ++++++++++++++++++------------------ dumux/io/gridcreator.hh | 37 ++++++++++++++++++------------------- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/dumux/io/cakegridcreator.hh b/dumux/io/cakegridcreator.hh index 5970ef51a1..bc77c8e1a8 100644 --- a/dumux/io/cakegridcreator.hh +++ b/dumux/io/cakegridcreator.hh @@ -243,7 +243,7 @@ public: Scalar gradingFactor = grading[dimIdx][zoneIdx]; Scalar length = upper - lower; Scalar height = 1.0; - bool reverse = false; + bool increasingCellSize = false; if (verbose) { @@ -254,6 +254,22 @@ public: << " grading " << gradingFactor; } + if (gradingFactor > 1.0) + { + increasingCellSize = true; + } + + // take absolute values and reverse cell size increment to achieve + // reverse behavior for negative values + if (gradingFactor < 0.0) + { + gradingFactor = -gradingFactor; + if (gradingFactor < 1.0) + { + increasingCellSize = true; + } + } + if (gradingFactor > 1.0 - 1e-7 && gradingFactor < 1.0 + 1e-7) { height = 1.0 / numCells; @@ -264,22 +280,6 @@ public: } else { - if (gradingFactor < -1.0) - { - gradingFactor = -gradingFactor; - } - else if (gradingFactor > 0.0 && gradingFactor < 1.0) - { - gradingFactor = 1.0 / gradingFactor; - } - else if (gradingFactor > 1.0) - { - reverse = true; - } - else - { - DUNE_THROW(Dune::NotImplemented, "This grading factor is not implemented."); - } height = (1.0 - gradingFactor) / (1.0 - std::pow(gradingFactor, numCells)); if (verbose) @@ -298,7 +298,7 @@ public: Scalar hI = height; if (!(gradingFactor < 1.0 + 1e-7 && gradingFactor > 1.0 - 1e-7)) { - if (reverse) + if (increasingCellSize) { hI *= std::pow(gradingFactor, i); } diff --git a/dumux/io/gridcreator.hh b/dumux/io/gridcreator.hh index 14c3d4b868..30c51a1d86 100644 --- a/dumux/io/gridcreator.hh +++ b/dumux/io/gridcreator.hh @@ -776,7 +776,7 @@ public: Scalar gradingFactor = grading[dimIdx][zoneIdx]; Scalar length = upper - lower; Scalar height = 1.0; - bool reverse = false; + bool increasingCellSize = false; if (verbose) { @@ -787,6 +787,22 @@ public: << " grading " << gradingFactor; } + if (gradingFactor > 1.0) + { + increasingCellSize = true; + } + + // take absolute values and reverse cell size increment to achieve + // reverse behavior for negative values + if (gradingFactor < 0.0) + { + gradingFactor = -gradingFactor; + if (gradingFactor < 1.0) + { + increasingCellSize = true; + } + } + if (gradingFactor > 1.0 - 1e-7 && gradingFactor < 1.0 + 1e-7) { height = 1.0 / numCells; @@ -797,23 +813,6 @@ public: } else { - if (gradingFactor < -1.0) - { - gradingFactor = -gradingFactor; - } - else if (gradingFactor > 0.0 && gradingFactor < 1.0) - { - gradingFactor = 1.0 / gradingFactor; - } - else if (gradingFactor > 1.0) - { - reverse = true; - } - else - { - DUNE_THROW(Dune::NotImplemented, "This grading factor is not implemented."); - } - height = (1.0 - gradingFactor) / (1.0 - pow(gradingFactor, numCells)); if (verbose) @@ -832,7 +831,7 @@ public: Scalar hI = height; if (!(gradingFactor < 1.0 + 1e-7 && gradingFactor > 1.0 - 1e-7)) { - if (reverse) + if (increasingCellSize) { hI *= pow(gradingFactor, i); } -- GitLab