コード例 #1
0
ファイル: test_integrator_cl.py プロジェクト: pankajp/pysph
    def setUp(self):
        """ The setup consists of two fluid particle arrays, each
        having one particle. The fluids are acted upon by an external
        vector force and gravity.

        Comparison is made with the PySPH integration of the system.
        
        """

        x1 = numpy.array([-0.5])
        y1 = numpy.array([1.0])

        x2 = numpy.array([0.5])
        y2 = numpy.array([1.0])

        tmpx1 = numpy.ones_like(x1)
        tmpx2 = numpy.ones_like(x2)

        self.f1 = base.get_particle_array(name="fluid1", x=x1, y=y1, tmpx=tmpx1)
        self.f2 = base.get_particle_array(name="fluid2", x=x2, y=y2, tmpx=tmpx2)

        self.particles = base.Particles(arrays=[self.f1, self.f2])
        self.kernel = kernel = base.CubicSplineKernel(dim=2)

        gravity = solver.SPHIntegration(
            sph.GravityForce.withargs(gy=-10.0), on_types=[Fluid], updates=["u", "v"], id="gravity"
        )

        force = solver.SPHIntegration(
            sph.GravityForce.withargs(gx=-10.0), on_types=[Fluid], updates=["u", "v"], id="force"
        )

        position = solver.SPHIntegration(sph.PositionStepping, on_types=[Fluid], updates=["x", "y"], id="step")

        gravity.calc_type = sph.CLCalc
        force.calc_type = sph.CLCalc
        position.calc_type = sph.CLCalc

        gravity_calcs = gravity.get_calcs(self.particles, kernel)
        force_calcs = force.get_calcs(self.particles, kernel)
        position_calcs = position.get_calcs(self.particles, kernel)

        self.calcs = calcs = []
        calcs.extend(gravity_calcs)
        calcs.extend(force_calcs)
        calcs.extend(position_calcs)

        self.integrator = CLIntegrator(self.particles, calcs)

        self.ctx = ctx = cl.create_some_context()
        self.integrator.setup_integrator(ctx)
        self.queue = calcs[0].queue

        self.dt = 0.1
        self.nsteps = 10
コード例 #2
0
ファイル: test_integrator_cl.py プロジェクト: sabago/pysph
    def setUp(self):
        """ The setup consists of two fluid particle arrays, each
        having one particle. The fluids are acted upon by an external
        vector force and gravity.

        Comparison is made with the PySPH integration of the system.
        
        """

        x1 = numpy.array([-0.5,])
        y1 = numpy.array([1.0, ])

        x2 = numpy.array([0.5,])
        y2 = numpy.array([1.0,])

        self.f1 = base.get_particle_array(name="fluid1", x=x1, y=y1)
        self.f2 = base.get_particle_array(name="fluid2", x=x2, y=y2)

        self.particles = base.CLParticles(
            arrays=[self.f1,self.f2],
            domain_manager_type=CLDomain.DomainManager,
            cl_locator_type=CLLocator.AllPairNeighborLocator
            )

        
        self.kernel = kernel = base.CubicSplineKernel(dim=2)

        gravity = solver.SPHIntegration(

            sph.GravityForce.withargs(gy=-10.0), on_types=[Fluid],
            updates=['u','v'], id='gravity'

            )

        force = solver.SPHIntegration(

            sph.GravityForce.withargs(gx = -10.0), on_types=[Fluid],
            updates=['u','v'], id='force'

            )

        position = solver.SPHIntegration(

            sph.PositionStepping, on_types=[Fluid],
            updates=['x','y'], id='step',

            )                    
        
        gravity.calc_type = sph.CLCalc
        force.calc_type = sph.CLCalc
        position.calc_type = sph.CLCalc

        gravity_calcs = gravity.get_calcs(self.particles, kernel)
        force_calcs = force.get_calcs(self.particles, kernel)
        position_calcs = position.get_calcs(self.particles, kernel)

        self.calcs = calcs = []
        calcs.extend(gravity_calcs)
        calcs.extend(force_calcs)
        calcs.extend(position_calcs)

        self.integrator = CLIntegrator(self.particles, calcs)

        self.ctx = ctx = solver.create_some_context()
        self.queue = calcs[0].queue

        self.dt = 0.1
        self.nsteps = 10
