polish for inclusion into thesis

This commit is contained in:
Stephen McQuay 2011-06-07 22:37:12 -06:00
parent 14fef76b2b
commit c682b12bea
10 changed files with 43 additions and 76 deletions

View File

@ -2,9 +2,9 @@
import sys
import time
import interp.bootstrap
from interp.cluster import QueueManager, get_qs
from optparse import OptionParser
from interp.cluster import QueueManager, get_qs
from optparse import OptionParser
if __name__ == '__main__':
parser = OptionParser(usage = "usage: %s [options] <status|watch|add|fresult #|slay|clear|clearall|clearresults>")

View File

@ -4,20 +4,18 @@ import sys
import os
import time
import shelve
from progressbar import *
from collections import defaultdict
from optparse import OptionParser
import numpy as np
import interp.bootstrap
import logging
log = logging.getLogger("interp")
from interp.cluster import QueueManager, get_qs
import numpy as np
from interp.cluster import QueueManager, get_qs
from progressbar import *
if __name__ == '__main__':
parser = OptionParser(usage = "usage: %s [options] <server> <interp count>")

View File

@ -11,7 +11,6 @@ import datetime
import numpy as np
import interp.bootstrap
from interp.grid.gmsh import ggrid
from interp.tools import baker_exact_3D as exact

View File

@ -6,8 +6,8 @@ import time
from progressbar import *
from interp.grid.DD import *
from interp.tools import *
from interp import bootstrap
from interp.tools import *
from interp import bootstrap
EXTRA_POINTS = 64

View File

@ -10,8 +10,6 @@ import pickle
import numpy as np
import interp.bootstrap
from interp.cluster import QueueManager, get_qs
if __name__ == '__main__':

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 = {}

View File

@ -20,8 +20,9 @@ class grid(object):
"""
verts = array of arrays (if passed in, will convert to numpy.array)
[
[x0,y0],
[x1,y1], ...
[x0,y0 <, z0>],
[x1,y1 <, z1>],
...
]
q = array (1D) of physical values
@ -97,10 +98,9 @@ class grid(object):
"""
this returns two grid objects: R and S.
R is a grid object that is supposedly a containing simplex around point X
R is a grid object that is a containing simplex around point X
S is S_j from baker's paper : some verts from all point that are not the
simplex
S : some verts from all points that are not the simplex
"""
simplex_size = self.dim + 1
log.debug("extra verts: %d" % extra_points)
@ -228,8 +228,9 @@ class cell(object):
X = point of interest
G = corrensponding grid object (G.verts)
because of the way i'm storing things, a cell simply stores indicies, and
so one must pass in a reference to the grid object containing real verts.
because of the way i'm storing things, a cell simply stores indicies,
and so one must pass in a reference to the grid object containing real
verts.
this simply calls grid.simplex.contains
"""
@ -255,10 +256,6 @@ def contains(X, R):
tests if X (point) is in R
R is a simplex, represented by a list of n-degree coordinates
it now correctly checks for 2/3-D verts
TODO: write unit test ...
"""
phis = get_phis(X, R)

View File

@ -51,9 +51,6 @@ class dgrid(basegrid):
def construct_connectivity(self):
"""
a call to this method prepares the internal connectivity structure.
this is part of the __init__ for a interp.grid.delaunay.grid, but can be
called from any grid object
"""
log.info('start')
qdelaunay_string = get_qdelaunay_dump_str(self)

View File

@ -1,14 +0,0 @@
def parse_qhull_file(filename, verbose=False):
f = open(filename, 'r')
if verbose:
print 'filename: ', filename
degree = int(f.readline().strip())
print "degree:", degree
print "number of points", f.readline().strip()
verts = []
for p in f:
v = [float(i) for i in p.strip().split()]
verts.append(v)
return verts

View File

@ -1,6 +1,5 @@
import os
import inspect
import numpy as np
import logging
@ -27,8 +26,6 @@ def baker_exact_2D(X):
"""
x ,y = X
# TODO: this is not baker's function!! this is:
# np.power(np.sin(x*np.pi/2.0) * np.sin(y*np.pi/2.0),2)
answer = np.power((np.sin(x * np.pi) * np.cos(y * np.pi)), 2)
log.debug(answer)
return answer
@ -83,6 +80,3 @@ def improved(qlin, err, final, exact):
return True
else:
return False
def percent_improvement(answer, exact):
return np.abs(answer['error']) / exact