Coverage for pySDC/implementations/transfer_classes/TransferParticles_NoCoarse.py: 73%

22 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-04-29 09:02 +0000

1from pySDC.core.Errors import TransferError 

2from pySDC.core.SpaceTransfer import space_transfer 

3from pySDC.implementations.datatype_classes.particles import particles, fields, acceleration 

4 

5 

6class particles_to_particles(space_transfer): 

7 """ 

8 Custon transfer class, implements SpaceTransfer.py 

9 

10 This implementation is just a dummy for particles with no direct functionality, i.e. the number of particles is not 

11 reduced on the coarse problem 

12 """ 

13 

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

15 """ 

16 Initialization routine 

17 

18 Args: 

19 fine_prob: fine problem 

20 coarse_prob: coarse problem 

21 params: parameters for the transfer operators 

22 """ 

23 super(particles_to_particles, self).__init__(fine_prob, coarse_prob, params) 

24 pass 

25 

26 def restrict(self, F): 

27 """ 

28 Dummy restriction routine 

29 

30 Args: 

31 F: the fine level data 

32 """ 

33 

34 if isinstance(F, particles): 

35 G = particles(F) 

36 elif isinstance(F, fields): 

37 G = fields(F) 

38 elif isinstance(F, acceleration): 

39 G = acceleration(F) 

40 else: 

41 raise TransferError("Unknown type of fine data, got %s" % type(F)) 

42 return G 

43 

44 def prolong(self, G): 

45 """ 

46 Dummy prolongation routine 

47 

48 Args: 

49 G: the coarse level data 

50 """ 

51 

52 if isinstance(G, particles): 

53 F = particles(G) 

54 elif isinstance(G, fields): 

55 F = fields(G) 

56 elif isinstance(G, acceleration): 

57 F = acceleration(G) 

58 else: 

59 raise TransferError("Unknown type of coarse data, got %s" % type(G)) 

60 return F