Peano
Loading...
Searching...
No Matches
BlockMatrix.py
Go to the documentation of this file.
1from abc import ABC
2import numpy as np
3
4
5class BlockMatrix(ABC):
6 """Base class for block matrix storage format, defining the interface"""
7
8 def __init__(self, dim, basis): # ! pass degree instead of basis, and construct basis inside
9 """Initialise instance
10 :arg dim: dimension
11 :arg basis: nodal basis
12 """
13 self.dim = dim
14 self._L_C = []
15 self._L_F = []
16 self._A_CC = {}
17 self._A_CF = {}
18 self._A_FC = {}
19 self._A_FF = {}
20 self._fs_labels_C = []
21 self._fs_labels_F = []
22 self._Xi_C = []
23 self._Xi_F = []
24
25 @property
26 def L_C(self):
27 """Return list L_C defining the cell function spaces"""
28 return self._L_C
29
30 @property
31 def L_F(self):
32 """Return list L_F defining the facet function spaces"""
33 return self._L_F
34
35 @property
36 def fs_labels_C(self):
37 """Return list of cell function space labels"""
38 return self._fs_labels_C
39
40 @property
41 def fs_labels_F(self):
42 """Return list of facet function space labels"""
43 return self._fs_labels_F
44
45 def n_C(self, ell):
46 """number of unknowns per cell for the ell-th cell function space
47 :arg ell: index of function space
48 """
49 return (self._L_C[ell] + 1) ** self.dim
50
51 def n_F(self, ell):
52 """number of unknowns per cell for the ell-th facet function space
53 :arg ell: index of function space
54 """
55 return (self._L_F[ell] + 1) ** (self.dim - 1)
56
57 def A_CC(self, k, ell, gamma):
58 """Return matrix hat(A)_CC^{(k,ell); gamma}
59 :arg ell: second function space (from-space)
60 :arg k: first function space (to-space)
61 :arg gamma: power gamma, tuple of size dim
62 """
63 return self._A_CC[(k, ell)][gamma]
64
65 def A_CF(self, k, ell, beta_ref, gamma):
66 """Return matrix hat(A)_CF^{(k,ell); beta_ref; gamma}
67 :arg ell: second function space (from-space)
68 :arg k: first function space (to-space)
69 :arg beta_ref: type of facet
70 :arg gamma: power gamma, tuple of size dim
71 """
72 return self._A_CF[(k, ell)][beta_ref][gamma]
73
74 def A_FC(self, k, ell, beta_ref, gamma):
75 """Return matrix hat(A)_FC^{(k,ell); beta_ref; gamma}
76 :arg ell: second function space (from-space)
77 :arg k: first function space (to-space)
78 :arg beta_ref: type of facet
79 :arg gamma: power gamma, tuple of size dim
80 """
81 return self._A_FC[(k, ell)][beta_ref][gamma]
82
83 def A_FF(self, k, ell, beta_ref, gamma):
84 """Return matrix hat(A)_FF^{(k,ell); beta_ref; gamma}
85 :arg ell: second function space (from-space)
86 :arg k: first function space (to-space)
87 :arg beta_ref: type of facet
88 :arg gamma: power gamma, tuple of size dim
89 """
90 return self._A_FF[(k, ell)][beta_ref][gamma]
91
92 def Xi_C(self, ell):
93 """return nodal points of ell-th cell function space
94 :arg ell: index of function space
95 """
96 return self._Xi_C[ell]
97
98 def Xi_F(self, ell, orientation):
99 """return nodal points of ell-th cell function space
100 :arg ell: index of function space
101 :arg orientation: orientation of reference element
102 """
103 return self._Xi_F[ell][orientation]
104
105
106 def print_dictionary(self, input, indent=0):
107 """
108 Visualise nested dictionary
109 """
110
111 if type(input) == dict:
112 for k, v in input.items():
113 print(" "*indent + f"{k}:")
114 self.print_dictionary(v, indent+2)
115 else:
116 assert type(input) == np.ndarray
117
118 print(" "*indent + f"{repr(input)}")
Base class for block matrix storage format, defining the interface.
Definition BlockMatrix.py:5
L_C(self)
Return list L_C defining the cell function spaces.
print_dictionary(self, input, indent=0)
Visualise nested dictionary.
fs_labels_C(self)
Return list of cell function space labels.
A_FC(self, k, ell, beta_ref, gamma)
Return matrix hat(A)_FC^{(k,ell); beta_ref; gamma} :arg ell: second function space (from-space) :arg ...
n_F(self, ell)
number of unknowns per cell for the ell-th facet function space :arg ell: index of function space
L_F(self)
Return list L_F defining the facet function spaces.
__init__(self, dim, basis)
Initialise instance :arg dim: dimension :arg basis: nodal basis.
Definition BlockMatrix.py:8
A_FF(self, k, ell, beta_ref, gamma)
Return matrix hat(A)_FF^{(k,ell); beta_ref; gamma} :arg ell: second function space (from-space) :arg ...
Xi_C(self, ell)
return nodal points of ell-th cell function space :arg ell: index of function space
Xi_F(self, ell, orientation)
return nodal points of ell-th cell function space :arg ell: index of function space :arg orientation:...
A_CC(self, k, ell, gamma)
Return matrix hat(A)_CC^{(k,ell); gamma} :arg ell: second function space (from-space) :arg k: first f...
A_CF(self, k, ell, beta_ref, gamma)
Return matrix hat(A)_CF^{(k,ell); beta_ref; gamma} :arg ell: second function space (from-space) :arg ...
fs_labels_F(self)
Return list of facet function space labels.
n_C(self, ell)
number of unknowns per cell for the ell-th cell function space :arg ell: index of function space