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-12) return X, cells
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.5457720168192884e+02, 3.1356929329612782e+01, 2.2111300269652543e+00] assert_norm_equality(X.flatten(), ref_norms, 1.0e-12) return X, cells
def test_rectangle(show=False): geo = dmsh.Rectangle(-1.0, +2.0, -1.0, +1.0) X, cells = dmsh.generate(geo, 0.1, show=show) ref_norms = [9.7542898028694776e02, 3.1710503119308623e01, 2.0] assert_norm_equality(X.flatten(), ref_norms, 1.0e-12) return X, cells
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.7525e+03, 5.5677441324948013e+01, 3.0] assert_norm_equality(X.flatten(), ref_norms, 1.0e-12) return
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, max_steps=100) ref_norms = [7.6829959173892494e03, 1.2466061090733828e02, 4.0000000000000000e00] assert_norm_equality(X.flatten(), ref_norms, 1.0e-7) return X, cells
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.2, show=show, tol=1.0e-3) ref_norms = [4.3338293115124242e02, 2.3621770543834902e01, 2.6213203435596428e00] assert_norm_equality(X.flatten(), ref_norms, 1.0e-12) return X, cells
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, max_steps=100) ref_norms = [ 1.7524999999999998e03, 5.5612899955332637e01, 3.0000000000000000e00 ] assert_norm_equality(X.flatten(), ref_norms, 1.0e-7)
def test(show=False): # should both work geo = [1.0, 1.0] + dmsh.Rectangle(-1.0, +2.0, -1.0, +1.0) geo = dmsh.Rectangle(-1.0, +2.0, -1.0, +1.0) + [1.0, 1.0] X, _ = dmsh.generate(geo, 0.1, show=show, max_steps=100) ref_norms = [1.7524999999999998e03, 5.5612899955332637e01, 3.0000000000000000e00] assert_norm_equality(X.flatten(), ref_norms, 1.0e-7)
def test_union(show=False): geo = dmsh.Union( [dmsh.Circle([-0.5, 0.0], 1.0), dmsh.Circle([+0.5, 0.0], 1.0)]) X, cells = dmsh.generate(geo, 0.15, show=show, tol=1.0e-10) ref_norms = [3.0088043884612756e+02, 1.5785099320497183e+01, 1.5] assert_norm_equality(X.flatten(), ref_norms, 1.0e-12) return X, cells
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
def test(show=False): geo = dmsh.Rotation(dmsh.Rectangle(-1.0, +2.0, -1.0, +1.0), 0.1 * np.pi) X, cells = dmsh.generate(geo, 0.1, show=show, tol=1.0e-10, max_steps=100) ref_norms = [ 9.4730152857365385e02, 3.1160562530932285e01, 2.2111300269652543e00 ] assert_norm_equality(X.flatten(), ref_norms, 1.0e-10) return X, cells
def test_circle(radius, ref_norms, show=False): geo = dmsh.Circle([0.0, 0.0], 1.0) X, cells = dmsh.generate(geo, radius, show=show) # make sure the origin is part of the mesh assert numpy.sum(numpy.einsum("ij,ij->i", X, X) < 1.0e-10) == 1 assert_norm_equality(X.flatten(), ref_norms, 1.0e-5) return X, cells
def test_circle(show=True): geo = dmsh.Circle([0.0, 0.0], 1.0) X, cells = dmsh.generate(geo, 0.1, show=show) ref_norms = [ 3.2795193920779542e02, 1.4263721858241993e01, 1.0000000000000000e00 ] assert_norm_equality(X.flatten(), ref_norms, 1.0e-12) return X, cells
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
def test_rectangle(show=False): geo = dmsh.Rectangle(-1.0, +2.0, -1.0, +1.0) X, cells = dmsh.generate(geo, 0.1, show=show, max_steps=100) ref_norms = [ 9.7172325705673779e02, 3.1615286239175994e01, 2.0000000000000000e00 ] assert_norm_equality(X.flatten(), ref_norms, 1.0e-10) return X, cells
def test(show=False): 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, max_steps=100) ref_norms = [ 1.9006907971528796e02, 1.5666202908904914e01, 2.6213203435596428e00 ] assert_norm_equality(X.flatten(), ref_norms, 1.0e-2) return X, cells
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
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) ref_norms = [ 2.9445552442961758e+02, 1.5856356670813716e+01, 1.4999999157880513e+00 ] assert_norm_equality(X.flatten(), ref_norms, 1.0e-9) return X, cells
def test_union(show=False): geo = dmsh.Union([ dmsh.Rectangle(-1.0, +0.5, -1.0, +0.5), dmsh.Rectangle(-0.5, +1.0, -0.5, +1.0) ]) X, cells = dmsh.generate(geo, 0.15, show=show, tol=1.0e-10) ref_norms = [1.7868961429998612e+02, 1.1117047580567053e+01, 1.0] assert_norm_equality(X.flatten(), ref_norms, 1.0e-12) return X, cells
def test_circle(radius, ref_norms, show=False): geo = dmsh.Circle([0.0, 0.0], 1.0) X, cells = dmsh.generate(geo, radius, show=show, max_steps=100) meshplex.MeshTri(X, cells).show() # make sure the origin is part of the mesh assert np.sum(np.einsum("ij,ij->i", X, X) < 1.0e-6) == 1 assert_norm_equality(X.flatten(), ref_norms, 1.0e-5) return X, cells
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
def test_union_rectangles(show=False): geo = dmsh.Rectangle(-1.0, +0.5, -1.0, +0.5) | dmsh.Rectangle( -0.5, +1.0, -0.5, +1.0) X, cells = dmsh.generate(geo, 0.15, show=show, tol=1.0e-5, max_steps=100) ref_norms = [ 1.8417796811774514e02, 1.1277323166424049e01, 1.0000000000000000e00 ] assert_norm_equality(X.flatten(), ref_norms, 1.0e-10) return X, cells
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) assert_norm_equality(X.flatten(), [1.2599887992309357e02, 2.2109217065599051e01, 5.0], 1.0e-12) return
def test_ellipse(show=False): geo = dmsh.Ellipse([0.0, 0.0], 2.0, 1.0) X, cells = dmsh.generate(geo, 0.2, show=show) geo.plot() ref_norms = [ 2.5108886251367960e02, 1.5652935519539316e01, 1.9890059982474428e00 ] assert_norm_equality(X.flatten(), ref_norms, 1.0e-12) return X, cells
def test_ellipse(show=False): geo = dmsh.Ellipse([0.0, 0.0], 2.0, 1.0) X, cells = dmsh.generate(geo, 0.2, show=show) geo.plot() ref_norms = [ 2.5108941453435716e02, 1.5652963447587933e01, 1.9890264390440919e00 ] assert_norm_equality(X.flatten(), ref_norms, 2.0e-2) return X, cells
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)
def test_rectangle_hole2(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, max_steps=100) ref_norms = [ 1.3990406144096474e02, 2.2917592510234346e01, 5.0000000000000000e00 ] assert_norm_equality(X.flatten(), ref_norms, 1.0e-2)
def test_intersection(show=False): geo = dmsh.Intersection( [dmsh.Circle([0.0, -0.5], 1.0), dmsh.Circle([0.0, +0.5], 1.0)]) X, cells = dmsh.generate(geo, 0.1, show=show, tol=1.0e-10) ref_norms = [ 8.6619344595913475e+01, 6.1599895121114274e+00, 8.6602540378466342e-01 ] assert_norm_equality(X.flatten(), ref_norms, 1.0e-12) return X, cells
def test_intersection(show=False): geo = dmsh.Circle([0.0, -0.5], 1.0) & dmsh.Circle([0.0, +0.5], 1.0) X, cells = dmsh.generate(geo, 0.1, show=show, tol=1.0e-10, max_steps=100) geo.plot() ref_norms = [ 8.6491736892894920e01, 6.1568624411912278e00, 8.6602540378466342e-01 ] assert_norm_equality(X.flatten(), ref_norms, 1.0e-10) return X, cells
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)