def setUp(self):
        self.l = l = 1.0
        n = 20
        dx = l / n
        hdx = 1.5

        x, y, z = G.get_3d_block(dx, l, l, l)
        h = np.ones_like(x) * hdx * dx
        m = np.ones_like(x) * dx * dx * dx
        V = np.zeros_like(x)
        fluid = get_particle_array(name='fluid', x=x, y=y, z=z, h=h, m=m, V=V)

        x, y = G.get_2d_block(dx, l, l)
        z = np.ones_like(x) * (l + 5 * dx) / 2.0
        z = np.concatenate([z, -z])
        x = np.tile(x, 2)
        y = np.tile(y, 2)
        m = np.ones_like(x) * dx * dx * dx
        h = np.ones_like(x) * hdx * dx
        V = np.zeros_like(x)
        channel = get_particle_array(name='channel',
                                     x=x,
                                     y=y,
                                     z=z,
                                     h=h,
                                     m=m,
                                     V=V)

        self.particles = [fluid, channel]
        self.kernel = get_compiled_kernel(Gaussian(dim=3))
    def common_setup(self):
        # create the particle arrays
        L = 1.0
        n = 10
        dx = L / n
        hdx = 1.5
        self.L = L
        _x = np.arange(dx / 2, L, dx)
        self.vol = vol = dx * dx

        # fluid particles
        xx, yy = np.meshgrid(_x, _x)

        x = xx.ravel()
        y = yy.ravel()  # particle positions
        p = self._get_pressure(x, y, 0.0)
        h = np.ones_like(x) * hdx * dx   # smoothing lengths
        m = np.ones_like(x) * vol      # mass
        V = np.zeros_like(x)           # volumes

        fluid = get_particle_array(name='fluid', x=x, y=y, h=h, m=m, V=V, p=p)

        # particles and domain
        self.fluid = fluid
        self.domain = DomainManager(xmin=0, xmax=L, ymin=0, ymax=L,
                                    periodic_in_x=True, periodic_in_y=True,
                                    backend=self.backend
                                    )
        self.kernel = get_compiled_kernel(Gaussian(dim=2))
Beispiel #3
0
    def __init__(self, dim, dst, src, kernel=None):
        self.dst = dst; self.src = src
        if kernel is None:
            self.kernel = get_compiled_kernel(Gaussian(dim))

        # create the neighbor locator object
        self.nnps = nnps = NNPS(dim=dim, particles=[dst, src],
                                radius_scale=self.kernel.radius_scale)
        nnps.update()
Beispiel #4
0
    def __init__(self, dim, dst, src, kernel=None):
        self.dst = dst
        self.src = src
        if kernel is None:
            self.kernel = get_compiled_kernel(Gaussian(dim))

        # create the neighbor locator object
        self.nnps = nnps = NNPS(dim=dim,
                                particles=[dst, src],
                                radius_scale=self.kernel.radius_scale)
        nnps.update()
Beispiel #5
0
    def setUp(self):
        # create the particle arrays
        L = 1.0
        n = 100
        dx = L / n
        hdx = 1.5
        _x = np.arange(dx / 2, L, dx)
        self.vol = vol = dx * dx

        # fluid particles
        xx, yy = np.meshgrid(_x, _x)

        x = xx.ravel()
        y = yy.ravel()  # particle positions
        h = np.ones_like(x) * hdx * dx  # smoothing lengths
        m = np.ones_like(x) * vol  # mass
        V = np.zeros_like(x)  # volumes

        fluid = get_particle_array(name='fluid', x=x, y=y, h=h, m=m, V=V)

        # channel particles
        _y = np.arange(L + dx / 2, L + dx / 2 + 10 * dx, dx)
        xx, yy = np.meshgrid(_x, _y)

        xtop = xx.ravel()
        ytop = yy.ravel()

        _y = np.arange(-dx / 2, -dx / 2 - 10 * dx, -dx)
        xx, yy = np.meshgrid(_x, _y)

        xbot = xx.ravel()
        ybot = yy.ravel()

        x = np.concatenate((xtop, xbot))
        y = np.concatenate((ytop, ybot))

        h = np.ones_like(x) * hdx * dx
        m = np.ones_like(x) * vol
        V = np.zeros_like(x)

        channel = get_particle_array(name='channel', x=x, y=y, h=h, m=m, V=V)

        # particles and domain
        self.particles = particles = [fluid, channel]
        self.domain = domain = DomainManager(xmin=0,
                                             xmax=L,
                                             periodic_in_x=True)
        self.kernel = get_compiled_kernel(Gaussian(dim=2))
    def setUp(self):
        # create the particle arrays
        L = 1.0
        n = 5
        dx = L / n
        hdx = 1.5
        self.L = L
        self.vol = vol = dx * dx * dx

        # fluid particles
        xx, yy, zz = np.mgrid[dx / 2:L:dx, dx / 2:L:dx, dx / 2:L:dx]

        x = xx.ravel()
        y = yy.ravel()
        z = zz.ravel()  # particle positions
        p = self._get_pressure(x, y, z)
        h = np.ones_like(x) * hdx * dx  # smoothing lengths
        m = np.ones_like(x) * vol  # mass
        V = np.zeros_like(x)  # volumes

        fluid = get_particle_array(name='fluid',
                                   x=x,
                                   y=y,
                                   z=z,
                                   h=h,
                                   m=m,
                                   V=V,
                                   p=p)

        # particles and domain
        self.fluid = fluid
        self.domain = DomainManager(xmin=0,
                                    xmax=L,
                                    ymin=0,
                                    ymax=L,
                                    zmin=0,
                                    zmax=L,
                                    periodic_in_x=True,
                                    periodic_in_y=True,
                                    periodic_in_z=True)
        self.kernel = get_compiled_kernel(Gaussian(dim=3))

        self.orig_n = self.fluid.get_number_of_particles()
        self.nnps = LinkedListNNPS(dim=3,
                                   particles=[self.fluid],
                                   domain=self.domain,
                                   radius_scale=self.kernel.radius_scale)
