예제 #1
0
    def test_vert_spread(self):
        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0

            if runner._spec.id == 0:
                dbuf[vi(-1, 1), 128, 64] = 0.11
                dbuf[vi(0, 1), 128, 64] = 0.12
                dbuf[vi(1, 1), 128, 64] = 0.13

            runner._debug_set_dist(dbuf)

        VertTest = type("VertTest", (AASimulationTest,), {"initial_conditions": ic})
        ctrl = LBSimulationController(VertTest, Vertical2BlockGeo)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, "test_out")
        b0 = np.load(io.dists_filename(output, 1, 0, 1))["arr_0"]
        b1 = np.load(io.dists_filename(output, 1, 1, 1))["arr_0"]
        ae = np.testing.assert_equal

        # No propagation in the first step, but the distributions are stored
        # in opposite slots.
        ae(b1[vi(1, -1), 0, 64], np.float32(0.11))
        ae(b1[vi(0, -1), 0, 64], np.float32(0.12))
        ae(b1[vi(-1, -1), 0, 64], np.float32(0.13))
예제 #2
0
    def test_horiz_spread(self):
        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0

            if runner._spec.id == 0:
                dbuf[vi(1, 0), 64, 128] = 0.11
                dbuf[vi(1, 1), 64, 128] = 0.12
                dbuf[vi(1, -1), 64, 128] = 0.13

            runner._debug_set_dist(dbuf)

        HorizTest = type('HorizTest', (AASimulationTest,),
                {'initial_conditions': ic})
        ctrl = LBSimulationController(HorizTest, DoubleBlockGeometryTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']
        ae = np.testing.assert_equal

        # No propagation in the first step, but the distributions are stored
        # in opposite slots.
        ae(b1[vi(-1, 0), 64, 0], np.float32(0.11))
        ae(b1[vi(-1, -1), 64, 0], np.float32(0.12))
        ae(b1[vi(-1, 1), 64, 0], np.float32(0.13))
예제 #3
0
    def test_horiz_spread(self):
        ctrl = LBSimulationController(PeriodicSimulationTest,
                                      TwoBlocksXConnGeoTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'per_horiz_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']

        ae = np.testing.assert_equal

        ae(b1[vi(-1, 0, 0), 32, 32, 64], np.float32(0.11))
        ae(b1[vi(-1, 1, 0), 32, 33, 64], np.float32(0.12))
        ae(b1[vi(-1, -1, 0), 32, 31, 64], np.float32(0.13))
        ae(b1[vi(-1, 0, 1), 33, 32, 64], np.float32(0.14))
        ae(b1[vi(-1, 0, -1), 31, 32, 64], np.float32(0.15))

        ae(b0[vi(1, 0, 0), 1, 1, 1], np.float32(0.21))
        ae(b0[vi(1, 1, 0), 1, 2, 1], np.float32(0.22))
        ae(b0[vi(1, 0, 1), 2, 1, 1], np.float32(0.23))

        ae(b0[vi(1, 0, 0), 1, 32, 1], np.float32(0.33))
        ae(b0[vi(1, 1, 0), 1, 33, 1], np.float32(0.34))
        ae(b0[vi(1, -1, 0), 1, 31, 1], np.float32(0.35))
        ae(b0[vi(1, 0, 1), 2, 32, 1], np.float32(0.36))
예제 #4
0
    def test_vert_spread(self):
        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0

            if runner._spec.id == 0:
                dbuf[vi(-1, 1), 128, 64] = 0.11
                dbuf[vi(0, 1), 128, 64] = 0.12
                dbuf[vi(1, 1), 128, 64] = 0.13

            runner._debug_set_dist(dbuf)

        VertTest = type('VertTest', (AASimulationTest, ),
                        {'initial_conditions': ic})
        ctrl = LBSimulationController(VertTest, Vertical2BlockGeo)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']
        ae = np.testing.assert_equal

        # No propagation in the first step, but the distributions are stored
        # in opposite slots.
        ae(b1[vi(1, -1), 0, 64], np.float32(0.11))
        ae(b1[vi(0, -1), 0, 64], np.float32(0.12))
        ae(b1[vi(-1, -1), 0, 64], np.float32(0.13))
예제 #5
0
    def test_horiz_spread(self):

        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0

            if runner._spec.id == 1:
                dbuf[vi(1, 0), 128, 128] = 0.11
                dbuf[vi(1, 1), 128, 128] = 0.12
                dbuf[vi(1, -1), 128, 128] = 0.13

                # At the top
                dbuf[vi(1, 0), 256, 128] = 0.31
                dbuf[vi(1, 1), 256, 128] = 0.32
                dbuf[vi(1, -1), 256, 128] = 0.33

                dbuf[vi(-1, -1), 256, 128] = 0.66   # should not be overwritten
            elif runner._spec.id == 0:
                dbuf[vi(-1, 0), 128, 1] = 0.21
                dbuf[vi(-1, 1), 128, 1] = 0.22
                dbuf[vi(-1, -1), 128, 1] = 0.23

                # At the bottom
                dbuf[vi(-1, 0), 1, 1] = 0.41
                dbuf[vi(-1, 1), 1, 1] = 0.42
                dbuf[vi(-1, -1), 1, 1] = 0.43

                dbuf[vi(1, 1), 1, 1] = 0.77     # should not be overwritten

            runner._debug_set_dist(dbuf)
            runner._debug_set_dist(dbuf, False)

        HorizTest = type('HorizTest', (SimulationTest,),
                {'initial_conditions': ic})
        ctrl = LBSimulationController(HorizTest, DoubleBlockGeometryTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']

        ae = np.testing.assert_equal

        ae(b0[vi(1, 0), 128, 1], np.float32(0.11))
        ae(b0[vi(1, 1), 129, 1], np.float32(0.12))
        ae(b0[vi(1, -1), 127, 1], np.float32(0.13))

        ae(b0[vi(1, 0), 256, 1], np.float32(0.31))
        ae(b0[vi(1, -1), 255, 1], np.float32(0.33))

        ae(b1[vi(-1, 0), 128, 128], np.float32(0.21))
        ae(b1[vi(-1, 1), 129, 128], np.float32(0.22))
        ae(b1[vi(-1, -1), 127, 128], np.float32(0.23))

        ae(b1[vi(-1, 0), 1, 128], np.float32(0.41))
        ae(b1[vi(-1, 1), 2, 128], np.float32(0.42))

        ae(b1[vi(-1, -1), 256, 128], np.float32(0.66))
        ae(b0[vi(1, 1), 1, 1], np.float32(0.77))
예제 #6
0
    def test_b0_spread(self):
        global tmpdir

        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0

            if runner._spec.id == 0:
                # Top right corner
                dbuf[vi(1, 1), 128, 128] = 0.11
                dbuf[vi(0, 1), 128, 128] = 0.01
                dbuf[vi(1, 0), 128, 128] = 0.10
                dbuf[vi(0, -1), 128, 128] = 0.02
                dbuf[vi(-1, 0), 128, 128] = 0.20
                dbuf[vi(1, -1), 128, 128] = 0.30
                dbuf[vi(-1, 1), 128, 128] = 0.40

                # Bottom right corner
                dbuf[vi(1, 1), 1, 128] = 0.50
                dbuf[vi(1, -1), 1, 128] = 0.51
                dbuf[vi(1, 0), 1, 128] = 0.52
            elif runner._spec.id == 1:
                dbuf[vi(1, 0), 127, 128] = 0.60
                dbuf[vi(1, 1), 127, 128] = 0.61
                dbuf[vi(1, -1), 127, 128] = 0.62
                dbuf[vi(1, 0), 128, 128] = 0.70
                dbuf[vi(1, -1), 128, 128] = 0.71

            runner._debug_set_dist(dbuf)
            runner._debug_set_dist(dbuf, False)

        RightSide = type('RightSide', (SimulationTest, ),
                         {'initial_conditions': ic})
        ctrl = LBSimulationController(RightSide, GeometryTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']
        b2 = np.load(io.dists_filename(output, 1, 2, 1))['arr_0']
        b3 = np.load(io.dists_filename(output, 1, 3, 1))['arr_0']
        ae = np.testing.assert_equal

        ae(b3[vi(1, 1), 1, 1], np.float32(0.11))
        ae(b0[vi(-1, 0), 128, 127], np.float32(0.20))
        ae(b0[vi(0, -1), 127, 128], np.float32(0.02))
        ae(b2[vi(1, 0), 128, 1], np.float32(0.10))
        ae(b1[vi(0, 1), 1, 128], np.float32(0.01))
        ae(b2[vi(1, -1), 127, 1], np.float32(0.30))
        ae(b1[vi(-1, 1), 1, 127], np.float32(0.40))
        ae(b2[vi(1, 1), 2, 1], np.float32(0.50))
        ae(b2[vi(1, 0), 1, 1], np.float32(0.52))

        ae(b3[vi(1, 0), 127, 1], np.float32(0.60))
        ae(b3[vi(1, 0), 128, 1], np.float32(0.70))
        ae(b3[vi(1, 1), 128, 1], np.float32(0.61))
        ae(b3[vi(1, -1), 127, 1], np.float32(0.71))
        ae(b3[vi(1, -1), 126, 1], np.float32(0.62))
예제 #7
0
    def test_horiz_spread(self):
        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0

            if runner._spec.id == 1:
                dbuf[vi(1, 0), 128, 128] = 0.11
                dbuf[vi(1, 1), 128, 128] = 0.12
                dbuf[vi(1, -1), 128, 128] = 0.13

                # At the top
                dbuf[vi(1, 0), 256, 128] = 0.31
                dbuf[vi(1, 1), 256, 128] = 0.32
                dbuf[vi(1, -1), 256, 128] = 0.33

                dbuf[vi(-1, -1), 256, 128] = 0.66  # should not be overwritten
            elif runner._spec.id == 0:
                dbuf[vi(-1, 0), 128, 1] = 0.21
                dbuf[vi(-1, 1), 128, 1] = 0.22
                dbuf[vi(-1, -1), 128, 1] = 0.23

                # At the bottom
                dbuf[vi(-1, 0), 1, 1] = 0.41
                dbuf[vi(-1, 1), 1, 1] = 0.42
                dbuf[vi(-1, -1), 1, 1] = 0.43

                dbuf[vi(1, 1), 1, 1] = 0.77  # should not be overwritten

            runner._debug_set_dist(dbuf)
            runner._debug_set_dist(dbuf, False)

        HorizTest = type('HorizTest', (SimulationTest, ),
                         {'initial_conditions': ic})
        ctrl = LBSimulationController(HorizTest, DoubleBlockGeometryTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']

        ae = np.testing.assert_equal

        ae(b0[vi(1, 0), 128, 1], np.float32(0.11))
        ae(b0[vi(1, 1), 129, 1], np.float32(0.12))
        ae(b0[vi(1, -1), 127, 1], np.float32(0.13))

        ae(b0[vi(1, 0), 256, 1], np.float32(0.31))
        ae(b0[vi(1, -1), 255, 1], np.float32(0.33))

        ae(b1[vi(-1, 0), 128, 128], np.float32(0.21))
        ae(b1[vi(-1, 1), 129, 128], np.float32(0.22))
        ae(b1[vi(-1, -1), 127, 128], np.float32(0.23))

        ae(b1[vi(-1, 0), 1, 128], np.float32(0.41))
        ae(b1[vi(-1, 1), 2, 128], np.float32(0.42))

        ae(b1[vi(-1, -1), 256, 128], np.float32(0.66))
        ae(b0[vi(1, 1), 1, 1], np.float32(0.77))
예제 #8
0
    def test_b0_spread(self):
        global tmpdir

        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0

            if runner._spec.id == 0:
                # Top right corner
                dbuf[vi(1, 1), 128, 128] = 0.11
                dbuf[vi(0, 1), 128, 128] = 0.01
                dbuf[vi(1, 0), 128, 128] = 0.10
                dbuf[vi(0, -1), 128, 128] = 0.02
                dbuf[vi(-1, 0), 128, 128] = 0.20
                dbuf[vi(1, -1), 128, 128] = 0.30
                dbuf[vi(-1, 1), 128, 128] = 0.40

                # Bottom right corner
                dbuf[vi(1, 1), 1, 128] = 0.50
                dbuf[vi(1, -1), 1, 128] = 0.51
                dbuf[vi(1, 0), 1, 128] = 0.52
            elif runner._spec.id == 1:
                dbuf[vi(1, 0), 127, 128] = 0.60
                dbuf[vi(1, 1), 127, 128] = 0.61
                dbuf[vi(1, -1), 127, 128] = 0.62
                dbuf[vi(1, 0), 128, 128] = 0.70
                dbuf[vi(1, -1), 128, 128] = 0.71

            runner._debug_set_dist(dbuf)
            runner._debug_set_dist(dbuf, False)

        RightSide = type("RightSide", (SimulationTest,), {"initial_conditions": ic})
        ctrl = LBSimulationController(RightSide, GeometryTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, "test_out")
        b0 = np.load(io.dists_filename(output, 1, 0, 1))["arr_0"]
        b1 = np.load(io.dists_filename(output, 1, 1, 1))["arr_0"]
        b2 = np.load(io.dists_filename(output, 1, 2, 1))["arr_0"]
        b3 = np.load(io.dists_filename(output, 1, 3, 1))["arr_0"]
        ae = np.testing.assert_equal

        ae(b3[vi(1, 1), 1, 1], np.float32(0.11))
        ae(b0[vi(-1, 0), 128, 127], np.float32(0.20))
        ae(b0[vi(0, -1), 127, 128], np.float32(0.02))
        ae(b2[vi(1, 0), 128, 1], np.float32(0.10))
        ae(b1[vi(0, 1), 1, 128], np.float32(0.01))
        ae(b2[vi(1, -1), 127, 1], np.float32(0.30))
        ae(b1[vi(-1, 1), 1, 127], np.float32(0.40))
        ae(b2[vi(1, 1), 2, 1], np.float32(0.50))
        ae(b2[vi(1, 0), 1, 1], np.float32(0.52))

        ae(b3[vi(1, 0), 127, 1], np.float32(0.60))
        ae(b3[vi(1, 0), 128, 1], np.float32(0.70))
        ae(b3[vi(1, 1), 128, 1], np.float32(0.61))
        ae(b3[vi(1, -1), 127, 1], np.float32(0.71))
        ae(b3[vi(1, -1), 126, 1], np.float32(0.62))
예제 #9
0
    def test_vert_spread(self):
        global tmpdir
        VertTest = type('VertTest', (SimulationTest,), {'axis': 1})
        ctrl = LBSimulationController(VertTest, TwoBlocksYConnGeoTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']
        self._verify(b0, b1, VertTest)
예제 #10
0
    def test_depth_spread(self):
        global tmpdir
        DepthTest = type('DepthTest', (SimulationTest,), {'axis': 2})
        ctrl = LBSimulationController(DepthTest, TwoBlocksZConnGeoTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))
        b1 = np.load(io.dists_filename(output, 1, 1, 1))
        self._verify(b0, b1, DepthTest)
예제 #11
0
    def test_depth_spread(self):
        global tmpdir
        DepthTest = type('DepthTest', (SimulationTest, ), {'axis': 2})
        ctrl = LBSimulationController(DepthTest, TwoBlocksZConnGeoTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']
        self._verify(b0, b1, DepthTest)
예제 #12
0
    def test_2subdomains(self):
        ctrl = LBSimulationController(AASimulationTest2,
                                      EqualSubdomainsGeometry3D)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 2))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 2))['arr_0']
        ae = np.testing.assert_equal

        ae(b0[vi(0, 1, -1), 40, 39, 10], np.float32(0.11))
예제 #13
0
    def test_2subdomains(self):
        ctrl = LBSimulationController(AASimulationTest2,
                                      EqualSubdomainsGeometry3D)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 2))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 2))['arr_0']
        ae = np.testing.assert_equal

        ae(b0[vi(0, 1, -1), 40, 39, 10], np.float32(0.11))
