trying to guarantee a containing simplex

This commit is contained in:
Stephen Mardson McQuay 2010-04-23 09:58:30 -06:00
parent 79880acad4
commit 0a388ff1b5
4 changed files with 24 additions and 13 deletions

View File

@ -3,8 +3,7 @@
import sys
from grid.DDD import random_grid
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:
total_points = int(sys.argv[1])
except:
@ -33,14 +32,13 @@ if [i for i in phis if i < 0.0]:
try:
r = run_baker_3D(X, R, S)
print 'qlin' , r['qlin']
print 'error', r['error']
print 'final', r['final']
if abs(r['final'] - exact) <= abs(r['qlin'] - exact):
print "win"
else:
print "failure"
evaluate_answer(r, exact)
except smberror as e:
print e
try:
answer = g.run_baker(X)
evaluate_answer(answer, exact)
except smberror as e:
print e
print 'TAINT'

View File

@ -35,3 +35,13 @@ def exact_func_3D(X):
y = X[1]
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)
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"

View File

@ -54,7 +54,9 @@ class grid(object):
"""
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
"""
(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
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
S is a connectivity-based nearest-neighbor lookup, limited to 3 extra points
"""

View File

@ -28,7 +28,6 @@ class TestSequenceFunctions(unittest.TestCase):
]
self.q = [exact_func(p) for p in self.points]
self.X = [0.25, 0.4001]
self.X = [0.55, 0.45]
self.g = grid(self.points, self.q)