2010-11-01 14:51:40 -07:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import sys
|
2011-02-21 15:48:21 -08:00
|
|
|
import cProfile
|
2010-11-01 14:51:40 -07:00
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
import interp.bootstrap
|
2010-11-01 19:20:05 -07:00
|
|
|
from interp.grid.gmsh import gmsh_grid3D
|
2011-03-02 22:44:08 -08:00
|
|
|
from interp.tools import improved_answer, log, exact
|
2010-11-01 19:20:05 -07:00
|
|
|
|
2011-02-15 14:22:54 -08:00
|
|
|
from interp.grid import grid
|
|
|
|
|
2010-11-01 14:51:40 -07:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if len(sys.argv) != 2:
|
|
|
|
print >> sys.stderr, "usage: %s <gmsh file>" % sys.argv[0]
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
g = gmsh_grid3D(sys.argv[1])
|
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
|
|
|
|
|
|
|
X = np.array([0.2, 0.5, 0.01])
|
|
|
|
R = g.get_containing_simplex(X)
|
|
|
|
R, S = g.get_simplex_and_nearest_points(X, 10)
|
2011-02-15 14:22:54 -08:00
|
|
|
print R
|
|
|
|
print "r", R
|
|
|
|
print "s", S
|
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()
|
2011-02-15 14:22:54 -08:00
|
|
|
for i in xrange(1000):
|
|
|
|
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
|
|
|
|
2011-02-15 14:22:54 -08:00
|
|
|
print results
|
2011-02-20 18:23:57 -08:00
|
|
|
# g.normalize_q()
|
2011-01-28 11:21:26 -08:00
|
|
|
# print g.toxml()
|
2011-02-15 14:22:54 -08:00
|
|
|
|
|
|
|
igg = grid(g.verts, g.q)
|