예제 #14
0
    def test_spread(self):
        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0

            if runner._spec.id == 1:
                dbuf[vi(1, 0), 1, 128] = 0.11
                dbuf[vi(1, 1), 1, 128] = 0.12
                dbuf[vi(1, -1), 1, 128] = 0.13

                # At the top
                dbuf[vi(1, 0), 256, 128] = 0.31
                dbuf[vi(1, 1), 256, 128] = 0.32
                dbuf[vi(1, -1), 256, 128] = 0.33

            elif runner._spec.id == 0:
                dbuf[vi(-1, 0), 256, 1] = 0.21
                dbuf[vi(-1, 1), 256, 1] = 0.22
                dbuf[vi(-1, -1), 256, 1] = 0.23

                # At the bottom
                dbuf[vi(-1, 0), 1, 1] = 0.41
                dbuf[vi(-1, 1), 1, 1] = 0.42
                dbuf[vi(-1, -1), 1, 1] = 0.43

            runner._debug_set_dist(dbuf)
            runner._debug_set_dist(dbuf, False)

        HorizTest = type("HorizTest", (SimulationTest,), {"initial_conditions": ic})
        ctrl = LBSimulationController(HorizTest, DoubleBlockGeometryTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, "test_out")
        b0 = np.load(io.dists_filename(output, 1, 0, 1))["arr_0"]
        b1 = np.load(io.dists_filename(output, 1, 1, 1))["arr_0"]
        ae = np.testing.assert_equal

        ae(b0[vi(1, 0), 1, 1], np.float32(0.11))
        ae(b0[vi(1, 1), 2, 1], np.float32(0.12))
        ae(b0[vi(1, -1), 256, 1], np.float32(0.13))

        ae(b0[vi(1, 0), 256, 1], np.float32(0.31))
        ae(b0[vi(1, 1), 1, 1], np.float32(0.32))
        ae(b0[vi(1, -1), 255, 1], np.float32(0.33))

        ae(b1[vi(-1, 0), 256, 128], np.float32(0.21))
        ae(b1[vi(-1, 1), 1, 128], np.float32(0.22))
        ae(b1[vi(-1, -1), 255, 128], np.float32(0.23))

        ae(b1[vi(-1, 0), 1, 128], np.float32(0.41))
        ae(b1[vi(-1, 1), 2, 128], np.float32(0.42))
        ae(b1[vi(-1, -1), 256, 128], np.float32(0.43))
