Exemple #1
0
 def quadrature_rule(self):
     dims = self.mesh_el_group.dim
     if dims == 0:
         return mp.ZeroDimensionalQuadrature()
     elif dims == 1:
         return mp.LegendreGaussQuadrature(self.order, force_dim_axis=True)
     else:
         return mp.XiaoGimbutasSimplexQuadrature(self.order, dims)
 def _quadrature_rule(self):
     dims = self.mesh_el_group.dim
     if dims == 0:
         return mp.Quadrature(np.empty((0, 1)), np.empty((0, 1)))
     elif dims == 1:
         return mp.LegendreGaussQuadrature(self.order)
     else:
         return mp.XiaoGimbutasSimplexQuadrature(self.order, dims)
Exemple #3
0
def test_modal_coeffs_by_projection(dim):
    shape = mp.Simplex(dim)
    space = mp.space_for_shape(shape, order=5)
    basis = mp.orthonormal_basis_for_space(space, shape)

    quad = mp.XiaoGimbutasSimplexQuadrature(10, dim)
    assert quad.exact_to >= 2 * space.order

    modal_coeffs = np.random.randn(space.space_dim)
    vdm = mp.vandermonde(basis.functions, quad.nodes)

    evaluated = vdm @ modal_coeffs

    modal_coeffs_2 = vdm.T @ (evaluated * quad.weights)

    diff = modal_coeffs - modal_coeffs_2

    assert la.norm(diff, 2) < 3e-13
Exemple #4
0
def _(space: PN, shape: Simplex):
    if not isinstance(shape, Simplex):
        raise NotImplementedError((type(space).__name__, type(shape).__name))
    if space.spatial_dim != shape.dim:
        raise ValueError("spatial dimensions of shape and space must match")

    import modepy as mp
    if space.spatial_dim == 0:
        quad = ZeroDimensionalQuadrature()
    else:
        try:
            quad = mp.XiaoGimbutasSimplexQuadrature(space.order,
                                                    space.spatial_dim)
        except QuadratureRuleUnavailable:
            quad = mp.GrundmannMoellerSimplexQuadrature(
                space.order // 2, space.spatial_dim)

    assert quad.exact_to >= space.order
    return quad