Beispiel #1
0
 def get_c0_mesh(self):
     # Create the C0-mesh
     nx, ny, nz = self.n
     X = self.raw.get_c0_avg()
     b1 = BSplineBasis(2, [0] + [i/nx for i in range(nx+1)] + [1])
     b2 = BSplineBasis(2, [0] + [i/ny for i in range(ny+1)] + [1])
     b3 = BSplineBasis(2, [0] + [i/nz for i in range(nz+1)] + [1])
     c0_vol = volume_factory.interpolate(X, [b1, b2, b3])
     return c0_vol
Beispiel #2
0
    def test_lower_order(self):
        b = BSplineBasis(4, [0, 0, 0, 0, .2, .3, .3, .6, .9, 1, 1, 1, 1])
        t = b.greville()
        Y, X, Z = np.meshgrid(t, t, t)
        cp = np.zeros((len(t), len(t), len(t), 3))
        cp[..., 0] = X * (1 - Y)
        cp[..., 1] = X * X
        cp[..., 2] = Z**2 + 2

        vol = vf.interpolate(cp, [b, b, b])
        vol2 = vol.lower_order(1)  # still in space, vol2 is *also* exact
        u = np.linspace(0, 1, 5)
        v = np.linspace(0, 1, 6)
        w = np.linspace(0, 1, 7)
        self.assertTrue(np.allclose(vol(u, v, w), vol2(u, v, w)))
        self.assertTupleEqual(vol.order(), (4, 4, 4))
        self.assertTupleEqual(vol2.order(), (3, 3, 3))
Beispiel #3
0
    def test_lower_order(self):
        b = BSplineBasis(4, [0,0,0,0,.2, .3, .3, .6, .9, 1,1,1,1])
        t = b.greville()
        Y, X, Z = np.meshgrid(t,t,t)
        cp = np.zeros((len(t), len(t), len(t), 3))
        cp[...,0] = X*(1-Y)
        cp[...,1] = X*X
        cp[...,2] = Z**2 + 2

        vol  = VolumeFactory.interpolate(cp, [b,b,b])
        vol2 = vol.lower_order(1) # still in space, vol2 is *also* exact
        u = np.linspace(0,1, 5)
        v = np.linspace(0,1, 6)
        w = np.linspace(0,1, 7)
        self.assertTrue(np.allclose( vol(u,v,w), vol2(u,v,w) ))
        self.assertTupleEqual(vol.order(), (4,4,4))
        self.assertTupleEqual(vol2.order(), (3,3,3))
Beispiel #4
0
    def test_interpolate(self):
        t = np.linspace(0, 1, 5)
        V,U,W = np.meshgrid(t,t,t)
        x = np.zeros((5,5,5,3))
        x[:,:,:,0] = U*U + V*V
        x[:,:,:,1] = U*U*W
        x[:,:,:,2] = W*W*W + U*V
        b1 = BSplineBasis(3, [0,0,0,.33,.66,1,1,1])
        b2 = BSplineBasis(4, [0,0,0,0,.5,1,1,1,1])
        b3 = BSplineBasis(4, [0,0,0,0,.2,1,1,1,1])

        vol = VolumeFactory.interpolate(x, [b1,b2,b3], [t,t,t])
        t = np.linspace(0, 1, 7)
        V,U,W = np.meshgrid(t,t,t)
        x = vol(t,t,t)

        self.assertTrue(np.allclose(x[:,:,:,0], U*U + V*V))
        self.assertTrue(np.allclose(x[:,:,:,1], U*U*W))
        self.assertTrue(np.allclose(x[:,:,:,2], W*W*W + U*V))
Beispiel #5
0
    def test_interpolate(self):
        t = np.linspace(0, 1, 5)
        V,U,W = np.meshgrid(t,t,t)
        x = np.zeros((5,5,5,3))
        x[:,:,:,0] = U*U + V*V
        x[:,:,:,1] = U*U*W
        x[:,:,:,2] = W*W*W + U*V
        b1 = BSplineBasis(3, [0,0,0,.33,.66,1,1,1])
        b2 = BSplineBasis(4, [0,0,0,0,.5,1,1,1,1])
        b3 = BSplineBasis(4, [0,0,0,0,.2,1,1,1,1])

        vol = vf.interpolate(x, [b1,b2,b3], [t,t,t])
        t = np.linspace(0, 1, 7)
        V,U,W = np.meshgrid(t,t,t)
        x = vol(t,t,t)

        self.assertTrue(np.allclose(x[:,:,:,0], U*U + V*V))
        self.assertTrue(np.allclose(x[:,:,:,1], U*U*W))
        self.assertTrue(np.allclose(x[:,:,:,2], W*W*W + U*V))