smbinterp/bin/parse_gmsh3D.py

36 lines
792 B
Python
Executable File

#!/usr/bin/env python
import sys
import cProfile
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)
g.q = np.array([exact(x) for x in g.verts])
results = {True:0, False:0}
# import pdb; pdb.set_trace()
for i in xrange(count):
X = np.random.random((1,3))[0]
a = g.run_baker(X, order = 3, extra_points = 32)
e = exact(X)
results[improved_answer(a, e)] += 1
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:]
print test_success(input_file, int(count))