コード例 #3
0
ファイル: test_integrator_cl.py プロジェクト: sabago/pysph
class CLIntegratorTestCase(unittest.TestCase):
    """ Test the CLEulerIntegrator """

    def setUp(self):
        """ The setup consists of two fluid particle arrays, each
        having one particle. The fluids are acted upon by an external
        vector force and gravity.

        Comparison is made with the PySPH integration of the system.
        
        """

        x1 = numpy.array([-0.5,])
        y1 = numpy.array([1.0, ])

        x2 = numpy.array([0.5,])
        y2 = numpy.array([1.0,])

        self.f1 = base.get_particle_array(name="fluid1", x=x1, y=y1)
        self.f2 = base.get_particle_array(name="fluid2", x=x2, y=y2)

        self.particles = base.CLParticles(
            arrays=[self.f1,self.f2],
            domain_manager_type=CLDomain.DomainManager,
            cl_locator_type=CLLocator.AllPairNeighborLocator
            )

        
        self.kernel = kernel = base.CubicSplineKernel(dim=2)

        gravity = solver.SPHIntegration(

            sph.GravityForce.withargs(gy=-10.0), on_types=[Fluid],
            updates=['u','v'], id='gravity'

            )

        force = solver.SPHIntegration(

            sph.GravityForce.withargs(gx = -10.0), on_types=[Fluid],
            updates=['u','v'], id='force'

            )

        position = solver.SPHIntegration(

            sph.PositionStepping, on_types=[Fluid],
            updates=['x','y'], id='step',

            )                    
        
        gravity.calc_type = sph.CLCalc
        force.calc_type = sph.CLCalc
        position.calc_type = sph.CLCalc

        gravity_calcs = gravity.get_calcs(self.particles, kernel)
        force_calcs = force.get_calcs(self.particles, kernel)
        position_calcs = position.get_calcs(self.particles, kernel)

        self.calcs = calcs = []
        calcs.extend(gravity_calcs)
        calcs.extend(force_calcs)
        calcs.extend(position_calcs)

        self.integrator = CLIntegrator(self.particles, calcs)

        self.ctx = ctx = solver.create_some_context()
        self.queue = calcs[0].queue

        self.dt = 0.1
        self.nsteps = 10

    def test_setup_integrator(self):
        """ Test the construction of the integrator """

        integrator = self.integrator
        self.integrator.setup_integrator(self.ctx)
        calcs = integrator.calcs

        self.assertEqual( len(calcs), 6 )
        for calc in calcs:
            self.assertTrue( isinstance(calc, sph.CLCalc) )

        # check that setup_cl has been called for the arrays

        self.assertTrue(self.f1.cl_setup_done)
        self.assertTrue(self.f2.cl_setup_done)

        # check for the additional properties created by the integrator

        for arr in [self.f1, self.f2]:

            # Initial props
            self.assertTrue( arr.properties.has_key('_x0') )
            self.assertTrue( arr.properties.has_key('_y0') )
            self.assertTrue( arr.properties.has_key('_u0') )
            self.assertTrue( arr.properties.has_key('_v0') )
            
            self.assertTrue( arr.cl_properties.has_key('cl__x0') )
            self.assertTrue( arr.cl_properties.has_key('cl__y0') )
            self.assertTrue( arr.cl_properties.has_key('cl__u0') )
            self.assertTrue( arr.cl_properties.has_key('cl__v0') )

        # check for the k1 step props

        arr = self.f1

        self.assertTrue( arr.properties.has_key('_a_x_1') )
        self.assertTrue( arr.properties.has_key('_a_y_1') )

        self.assertTrue( arr.properties.has_key('_a_u_1') )
        self.assertTrue( arr.properties.has_key('_a_v_1') )

        self.assertTrue( arr.cl_properties.has_key('cl__a_x_1') )
        self.assertTrue( arr.cl_properties.has_key('cl__a_y_1') )

        self.assertTrue( arr.cl_properties.has_key('cl__a_u_1') )
        self.assertTrue( arr.cl_properties.has_key('cl__a_v_1') )
