예제 #1
0
    def test_domain_with_circle(self):
        fname = 'circle.npz'
        dom2d = copy.deepcopy(self.dom2d)
        dom2d['elements'] = [pyLBM.Circle([0.5, 1.], .5, label=10)]
        dom = pyLBM.Domain(dom2d)

        check_from_file(dom, fname)
예제 #2
0
    def test_domain_with_two_schemes_with_label(self):
        lleft, lright = 1, 2
        dom1d = copy.deepcopy(self.dom1d)
        dom1d['box'] = {'x': [0, 1], 'label': [lleft, lright]}
        dom1d['schemes'].append({'velocities': list(range(5))})

        dom = pyLBM.Domain(dom1d)

        desired_in_or_out = self.valin * np.ones(8)
        desired_in_or_out[[0, 1, -2, -1]] = self.valout
        assert (np.all(dom.in_or_out == desired_in_or_out))

        desired_distance = self.valin * np.ones((5, 8))
        desired_distance[[(1, 2), (-3, 2)]] = .5
        desired_distance[[(3, 4), (-3, 2)]] = .25
        desired_distance[[(3, 4), (-4, 3)]] = .75
        assert (np.all(dom.distance == desired_distance))

        desired_flag = self.valin * np.ones((5, 8), dtype=int)
        ind0_left = (2, ) + (4, ) * 2
        ind1_left = (2, ) * 2 + (3, )
        ind0_right = (1, ) + (3, ) * 2
        ind1_right = (-3, ) * 2 + (-4, )
        desired_flag[[ind0_left, ind1_left]] = lleft
        desired_flag[[ind0_right, ind1_right]] = lright
        assert (np.all(dom.flag == desired_flag))
예제 #3
0
    def test_domain_with_triangle(self):
        fname = 'triangle.npz'
        dom2d = copy.deepcopy(self.dom2d)
        dom2d['elements'] = [
            pyLBM.Triangle([0.23, 0.73], [0.5, 0], [0., .5], label=10)
        ]
        dom = pyLBM.Domain(dom2d)

        check_from_file(dom, fname)
예제 #4
0
 def test_with_given_geometry_and_stencil(self):
     geom = pyLBM.Geometry({'box': {'x': [0, 1]}})
     sten = pyLBM.Stencil({
         'dim': 1,
         'schemes': [{
             'velocities': list(range(3))
         }]
     })
     dom = pyLBM.Domain(geometry=geom, stencil=sten, space_step=.25)
예제 #5
0
    def test_domain_with_fluid_circle(self):
        fname = 'fluid_circle.npz'
        dom2d = copy.deepcopy(self.dom2d)
        dom2d['elements'] = [
            pyLBM.Parallelogram([0., 0.], [1., 0], [0., 2.], label=20),
            pyLBM.Circle([0.5, 1.], .5, label=10, isfluid=True)
        ]
        dom = pyLBM.Domain(dom2d)

        check_from_file(dom, fname)
예제 #6
0
    def test_simple_domain_with_labels(self):
        dom1d = copy.deepcopy(self.dom1d)
        dom1d['box'] = {'x': [0, 1], 'label': [0, 1]}
        dom = pyLBM.Domain(dom1d)

        assert (dom.shape_halo == [6])
        assert (dom.shape_in == [4])
        assert (dom.dx == .25)
        assert (np.all(dom.geom.bounds == [[0., 1.]]))
        assert (np.all(dom.x_halo == np.linspace(-.125, 1.125, 6)))
예제 #7
0
    def test_simple_domain_with_labels(self):
        dom2d = copy.deepcopy(self.dom2d)
        dom2d['box']['label'] = [0, 1, 2, 0]
        dom = pyLBM.Domain(dom2d)

        # assert(dom.Ng == [4, 8])
        # assert(dom.N == [4, 8])
        assert (dom.dx == .25)
        #assert(np.all(dom.bounds == [[0., 1.], [0., 2.]]))
        assert (np.all(dom.x_halo == [np.linspace(-.125, 1.125, 6)]))
        assert (np.all(dom.y_halo == [np.linspace(-.125, 2.125, 10)]))
예제 #8
0
    def test_domain_with_one_scheme(self):
        dom = pyLBM.Domain(self.dom1d)

        desired_in_or_out = self.valin * np.ones(6)
        desired_in_or_out[[0, -1]] = self.valout
        assert (np.all(dom.in_or_out == desired_in_or_out))

        desired_distance = self.valin * np.ones((3, 6))
        desired_distance[[(1, 2), (-2, 1)]] = .5
        print(dom.distance)
        assert (np.all(dom.distance == desired_distance))

        desired_flag = self.valin * np.ones((3, 6), dtype=int)
        desired_flag[[(1, 2), (-2, 1)]] = 0
        assert (np.all(dom.flag == desired_flag))
예제 #9
0
    def test_domain_with_two_schemes_without_label(self):
        dom1d = copy.deepcopy(self.dom1d)
        dom1d['schemes'].append({'velocities': list(range(5))})

        dom = pyLBM.Domain(dom1d)

        desired_in_or_out = self.valin * np.ones(8)
        desired_in_or_out[[0, 1, -2, -1]] = self.valout
        assert (np.all(dom.in_or_out == desired_in_or_out))

        desired_distance = self.valin * np.ones((5, 8))
        desired_distance[[(1, 2), (-3, 2)]] = .5
        desired_distance[[(3, 4), (-3, 2)]] = .25
        desired_distance[[(3, 4), (-4, 3)]] = .75
        assert (np.all(dom.distance == desired_distance))

        desired_flag = self.valin * np.ones((5, 8), dtype=int)
        ind0 = (1, 2) + (3, 4) * 2
        ind1 = (-3, 2) * 2 + (-4, 3)
        desired_flag[[ind0, ind1]] = 0
        assert (np.all(dom.flag == desired_flag))
예제 #10
0
# Authors:
#     Loic Gouarin <*****@*****.**>
#     Benjamin Graille <*****@*****.**>
#
# License: BSD 3 clause

"""
Example of the cube in 3D with a D3Q19
"""
from six.moves import range
import pyLBM
dico = {
    'box':{'x': [0, 2], 'y': [0, 2], 'z':[0, 2], 'label':0},
    'space_step':.5,
    'schemes':[{'velocities':list(range(19))}]
}
dom = pyLBM.Domain(dico)
dom.visualize()
dom.visualize(view_distance=True)
예제 #11
0
    def test_domain_with_one_scheme(self):
        fname = 'simple_domain.npz'
        dom = pyLBM.Domain(self.dom2d)

        check_from_file(dom, fname)