finally added proper (in my opinon) exception handling to the grid's run_baker method. it should properly autocorrect, and switch the extra point lookup scheme to connectivity-based if solving the system of equations yields a singular solution

This commit is contained in:
Stephen Mardson McQuay
2010-03-05 08:58:07 -07:00
parent a25e6d03d1
commit 9a1b8d14b2
4 changed files with 50 additions and 33 deletions
+19 -11
View File
@@ -6,30 +6,38 @@ import pickle
from grid import simple_rect_grid, simple_random_grid
from baker import run_baker
from tools import smberror
qfile = '/tmp/grid_regular.txt'
if __name__ == '__main__':
try:
rx = int(sys.argv[1])
ry = int(sys.argv[2])
except ValueError as e:
print e
except (IndexError, ValueError) as e:
print "problem with argv: %s" % e
rx = 4
ry = 4 * rx
source_mesh = simple_rect_grid(rx, ry)
print source_mesh
# print source_mesh
X = [0.1, 0.1]
(R, S) = source_mesh.get_simplex_and_nearest_points(X, extra_points=4)
print "R for nearest-neighbor:\n", R
print "S for nearest-neighbor:\n", S
print run_baker(X, R, S)
try:
(R, S) = source_mesh.get_simplex_and_nearest_points(X, extra_points=4)
print "R for nearest-neighbor:\n", R
print "S for nearest-neighbor:\n", S
print run_baker(X, R, S)
except smberror as e:
print "caught error: %s" % e
(R, S) = source_mesh.get_points_conn(X)
print "R for connectivity:\n", R
print "S for connectivity:\n", S
print run_baker(X, R, S)
(R, S) = source_mesh.get_points_conn(X)
print "R for connectivity:\n", R
print "S for connectivity:\n", S
print run_baker(X, R, S)
print "repeating the above just using the grid object:"
print source_mesh.run_baker(X)
open(qfile, 'w').write(source_mesh.for_qhull())