コード例 #4
0
ファイル: test_integrator_cl.py プロジェクト: pankajp/pysph
    def setUp(self):
        """ The setup consists of two fluid particle arrays, each
        having one particle. The fluids are acted upon by an external
        vector force and gravity.

        Comparison is made with the PySPH integration of the system.
        
        """

        x1 = numpy.array([
            -0.5,
        ])
        y1 = numpy.array([
            1.0,
        ])

        x2 = numpy.array([
            0.5,
        ])
        y2 = numpy.array([
            1.0,
        ])

        tmpx1 = numpy.ones_like(x1)
        tmpx2 = numpy.ones_like(x2)

        self.f1 = base.get_particle_array(name="fluid1",
                                          x=x1,
                                          y=y1,
                                          tmpx=tmpx1)
        self.f2 = base.get_particle_array(name="fluid2",
                                          x=x2,
                                          y=y2,
                                          tmpx=tmpx2)

        self.particles = base.Particles(arrays=[self.f1, self.f2])
        self.kernel = kernel = base.CubicSplineKernel(dim=2)

        gravity = solver.SPHIntegration(sph.GravityForce.withargs(gy=-10.0),
                                        on_types=[Fluid],
                                        updates=['u', 'v'],
                                        id='gravity')

        force = solver.SPHIntegration(sph.GravityForce.withargs(gx=-10.0),
                                      on_types=[Fluid],
                                      updates=['u', 'v'],
                                      id='force')

        position = solver.SPHIntegration(
            sph.PositionStepping,
            on_types=[Fluid],
            updates=['x', 'y'],
            id='step',
        )

        gravity.calc_type = sph.CLCalc
        force.calc_type = sph.CLCalc
        position.calc_type = sph.CLCalc

        gravity_calcs = gravity.get_calcs(self.particles, kernel)
        force_calcs = force.get_calcs(self.particles, kernel)
        position_calcs = position.get_calcs(self.particles, kernel)

        self.calcs = calcs = []
        calcs.extend(gravity_calcs)
        calcs.extend(force_calcs)
        calcs.extend(position_calcs)

        self.integrator = CLIntegrator(self.particles, calcs)

        self.ctx = ctx = cl.create_some_context()
        self.integrator.setup_integrator(ctx)
        self.queue = calcs[0].queue

        self.dt = 0.1
        self.nsteps = 10
