Peano
Loading...
Searching...
No Matches
Utils.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3from enum import Enum
4
5
6class StepType(Enum):
7 """ """
8
9 TIME_STEP = 0
10 INITIALISATION = 1
11
12
13def get_observer_prefix(step_type: StepType):
14 if step_type == StepType.TIME_STEP:
15 return "Step"
16 elif step_type == StepType.INITIALISATION:
17 return "Init"
18 else:
19 assert False, "not valid switch"
20
21
22def does_one_species_require_gather(sequence_of_steps):
23 """!
24
25 Look through a sequence of tuples of species and steps and look whether any
26 species therein requires us to gather data.
27
28 """
29 some_particles_need_to_be_gathered = False
30 for x in sequence_of_steps:
31 current_species = x[0]
32 some_particles_need_to_be_gathered = (
33 some_particles_need_to_be_gathered
34 or current_species.generator.gather_particles
35 )
36 return some_particles_need_to_be_gathered
37
38
39def get_species_set(sequence_of_steps):
40 """!
41
42 Take a sequence of steps over multiple species and return the set of
43 species used in this set.
44
45 """
46 species_sets = []
47 for x in sequence_of_steps:
48 current_species = x[0]
49 if not current_species in species_sets:
50 species_sets.append(current_species)
51 return species_sets