removed the 3d-specific run_baker method

This commit is contained in:
Stephen McQuay 2011-02-15 11:48:33 -07:00
parent 9827035e72
commit a96df3b31c

View File

@ -39,6 +39,7 @@ def get_phis(X, R):
# baker: eq 7
# TODO: perhaps also test len(R[0]) .. ?
if len(X) == 2:
log.debug("running 2D")
A = np.array([
[ 1, 1, 1],
[R[0][0], R[1][0], R[2][0]],
@ -49,6 +50,7 @@ def get_phis(X, R):
X[1]
])
elif len(X) == 3:
log.debug("running 3D")
A = np.array([
[ 1, 1, 1, 1 ],
[R[0][0], R[1][0], R[2][0], R[3][0]],
@ -176,89 +178,6 @@ def run_baker(X, R, S, order=2):
return answer
def run_baker_3D(X, R, S):
"""
This is the main function to call to get an interpolation to X from the input meshes
X -- the destination point (3D)
X = [0,0,0]
R = Simplex (4 points, contains X)
S = extra points (surrounding, in some manner, R and X, but not in R)
"""
# calculate values only for the triangle
phi, qlin = qlinear_3D(X, R)
if len(S.verts) == 0:
answer = {
'a': None,
'b': None,
'c': None,
'd': None,
'e': None,
'f': None,
'qlin': qlin,
'error': None,
'final': None,
}
return answer
B = [] # baker eq 9
w = [] # baker eq 11
for (s, q) in zip(S.verts, S.q):
cur_phi, cur_qlin = qlinear_3D(s, R)
(phi1, phi2, phi3, phi4) = cur_phi
B.append(
[
phi1 * phi2,
phi1 * phi3,
phi1 * phi4,
phi2 * phi3,
phi2 * phi4,
phi3 * phi4,
]
)
w.append(q - cur_qlin)
B = np.array(B)
w = np.array(w)
A = np.dot(B.T, B)
b = np.dot(B.T, w)
# baker solve eq 10
try:
(a, b, c, d, e, f) = np.linalg.solve(A,b)
except np.linalg.LinAlgError as e:
log.error("linear calculation went bad, resorting to np.linalg.pinv: %s", e)
(a, b, c, d, e, f) = np.dot(np.linalg.pinv(A), b)
error_term = a * phi[0] * phi[1]\
+ b * phi[0] * phi[2]\
+ c * phi[0] * phi[3]\
+ d * phi[1] * phi[2]\
+ e * phi[1] * phi[3]\
+ f * phi[2] * phi[3]
q_final = qlin + error_term
answer = {
'a': a,
'b': b,
'c': c,
'd': d,
'e': e,
'f': f,
'qlin': qlin,
'error': error_term,
'final': q_final,
}
return answer
def _boxings(n, k):
"""\