fixed a little bug and getting good results again. still will have problems if you try to simply get a linear interpolation
This commit is contained in:
parent
2113abb8dc
commit
0f4daa9a9c
@ -100,9 +100,14 @@ if __name__ == '__main__':
|
|||||||
S = [mesh_source.points[i] for i in indicies[3:] ]
|
S = [mesh_source.points[i] for i in indicies[3:] ]
|
||||||
Sq = [mesh_source.q[i] for i in indicies[3:] ]
|
Sq = [mesh_source.q[i] for i in indicies[3:] ]
|
||||||
s_mesh = grid.grid(S, Sq)
|
s_mesh = grid.grid(S, Sq)
|
||||||
|
print len(S)
|
||||||
|
|
||||||
answer = baker.run_baker(X, r_mesh, s_mesh, options.extra, options.verbose)
|
answer = baker.run_baker(X, r_mesh, s_mesh, options.verbose)
|
||||||
|
|
||||||
|
print "]\n[".join([str(i) for i in [answer, r_mesh, s_mesh]])
|
||||||
|
print
|
||||||
|
print
|
||||||
|
print
|
||||||
exact = exact_func(X[0], X[1])
|
exact = exact_func(X[0], X[1])
|
||||||
if np.abs(exact - answer['final']) < np.abs(exact - answer['qlin']):
|
if np.abs(exact - answer['final']) < np.abs(exact - answer['qlin']):
|
||||||
success += 1
|
success += 1
|
||||||
|
17
lib/baker.py
17
lib/baker.py
@ -93,7 +93,7 @@ def qlinear_3D(X, R, q):
|
|||||||
qlin = sum([q_i * phi_i for q_i, phi_i in zip(q, phis)])
|
qlin = sum([q_i * phi_i for q_i, phi_i in zip(q, phis)])
|
||||||
return qlin
|
return qlin
|
||||||
|
|
||||||
def run_baker(X, R, S, extra_points = 3, verbose = False):
|
def run_baker(X, R, S, verbose = False):
|
||||||
"""
|
"""
|
||||||
This is the main function to call to get an interpolation to X from the tree
|
This is the main function to call to get an interpolation to X from the tree
|
||||||
|
|
||||||
@ -107,10 +107,19 @@ def run_baker(X, R, S, extra_points = 3, verbose = False):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# calculate values only for the triangle
|
# calculate values only for the triangle
|
||||||
phi = get_phis(X, S.points)
|
phi = get_phis(X, R.points)
|
||||||
qlin = qlinear (X, S.points, S.q)
|
qlin = qlinear (X, R.points, R.q)
|
||||||
|
|
||||||
if extra_points == 0: return qlin
|
if len(S.points) == 0:
|
||||||
|
answer = {
|
||||||
|
'a': None,
|
||||||
|
'b': None,
|
||||||
|
'c': None,
|
||||||
|
'qlin': qlin,
|
||||||
|
'error': None,
|
||||||
|
'final': None,
|
||||||
|
}
|
||||||
|
return answer
|
||||||
|
|
||||||
B = [] # baker eq 9
|
B = [] # baker eq 9
|
||||||
w = [] # baker eq 11
|
w = [] # baker eq 11
|
||||||
|
@ -91,6 +91,7 @@ class TestSequenceFunctions(unittest.TestCase):
|
|||||||
self.q[size_of_simplex:size_of_simplex + extra_points])
|
self.q[size_of_simplex:size_of_simplex + extra_points])
|
||||||
|
|
||||||
answer = baker.run_baker(self.X, R, S)
|
answer = baker.run_baker(self.X, R, S)
|
||||||
|
|
||||||
a = self.approx_fmt % answer['a']
|
a = self.approx_fmt % answer['a']
|
||||||
b = self.approx_fmt % answer['b']
|
b = self.approx_fmt % answer['b']
|
||||||
c = self.approx_fmt % answer['c']
|
c = self.approx_fmt % answer['c']
|
||||||
|
Loading…
Reference in New Issue
Block a user