示例#1
0
#     Benjamin Graille <*****@*****.**>
#
# License: BSD 3 clause
"""
pylbm: tests for the geometry
"""

import pytest
import pylbm

ELEMENTS = [
    [2, pylbm.Circle([0, 0], 1)],
    [2, pylbm.Ellipse([0, 0], [1, 0], [0, 1])],
    [2, pylbm.Triangle([-1, -1], [0, 2], [2, 0])],
    [2, pylbm.Parallelogram([-1, -1], [0, 2], [2, 0])],
    [3, pylbm.CylinderCircle([0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1])],
    [3, pylbm.CylinderEllipse([0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1])],
    [3, pylbm.CylinderTriangle([0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1])],
    [3, pylbm.Parallelepiped([-1, -1, -1], [2, 0, 0], [0, 2, 0], [0, 0, 2])],
    [3, pylbm.Ellipsoid([0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1])],
    [3, pylbm.Sphere([0, 0, 0], 1)],
]


@pytest.fixture(params=ELEMENTS,
                ids=[elem[1].__class__.__name__ for elem in ELEMENTS])
def get_element(request):
    """get one element of the geometry"""
    return request.param

示例#2
0
"""
Example of a 3D geometry: the cube [0,1] x [0,1] x [0,1]
with a cylindrical hole
"""
import pylbm

# pylint: disable=invalid-name

v1 = [0, 1., 1.]
v2 = [0, -1.5, 1.5]
v3 = [1, -1, 0]
w1 = [.5, 0, 0]
w2 = [0, .5, 0]
w3 = [0, 0, 1.5]
dgeom = {
    'box': {
        'x': [-3, 3],
        'y': [-3, 3],
        'z': [-3, 3],
        'label': 9
    },
    'elements': [
        # pylbm.CylinderEllipse((0.5,0,0), v1, v2, v3, label=[1,0,0]),
        pylbm.CylinderTriangle((0.5, 0, 0), v1, v2, v3, label=0),
        pylbm.CylinderCircle((-1.5, -1.5, 0), w1, w2, w3, label=[1, 0, 0]),
    ],
}
geom = pylbm.Geometry(dgeom)
print(geom)
geom.visualize(viewlabel=True)