示例#1
0
"""
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


BOX = [
    (1, {
        'x': [-2, 2],
示例#2
0
# Authors:
#     Loic Gouarin <*****@*****.**>
#     Benjamin Graille <*****@*****.**>
#
# License: BSD 3 clause
"""
Example of a 3D geometry: the cube [0,1] x [0,1] x [0,1] with a cylindrical hole
"""
import pylbm
import numpy as np
a, b = 1. / np.sqrt(3), 1. / np.sqrt(2)
c = a * b
v0 = [a, a, a]
v1 = [b, -b, 0]
v2 = [c, c, -2 * c]
v0, v1, v2 = [1, 0, 0], [0, 1, 0], [0, 0, 1]
dico = {
    'box': {
        'x': [-3, 3],
        'y': [-3, 3],
        'z': [-3, 3],
        'label': 9
    },
    'elements': [pylbm.Parallelepiped((0, 0, 0), v0, v1, v2, label=0)],
}
geom = pylbm.Geometry(dico)
print(geom)
geom.visualize(viewlabel=True)