Ejemplo n.º 1
0
def test_adaptive_splitting_3d_3():
    # adaptively refine one face of a cube, check that the mesh parameter h
    # is approximately linear w.r.t to distance from the face
    m = MeshTet.init_tensor(np.linspace(0, 1, 3), np.linspace(0, 1, 3),
                            np.linspace(0, 1, 3))

    for itr in range(15):
        m = m.refined(m.f2t[0, m.facets_satisfying(lambda x: x[0] == 0)])

    @LinearForm
    def hproj(v, w):
        return w.h * v

    basis = Basis(m, ElementTetP1())
    h = projection(hproj, basis)

    funh = basis.interpolator(h)

    xs = np.vstack((
        np.linspace(0, .5, 20),
        np.zeros(20) + .5,
        np.zeros(20) + .5,
    ))
    hs = funh(xs)

    assert np.max(np.abs(hs - xs[0])) < 0.063
Ejemplo n.º 2
0
def test_adaptive_splitting_3d_4():
    # check that the same mesh is reproduced by any future versions
    m = MeshTet.init_tensor(np.linspace(0, 1, 2), np.linspace(0, 1, 2),
                            np.linspace(0, 1, 2))

    m = m.refined(m.f2t[0, m.facets_satisfying(lambda x: x[0] == 0)])

    assert_array_equal(
        m.p,
        np.array([[0., 0., 1., 1., 0., 0., 1., 1., 0.5],
                  [0., 1., 0., 1., 0., 1., 0., 1., 0.5],
                  [0., 0., 0., 0., 1., 1., 1., 1., 0.5]]))

    assert_array_equal(
        m.t,
        np.array([[5, 3, 3, 5, 6, 6, 1, 4, 1, 2, 2, 4],
                  [0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7],
                  [1, 1, 2, 4, 2, 4, 5, 5, 3, 3, 6, 6],
                  [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]]))