2011-03-23 10:47:42 -07:00
|
|
|
from interp.grid.delaunay import dgrid as basegrid
|
2011-03-24 14:48:36 -07:00
|
|
|
from interp.tools import baker_exact_3D, log
|
2010-03-18 22:32:24 -07:00
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
2011-03-23 10:47:42 -07:00
|
|
|
class rect_grid(basegrid):
|
2010-03-18 22:32:24 -07:00
|
|
|
def __init__(self, xres = 5, yres = 5, zres = 5):
|
2011-05-20 11:40:42 -07:00
|
|
|
xmin = 0.0
|
|
|
|
xmax = 1.0
|
2010-03-18 22:32:24 -07:00
|
|
|
xspan = xmax - xmin
|
2011-05-20 11:40:42 -07:00
|
|
|
xdel = xspan / float(xres - 1)
|
2010-03-18 22:32:24 -07:00
|
|
|
|
2011-05-20 11:40:42 -07:00
|
|
|
ymin = 0.0
|
|
|
|
ymay = 1.0
|
2010-03-18 22:32:24 -07:00
|
|
|
yspan = ymay - ymin
|
2011-05-20 11:40:42 -07:00
|
|
|
ydel = yspan / float(yres - 1)
|
2010-03-18 22:32:24 -07:00
|
|
|
|
2011-05-20 11:40:42 -07:00
|
|
|
zmin = 0.0
|
|
|
|
zmaz = 1.0
|
2010-03-18 22:32:24 -07:00
|
|
|
zspan = zmaz - zmin
|
2011-05-20 11:40:42 -07:00
|
|
|
zdel = zspan / float(zres - 1)
|
2010-03-18 22:32:24 -07:00
|
|
|
|
|
|
|
|
2010-11-08 15:25:09 -08:00
|
|
|
verts = []
|
2011-05-20 11:40:42 -07:00
|
|
|
q = np.zeros(xres * yres * zres)
|
2010-03-18 22:32:24 -07:00
|
|
|
for x in xrange(xres):
|
|
|
|
cur_x = xmin + (x * xdel)
|
|
|
|
for y in xrange(yres):
|
|
|
|
cur_y = ymin + (y * ydel)
|
|
|
|
for z in xrange(zres):
|
|
|
|
cur_z = zmin + (z * zdel)
|
2010-11-08 15:25:09 -08:00
|
|
|
verts.append([cur_x, cur_y, cur_z])
|
2011-05-20 11:40:42 -07:00
|
|
|
|
2011-03-23 10:47:42 -07:00
|
|
|
basegrid.__init__(self, verts, q)
|
2010-03-18 22:32:24 -07:00
|
|
|
|
2011-03-21 14:24:25 -07:00
|
|
|
|
2010-03-18 22:32:24 -07:00
|
|
|
|
2010-03-20 16:10:02 -07:00
|
|
|
class random_grid(rect_grid):
|
2010-11-08 15:25:09 -08:00
|
|
|
def __init__(self, num_verts = 10):
|
|
|
|
verts = []
|
2010-03-18 22:32:24 -07:00
|
|
|
q = []
|
|
|
|
|
|
|
|
r = np.random
|
|
|
|
|
2010-11-08 15:25:09 -08:00
|
|
|
appx_side_res = int(np.power(num_verts, 1/3.0))
|
|
|
|
log.debug("appx_side_res: %d" % appx_side_res)
|
2010-09-04 15:52:16 -07:00
|
|
|
delta = 1.0 / float(appx_side_res)
|
2010-05-04 22:03:07 -07:00
|
|
|
|
|
|
|
for x in xrange(appx_side_res + 1):
|
|
|
|
pass
|
|
|
|
|
2010-11-08 15:25:09 -08:00
|
|
|
for i in xrange(num_verts):
|
2010-03-18 22:32:24 -07:00
|
|
|
cur_x = r.rand()
|
|
|
|
cur_y = r.rand()
|
|
|
|
cur_z = r.rand()
|
|
|
|
|
2010-11-08 15:25:09 -08:00
|
|
|
verts.append([cur_x, cur_y, cur_z])
|
2011-03-24 14:48:36 -07:00
|
|
|
q.append(baker_exact_3D((cur_x, cur_y, cur_z)))
|
|
|
|
basegrid.__init__(self, verts, q)
|
2010-03-18 22:32:24 -07:00
|
|
|
|
2010-11-08 15:25:09 -08:00
|
|
|
self.verts = np.array(self.verts)
|
2010-03-18 22:32:24 -07:00
|
|
|
self.q = np.array(self.q)
|