smbinterp/bin/parse_gmsh.py

85 lines
1.7 KiB
Python
Executable File

#!/usr/bin/env python
import sys
import numpy as np
from interp.grid.gmsh import gmsh_grid
from interp.tools import exact_func, improved_answer
from interp import bootstrap
if __name__ == '__main__':
if len(sys.argv) != 2:
print >> sys.stderr, "usage: %s <gmsh file>" % sys.argv[0]
sys.exit(1)
g = gmsh_grid(sys.argv[1])
# g.dump_to_blender_files()
X = np.array([0.2, 0.5, 0.0])
R = g.get_containing_simplex(X)
print R
R, S = g.get_simplex_and_nearest_points(X, 10)
print "r", R
print "s", S
a = g.run_baker(X)
print a
e = exact_func(X)
print e
print improved_answer(a, e)
a = g.run_baker(X, extra_points = 5)
print a
e = exact_func(X)
print e
print improved_answer(a, e)
a = g.run_baker(X, extra_points = 7)
print a
e = exact_func(X)
print e
print improved_answer(a, e)
a = g.run_baker(X, order=3)
print a
e = exact_func(X)
print e
print improved_answer(a, e)
a = g.run_baker(X, order=3, extra_points = 5)
print a
e = exact_func(X)
print e
print improved_answer(a, e)
a = g.run_baker(X, order=3, extra_points = 7)
print a
e = exact_func(X)
print e
print improved_answer(a, e)
a = g.run_baker(X, order=3, extra_points = 10)
print a
e = exact_func(X)
print e
print improved_answer(a, e)
sys.exit(0)
results = {True:0, False:0}
for i in xrange(1000):
X = np.random.random((1,3))[0]
try:
a = g.run_baker(X, order=2, extra_points = 10)
e = exact_func(X)
ia = improved_answer(a, e)
if not ia:
print a['final'] - e, a, e
results[ia] += 1
except Exception,e:
print >>sys.stderr, e
print >>sys.stderr, X
print results