Coverage for pySDC/projects/Monodomain/transfer_classes/TransferVectorOfDCTVectors.py: 100%

25 statements  

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

1from pySDC.core.space_transfer import SpaceTransfer 

2from pySDC.projects.Monodomain.transfer_classes.Transfer_DCT_Vector import DCT_to_DCT 

3from pySDC.implementations.datatype_classes.mesh import mesh 

4from pySDC.projects.Monodomain.datatype_classes.my_mesh import imexexp_mesh 

5 

6 

7class TransferVectorOfDCTVectors(SpaceTransfer): 

8 """ 

9 This implementation can restrict and prolong VectorOfVectors 

10 """ 

11 

12 def __init__(self, fine_prob, coarse_prob, params): 

13 # invoke super initialization 

14 super(TransferVectorOfDCTVectors, self).__init__(fine_prob, coarse_prob, params) 

15 

16 self.DCT_to_DCT = DCT_to_DCT(fine_prob, coarse_prob, params) 

17 

18 def restrict(self, F): 

19 

20 u_coarse = mesh(self.coarse_prob.init) 

21 

22 for i in range(self.coarse_prob.size): 

23 u_coarse[i][:] = self.DCT_to_DCT.restrict(F[i]) 

24 

25 return u_coarse 

26 

27 def prolong(self, G): 

28 

29 if isinstance(G, imexexp_mesh): 

30 u_fine = imexexp_mesh(self.fine_prob.init) 

31 for i in range(self.fine_prob.size): 

32 u_fine.impl[i][:] = self.DCT_to_DCT.prolong(G.impl[i]) 

33 u_fine.expl[i][:] = self.DCT_to_DCT.prolong(G.expl[i]) 

34 u_fine.exp[i][:] = self.DCT_to_DCT.prolong(G.exp[i]) 

35 elif isinstance(G, mesh): 

36 u_fine = mesh(self.fine_prob.init) 

37 for i in range(self.fine_prob.size): 

38 u_fine[i][:] = self.DCT_to_DCT.prolong(G[i]) 

39 

40 return u_fine