Beispiel #1
0
    def get_ref_stiffness_transpose_mat(out_grp, in_grp):
        if in_grp == out_grp:
            from meshmode.discretization.poly_element import \
                mass_matrix, diff_matrices

            mmat = mass_matrix(out_grp)
            return actx.freeze(
                actx.from_numpy(
                    np.asarray(
                        [dmat.T @ mmat.T for dmat in diff_matrices(out_grp)])))

        from modepy import vandermonde
        basis = out_grp.basis_obj()
        vand = vandermonde(basis.functions, out_grp.unit_nodes)
        grad_vand = vandermonde(basis.gradients, in_grp.unit_nodes)
        vand_inv_t = np.linalg.inv(vand).T

        if not isinstance(grad_vand, tuple):
            # NOTE: special case for 1d
            grad_vand = (grad_vand, )

        weights = in_grp.quadrature_rule().weights
        return actx.freeze(
            actx.from_numpy(
                np.einsum("c,bz,acz->abc", weights, vand_inv_t,
                          grad_vand).copy()  # contigify the array
            ))
Beispiel #2
0
    def matrix(out_element_group, in_element_group):
        if out_element_group == in_element_group:
            from meshmode.discretization.poly_element import mass_matrix
            return mass_matrix(in_element_group)

        from modepy import vandermonde
        basis = out_element_group.basis_obj()
        vand = vandermonde(basis.functions, out_element_group.unit_nodes)
        o_vand = vandermonde(basis.functions, in_element_group.unit_nodes)
        vand_inv_t = np.linalg.inv(vand).T

        weights = in_element_group.quadrature_rule().weights
        return np.einsum("j,ik,jk->ij", weights, vand_inv_t, o_vand)
Beispiel #3
0
    def get_ref_mass_mat(out_grp, in_grp):
        if out_grp == in_grp:
            from meshmode.discretization.poly_element import mass_matrix

            return actx.freeze(
                actx.from_numpy(np.asarray(mass_matrix(out_grp), order="C")))

        from modepy import vandermonde
        basis = out_grp.basis_obj()
        vand = vandermonde(basis.functions, out_grp.unit_nodes)
        o_vand = vandermonde(basis.functions, in_grp.unit_nodes)
        vand_inv_t = np.linalg.inv(vand).T

        weights = in_grp.quadrature_rule().weights
        return actx.freeze(
            actx.from_numpy(
                np.asarray(np.einsum("j,ik,jk->ij", weights, vand_inv_t,
                                     o_vand),
                           order="C")))
Beispiel #4
0
    def matrices(out_elem_grp, in_elem_grp):
        if in_elem_grp == out_elem_grp:
            assert in_elem_grp.is_orthonormal_basis()
            from meshmode.discretization.poly_element import (mass_matrix,
                                                              diff_matrices)
            mmat = mass_matrix(in_elem_grp)
            return [dmat.T.dot(mmat.T) for dmat in diff_matrices(in_elem_grp)]

        from modepy import vandermonde
        basis = out_elem_grp.basis_obj()
        vand = vandermonde(basis.functions, out_elem_grp.unit_nodes)
        grad_vand = vandermonde(basis.gradients, in_elem_grp.unit_nodes)
        vand_inv_t = np.linalg.inv(vand).T

        if not isinstance(grad_vand, tuple):
            # NOTE: special case for 1d
            grad_vand = (grad_vand, )

        weights = in_elem_grp.quadrature_rule().weights
        return np.einsum("c,bz,acz->abc", weights, vand_inv_t, grad_vand)