Peano
Loading...
Searching...
No Matches
quadrature.py
Go to the documentation of this file.
1"""Quadrature rules"""
2import numpy as np
3from numpy.polynomial.legendre import leggauss # To calculate the Gauss-Legendre points and weights
4
5
7 """Abstract base class for quadrature on the reference interval [-1,+1]"""
8
9 def __init__(self, npoints):
10 """Initialise object
11
12 :arg npoints: number of quadrature points"""
13 self.npoints = npoints
14
15
17 """Gaussian quadrature on the reference interval [-1,+1]"""
18
19 def __init__(self, npoints):
20 """Initialise object
21
22 :arg npoints: number of quadrature points"""
23 super().__init__(npoints)
24 self.points, self.weights = leggauss(npoints)
25
26
28 """Product of two 1d quadrature rules"""
29
30 def __init__(self, quadrature_1d):
31 """Initialise object
32
33 :arg underlying 1d quadrature
34 """
35 quadrature = quadrature_1d
36 self.weights = [
37 w1 * w2 for w1 in quadrature.weights for w2 in quadrature.weights
38 ]
39 self.points = [
40 np.asarray([xi, eta]) for xi in quadrature.points for eta in quadrature.points
41 ]
42
43# N = 3
44# Q = GaussianQuadrature(N)
45# Q = Quadrature2d(Q)
46# print(f'{N}: {Q.points}, {Q.weights}')
47# pass
Gaussian quadrature on the reference interval [-1,+1].
Definition quadrature.py:16
Abstract base class for quadrature on the reference interval [-1,+1].
Definition quadrature.py:6