putting together a simple test case so that I can test my quad/cubic interpolator

This commit is contained in:
Stephen Mardson McQuay
2010-03-20 17:10:02 -06:00
parent 993c901cec
commit 1fc988428d
14 changed files with 616 additions and 538 deletions
+6 -6
View File
@@ -6,18 +6,18 @@ from optparse import OptionParser
import numpy as np
from baker.tools import rms, exact_func
from grid.DD import simple_random_grid, simple_rect_grid
from grid.DD import random_grid, rect_grid
def get_mesh(source, destination, use_structured_grid = False):
mesh_source = None
mesh_dest = None
if use_structured_grid:
mesh_source = simple_rect_grid(source, source)
mesh_dest = simple_rect_grid(destination, destination)
mesh_source = rect_grid(source, source)
mesh_dest = rect_grid(destination, destination)
else:
mesh_source = simple_random_grid(source)
mesh_dest = simple_random_grid(destination)
mesh_source = random_grid(source)
mesh_dest = random_grid(destination)
if not (mesh_dest and mesh_source):
raise smberror('problem creating mesh objects')
@@ -88,7 +88,7 @@ if __name__ == '__main__':
errors.append(0)
continue
exact = exact_func(X[0], X[1])
exact = exact_func(X)
if np.abs(exact - answer['final']) <= np.abs(exact - answer['qlin']):
success += 1
-16
View File
@@ -1,16 +0,0 @@
#!/usr/bin/perl
use strict;
use warnings;
my $output_filename = $ARGV[0] or die "no args";
my $tmp_grid_file = "$output_filename.grid.txt";
system("grid.py > $tmp_grid_file");
system("cat $tmp_grid_file | qdelaunay GD2 s > $output_filename.txt\n" );
system("cat $tmp_grid_file | qdelaunay GD2 s Qt > ${output_filename}_qt.txt\n");
system("cat $tmp_grid_file | qdelaunay GD2 s QJ > ${output_filename}_qj.txt\n");
unlink($tmp_grid_file);
+20 -5
View File
@@ -3,9 +3,9 @@
import sys
import pickle
from grid.DD import simple_rect_grid, simple_random_grid
from grid.DD import rect_grid, random_grid
from baker import run_baker
from baker.tools import smberror
from baker.tools import exact_func, smberror
qfile = '/tmp/grid_regular.txt'
@@ -18,19 +18,23 @@ if __name__ == '__main__':
rx = 4
ry = 4 * rx
source_mesh = simple_rect_grid(rx, ry)
source_mesh = rect_grid(rx, ry)
# print source_mesh
X = [0.1, 0.1]
X = [0.1, 0.01]
try:
print "trying to get simplex and nearest points using nearest points (kdtree)"
(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 "trying to run baker"
print run_baker(X, R, S)
except smberror as e:
print "caught error: %s" % e
print "trying to get simplex and nearest points using connectivity scheme"
(R, S) = source_mesh.get_points_conn(X)
print "R for connectivity:\n", R
print "S for connectivity:\n", S
@@ -38,5 +42,16 @@ if __name__ == '__main__':
print "repeating the above just using the grid object:"
print source_mesh.run_baker(X)
r = source_mesh.run_baker(X)
exact = exact_func(X)
print r
print 'exact', exact
print 'qlin' , r['qlin']
print 'error', r['error']
print 'final', r['final']
if abs(r['final'] - exact) <= abs(r['qlin'] - exact):
print "win"
else:
print "failure"
open(qfile, 'w').write(source_mesh.for_qhull())
+15 -12
View File
@@ -1,9 +1,9 @@
#!/usr/bin/python2.6
import sys
from grid.DDD import simple_random_grid
from grid.DDD import random_grid
from baker import get_phis_3D, run_baker_3D
from baker.tools import exact_func_3D
from baker.tools import exact_func_3D, smberror
try:
total_points = int(sys.argv[1])
@@ -12,7 +12,7 @@ except:
print total_points
g = simple_random_grid(total_points)
g = random_grid(total_points)
open('/tmp/for_qhull.txt', 'w').write(g.for_qhull())
@@ -31,13 +31,16 @@ print "phi values (should all be positive): ", phis, sum(phis)
if [i for i in phis if i < 0.0]:
print "problems"
r = run_baker_3D(X, R, S)
try:
r = run_baker_3D(X, R, S)
print 'qlin' , r['qlin']
print 'error', r['error']
print 'final', r['final']
print 'qlin' , r['qlin']
print 'error', r['error']
print 'final', r['final']
if abs(r['final'] - exact) <= abs(r['qlin'] - exact):
print "win"
else:
print "failure"
if abs(r['final'] - exact) <= abs(r['qlin'] - exact):
print "win"
else:
print "failure"
except smberror as e:
print e
print 'TAINT'