コード例 #5
0
ファイル: test_integrator_cl.py プロジェクト: pankajp/pysph
class CLIntegratorTestCase(unittest.TestCase):
    """ Test the CLEulerIntegrator """
    def runTest(self):
        pass

    def setUp(self):
        """ The setup consists of two fluid particle arrays, each
        having one particle. The fluids are acted upon by an external
        vector force and gravity.

        Comparison is made with the PySPH integration of the system.
        
        """

        x1 = numpy.array([
            -0.5,
        ])
        y1 = numpy.array([
            1.0,
        ])

        x2 = numpy.array([
            0.5,
        ])
        y2 = numpy.array([
            1.0,
        ])

        tmpx1 = numpy.ones_like(x1)
        tmpx2 = numpy.ones_like(x2)

        self.f1 = base.get_particle_array(name="fluid1",
                                          x=x1,
                                          y=y1,
                                          tmpx=tmpx1)
        self.f2 = base.get_particle_array(name="fluid2",
                                          x=x2,
                                          y=y2,
                                          tmpx=tmpx2)

        self.particles = base.Particles(arrays=[self.f1, self.f2])
        self.kernel = kernel = base.CubicSplineKernel(dim=2)

        gravity = solver.SPHIntegration(sph.GravityForce.withargs(gy=-10.0),
                                        on_types=[Fluid],
                                        updates=['u', 'v'],
                                        id='gravity')

        force = solver.SPHIntegration(sph.GravityForce.withargs(gx=-10.0),
                                      on_types=[Fluid],
                                      updates=['u', 'v'],
                                      id='force')

        position = solver.SPHIntegration(
            sph.PositionStepping,
            on_types=[Fluid],
            updates=['x', 'y'],
            id='step',
        )

        gravity.calc_type = sph.CLCalc
        force.calc_type = sph.CLCalc
        position.calc_type = sph.CLCalc

        gravity_calcs = gravity.get_calcs(self.particles, kernel)
        force_calcs = force.get_calcs(self.particles, kernel)
        position_calcs = position.get_calcs(self.particles, kernel)

        self.calcs = calcs = []
        calcs.extend(gravity_calcs)
        calcs.extend(force_calcs)
        calcs.extend(position_calcs)

        self.integrator = CLIntegrator(self.particles, calcs)

        self.ctx = ctx = cl.create_some_context()
        self.integrator.setup_integrator(ctx)
        self.queue = calcs[0].queue

        self.dt = 0.1
        self.nsteps = 10

    def test_setup_integrator(self):
        """ Test the construction of the integrator """

        integrator = self.integrator
        calcs = integrator.calcs

        self.assertEqual(len(calcs), 6)
        for calc in calcs:
            self.assertTrue(isinstance(calc, sph.CLCalc))

        # check that setup_cl has been called for the arrays

        self.assertTrue(self.f1.cl_setup_done)
        self.assertTrue(self.f2.cl_setup_done)

        # check for the additional properties created by the integrator

        for arr in [self.f1, self.f2]:

            # Initial props
            self.assertTrue(arr.properties.has_key('_x_0'))
            self.assertTrue(arr.properties.has_key('_y_0'))
            self.assertTrue(arr.properties.has_key('_u_0'))
            self.assertTrue(arr.properties.has_key('_v_0'))

            self.assertTrue(arr.cl_properties.has_key('cl__x_0'))
            self.assertTrue(arr.cl_properties.has_key('cl__y_0'))
            self.assertTrue(arr.cl_properties.has_key('cl__u_0'))
            self.assertTrue(arr.cl_properties.has_key('cl__v_0'))

        # check for the k1 step props

        arr = self.f1

        self.assertTrue(arr.properties.has_key('_k1_u00'))
        self.assertTrue(arr.properties.has_key('_k1_v01'))

        self.assertTrue(arr.properties.has_key('_k1_u20'))
        self.assertTrue(arr.properties.has_key('_k1_v21'))

        self.assertTrue(arr.properties.has_key('_k1_x40'))
        self.assertTrue(arr.properties.has_key('_k1_y41'))

        self.assertTrue(arr.cl_properties.has_key('cl__k1_u00'))
        self.assertTrue(arr.cl_properties.has_key('cl__k1_v01'))

        self.assertTrue(arr.cl_properties.has_key('cl__k1_u20'))
        self.assertTrue(arr.cl_properties.has_key('cl__k1_v21'))

        self.assertTrue(arr.cl_properties.has_key('cl__k1_x40'))
        self.assertTrue(arr.cl_properties.has_key('cl__k1_y41'))