예제 #15
0
    def test_4subdomains(self):
        ctrl = LBSimulationController(AASimulationTest, FourSubdomainsTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']
        b2 = np.load(io.dists_filename(output, 1, 2, 1))['arr_0']
        b3 = np.load(io.dists_filename(output, 1, 3, 1))['arr_0']
        ae = np.testing.assert_equal

        # No propagation in the first step, but the distributions are stored
        # in opposite slots.
        ae(b3[vi(0, -1, -1), 0, 0, 10], np.float32(0.11))
예제 #16
0
    def test_4subdomains(self):
        ctrl = LBSimulationController(AASimulationTest, FourSubdomainsTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))
        b1 = np.load(io.dists_filename(output, 1, 1, 1))
        b2 = np.load(io.dists_filename(output, 1, 2, 1))
        b3 = np.load(io.dists_filename(output, 1, 3, 1))
        ae = np.testing.assert_equal

        # No propagation in the first step, but the distributions are stored
        # in opposite slots.
        ae(b3[vi(0, -1, -1), 0, 0, 10], np.float32(0.11))
예제 #17
0
    def test_4corners(self):
        global tmpdir
        ctrl = LBSimulationController(SimulationTest, GeometryTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']
        b2 = np.load(io.dists_filename(output, 1, 2, 1))['arr_0']
        b3 = np.load(io.dists_filename(output, 1, 3, 1))['arr_0']

        np.testing.assert_equal(b0[vi(-1, -1), 128, 128], np.float32(0.44))
        np.testing.assert_equal(b1[vi(-1, 1), 1, 128], np.float32(0.33))
        np.testing.assert_equal(b2[vi(1, -1), 128, 1], np.float32(0.22))
        np.testing.assert_equal(b3[vi(1, 1), 1, 1], np.float32(0.11))
예제 #18
0
    def test_4corners(self):
        global tmpdir
        ctrl = LBSimulationController(SimulationTest, GeometryTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, "test_out")
        b0 = np.load(io.dists_filename(output, 1, 0, 1))["arr_0"]
        b1 = np.load(io.dists_filename(output, 1, 1, 1))["arr_0"]
        b2 = np.load(io.dists_filename(output, 1, 2, 1))["arr_0"]
        b3 = np.load(io.dists_filename(output, 1, 3, 1))["arr_0"]

        np.testing.assert_equal(b0[vi(-1, -1), 128, 128], np.float32(0.44))
        np.testing.assert_equal(b1[vi(-1, 1), 1, 128], np.float32(0.33))
        np.testing.assert_equal(b2[vi(1, -1), 128, 1], np.float32(0.22))
        np.testing.assert_equal(b3[vi(1, 1), 1, 1], np.float32(0.11))
예제 #19
0
    def test_3blocks(self):
        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0

            if runner._spec.id == 0:
                dbuf[vi(1, 1), 128, 128] = 0.11
                dbuf[vi(0, 1), 128, 128] = 0.12
                dbuf[vi(1, 0), 128, 128] = 0.13
                dbuf[vi(1, -1), 128, 128] = 0.14
                dbuf[vi(-1, 1), 128, 128] = 0.15
            elif runner._spec.id == 1:
                dbuf[vi(-1, -1), 1, 128] = 0.16
                dbuf[vi(0, -1), 1, 128] = 0.17
            elif runner._spec.id == 2:
                dbuf[vi(-1, -1), 129, 1] = 0.18
                dbuf[vi(-1, -1), 128, 1] = 0.19
                dbuf[vi(-1, 0), 128, 1] = 0.20

            runner._debug_set_dist(dbuf)

        SimTest = type('SimTest', (AASimulationTest,),
                {'initial_conditions': ic})
        ctrl = LBSimulationController(SimTest, ThreeBlocksGeometryTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']
        b2 = np.load(io.dists_filename(output, 1, 2, 1))['arr_0']
        ae = np.testing.assert_equal

        # No propagation in the first step, but the distributions are stored
        # in opposite slots.
        ae(b2[vi(-1, -1), 128, 0], np.float32(0.11))
        ae(b2[vi(-1, 0), 128, 0], np.float32(0.13))
        ae(b2[vi(-1, 1), 128, 0], np.float32(0.14))
        ae(b1[vi(1, -1), 0, 128], np.float32(0.15))
        ae(b1[vi(0, -1), 0, 128], np.float32(0.12))

        # From b1
        ae(b0[vi(1, 1), 129, 128], np.float32(0.16))
        ae(b0[vi(0, 1), 129, 128], np.float32(0.17))

        # From b2
        ae(b0[vi(1, 1), 128, 129], np.float32(0.19))
        ae(b0[vi(1, 1), 129, 129], np.float32(0.18))
        ae(b0[vi(1, 0), 128, 129], np.float32(0.20))
예제 #20
0
    def test_3blocks(self):
        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0

            if runner._spec.id == 0:
                dbuf[vi(1, 1), 128, 128] = 0.11
                dbuf[vi(0, 1), 128, 128] = 0.12
                dbuf[vi(1, 0), 128, 128] = 0.13
                dbuf[vi(1, -1), 128, 128] = 0.14
                dbuf[vi(-1, 1), 128, 128] = 0.15
            elif runner._spec.id == 1:
                dbuf[vi(-1, -1), 1, 128] = 0.16
                dbuf[vi(0, -1), 1, 128] = 0.17
            elif runner._spec.id == 2:
                dbuf[vi(-1, -1), 129, 1] = 0.18
                dbuf[vi(-1, -1), 128, 1] = 0.19
                dbuf[vi(-1, 0), 128, 1] = 0.20

            runner._debug_set_dist(dbuf)

        SimTest = type('SimTest', (AASimulationTest, ),
                       {'initial_conditions': ic})
        ctrl = LBSimulationController(SimTest, ThreeBlocksGeometryTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']
        b2 = np.load(io.dists_filename(output, 1, 2, 1))['arr_0']
        ae = np.testing.assert_equal

        # No propagation in the first step, but the distributions are stored
        # in opposite slots.
        ae(b2[vi(-1, -1), 128, 0], np.float32(0.11))
        ae(b2[vi(-1, 0), 128, 0], np.float32(0.13))
        ae(b2[vi(-1, 1), 128, 0], np.float32(0.14))
        ae(b1[vi(1, -1), 0, 128], np.float32(0.15))
        ae(b1[vi(0, -1), 0, 128], np.float32(0.12))

        # From b1
        ae(b0[vi(1, 1), 129, 128], np.float32(0.16))
        ae(b0[vi(0, 1), 129, 128], np.float32(0.17))

        # From b2
        ae(b0[vi(1, 1), 128, 129], np.float32(0.19))
        ae(b0[vi(1, 1), 129, 129], np.float32(0.18))
        ae(b0[vi(1, 0), 128, 129], np.float32(0.20))
예제 #21
0
    def test_corner_global_periodic(self):
        global tmpdir, periodic_y
        periodic_y = True

        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0
            dbuf[vi(1, 1), 256, 256] = 0.11
            dbuf[vi(-1, -1), 1, 1] = 0.12
            dbuf[vi(1, -1), 1, 256] = 0.13
            dbuf[vi(-1, 1), 256, 1] = 0.14
            runner._debug_set_dist(dbuf)
            runner._debug_set_dist(dbuf, False)

        CornerTest = type('CornerTest', (SimulationTest, ),
                          {'initial_conditions': ic})
        ctrl = LBSimulationController(CornerTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        ae = np.testing.assert_equal

        ae(b0[vi(1, 1), 1, 1], np.float32(0.11))
        ae(b0[vi(-1, -1), 256, 256], np.float32(0.12))
        ae(b0[vi(1, -1), 256, 1], np.float32(0.13))
        ae(b0[vi(-1, 1), 1, 256], np.float32(0.14))
예제 #22
0
    def test_x_face_propagation(self):
        global tmpdir
        ctrl = LBSimulationController(SingleBlockPeriodicSimulationTest,
                SingleBlockGeoTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'per_single_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))
        ae = np.testing.assert_equal

        ae(b0[vi(-1, 0, 0), 32, 32, 64], np.float32(0.11))
        ae(b0[vi(-1, 1, 0), 32, 33, 64], np.float32(0.12))
        ae(b0[vi(-1, -1, 0), 32, 31, 64], np.float32(0.13))
        ae(b0[vi(-1, 0, 1), 33, 32, 64], np.float32(0.14))
        ae(b0[vi(-1, 0, -1), 31, 32, 64], np.float32(0.15))

        ae(b0[vi(0, 1, 0), 33, 1, 31], np.float32(0.41))
        ae(b0[vi(0, 0, 1), 1, 35, 31], np.float32(0.42))

        ae(b0[vi(-1, 0, 0), 1, 1, 64], np.float32(0.21))
        ae(b0[vi(0, -1, 0), 1, 62, 1], np.float32(0.22))
        ae(b0[vi(0, 0, -1), 66, 1, 1], np.float32(0.23))

        ae(b0[vi(-1, -1, 0), 1, 62, 64], np.float32(0.24))
        ae(b0[vi(0, -1, -1), 66, 62, 1], np.float32(0.25))
        ae(b0[vi(-1, 0, -1), 66, 1, 64], np.float32(0.26))

        ae(b0[vi(-1, 0, 0), 32, 1, 64], np.float32(0.31))
        ae(b0[vi(-1, -1, 0), 32, 1, 64], np.float32(0.32))
예제 #23
0
    def test_x_face_propagation(self):
        global tmpdir
        ctrl = LBSimulationController(SingleBlockPeriodicSimulationTest,
                                      SingleBlockGeoTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'per_single_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        ae = np.testing.assert_equal

        ae(b0[vi(-1, 0, 0), 32, 32, 64], np.float32(0.11))
        ae(b0[vi(-1, 1, 0), 32, 33, 64], np.float32(0.12))
        ae(b0[vi(-1, -1, 0), 32, 31, 64], np.float32(0.13))
        ae(b0[vi(-1, 0, 1), 33, 32, 64], np.float32(0.14))
        ae(b0[vi(-1, 0, -1), 31, 32, 64], np.float32(0.15))

        ae(b0[vi(0, 1, 0), 33, 1, 31], np.float32(0.41))
        ae(b0[vi(0, 0, 1), 1, 35, 31], np.float32(0.42))

        ae(b0[vi(-1, 0, 0), 1, 1, 64], np.float32(0.21))
        ae(b0[vi(0, -1, 0), 1, 62, 1], np.float32(0.22))
        ae(b0[vi(0, 0, -1), 66, 1, 1], np.float32(0.23))

        ae(b0[vi(-1, -1, 0), 1, 62, 64], np.float32(0.24))
        ae(b0[vi(0, -1, -1), 66, 62, 1], np.float32(0.25))
        ae(b0[vi(-1, 0, -1), 66, 1, 64], np.float32(0.26))

        ae(b0[vi(-1, 0, 0), 32, 1, 64], np.float32(0.31))
        ae(b0[vi(-1, -1, 0), 32, 1, 64], np.float32(0.32))
예제 #24
0
    def test_corner_global_periodic(self):
        global tmpdir, periodic_y
        periodic_y = True

        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0
            dbuf[vi(1, 1), 256, 256] = 0.11
            dbuf[vi(-1, -1), 1, 1] = 0.12
            dbuf[vi(1, -1), 1, 256] = 0.13
            dbuf[vi(-1, 1), 256, 1] = 0.14
            runner._debug_set_dist(dbuf)
            runner._debug_set_dist(dbuf, False)

        CornerTest = type("CornerTest", (SimulationTest,), {"initial_conditions": ic})
        ctrl = LBSimulationController(CornerTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, "test_out")
        b0 = np.load(io.dists_filename(output, 1, 0, 1))["arr_0"]
        ae = np.testing.assert_equal

        ae(b0[vi(1, 1), 1, 1], np.float32(0.11))
        ae(b0[vi(-1, -1), 256, 256], np.float32(0.12))
        ae(b0[vi(1, -1), 256, 1], np.float32(0.13))
        ae(b0[vi(-1, 1), 1, 256], np.float32(0.14))
예제 #25
0
    def test_x_conn(self):
        ctrl = LBSimulationController(PartialPeriodicSimulationTest,
                TwoBlocksXConnGeoTest).run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'per_horiz_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))
        b1 = np.load(io.dists_filename(output, 1, 1, 1))

        ae = np.testing.assert_equal
        ae(b1[vi(1, 1, 0), 32, 1, 1], np.float32(0.11))
        ae(b1[vi(1, 0, 1), 1, 32, 1], np.float32(0.12))
        ae(b1[vi(1, -1, 0), 32, 64, 1], np.float32(0.13))
        ae(b1[vi(1, 0, -1), 66, 32, 1], np.float32(0.14))

        ae(b0[vi(-1, 1, 0), 20, 1, 64], np.float32(0.21))
        ae(b0[vi(-1, 0, 1), 1, 20, 64], np.float32(0.22))
        ae(b0[vi(-1, -1, 0), 20, 64, 64], np.float32(0.23))
        ae(b0[vi(-1, 0, -1), 66, 20, 64], np.float32(0.24))
예제 #26
0
    def test_propagation(self):
        global tmpdir
        ctrl = LBSimulationController(ThreeBlocksSimulationTest, ThreeBlocksGeometryTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, "test_out")
        b0 = np.load(io.dists_filename(output, 1, 0, 1))["arr_0"]
        b1 = np.load(io.dists_filename(output, 1, 1, 1))["arr_0"]
        b2 = np.load(io.dists_filename(output, 1, 2, 1))["arr_0"]

        ae = np.testing.assert_equal

        ae(b0[vi(0, -1), 128, 64], np.float32(0.21))
        ae(b1[vi(0, 1), 1, 64], np.float32(0.13))
        ae(b2[vi(1, 0), 64, 1], np.float32(0.12))
        ae(b2[vi(1, 0), 64 + 128, 1], np.float32(0.23))
        ae(b0[vi(-1, 0), 64, 128], np.float32(0.31))
        ae(b2[vi(1, 1), 129, 1], np.float32(0.11))
        ae(b2[vi(1, -1), 128, 1], np.float32(0.22))
예제 #27
0
    def test_propagation(self):
        global tmpdir
        ctrl = LBSimulationController(ThreeBlocksSimulationTest,
                                      ThreeBlocksGeometryTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']
        b2 = np.load(io.dists_filename(output, 1, 2, 1))['arr_0']

        ae = np.testing.assert_equal

        ae(b0[vi(0, -1), 128, 64], np.float32(0.21))
        ae(b1[vi(0, 1), 1, 64], np.float32(0.13))
        ae(b2[vi(1, 0), 64, 1], np.float32(0.12))
        ae(b2[vi(1, 0), 64 + 128, 1], np.float32(0.23))
        ae(b0[vi(-1, 0), 64, 128], np.float32(0.31))
        ae(b2[vi(1, 1), 129, 1], np.float32(0.11))
        ae(b2[vi(1, -1), 128, 1], np.float32(0.22))
예제 #28
0
    def test_horiz_global_periodic(self):
        global tmpdir

        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0

            dbuf[vi(1, 0), 128, 256] = 0.11
            dbuf[vi(1, 1), 128, 256] = 0.12
            dbuf[vi(1, -1), 128, 256] = 0.13

            # At the top
            dbuf[vi(1, 0), 256, 256] = 0.31
            dbuf[vi(1, 1), 256, 256] = 0.32
            dbuf[vi(1, -1), 256, 256] = 0.33

            dbuf[vi(-1, -1), 256, 256] = 0.66  # should not be overwritten
            dbuf[vi(-1, 0), 128, 1] = 0.21
            dbuf[vi(-1, 1), 128, 1] = 0.22
            dbuf[vi(-1, -1), 128, 1] = 0.23

            # At the bottom
            dbuf[vi(-1, 0), 1, 1] = 0.41
            dbuf[vi(-1, 1), 1, 1] = 0.42
            dbuf[vi(-1, -1), 1, 1] = 0.43

            dbuf[vi(1, 1), 1, 1] = 0.77  # should not be overwritten

            runner._debug_set_dist(dbuf)
            runner._debug_set_dist(dbuf, False)

        HorizTest = type("HorizTest", (SimulationTest,), {"initial_conditions": ic})
        ctrl = LBSimulationController(HorizTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, "test_out")
        b0 = np.load(io.dists_filename(output, 1, 0, 1))["arr_0"]
        ae = np.testing.assert_equal

        ae(b0[vi(1, 0), 128, 1], np.float32(0.11))
        ae(b0[vi(1, 1), 129, 1], np.float32(0.12))
        ae(b0[vi(1, -1), 127, 1], np.float32(0.13))
        ae(b0[vi(1, 0), 256, 1], np.float32(0.31))
        ae(b0[vi(1, -1), 255, 1], np.float32(0.33))

        ae(b0[vi(-1, 0), 128, 256], np.float32(0.21))
        ae(b0[vi(-1, 1), 129, 256], np.float32(0.22))
        ae(b0[vi(-1, -1), 127, 256], np.float32(0.23))
        ae(b0[vi(-1, 0), 1, 256], np.float32(0.41))
        ae(b0[vi(-1, 1), 2, 256], np.float32(0.42))

        ae(b0[vi(1, 1), 1, 1], np.float32(0.77))
        ae(b0[vi(-1, -1), 256, 256], np.float32(0.66))
예제 #29
0
    def test_vert_spread(self):
        ctrl = LBSimulationController(MisalignedVertTest,
                                      TwoBlocksShiftedYConnGeoTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']

        ae = np.testing.assert_equal
        ae(b1[vi(0, 1, 0), 5, 1, 20], np.float32(0.11))
        ae(b1[vi(1, 1, 0), 5, 1, 21], np.float32(0.12))
        ae(b1[vi(-1, 1, 0), 5, 1, 19], np.float32(0.13))
        ae(b1[vi(0, 1, 1), 6, 1, 20], np.float32(0.14))
        ae(b1[vi(0, 1, -1), 4, 1, 20], np.float32(0.15))

        ae(b0[vi(0, -1, 0), 5, 30, 30], np.float32(0.21))
        ae(b0[vi(1, -1, 0), 5, 30, 31], np.float32(0.22))
        ae(b0[vi(-1, -1, 0), 5, 30, 29], np.float32(0.23))
        ae(b0[vi(0, -1, 1), 6, 30, 30], np.float32(0.24))
        ae(b0[vi(0, -1, -1), 4, 30, 30], np.float32(0.25))
예제 #30
0
    def test_horiz_spread(self):
        ctrl = LBSimulationController(MisalignedHorizTest,
                                      TwoBlocksShiftedXConnGeoTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']

        ae = np.testing.assert_equal
        ae(b1[vi(1, 0, 0), 8, 5, 1], np.float32(0.11))
        ae(b1[vi(1, 1, 0), 8, 6, 1], np.float32(0.12))
        ae(b1[vi(1, -1, 0), 8, 4, 1], np.float32(0.13))
        ae(b1[vi(1, 0, 1), 9, 5, 1], np.float32(0.14))
        ae(b1[vi(1, 0, -1), 7, 5, 1], np.float32(0.15))

        ae(b0[vi(-1, 0, 0), 17, 9, 20], np.float32(0.21))
        ae(b0[vi(-1, 1, 0), 17, 10, 20], np.float32(0.22))
        ae(b0[vi(-1, -1, 0), 17, 8, 20], np.float32(0.23))
        ae(b0[vi(-1, 0, 1), 18, 9, 20], np.float32(0.24))
        ae(b0[vi(-1, 0, -1), 16, 9, 20], np.float32(0.25))
예제 #31
0
    def test_vert_spread(self):
        ctrl = LBSimulationController(MisalignedVertTest,
                TwoBlocksShiftedYConnGeoTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))
        b1 = np.load(io.dists_filename(output, 1, 1, 1))

        ae = np.testing.assert_equal
        ae(b1[vi(0, 1, 0),  5, 1, 20], np.float32(0.11))
        ae(b1[vi(1, 1, 0),  5, 1, 21], np.float32(0.12))
        ae(b1[vi(-1, 1, 0), 5, 1, 19], np.float32(0.13))
        ae(b1[vi(0, 1, 1),  6, 1, 20], np.float32(0.14))
        ae(b1[vi(0, 1, -1), 4, 1, 20], np.float32(0.15))

        ae(b0[vi(0, -1, 0),  5, 30, 30], np.float32(0.21))
        ae(b0[vi(1, -1, 0),  5, 30, 31], np.float32(0.22))
        ae(b0[vi(-1, -1, 0), 5, 30, 29], np.float32(0.23))
        ae(b0[vi(0, -1, 1),  6, 30, 30], np.float32(0.24))
        ae(b0[vi(0, -1, -1), 4, 30, 30], np.float32(0.25))
예제 #32
0
    def test_horiz_spread(self):
        ctrl = LBSimulationController(MisalignedHorizTest,
                TwoBlocksShiftedXConnGeoTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))
        b1 = np.load(io.dists_filename(output, 1, 1, 1))

        ae = np.testing.assert_equal
        ae(b1[vi(1, 0, 0),  8, 5, 1], np.float32(0.11))
        ae(b1[vi(1, 1, 0),  8, 6, 1], np.float32(0.12))
        ae(b1[vi(1, -1, 0), 8, 4, 1], np.float32(0.13))
        ae(b1[vi(1, 0, 1),  9, 5, 1], np.float32(0.14))
        ae(b1[vi(1, 0, -1), 7, 5, 1], np.float32(0.15))

        ae(b0[vi(-1, 0, 0),  17, 9, 20], np.float32(0.21))
        ae(b0[vi(-1, 1, 0),  17, 10, 20], np.float32(0.22))
        ae(b0[vi(-1, -1, 0), 17, 8, 20], np.float32(0.23))
        ae(b0[vi(-1, 0, 1),  18, 9, 20], np.float32(0.24))
        ae(b0[vi(-1, 0, -1), 16, 9, 20], np.float32(0.25))
예제 #33
0
    def test_horiz_spread(self):
        """Two blocks connected along the X axis, with Y PBC enabled.

        This test verifies distribution streaming from the corner nodes
        on the surface connecting the two blocks."""
        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0

            if runner._spec.id == 1:
                # At the top
                dbuf[vi(-1, 0), 256, 1] = 0.31
                dbuf[vi(-1, 1), 256, 1] = 0.32
                dbuf[vi(-1, -1), 256, 1] = 0.33
            elif runner._spec.id == 0:
                # At the bottom
                dbuf[vi(1, 0), 1, 128] = 0.41
                dbuf[vi(1, 1), 1, 128] = 0.42
                dbuf[vi(1, -1), 1, 128] = 0.43

            runner._debug_set_dist(dbuf)
            runner._debug_set_dist(dbuf, False)

        HorizTest = type('HorizTest', (SimulationTest, ),
                         {'initial_conditions': ic})
        ctrl = LBSimulationController(HorizTest, DoubleBlockGeometryTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'test_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']
        ae = np.testing.assert_equal

        ae(b0[vi(-1, 0), 256, 128], np.float32(0.31))
        ae(b0[vi(-1, -1), 255, 128], np.float32(0.33))
        ae(b0[vi(-1, 1), 1, 128], np.float32(0.32))

        ae(b1[vi(1, 0), 1, 1], np.float32(0.41))
        ae(b1[vi(1, 1), 2, 1], np.float32(0.42))
        ae(b1[vi(1, -1), 256, 1], np.float32(0.43))
예제 #34
0
    def test_horiz_spread(self):
        """Two blocks connected along the X axis, with Y PBC enabled.

        This test verifies distribution streaming from the corner nodes
        on the surface connecting the two blocks."""

        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0

            if runner._spec.id == 1:
                # At the top
                dbuf[vi(-1, 0), 256, 1] = 0.31
                dbuf[vi(-1, 1), 256, 1] = 0.32
                dbuf[vi(-1, -1), 256, 1] = 0.33
            elif runner._spec.id == 0:
                # At the bottom
                dbuf[vi(1, 0), 1, 128] = 0.41
                dbuf[vi(1, 1), 1, 128] = 0.42
                dbuf[vi(1, -1), 1, 128] = 0.43

            runner._debug_set_dist(dbuf)
            runner._debug_set_dist(dbuf, False)

        HorizTest = type("HorizTest", (SimulationTest,), {"initial_conditions": ic})
        ctrl = LBSimulationController(HorizTest, DoubleBlockGeometryTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, "test_out")
        b0 = np.load(io.dists_filename(output, 1, 0, 1))["arr_0"]
        b1 = np.load(io.dists_filename(output, 1, 1, 1))["arr_0"]
        ae = np.testing.assert_equal

        ae(b0[vi(-1, 0), 256, 128], np.float32(0.31))
        ae(b0[vi(-1, -1), 255, 128], np.float32(0.33))
        ae(b0[vi(-1, 1), 1, 128], np.float32(0.32))

        ae(b1[vi(1, 0), 1, 1], np.float32(0.41))
        ae(b1[vi(1, 1), 2, 1], np.float32(0.42))
        ae(b1[vi(1, -1), 256, 1], np.float32(0.43))
예제 #35
0
    def test_horiz_spread(self):
        ctrl = LBSimulationController(PeriodicSimulationTest, TwoBlocksXConnGeoTest)
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, 'per_horiz_out')
        b0 = np.load(io.dists_filename(output, 1, 0, 1))['arr_0']
        b1 = np.load(io.dists_filename(output, 1, 1, 1))['arr_0']

        ae = np.testing.assert_equal

        ae(b1[vi(-1, 0, 0), 32, 32, 64], np.float32(0.11))
        ae(b1[vi(-1, 1, 0), 32, 33, 64], np.float32(0.12))
        ae(b1[vi(-1, -1, 0), 32, 31, 64], np.float32(0.13))
        ae(b1[vi(-1, 0, 1), 33, 32, 64], np.float32(0.14))
        ae(b1[vi(-1, 0, -1), 31, 32, 64], np.float32(0.15))

        ae(b0[vi(1, 0, 0), 1, 1, 1], np.float32(0.21))
        ae(b0[vi(1, 1, 0), 1, 2, 1], np.float32(0.22))
        ae(b0[vi(1, 0, 1), 2, 1, 1], np.float32(0.23))

        ae(b0[vi(1, 0, 0), 1, 32, 1], np.float32(0.33))
        ae(b0[vi(1, 1, 0), 1, 33, 1], np.float32(0.34))
        ae(b0[vi(1,-1, 0), 1, 31, 1], np.float32(0.35))
        ae(b0[vi(1, 0, 1), 2, 32, 1], np.float32(0.36))
예제 #36
0
    def test_horiz_spread(self):
        def ic(self, runner):
            dbuf = runner._debug_get_dist()
            dbuf[:] = 0.0

            # In-warp location x = 20.
            dbuf[vi(1, 0), 30, 20] = 0.11
            dbuf[vi(1, 1), 30, 20] = 0.12
            dbuf[vi(1, -1), 30, 20] = 0.13

            # End of warp location x = 31.
            dbuf[vi(1, 0), 30, 31] = 0.14

            # Beginning of warp location x = 32.
            dbuf[vi(1, 0), 30, 32] = 0.16

            # End of block location x = 63.
            dbuf[vi(1, 0), 30, 63] = 0.15

            runner._debug_set_dist(dbuf)
            runner._debug_set_dist(dbuf, False)

        HorizTest = type("HorizTest", (SimulationTest,), {"initial_conditions": ic})
        ctrl = LBSimulationController(HorizTest, LBGeometry2D, {"block_size": 64})
        ctrl.run(ignore_cmdline=True)

        output = os.path.join(tmpdir, "test_out")
        b0 = np.load(io.dists_filename(output, 1, 0, 1))["arr_0"]
        ae = np.testing.assert_equal

        ae(b0[vi(1, 0), 30, 21], np.float32(0.11))
        ae(b0[vi(1, 1), 31, 21], np.float32(0.12))
        ae(b0[vi(1, -1), 29, 21], np.float32(0.13))
        ae(b0[vi(1, 0), 30, 32], np.float32(0.14))
        ae(b0[vi(1, 0), 30, 64], np.float32(0.15))
        ae(b0[vi(1, 0), 30, 33], np.float32(0.16))