smbinterp/bin/parse_gmsh3D.py

36 lines
792 B
Python
Raw Normal View History

2010-11-01 14:51:40 -07:00
#!/usr/bin/env python
import sys
import cProfile
2010-11-01 14:51:40 -07:00
import numpy as np
import interp.bootstrap
from interp.grid.gmsh import gmsh_grid3D
from interp.tools import improved_answer, exact
def test_success(input_file, count):
g = gmsh_grid3D(input_file)
2011-02-15 14:22:54 -08:00
g.q = np.array([exact(x) for x in g.verts])
2010-11-01 14:51:40 -07:00
2011-02-15 14:22:54 -08:00
results = {True:0, False:0}
2011-02-20 18:23:57 -08:00
# import pdb; pdb.set_trace()
for i in xrange(count):
2011-02-15 14:22:54 -08:00
X = np.random.random((1,3))[0]
2010-11-01 14:51:40 -07:00
2011-02-20 18:23:57 -08:00
a = g.run_baker(X, order = 3, extra_points = 32)
e = exact(X)
2011-02-15 14:22:54 -08:00
results[improved_answer(a, e)] += 1
2010-11-01 14:51:40 -07:00
return results
if __name__ == '__main__':
if len(sys.argv) != 3:
print >> sys.stderr, "usage: %s <input file> <number of attempts>" % sys.argv[0]
sys.exit(1)
input_file, count = sys.argv[1:]
2011-02-15 14:22:54 -08:00
print test_success(input_file, int(count))