コード例 #6
0
ファイル: test_integrator_cl.py プロジェクト: pankajp/pysph
class CLIntegratorTestCase(unittest.TestCase):
    """ Test the CLEulerIntegrator """

    def runTest(self):
        pass

    def setUp(self):
        """ The setup consists of two fluid particle arrays, each
        having one particle. The fluids are acted upon by an external
        vector force and gravity.

        Comparison is made with the PySPH integration of the system.
        
        """

        x1 = numpy.array([-0.5])
        y1 = numpy.array([1.0])

        x2 = numpy.array([0.5])
        y2 = numpy.array([1.0])

        tmpx1 = numpy.ones_like(x1)
        tmpx2 = numpy.ones_like(x2)

        self.f1 = base.get_particle_array(name="fluid1", x=x1, y=y1, tmpx=tmpx1)
        self.f2 = base.get_particle_array(name="fluid2", x=x2, y=y2, tmpx=tmpx2)

        self.particles = base.Particles(arrays=[self.f1, self.f2])
        self.kernel = kernel = base.CubicSplineKernel(dim=2)

        gravity = solver.SPHIntegration(
            sph.GravityForce.withargs(gy=-10.0), on_types=[Fluid], updates=["u", "v"], id="gravity"
        )

        force = solver.SPHIntegration(
            sph.GravityForce.withargs(gx=-10.0), on_types=[Fluid], updates=["u", "v"], id="force"
        )

        position = solver.SPHIntegration(sph.PositionStepping, on_types=[Fluid], updates=["x", "y"], id="step")

        gravity.calc_type = sph.CLCalc
        force.calc_type = sph.CLCalc
        position.calc_type = sph.CLCalc

        gravity_calcs = gravity.get_calcs(self.particles, kernel)
        force_calcs = force.get_calcs(self.particles, kernel)
        position_calcs = position.get_calcs(self.particles, kernel)

        self.calcs = calcs = []
        calcs.extend(gravity_calcs)
        calcs.extend(force_calcs)
        calcs.extend(position_calcs)

        self.integrator = CLIntegrator(self.particles, calcs)

        self.ctx = ctx = cl.create_some_context()
        self.integrator.setup_integrator(ctx)
        self.queue = calcs[0].queue

        self.dt = 0.1
        self.nsteps = 10

    def test_setup_integrator(self):
        """ Test the construction of the integrator """

        integrator = self.integrator
        calcs = integrator.calcs

        self.assertEqual(len(calcs), 6)
        for calc in calcs:
            self.assertTrue(isinstance(calc, sph.CLCalc))

        # check that setup_cl has been called for the arrays

        self.assertTrue(self.f1.cl_setup_done)
        self.assertTrue(self.f2.cl_setup_done)

        # check for the additional properties created by the integrator

        for arr in [self.f1, self.f2]:

            # Initial props
            self.assertTrue(arr.properties.has_key("_x_0"))
            self.assertTrue(arr.properties.has_key("_y_0"))
            self.assertTrue(arr.properties.has_key("_u_0"))
            self.assertTrue(arr.properties.has_key("_v_0"))

            self.assertTrue(arr.cl_properties.has_key("cl__x_0"))
            self.assertTrue(arr.cl_properties.has_key("cl__y_0"))
            self.assertTrue(arr.cl_properties.has_key("cl__u_0"))
            self.assertTrue(arr.cl_properties.has_key("cl__v_0"))

        # check for the k1 step props

        arr = self.f1

        self.assertTrue(arr.properties.has_key("_k1_u00"))
        self.assertTrue(arr.properties.has_key("_k1_v01"))

        self.assertTrue(arr.properties.has_key("_k1_u20"))
        self.assertTrue(arr.properties.has_key("_k1_v21"))

        self.assertTrue(arr.properties.has_key("_k1_x40"))
        self.assertTrue(arr.properties.has_key("_k1_y41"))

        self.assertTrue(arr.cl_properties.has_key("cl__k1_u00"))
        self.assertTrue(arr.cl_properties.has_key("cl__k1_v01"))

        self.assertTrue(arr.cl_properties.has_key("cl__k1_u20"))
        self.assertTrue(arr.cl_properties.has_key("cl__k1_v21"))

        self.assertTrue(arr.cl_properties.has_key("cl__k1_x40"))
        self.assertTrue(arr.cl_properties.has_key("cl__k1_y41"))