Skip to content
Snippets Groups Projects
Commit 07a740ae authored by Hörl, Maximilian's avatar Hörl, Maximilian
Browse files

fix EOC, now using the largest edge length

parent 3d89cd18
No related branches found
No related tags found
No related merge requests found
import numpy as np import numpy as np
from os import mkdir, remove
from os.path import join, exists from os.path import join, exists
from subprocess import call from subprocess import call
from math import log from math import log
...@@ -50,15 +51,15 @@ def readData(): ...@@ -50,15 +51,15 @@ def readData():
# create directory for the plots if necessary # create directory for the plots if necessary
if not exists("plots"): if not exists("plots"):
os.mkdir("plots") mkdir("plots")
# number of runs from which the run times are taken as mean value # number of runs from which the run times are taken as mean value
numberOfMeans = 3 numberOfMeans = 3
# numbers of grid elements per direction # numbers of grid elements per direction
numElemsPerDir = [1, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100] numElemsPerDir = [1, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]
dimensions = [1, 2] dimensions = [1,2]
for dim in dimensions: for dim in dimensions:
# storage for errors, run times and largestEdgeLength # storage for errors, run times and largestEdgeLength
...@@ -91,7 +92,7 @@ for dim in dimensions: ...@@ -91,7 +92,7 @@ for dim in dimensions:
for i in range(len(numElemsPerDir) - 1): for i in range(len(numElemsPerDir) - 1):
if data[i, 0] != 0: if data[i, 0] != 0:
EOC[i] = log(data[i, 0] / data[i+1, 0]) / \ EOC[i] = log(data[i, 0] / data[i+1, 0]) / \
log(data[i+1, 2] / data[i, 2]) log(data[i, 2] / data[i+1, 2])
else: else:
EOC[i] = -1.0*float('inf') EOC[i] = -1.0*float('inf')
# end for i # end for i
...@@ -108,4 +109,4 @@ for dim in dimensions: ...@@ -108,4 +109,4 @@ for dim in dimensions:
# end for dim # end for dim
# remove output files # remove output files
os.remove("convergenceData") remove("convergenceData")
...@@ -95,9 +95,16 @@ int main(int argc, char** argv) ...@@ -95,9 +95,16 @@ int main(int argc, char** argv)
//write error, runtime and number of grid elements to file //write error, runtime and number of grid elements to file
std::ofstream errorFile("convergenceData", std::ios::out | std::ios::trunc); std::ofstream errorFile("convergenceData", std::ios::out | std::ios::trunc);
//determine maximum edge length
double largestEdgeLength = 0.;
for (const auto& edge : edges(gridView))
{
largestEdgeLength = std::max(largestEdgeLength, edge.geometry().volume());
}
if (errorFile.is_open()) if (errorFile.is_open())
{ {
errorFile << error << "\n" << timeTotal << "\n" << gridView.size(0); errorFile << error << "\n" << timeTotal << "\n" << largestEdgeLength;//gridView.size(0);
errorFile.close(); errorFile.close();
} }
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment