Peano
Loading...
Searching...
No Matches
IntergridOperatorsH.py
Go to the documentation of this file.
1import numpy as np
2
4 """!
5 Class to produce restriction/prolongation matrices for multigrid tasks.
6
7 """
8
9 def __init__(self, dim=2, refinement_order=1):
10 self.dim = dim
11 self.refinement_order = refinement_order
12
13 assert dim < 3
14 assert refinement_order == 1
15
16 def prolongation(self):
17 prolong1d = np.asarray([[1, 0],
18 [2/3, 1/3],
19 [1/3, 2/3],
20 [0, 1]])
21
22 if self.dim == 1:
23 result = prolong1d
24 elif self.dim == 2:
25 result = np.kron(prolong1d, prolong1d)
26
27 return result
28
29 def restriction(self):
30 return self.prolongation().T
31
32
33if __name__ == "__main__":
34 operators = IntergridOperatorsH(dim=2, refinement_order=1)
Class to produce restriction/prolongation matrices for multigrid tasks.