Coverage for pySDC/implementations/transfer_classes/TransferMesh_NoCoarse.py: 78%

18 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-04-29 09:02 +0000

1from pySDC.core.Errors import TransferError 

2from pySDC.core.SpaceTransfer import space_transfer 

3from pySDC.implementations.datatype_classes.mesh import mesh, imex_mesh 

4 

5 

6class mesh_to_mesh(space_transfer): 

7 """ 

8 Custon base_transfer class, implements Transfer.py 

9 

10 This implementation can restrict and prolong between nd meshes with dirichlet-0 or periodic boundaries 

11 via matrix-vector products 

12 

13 Attributes: 

14 Rspace: spatial restriction matrix, dim. Nf x Nc 

15 Pspace: spatial prolongation matrix, dim. Nc x Nf 

16 """ 

17 

18 def __init__(self, fine_prob, coarse_prob, params): 

19 """ 

20 Initialization routine 

21 

22 Args: 

23 fine_prob: fine problem 

24 coarse_prob: coarse problem 

25 params: parameters for the transfer operators 

26 """ 

27 # invoke super initialization 

28 super(mesh_to_mesh, self).__init__(fine_prob, coarse_prob, params) 

29 

30 def restrict(self, F): 

31 """ 

32 Restriction implementation 

33 

34 Args: 

35 F: the fine level data (easier to access than via the fine attribute) 

36 """ 

37 if isinstance(F, mesh): 

38 G = mesh(F) 

39 elif isinstance(F, imex_mesh): 

40 G = imex_mesh(F) 

41 else: 

42 raise TransferError('Unknown data type, got %s' % type(F)) 

43 return G 

44 

45 def prolong(self, G): 

46 """ 

47 Prolongation implementation 

48 

49 Args: 

50 G: the coarse level data (easier to access than via the coarse attribute) 

51 """ 

52 if isinstance(G, mesh): 

53 F = mesh(G) 

54 elif isinstance(G, imex_mesh): 

55 F = imex_mesh(G) 

56 else: 

57 raise TransferError('Unknown data type, got %s' % type(G)) 

58 return F