コード例 #1
0
ファイル: subdomain.py プロジェクト: zherexli/sailfish
    def test_orientation(self):
        spec = SubdomainSpec2D((0, 0), self.lattice_size, envelope_size=1, id_=0)
        spec.runner = SubdomainRunner(self.sim, spec, output=None,
                                      backend=self.backend, quit_event=None)
        spec.runner._init_shape()
        sub = self._OrientationSubdomain2D(list(reversed(self.lattice_size)), spec, D2Q9)
        sub.allocate()
        sub.reset()

        nx, ny = self.lattice_size
        hx, hy = sub._get_mgrid()
        np.testing.assert_equal(sub._orientation[(hx == 0) & (hy > 0) &
                                                 (hy < ny - 1)],
                                D2Q9.vec_to_dir([1, 0]))
        np.testing.assert_equal(sub._orientation[(hx == nx - 1) & (hy > 0) &
                                                 (hy < ny - 1)],
                                D2Q9.vec_to_dir([-1, 0]))
        np.testing.assert_equal(sub._orientation[(hy == 0) & (hx > 0) &
                                                 (hx < nx - 1)],
                                D2Q9.vec_to_dir([0, 1]))
        np.testing.assert_equal(sub._orientation[(hy == ny - 1) & (hx > 0) &
                                                 (hx < nx - 1)],
                                D2Q9.vec_to_dir([0, -1]))

        # No orientation vector for corner nodes.
        np.testing.assert_equal(sub._orientation[0, 0], 0)
        np.testing.assert_equal(sub._orientation[0, nx - 1], 0)
        np.testing.assert_equal(sub._orientation[ny - 1, 0], 0)
        np.testing.assert_equal(sub._orientation[ny - 1, nx - 1], 0)
コード例 #2
0
ファイル: subdomain.py プロジェクト: brbr520/LBM-sailfish
    def test_orientation(self):
        spec = SubdomainSpec2D((0, 0), self.lattice_size, envelope_size=1, id_=0)
        spec.runner = SubdomainRunner(self.sim, spec, output=None,
                                      backend=self.backend, quit_event=None)
        spec.runner._init_shape()
        sub = OrientationSubdomain2D(list(reversed(self.lattice_size)), spec, D2Q9)
        sub.allocate()
        sub.reset()

        nx, ny = self.lattice_size
        hx, hy = sub._get_mgrid()
        np.testing.assert_equal(sub._orientation[(hx == 0) & (hy > 0) &
                                                 (hy < ny - 1)],
                                D2Q9.vec_to_dir([1, 0]))
        np.testing.assert_equal(sub._orientation[(hx == nx - 1) & (hy > 0) &
                                                 (hy < ny - 1)],
                                D2Q9.vec_to_dir([-1, 0]))
        np.testing.assert_equal(sub._orientation[(hy == 0) & (hx > 0) &
                                                 (hx < nx - 1)],
                                D2Q9.vec_to_dir([0, 1]))
        np.testing.assert_equal(sub._orientation[(hy == ny - 1) & (hx > 0) &
                                                 (hx < nx - 1)],
                                D2Q9.vec_to_dir([0, -1]))

        # No orientation vector for corner nodes.
        np.testing.assert_equal(sub._orientation[0, 0], 0)
        np.testing.assert_equal(sub._orientation[0, nx - 1], 0)
        np.testing.assert_equal(sub._orientation[ny - 1, 0], 0)
        np.testing.assert_equal(sub._orientation[ny - 1, nx - 1], 0)
コード例 #3
0
ファイル: 2d_propagation.py プロジェクト: hyln9/sailfish

class BlockTest(Subdomain2D):
    def boundary_conditions(self, hx, hy):
        pass

    def initial_conditions(self, sim, hx, hy):
        pass


mem_align = 32
block_size = 64
tmpdir = None
periodic_x = False
periodic_y = False
vi = lambda x, y: D2Q9.vec_idx([x, y])


class SimulationTest(LBFluidSim):
    subdomain = BlockTest

    @classmethod
    def modify_config(cls, config):
        config.relaxation_enabled = False
        config.periodic_x = periodic_x
        config.periodic_y = periodic_y

    @classmethod
    def update_defaults(cls, defaults):
        defaults.update(
            {
コード例 #4
0
import numpy as np
import unittest
from sailfish.config import LBConfig
from sailfish.controller import LBGeometryProcessor
from sailfish.geo import LBGeometry2D
from sailfish.subdomain import Subdomain2D, SubdomainSpec2D, SubdomainSpec3D
from sailfish.sym import D2Q9, D3Q15, D3Q19

vi = lambda x, y: D2Q9.vec_idx([x, y])
vi3 = lambda x, y, z: D3Q19.vec_idx([x, y, z])
vi15 = lambda x, y, z: D3Q15.vec_idx([x, y, z])


def _verify_partial_map(self, conn, expected_map):
    self.assertEqual(set(conn.dst_partial_map.keys()),
                     set(expected_map.keys()))
    for key, val in expected_map.iteritems():
        self.assertEqual(set([tuple(x) for x in val]),
                         set([tuple(x) for x in conn.dst_partial_map[key]]))


class TestBlock3D(unittest.TestCase):
    def test_subdomain_connection_y(self):
        base = SubdomainSpec3D((10, 10, 10), (10, 10, 12),
                               envelope_size=1,
                               id_=0)
        face_hi = SubdomainSpec3D.Y_HIGH

        # exact match
        b1 = SubdomainSpec3D((10, 20, 10), (10, 5, 12), envelope_size=1, id_=1)
        self.assertTrue(base.connect(b1, grid=D3Q19))