From 7b2ff735143ed0237c8a2e736c922abfa259b141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20H=C3=B6rl?= <maximilian.hoerl@mathematik.uni-stuttgart.de> Date: Sun, 19 Apr 2020 13:53:19 +0200 Subject: [PATCH] add parameter fastEOC --- src/dgAnalysis.py | 24 ++++++++++++++++++++++++ src/mmdg.cc | 12 ++++++------ src/mmdgAnalysis.py | 21 ++++++++++++++++----- src/parameterDG.ini | 3 ++- src/parameterMMDG.ini | 7 ++++--- 5 files changed, 52 insertions(+), 15 deletions(-) diff --git a/src/dgAnalysis.py b/src/dgAnalysis.py index e810854..a4d8fc3 100644 --- a/src/dgAnalysis.py +++ b/src/dgAnalysis.py @@ -47,6 +47,24 @@ def readData(): return np.array([error, timeTotal, numberOfElements]) +# determines the parameter "fastEOC" from the ini file +def determineFastEOC (): + # boolean that determines whether to exclude computationally expensive grids + fastEOC = False + + # read ini file content + with open("parameterDG.ini", "r") as file: + lines = file.read().splitlines() + + for i in range(len(lines)): + if (lines[i].startswith("fastEOC") and \ + lines[i].rstrip().lower().endswith("true")): + fastEOC = True + break + + return fastEOC + + # === main === # create directory for the plots if necessary @@ -60,6 +78,12 @@ numberOfMeans = 1 numElemsPerDir_12 = np.unique(np.logspace(0, 2.7, 15).astype(int)) numElemsPerDir_3 = np.unique(np.logspace(0, 1.5, 8).astype(int)) +if determineFastEOC(): # exclude computationally expensive grids + numElemsPerDir_12 = numElemsPerDir_12[:-3] + numElemsPerDir_3 = numElemsPerDir_3[:-2] +else: + print("fastEOC = false. This may take some minutes.\n") + for dim in [1, 2, 3]: numElemsPerDir = numElemsPerDir_3 if (dim == 3) else numElemsPerDir_12 diff --git a/src/mmdg.cc b/src/mmdg.cc index 11a081b..3152cf1 100644 --- a/src/mmdg.cc +++ b/src/mmdg.cc @@ -66,38 +66,38 @@ int main(int argc, char** argv) if (pt["problem"] == "mmdg1") { problem = new MMDGProblem1<Coordinate>(aperture); - gridType = "mmdg2_5e-2"; + gridType = "mmdg2_C"; xi = 0.75; } else if (pt["problem"] == "mmdg2") { problem = new MMDGProblem2<Coordinate>(aperture); - gridType = "mmdg2_5e-2"; + gridType = "mmdg2_C"; xi = 0.75; } else if (pt["problem"] == "mmdg3") { problem = new MMDGProblem3<Coordinate>(aperture); - gridType = "mmdg3_5e-2"; + gridType = "mmdg3_C"; xi = 1.0; } else if (pt["problem"] == "mmdg4") { problem = new MMDGProblem4<Coordinate>(aperture); - gridType = "mmdg2_5e-2"; + gridType = "mmdg2_C"; xi = 0.75; } else if (pt["problem"] == "mmdg5") { problem = new MMDGProblem5<Coordinate>(aperture); - gridType = "mmdg5_5e-2"; + gridType = "mmdg5_C"; xi = 0.75; } else if (pt["problem"] == "mmdg6") { xi = (pt.hasKey("xi")) ? std::stod(pt["xi"]) : 1.0; problem = new MMDGProblem6<Coordinate>(aperture, xi); - gridType = "mmdg2_5e-2"; + gridType = "mmdg2_C"; } else { diff --git a/src/mmdgAnalysis.py b/src/mmdgAnalysis.py index d204afd..4aecbc6 100644 --- a/src/mmdgAnalysis.py +++ b/src/mmdgAnalysis.py @@ -55,11 +55,14 @@ def readData(): hMaxInterface, timeTotal]) -# determines the problem type from the ini file +# determines the problem type and the parameter "fastEOC" from the ini file def getProblemType (): # storage for problem type (1 to 6) problemType = None + # boolean that determines whether to exclude computationally expensive grids + fastEOC = False + # read file content and get problem type with open("parameterMMDG.ini", "r") as file: lines = file.read().splitlines() @@ -67,9 +70,11 @@ def getProblemType (): for i in range(len(lines)): if (lines[i].startswith("problem")): problemType = int(lines[i].rstrip()[-1]) - break + elif (lines[i].startswith("fastEOC") and \ + lines[i].rstrip().lower().endswith("true")): + fastEOC = True - return problemType + return problemType, fastEOC # determines experimental order of convergence (EOC), @@ -84,7 +89,7 @@ def EOCloop (data): EOC[i] = log(data[i, 0] / data[i+1, 0]) / \ log(data[i, 1] / data[i+1, 1]) else: - EOC[i] = -1.0*float('inf') + EOC[i] = -1.0 * float('inf') # end for i return EOC @@ -106,11 +111,17 @@ gridfiles_2d = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"] gridfiles_3d = ["A", "B", "C", "D", "E", "F", "G"] # get problem type (integer from 1 to 6) from ini file -problemType = getProblemType() +problemType, fastEOC = getProblemType() if problemType in [1, 4, 6]: # these problems use the same grids problemType = 2 +if fastEOC: # exclude computationally expensive grids + gridfiles_2d = gridfiles_2d[:-3] + gridfiles_3d = gridfiles_3d[:-2] +else: + print("fastEOC = false. This may take some minutes.\n") + gridfiles_2d = ["mmdg" + str(problemType) + "_" + s for s in gridfiles_2d] gridfiles_3d = ["mmdg" + str(problemType) + "_" + s for s in gridfiles_3d] diff --git a/src/parameterDG.ini b/src/parameterDG.ini index e3e1b98..275babc 100644 --- a/src/parameterDG.ini +++ b/src/parameterDG.ini @@ -1,2 +1,3 @@ mu0 = 1000 -problem = dg1 +problem = dg2 +fastEOC = true diff --git a/src/parameterMMDG.ini b/src/parameterMMDG.ini index 95986ff..257871d 100644 --- a/src/parameterMMDG.ini +++ b/src/parameterMMDG.ini @@ -1,5 +1,6 @@ mu0 = 1000 -#xi = 0.75 -d = 0.01 problem = mmdg2 -gridfile = mmdg5_C +d = 1e-2 +#xi = 0.75 +gridfile = mmdg2_C +fastEOC = true -- GitLab