Coverage for pySDC / core / space_transfer.py: 100%
20 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-13 09:00 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-13 09:00 +0000
1import logging
2from typing import Any, Dict
4from pySDC.helpers.pysdc_helper import FrozenClass
7# short helper class to add params as attributes
8class _Pars(FrozenClass):
9 def __init__(self, pars: Dict[str, Any]) -> None:
10 self.periodic: bool = False
11 self.equidist_nested: bool = True
12 self.iorder: int = 2
13 self.rorder: int = 2
14 for k, v in pars.items():
15 setattr(self, k, v)
16 # freeze class, no further attributes allowed from this point
17 self._freeze()
20class SpaceTransfer(object):
21 """
22 Abstract SpaceTransfer class
24 Attributes:
25 params (__Pars): parameters given by the user
26 logger: custom logger for transfer-related logging
27 fine_prob (pySDC.Problem.ptype): reference to the fine problem
28 coarse_prob (pySDC.Problem.ptype): reference to the coarse problem
29 """
31 def __init__(self, fine_prob: Any, coarse_prob: Any, params: Dict[str, Any]) -> None:
32 """
33 Initialization routine
35 Args:
36 fine_prob (pySDC.Problem.ptype): reference to the fine problem
37 coarse_prob (pySDC.Problem.ptype): reference to the coarse problem
38 params (dict): user-defined parameters
39 """
41 self.params: _Pars = _Pars(params)
43 # set up logger
44 self.logger: logging.Logger = logging.getLogger('space-transfer')
46 # just copy by object
47 self.fine_prob: Any = fine_prob
48 self.coarse_prob: Any = coarse_prob
50 def restrict(self, F: Any) -> Any:
51 """
52 Abstract interface for restriction in space
54 Args:
55 F: the fine level data (easier to access than via the fine attribute)
56 """
57 raise NotImplementedError('ERROR: space_transfer has to implement restrict(self, F)')
59 def prolong(self, G: Any) -> Any:
60 """
61 Abstract interface for prolongation in space
63 Args:
64 G: the coarse level data (easier to access than via the coarse attribute)
65 """
66 raise NotImplementedError('ERROR: space_transfer has to implement prolong(self, G)')