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

20 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-03-04 07:15 +0000

1from pySDC.core.errors import TransferError 

2from pySDC.core.space_transfer import SpaceTransfer 

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

4 

5 

6class particles_to_particles(SpaceTransfer): 

7 """ 

8 Custom 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 restrict(self, F): 

15 """ 

16 Dummy restriction routine 

17 

18 Args: 

19 F: the fine level data 

20 """ 

21 

22 if isinstance(F, particles): 

23 G = particles(F) 

24 elif isinstance(F, fields): 

25 G = fields(F) 

26 elif isinstance(F, acceleration): 

27 G = acceleration(F) 

28 else: 

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

30 return G 

31 

32 def prolong(self, G): 

33 """ 

34 Dummy prolongation routine 

35 

36 Args: 

37 G: the coarse level data 

38 """ 

39 

40 if isinstance(G, particles): 

41 F = particles(G) 

42 elif isinstance(G, fields): 

43 F = fields(G) 

44 elif isinstance(G, acceleration): 

45 F = acceleration(G) 

46 else: 

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

48 return F