Coverage for src/methodsnm/intrule_2d.py: 68%

22 statements  

« prev     ^ index     » next       coverage.py v7.3.1, created at 2023-09-27 13:22 +0000

1""" 

2This module provides classes for numerical integration rules in 2D (triangles). 

3""" 

4 

5from abc import ABC, abstractmethod 

6import numpy as np 

7from numpy import array 

8from methodsnm.intrule import IntRule 

9 

10class IntRuleTriangle(IntRule): 

11 """ 

12 Abstract base class for numerical integration rules on triangle. 

13 """ 

14 def __init__(self): 

15 pass 

16 

17class EdgeMidPointRule(IntRuleTriangle): 

18 """ 

19 Class for the midpoint rule for 1D numerical integration. 

20 """ 

21 def __init__(self): 

22 """ 

23 Initializes the midpoint rule with the given interval. 

24 

25 """ 

26 self.nodes = array([[0.5,0.0],[0.5,0.5],[0.0,0.5]]) 

27 self.weights = array([1.0/6.0,1.0/6.0,1.0/6.0]) 

28 self.exactness_degree = 1 

29 

30from methodsnm.intrule_1d import NP_GaussLegendreRule 

31from methodsnm.intrule_1d import SP_GaussJacobiRule 

32class DuffyBasedRule(IntRule): 

33 def __init__(self, order): 

34 gp_points = max(order,0)//2+1 

35 self.gauss = NP_GaussLegendreRule(gp_points) 

36 self.gjacobi = SP_GaussJacobiRule(gp_points,alpha=1,beta=0) 

37 self.nodes = array([[(1-eta[0])*xi[0], eta[0]] for xi in self.gauss.nodes for eta in self.gjacobi.nodes]) 

38 self.weights = array([w1*w2 for w1 in self.gauss.weights for w2 in self.gjacobi.weights]) 

39 self.exactness_degree = 2*gp_points-1