Coverage for pySDC/core/space_transfer.py: 100%

19 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2024-12-20 14:51 +0000

1import logging 

2 

3from pySDC.helpers.pysdc_helper import FrozenClass 

4 

5 

6# short helper class to add params as attributes 

7class _Pars(FrozenClass): 

8 def __init__(self, pars): 

9 self.periodic = False 

10 self.equidist_nested = True 

11 self.iorder = 2 

12 self.rorder = 2 

13 for k, v in pars.items(): 

14 setattr(self, k, v) 

15 # freeze class, no further attributes allowed from this point 

16 self._freeze() 

17 

18 

19class SpaceTransfer(object): 

20 """ 

21 Abstract SpaceTransfer class 

22 

23 Attributes: 

24 params (__Pars): parameters given by the user 

25 logger: custom logger for transfer-related logging 

26 fine_prob (pySDC.Problem.ptype): reference to the fine problem 

27 coarse_prob (pySDC.Problem.ptype): reference to the coarse problem 

28 """ 

29 

30 def __init__(self, fine_prob, coarse_prob, space_transfer_params): 

31 """ 

32 Initialization routine 

33 

34 Args: 

35 fine_prob (pySDC.Problem.ptype): reference to the fine problem 

36 coarse_prob (pySDC.Problem.ptype): reference to the coarse problem 

37 space_transfer_params (dict): user-defined parameters 

38 """ 

39 

40 self.params = _Pars(space_transfer_params) 

41 

42 # set up logger 

43 self.logger = logging.getLogger('space-transfer') 

44 

45 # just copy by object 

46 self.fine_prob = fine_prob 

47 self.coarse_prob = coarse_prob 

48 

49 def restrict(self, F): 

50 """ 

51 Abstract interface for restriction in space 

52 

53 Args: 

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

55 """ 

56 raise NotImplementedError('ERROR: space_transfer has to implement restrict(self, F)') 

57 

58 def prolong(self, G): 

59 """ 

60 Abstract interface for prolongation in space 

61 

62 Args: 

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

64 """ 

65 raise NotImplementedError('ERROR: space_transfer has to implement prolong(self, G)')