Coverage for pySDC/implementations/transfer_classes/TransferMesh_NoCoarse.py: 78%
18 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
1from pySDC.core.errors import TransferError
2from pySDC.core.space_transfer import SpaceTransfer
3from pySDC.implementations.datatype_classes.mesh import mesh, imex_mesh
6class mesh_to_mesh(SpaceTransfer):
7 """
8 Custon base_transfer class, implements Transfer.py
10 This implementation can restrict and prolong between nd meshes with dirichlet-0 or periodic boundaries
11 via matrix-vector products
13 Attributes:
14 Rspace: spatial restriction matrix, dim. Nf x Nc
15 Pspace: spatial prolongation matrix, dim. Nc x Nf
16 """
18 def __init__(self, fine_prob, coarse_prob, params):
19 """
20 Initialization routine
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)
30 def restrict(self, F):
31 """
32 Restriction implementation
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
45 def prolong(self, G):
46 """
47 Prolongation implementation
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