Example #1
0
    def runTest(self):

        m = MeshTri()
        e = ElementTriArgyris()
        basis = InteriorBasis(m, e)
        all_dofs = basis.get_dofs()

        self.assertEqual(len(all_dofs.keep('u').nodal), 1)
        self.assertTrue('u' in all_dofs.keep('u').nodal)

        self.assertEqual(len(all_dofs.keep('u_n').facet), 1)
        self.assertEqual(len(all_dofs.drop('u').facet), 1)

        all_dofs = basis.dofs.get_facet_dofs(m.facets_satisfying(lambda x: 1))

        self.assertEqual(len(all_dofs.keep('u_n').facet), 1)
        self.assertEqual(len(all_dofs.drop('u').facet), 1)
Example #2
0
    def runTest(self):

        m = MeshTri()
        e = ElementTriArgyris()
        basis = InteriorBasis(m, e)
        all_dofs = basis.get_dofs()

        assert_allclose(
            all_dofs.keep(['u', 'u_n']).keep('u'), all_dofs.keep('u'))

        assert_allclose(
            all_dofs.drop(['u_x', 'u_y', 'u_xx', 'u_xy', 'u_yy', 'u_n']),
            all_dofs.keep('u'))

        assert_allclose(all_dofs, all_dofs.drop('does_not_exist'))

        assert_allclose(np.empty((0, ), dtype=np.int64),
                        all_dofs.keep('does_not_exist'))
Example #3
0
    case = (MeshHex(), ElementHexS2())
    intorder = 3
    test_integrate_volume = False


class NormalVectorTestHex2(NormalVectorTestTri):

    case = (MeshHex(), ElementHex2())
    intorder = 3
    test_integrate_volume = False


@pytest.mark.parametrize("mtype,e,mtype2", [
    (MeshTri, ElementTriP1(), None),
    (MeshTri, ElementTriArgyris(), None),
    (MeshHex, ElementHex1(), None),
    (MeshQuad, ElementQuad1(), None),
    (MeshQuad, ElementQuad2(), None),
    (MeshQuad, ElementQuad2(), MeshQuad2),
    (MeshTri, ElementTriP1(), MeshTri2),
    (MeshTet, ElementTetP1(), MeshTet2),
    (MeshHex, ElementHex1(), MeshHex2),
])
def test_evaluate_functional(mtype, e, mtype2):
    m = mtype().refined(3)
    if mtype2 is not None:
        m = mtype2.from_mesh(m)
    basis = Basis(m, e)

    @Functional
Example #4
0
class TestElementQuadBFS(TestCase):
    def test_throw_index_error(self):
        """Tests that exception is thrown when i % 4 not in (0, 1, 2, 3)."""
        element = ElementQuadBFS()
        with self.assertRaises(ValueError):
            element.gdof(0, 0, -1)
        with self.assertRaises(ValueError):
            element.gdof(0, 0, 16)


@pytest.mark.parametrize("m,e,edg", [
    (MeshTri().refined(), ElementTriP1(), ElementTriDG),
    (MeshTri().refined(), ElementTriP2(), ElementTriDG),
    (MeshTet().refined(), ElementTetP1(), ElementTetDG),
    (MeshTet().refined(), ElementTetP2(), ElementTetDG),
    (MeshTri().refined(), ElementTriArgyris(), ElementTriDG),
    (MeshTri().refined(), ElementTriMorley(), ElementTriDG),
    (MeshTri().refined(), ElementTriHermite(), ElementTriDG),
    (MeshHex().refined(), ElementHex1(), ElementHexDG),
    (MeshQuad().refined(), ElementQuad1(), ElementQuadDG),
])
def test_dg_element(m, e, edg):

    edg = edg(e)

    @Functional
    def square(w):
        return w['random']**2

    basis = InteriorBasis(m, e)
    basisdg = InteriorBasis(m, edg)