Beispiel #7
0
def sd_evaluate(nnps, pm, mass, src_index, dst_index):
    # the destination particle array
    dst = nnps.particles[dst_index]
    src = nnps.particles[src_index]

    # particle coordinates
    dx, dy, dz, dh, drho = dst.get('x',
                                   'y',
                                   'z',
                                   'h',
                                   'rho',
                                   only_real_particles=True)
    sx, sy, sz, sh, srho = src.get('x',
                                   'y',
                                   'z',
                                   'h',
                                   'rho',
                                   only_real_particles=False)

    neighbors = UIntArray()
    cubic = get_compiled_kernel(CubicSpline(dim=dim))

    # compute density for each destination particle
    num_particles = dst.num_real_particles

    # the number of local particles should have tag Local
    assert (num_particles == pm.num_local[dst_index])

    for i in range(num_particles):

        hi = dh[i]

        nnps.get_nearest_particles(src_index, dst_index, i, neighbors)

        nnbrs = neighbors.length

        rho_sum = 0.0
        for indexj in range(nnbrs):
            j = neighbors[indexj]

            wij = cubic.kernel(dx[i], dy[i], dz[i], sx[j], sy[j], sz[j], hi)

            rho_sum = rho_sum + mass * wij

        drho[i] += rho_sum
    def setUp(self):
        # create the particle arrays
        L = 1.0; n = 100; dx = L/n; hdx = 1.5
        _x = np.arange(dx/2, L, dx)
        self.vol = vol = dx*dx

        # fluid particles
        xx, yy = np.meshgrid(_x, _x)

        x = xx.ravel(); y = yy.ravel() # particle positions
        h = np.ones_like(x) * hdx*dx   # smoothing lengths
        m = np.ones_like(x) * vol      # mass
        V = np.zeros_like(x)           # volumes

        fluid = get_particle_array(name='fluid', x=x, y=y, h=h, m=m, V=V)

        # channel particles
        _y = np.arange(L+dx/2, L+dx/2 + 10*dx, dx)
        xx, yy = np.meshgrid(_x, _y)

        xtop = xx.ravel(); ytop = yy.ravel()

        _y = np.arange(-dx/2, -dx/2-10*dx, -dx)
        xx, yy = np.meshgrid(_x, _y)

        xbot = xx.ravel(); ybot = yy.ravel()

        x = np.concatenate( (xtop, xbot) )
        y = np.concatenate( (ytop, ybot) )

        h = np.ones_like(x) * hdx*dx
        m = np.ones_like(x) * vol
        V = np.zeros_like(x)

        channel = get_particle_array(name='channel', x=x, y=y, h=h, m=m, V=V)

        # particles and domain
        self.particles = particles = [fluid, channel]
        self.domain = domain = DomainManager(xmin=0, xmax=L, periodic_in_x=True)
        self.kernel = get_compiled_kernel(Gaussian(dim=2))
Beispiel #9
0
 def setUpClass(cls):
     cls.wrapper = get_compiled_kernel(cls.kernel_factory())
     cls.kernel = cls.wrapper.kernel
     cls.gradient = cls.wrapper.gradient
Beispiel #10
0
 def setUpClass(cls):
     cls.wrapper = get_compiled_kernel(cls.kernel_factory())
     cls.kernel = cls.wrapper.kernel
     cls.gradient = cls.wrapper.gradient