polish for inclusion into thesis

This commit is contained in:
sm
2011-06-07 22:37:12 -06:00
parent 14fef76b2b
commit c682b12bea
10 changed files with 43 additions and 76 deletions
+25 -27
View File
@@ -11,37 +11,35 @@ log = logging.getLogger('interp')
def get_phis(X, R):
"""
The get_phis function is used to get barycentric coordonites for a point on
a triangle or tetrahedron:
The get_phis function is used to get barycentric coordonites for a
point on a triangle or tetrahedron. This is equation (*\ref{eq:qlinarea}*)
in 2D:
X -- the destination point (2D)
X = [0,0]
r -- the three points that make up the containing triangular simplex (2D)
r = [[-1, -1], [0, 2], [1, -1]]
X - the destination point (2D)
X = [0,0]
R - the three points that make up the 2-D triangular simplex
R = [[-1, -1], [0, 2], [1, -1]]
this will return [0.333, 0.333, 0.333]
in 3D:
X -- the destination point (3D)
X = [0,0,0]
R -- the four points that make up the containing simplex, tetrahedron (3D)
R = [
[0.0, 0.0, 1.0],
[0.94280904333606508, 0.0, -0.3333333283722672],
[-0.47140452166803232, 0.81649658244673617, -0.3333333283722672],
[-0.47140452166803298, -0.81649658244673584, -0.3333333283722672],
]
X - the destination point (3D)
X = [0,0,0]
R - the four points that make up the 3-D simplex (tetrahedron)
R = [
[ 0.0000, 0.0000, 1.0000],
[ 0.9428, 0.0000, -0.3333],
[-0.4714, 0.8165, -0.3333],
[-0.4714, -0.8165, -0.3333],
]
this will return [0.25, 0.25, 0.25, 0.25]
"""
# baker: eq 7
# TODO: perhaps also test len(R[0]) .. ?
# equations (*\ref{eq:lin3d}*) and (*\ref{eq:lin2d}*)
if len(X) == 2:
log.debug("running 2D")
A = np.array([
@@ -85,7 +83,7 @@ def qlinear(X, R):
"""
this calculates the linear portion of q from R to X
also, this is baker eq 3
This is equation (*\ref{eq:qlinbasis}*)
X = destination point
R = a inter.grid object; must have R.points and R.q
@@ -100,9 +98,12 @@ def qlinear(X, R):
return phis, qlin
def get_error(phi, R, S, order = 2):
#TODO: change the equation names in the comments
B = [] # baker eq 9
w = [] # baker eq 11
"""
Calculate the error approximation terms, returning the unknowns
a,b, and c in equation (*\ref{eq:quadratic2d}*).
"""
B = [] # equation ((*\ref{eq:B2d}*)
w = [] # equation ((*\ref{eq:w}*)
cur_pattern = pattern(len(phi), order)
log.info("pattern: %s" % cur_pattern)
@@ -150,8 +151,7 @@ def run_baker(X, R, S, order=2):
This is the main function to call to get an interpolation to X from the
input meshes
X -- the destination point (2D)
X = [0,0]
X -- the destination point
R = Simplex
S = extra points
@@ -190,9 +190,7 @@ def run_baker(X, R, S, order=2):
def memoize(f):
"""
for more information on what I'm doing here,
please read:
for more information on what I'm doing here, please read:
http://en.wikipedia.org/wiki/Memoize
"""
cache = {}