示例#1
0
    def test_elem_label(self, get_box, get_element):
        dim_element, element = get_element
        dim_box, box = get_box
        dico = {'box': box, 'elements': [element]}

        if dim_element != dim_box:
            with pytest.raises(ValueError):
                geom = pylbm.Geometry(dico)
        else:
            geom = pylbm.Geometry(dico)
            assert geom.list_of_labels() == pytest.approx([0, 3])
            assert geom.list_of_elements_labels() == pytest.approx([0])
示例#2
0
    def test_visualize(self, get_box, get_element):
        dim_element, element = get_element
        dim_box, box = get_box
        dico = {'box': box, 'elements': [element]}

        if dim_element == dim_box:
            geom = pylbm.Geometry(dico)
            views = geom.visualize(viewlabel=False)
            return views.fig
        else:
            pytest.skip("incompatible dimension")
示例#3
0
# Authors:
#     Loic Gouarin <*****@*****.**>
#     Benjamin Graille <*****@*****.**>
#
# License: BSD 3 clause
"""
Example of a 2D geometry: the square [0,1]x[0,1] with a circular hole
"""
import pylbm
d = {
    'box': {
        'x': [0, 1],
        'y': [0, 1],
        'label': 0
    },
    'elements': [pylbm.Circle((.5, .5), .125, label=1)],
}
g = pylbm.Geometry(d)
g.visualize(viewlabel=True)
示例#4
0
# Authors:
#     Loic Gouarin <*****@*****.**>
#     Benjamin Graille <*****@*****.**>
#
# License: BSD 3 clause
"""
Example of a 2D geometry: the square [0,1]x[0,1] with a circular hole
"""
import pylbm

# pylint: disable=invalid-name

dgeom = {
    'box': {
        'x': [0, 1],
        'y': [0, 1],
        'label': 0
    },
    'elements': [pylbm.Circle((0.5, 0.5), 0.125, label=1)],
}
geom = pylbm.Geometry(dgeom)
print(geom)
geom.visualize(viewlabel=True, alpha=0.5)
示例#5
0
# Authors:
#     Loic Gouarin <*****@*****.**>
#     Benjamin Graille <*****@*****.**>
#
# License: BSD 3 clause
"""
Example of a 3D geometry with a STL file
"""
import pylbm

# pylint: disable=invalid-name

a, b = -1.5, 1.5

sponge = pylbm.STLElement('Menger_sponge_sample.stl', label=1)
dico = {
    'box': {
        'x': [a, b],
        'y': [a, b],
        'z': [a, b],
        'label': 0
    },
    'elements': [sponge],
}
geom = pylbm.Geometry(dico)
print(geom)
geom.visualize(viewlabel=True, alpha=0.25)
示例#6
0
 def test_box_label(self, get_box):
     dim_box, box = get_box
     dico = {'box': box}
     geom = pylbm.Geometry(dico)
     assert geom.list_of_labels() == [3]