def test_make_trapezoid_rule(): """ Testing creation of quadrature formula on equally distributed points of order 1. """ p, w = lagrange_polynomial.make_quadrature_formula( 1, lagrange_polynomial.PointDistributionType.EQUALLY_DISTRIBUTED) np_test.assert_array_almost_equal(p, [0.0, 1.0]) np_test.assert_array_almost_equal(w, [0.5, 0.5])
def test_make_gauss_lobatto_order2(): """ Testing creation of gauss-lobatto quadrature formula of order 2. """ p, w = lagrange_polynomial.make_quadrature_formula( 2, lagrange_polynomial.PointDistributionType.GAUSS_LOBATTO) np_test.assert_array_almost_equal(p, [0.0, 0.5, 1.0]) np_test.assert_array_almost_equal(w, [1.0 / 6.0, 2.0 / 3.0, 1.0 / 6.0])
def test_make_simpson_1_3_rule(): """ Testing creation of quadrature formula on equally distributed points of order 2. """ p, w = lagrange_polynomial.make_quadrature_formula( 2, lagrange_polynomial.PointDistributionType.EQUALLY_DISTRIBUTED) np_test.assert_array_almost_equal(p, [0.0, 0.5, 1.0]) np_test.assert_array_almost_equal(w, [1.0 / 6.0, 2.0 / 3.0, 1.0 / 6.0])
def test_make_gauss_lobatto_order3(): """ Testing creation of gauss-lobatto quadrature formula of order 3. """ p, w = lagrange_polynomial.make_quadrature_formula( 3, lagrange_polynomial.PointDistributionType.GAUSS_LOBATTO) np_test.assert_array_almost_equal(p, [0.0, 0.276393202, 0.723606798, 1.0]) np_test.assert_array_almost_equal( w, [0.0833333333, 0.4166666667, 0.4166666667, 0.0833333333])
def test_make_boole_villarceau(): """ Testing creation of quadrature formula on equally distributed points of order 4. """ p, w = lagrange_polynomial.make_quadrature_formula( 4, lagrange_polynomial.PointDistributionType.EQUALLY_DISTRIBUTED) np_test.assert_array_almost_equal(p, [0.0, 0.25, 0.50, 0.75, 1.0]) np_test.assert_array_almost_equal( w, [7.0 / 90.0, 32.0 / 90.0, 12.0 / 90.0, 32.0 / 90.0, 7.0 / 90.0])
def test_get_quadrature_weight(): """ Testing extractin of quadrature weights. """ fe_space = fe_sp.FiniteElementSpace(mesh.Mesh([0.0, 1.0]), fe_order=3, quad_order=4) _, w = lag_poly.make_quadrature_formula( 4, lag_poly.PointDistributionType.GAUSS_LOBATTO) for iq in range(len(w)): np_test.assert_almost_equal(fe_space.get_quadrature_weight(iq), w[iq])
def test_eval_at_quadrature_pnts(): """ Testing evaluation of callable at quadrature points. """ fe_space = fe_sp.FiniteElementSpace( mesh.Mesh([0.0, -1.0, -4.0]), quad_order=3, quad_type=lag_poly.PointDistributionType.EQUALLY_DISTRIBUTED) # Testing quadrature point indexes. np_test.assert_array_equal( fe_space.eval_at_quadrature_pnts(lambda k, s: k), [0, 1, 2, 3]) # Testing quadrature points coordinates. p, _ = lag_poly.make_quadrature_formula( 3, lag_poly.PointDistributionType.EQUALLY_DISTRIBUTED) np_test.assert_array_equal( fe_space.eval_at_quadrature_pnts(lambda k, s: s), p)