trying to guarantee a containing simplex
This commit is contained in:
parent
79880acad4
commit
0a388ff1b5
20
bin/test.py
20
bin/test.py
@ -3,8 +3,7 @@
|
|||||||
import sys
|
import sys
|
||||||
from grid.DDD import random_grid
|
from grid.DDD import random_grid
|
||||||
from baker import get_phis_3D, run_baker_3D
|
from baker import get_phis_3D, run_baker_3D
|
||||||
from baker.tools import exact_func_3D, smberror
|
from baker.tools import exact_func_3D, smberror, evaluate_answer
|
||||||
|
|
||||||
try:
|
try:
|
||||||
total_points = int(sys.argv[1])
|
total_points = int(sys.argv[1])
|
||||||
except:
|
except:
|
||||||
@ -33,14 +32,13 @@ if [i for i in phis if i < 0.0]:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
r = run_baker_3D(X, R, S)
|
r = run_baker_3D(X, R, S)
|
||||||
print 'qlin' , r['qlin']
|
evaluate_answer(r, exact)
|
||||||
print 'error', r['error']
|
except smberror as e:
|
||||||
print 'final', r['final']
|
print e
|
||||||
|
|
||||||
if abs(r['final'] - exact) <= abs(r['qlin'] - exact):
|
|
||||||
print "win"
|
try:
|
||||||
else:
|
answer = g.run_baker(X)
|
||||||
print "failure"
|
evaluate_answer(answer, exact)
|
||||||
except smberror as e:
|
except smberror as e:
|
||||||
print e
|
print e
|
||||||
print 'TAINT'
|
|
||||||
|
@ -35,3 +35,13 @@ def exact_func_3D(X):
|
|||||||
y = X[1]
|
y = X[1]
|
||||||
z = X[2]
|
z = X[2]
|
||||||
return np.power((np.sin(x * np.pi / 2.0) * np.sin(y * np.pi / 2.0) * np.sin(z * np.pi / 2.0)), 2)
|
return np.power((np.sin(x * np.pi / 2.0) * np.sin(y * np.pi / 2.0) * np.sin(z * np.pi / 2.0)), 2)
|
||||||
|
|
||||||
|
def evaluate_answer(answer, exact):
|
||||||
|
print 'qlin' , answer['qlin']
|
||||||
|
print 'error', answer['error']
|
||||||
|
print 'final', answer['final']
|
||||||
|
|
||||||
|
if abs(answer['final'] - exact) <= abs(answer['qlin'] - exact):
|
||||||
|
print ":) improved result"
|
||||||
|
else:
|
||||||
|
print ":( damaged result"
|
||||||
|
@ -54,7 +54,9 @@ class grid(object):
|
|||||||
"""
|
"""
|
||||||
this returns two grid objects: R and S.
|
this returns two grid objects: R and S.
|
||||||
|
|
||||||
R is a grid object that is the (a) containing simplex around point X
|
R is a grid object that is supposedly a containing simplex
|
||||||
|
around point X (it tends not to be)
|
||||||
|
|
||||||
S is S_j from baker's paper : some points from all point that are not the simplex
|
S is S_j from baker's paper : some points from all point that are not the simplex
|
||||||
"""
|
"""
|
||||||
(dist, indicies) = self.tree.query(X, simplex_size + extra_points)
|
(dist, indicies) = self.tree.query(X, simplex_size + extra_points)
|
||||||
@ -78,6 +80,8 @@ class grid(object):
|
|||||||
points near a short edge in a boundary layer cell where the
|
points near a short edge in a boundary layer cell where the
|
||||||
nearest points would all be colinear
|
nearest points would all be colinear
|
||||||
|
|
||||||
|
also, it guarantees that we find a containing simplex
|
||||||
|
|
||||||
R is a grid object that is the (a) containing simplex around point X
|
R is a grid object that is the (a) containing simplex around point X
|
||||||
S is a connectivity-based nearest-neighbor lookup, limited to 3 extra points
|
S is a connectivity-based nearest-neighbor lookup, limited to 3 extra points
|
||||||
"""
|
"""
|
||||||
|
@ -28,7 +28,6 @@ class TestSequenceFunctions(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
self.q = [exact_func(p) for p in self.points]
|
self.q = [exact_func(p) for p in self.points]
|
||||||
|
|
||||||
self.X = [0.25, 0.4001]
|
|
||||||
self.X = [0.55, 0.45]
|
self.X = [0.55, 0.45]
|
||||||
|
|
||||||
self.g = grid(self.points, self.q)
|
self.g = grid(self.points, self.q)
|
||||||
|
Loading…
Reference in New Issue
Block a user