Coverage for pySDC/implementations/transfer_classes/TransferMesh_NoCoarse.py: 75%
16 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-02-04 12:37 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-02-04 12:37 +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 Custom 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 restrict(self, F):
19 """
20 Restriction implementation
22 Args:
23 F: the fine level data (easier to access than via the fine attribute)
24 """
25 if isinstance(F, mesh):
26 G = mesh(F)
27 elif isinstance(F, imex_mesh):
28 G = imex_mesh(F)
29 else:
30 raise TransferError('Unknown data type, got %s' % type(F))
31 return G
33 def prolong(self, G):
34 """
35 Prolongation implementation
37 Args:
38 G: the coarse level data (easier to access than via the coarse attribute)
39 """
40 if isinstance(G, mesh):
41 F = mesh(G)
42 elif isinstance(G, imex_mesh):
43 F = imex_mesh(G)
44 else:
45 raise TransferError('Unknown data type, got %s' % type(G))
46 return F