How to use dmsh - 10 common examples

To help you get started, we’ve selected a few dmsh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nschloe / dmsh / test / test_scaling.py View on Github external
def test(show=False):
    geo = dmsh.Scaling(dmsh.Rectangle(-1.0, +2.0, -1.0, +1.0), 2.0)
    X, cells = dmsh.generate(geo, 0.1, show=show, tol=1.0e-5)

    ref_norms = [7.7120645429243405e03, 1.2509238632152577e02, 4.0]
    assert_norm_equality(X.flatten(), ref_norms, 1.0e-10)
    return X, cells
github nschloe / dmsh / test / test_stretch.py View on Github external
def test(show=True):
    geo = dmsh.Stretch(dmsh.Rectangle(-1.0, +2.0, -1.0, +1.0), [1.0, 1.0])
    X, cells = dmsh.generate(geo, 0.3, show=show, tol=1.0e-3)

    ref_norms = [1.9391178579025609e02, 1.5890693098212086e01, 2.6213203435596428e00]
    assert_norm_equality(X.flatten(), ref_norms, 1.0e-2)
    return X, cells
github nschloe / dmsh / test / test_square_hole_refined.py View on Github external
def test(show=False):
    r = dmsh.Rectangle(-1.0, +1.0, -1.0, +1.0)
    c = dmsh.Circle([0.0, 0.0], 0.3)
    geo = dmsh.Difference(r, c)

    X, cells = dmsh.generate(
        geo, lambda pts: numpy.abs(c.dist(pts)) / 5 + 0.05, show=show, tol=1.0e-10
    )

    ref_norms = [2.48e02, 1.200e01, 1.0]
    assert_norm_equality(X.flatten(), ref_norms, 1.0e-3)
    return X, cells
github nschloe / dmsh / test / test_translation.py View on Github external
def test(show=False):
    geo = dmsh.Translation(dmsh.Rectangle(-1.0, +2.0, -1.0, +1.0), [1.0, 1.0])
    X, cells = dmsh.generate(geo, 0.1, show=show)

    ref_norms = [1.7525e03, 5.5677444529404333e01, 3.0]
    assert_norm_equality(X.flatten(), ref_norms, 1.0e-10)
github nschloe / dmsh / test / test_rotation.py View on Github external
def test(show=False):
    geo = dmsh.Rotation(dmsh.Rectangle(-1.0, +2.0, -1.0, +1.0), 0.1 * numpy.pi)
    X, cells = dmsh.generate(geo, 0.1, show=show, tol=1.0e-10)

    ref_norms = [9.5352192763033452e02, 3.1344318120314945e01, 2.2111300269652543e00]
    assert_norm_equality(X.flatten(), ref_norms, 1.0e-10)
    return X, cells
github nschloe / dmsh / test / test_refinement_point_line.py View on Github external
def test(show=False):
    geo = dmsh.Rectangle(0.0, 1.0, 0.0, 1.0)

    # p0 = dmsh.Path([[0.0, 0.0]])
    p1 = dmsh.Path([[0.4, 0.6], [0.6, 0.4]])

    def edge_size(x):
        return 0.03 + 0.1 * p1.dist(x)

    X, cells = dmsh.generate(geo, edge_size, show=show, tol=1.0e-10)

    ref_norms = [3.8844963377954718e02, 1.5689926870601147e01, 1.0000000000000000e00]
    assert_norm_equality(X.flatten(), ref_norms, 1.0e-3)
    return X, cells
github nschloe / dmsh / test / test_stretch.py View on Github external
def test(show=True):
    geo = dmsh.Stretch(dmsh.Rectangle(-1.0, +2.0, -1.0, +1.0), [1.0, 1.0])
    X, cells = dmsh.generate(geo, 0.3, show=show, tol=1.0e-3)

    ref_norms = [1.9391178579025609e02, 1.5890693098212086e01, 2.6213203435596428e00]
    assert_norm_equality(X.flatten(), ref_norms, 1.0e-2)
    return X, cells
github nschloe / dmsh / test / test_rotate.py View on Github external
def test(h0=0.9, show=True):
    geo = dmsh.Rotation(dmsh.Rectangle(-1.0, +2.0, -1.0, +1.0), 0.1 * numpy.pi)
    X, cells = dmsh.generate(geo, h0, show=show)

    assert numpy.array_equal(
        cells, [[6, 3, 4], [3, 5, 2], [5, 3, 6], [0, 3, 2], [3, 1, 4], [0, 1, 3]]
    ), cells

    assert_norm_equality(
        X.flatten(),
        [1.2993750765965753e+01, 4.0926763862103552e+00, 2.2111300269652543e+00],
        1.0e-12,
    )
    return
github nschloe / dmsh / test / test_square_hole.py View on Github external
def test(show=False):
    geo = dmsh.Difference(
        dmsh.Rectangle(0.0, 5.0, 0.0, 5.0),
        dmsh.Polygon([[1, 1], [4, 1], [4, 4], [1, 4]]),
    )
    X, cells = dmsh.generate(geo, 1.0, show=show, tol=1.0e-3)

    ref_norms = [1.4000000000000000e02, 2.3176757306973560e01, 5.0000000000000000e00]
    assert_norm_equality(X.flatten(), ref_norms, 1.0e-10)
github nschloe / dmsh / test / test_square_hole_refined.py View on Github external
def test(show=False):
    r = dmsh.Rectangle(-1.0, +1.0, -1.0, +1.0)
    c = dmsh.Circle([0.0, 0.0], 0.3)
    geo = dmsh.Difference(r, c)

    X, cells = dmsh.generate(
        geo, lambda pts: numpy.abs(c.dist(pts)) / 5 + 0.05, show=show, tol=1.0e-10
    )

    ref_norms = [2.48e02, 1.200e01, 1.0]
    assert_norm_equality(X.flatten(), ref_norms, 1.0e-3)
    return X, cells