Coverage for pySDC/core/space_transfer.py: 100%
19 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-16 14:51 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-16 14:51 +0000
1import logging
3from pySDC.helpers.pysdc_helper import FrozenClass
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()
19class SpaceTransfer(object):
20 """
21 Abstract SpaceTransfer class
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 """
30 def __init__(self, fine_prob, coarse_prob, space_transfer_params):
31 """
32 Initialization routine
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 """
40 self.params = _Pars(space_transfer_params)
42 # set up logger
43 self.logger = logging.getLogger('space-transfer')
45 # just copy by object
46 self.fine_prob = fine_prob
47 self.coarse_prob = coarse_prob
49 def restrict(self, F):
50 """
51 Abstract interface for restriction in space
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)')
58 def prolong(self, G):
59 """
60 Abstract interface for prolongation in space
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)')