How to use the dmsh.Difference function in dmsh

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_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
github nschloe / dmsh / test / test_difference.py View on Github external
def test_difference(show=False):
    geo = dmsh.Difference(dmsh.Circle([-0.5, 0.0], 1.0), dmsh.Circle([+0.5, 0.0], 1.0))
    X, cells = dmsh.generate(geo, 0.1, show=show)

    geo.plot()

    ref_norms = [2.9445555e02, 1.58563569e01, 1.499999914e00]
    assert_norm_equality(X.flatten(), ref_norms, 1.0e-7)
    return X, cells
github nschloe / dmsh / test / test_large.py View on Github external
def test_large():
    # https://github.com/nschloe/dmsh/issues/11
    r = dmsh.Rectangle(-10.0, +20.0, -10.0, +20.0)
    c = dmsh.Circle([0.0, 0.0], 3)
    geo = dmsh.Difference(r, c)

    X, cells = dmsh.generate(geo, 2.0, tol=1.0e-5, max_steps=10000)

    ref_norms = [4.6422985179724637e03, 2.4202897690682192e02, 2.0000000000000000e01]
    assert_norm_equality(X.flatten(), ref_norms, 1.0e-4)
github nschloe / dmsh / test / test_rectangle_hole.py View on Github external
def test_rectangle_hole():
    r = dmsh.Rectangle(60, 330, 380, 650)
    h = dmsh.Rectangle(143, 245, 440, 543)
    geo = dmsh.Difference(r, h)

    X, cells = dmsh.generate(geo, 20, tol=1.0e-5, show=False)

    ref_norms = [1.2901184909133780e05, 7.6243606395500592e03, 6.5000000000000000e02]
    assert_norm_equality(X.flatten(), ref_norms, 1.0e-10)
github nschloe / dmsh / test / test_pacman.py View on Github external
def test_pacman(show=False):
    geo = dmsh.Difference(
        dmsh.Circle([0.0, 0.0], 1.0),
        dmsh.Polygon([[0.0, 0.0], [1.5, 0.4], [1.5, -0.4]]),
    )
    X, cells = dmsh.generate(geo, 0.1, show=show, tol=1.0e-10)

    ref_norms = [3.0385105041432689e02, 1.3644964912810719e01, 1.0]
    assert_norm_equality(X.flatten(), ref_norms, 1.0e-10)
    return X, cells