added a script to parametrically obtain results
This commit is contained in:
parent
25eae429f5
commit
a1bd6a7257
79
bin/resultifier.py
Normal file
79
bin/resultifier.py
Normal file
@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import time
|
||||
|
||||
import pickle
|
||||
|
||||
import numpy as np
|
||||
|
||||
from optparse import OptionParser
|
||||
|
||||
import progressbar
|
||||
|
||||
import interp.bootstrap
|
||||
|
||||
from interp.grid.gmsh import ggrid
|
||||
from interp.tools import *
|
||||
|
||||
def get_right_exact_func(dimension, baker = False):
|
||||
f = None
|
||||
if dimension == 3:
|
||||
if baker:
|
||||
f = baker_exact_3D
|
||||
else:
|
||||
f =friendly_exact_3D
|
||||
elif dimension == 2:
|
||||
if baker:
|
||||
f = baker_exact_2D
|
||||
else:
|
||||
f = friendly_exact_2D
|
||||
return f
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
parser = OptionParser(usage = "%prog [options] <input file (gmsh)> <destination file (pickle)>")
|
||||
|
||||
parser.add_option("-v", "--verbose",
|
||||
action="store_true", dest="verbose", default=False,
|
||||
help="verbose flag")
|
||||
|
||||
parser.add_option("-b", "--baker",
|
||||
action="store_true", dest="baker", default=False,
|
||||
help="use more impressive baker funcs")
|
||||
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
if len(args) != 2:
|
||||
parser.print_usage()
|
||||
sys.exit(1)
|
||||
|
||||
source, dest = args
|
||||
|
||||
dest = pickle.load(open(dest, 'r'))
|
||||
|
||||
dimension = int(source.split('.')[1][0])
|
||||
|
||||
g = ggrid(source, dimension)
|
||||
g.q = np.array([get_right_exact_func(dimension, options.baker)(x) for x in g.verts])
|
||||
|
||||
exacts = (baker_exact_2D, friendly_exact_2D)
|
||||
orders = [2,3,4,5]
|
||||
extras = [4,6,8,12,16,20,32,48,64,96,128,192,256]
|
||||
|
||||
for exact_func in exacts:
|
||||
g.q = np.array([exact_func(x) for x in g.verts])
|
||||
for order in orders:
|
||||
for extra in extras:
|
||||
for d in dest:
|
||||
results = {True:0, False:0}
|
||||
errors = []
|
||||
s = time.time()
|
||||
for X in d:
|
||||
a = g.run_baker(X[:2], order = order, extra_points = extra)
|
||||
exact = exact_func(X[:2])
|
||||
results[improved_answer(a,exact)] += 1
|
||||
current_error = exact - a['final']
|
||||
errors.append(current_error)
|
||||
e = time.time()
|
||||
print exact_func.__name__, order, extra, results[True] / float(len(d)), rms(errors), e-s
|
Loading…
Reference in New Issue
Block a user