wolfgpu.SimulationRunner
Author: HECE - University of Liege, Stéphane Champailler, Pierre Archambeau Date: 2024
Copyright (c) 2024 University of Liege. All rights reserved.
This script and its content are protected by copyright law. Unauthorized copying or distribution of this file, via any medium, is strictly prohibited.
Module Contents
- class wolfgpu.SimulationRunner.GlWindowManagerInterface[source]
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- wolfgpu.SimulationRunner.MOSTLY_DRY_MESHES_THRESHOLD = 1e-05[source]
Number of steps recorded in the database of simulation times used by the injection triggering to estimate the next trigger.
- wolfgpu.SimulationRunner.count_infiltration_cells(a, nb_zones)[source]
- Parameters:
a – infiltration zones array. Zone indices are 1 baseD.
- Returns:
a numpy array (1D) with all the counts, one per zone.
- class wolfgpu.SimulationRunner.SimulatoryQuery(simulator: wolfgpu.glsimulation.GLSimulation, modifiable_area: tuple)[source]
Get data over the active zone, not the whoel domain!!!!!
- class wolfgpu.SimulationRunner.InjectorWrapper(injector: wolfgpu.injector.SimulationInjector, sim: wolfgpu.simple_simulation.SimpleSimulation, infiltration_chronolgy: wolfgpu.simple_simulation.InfiltrationChronology)[source]
- class wolfgpu.SimulationRunner.OpenGLContext(sim: wolfgpu.simple_simulation.SimpleSimulation, gl_wmi: GlWindowManagerInterface = GlWindowManagerInterface.PYGAME)[source]
- class wolfgpu.SimulationRunner.SimulationRunner(glsim: wolfgpu.glsimulation.GLSimulation, record_path: pathlib.Path | str = Path('.'), early_out_delta_max: float = 1e-06, record: bool = True, page_flip_func=pygame.display.flip, enable_alpha_recording: bool = False, data_injector: wolfgpu.injector.SimulationInjector = None)[source]
-
- _setup_injectors(data_injector, glsim: wolfgpu.glsimulation.GLSimulation)[source]
- classmethod continue_a_simulation(sim: wolfgpu.simple_simulation.SimpleSimulation, result_store_path: pathlib.Path | str, refresh_view: float = 0.1, early_out_threshold=None, injector: wolfgpu.injector.SimulationInjector = None) wolfgpu.results_store.ResultsStore [source]
- classmethod _prepare_quick_run(sim: wolfgpu.simple_simulation.SimpleSimulation, record_path: pathlib.Path | str, refresh_view: float = 0.1, early_out_threshold=None, gl_wmi: GlWindowManagerInterface = GlWindowManagerInterface.PYGAME, injector: wolfgpu.injector.SimulationInjector = None, tiling: wolfgpu.glsimulation.TilePackingMode = TilePackingMode.REGULAR) SimulationRunner [source]
Run a full simulation quickly. By quickly we mean a lot of the setup of the simulator (such as OpenGL context) is done automatically. In particular a progress window is displayed.
- Parameters:
sim – the simulation you want to run
record_path – a directory where to record the results of the simulation. We accept str as well as Path.
refresh_view – how often the progress window is displyaed (every N seconds).
- Returns:
At the end of the simulation a ´ResultStore´ is returned. It is open in read only mode, so that it can be used to query your results.
- classmethod quick_run(sim: wolfgpu.simple_simulation.SimpleSimulation, record_path: pathlib.Path | str, refresh_view: float = 0.1, early_out_threshold=None, gl_wmi: GlWindowManagerInterface = GlWindowManagerInterface.PYGAME, injector: wolfgpu.injector.SimulationInjector | List[wolfgpu.injector.SimulationInjector] = None, tiling: wolfgpu.glsimulation.TilePackingMode = TilePackingMode.REGULAR) wolfgpu.results_store.ResultsStore [source]
Run a full simulation quickly. By quickly we mean a lot of the setup of the simulator (such as OpenGL context) is done automatically. In particular a progress window is displayed.
- Parameters:
sim – the simulation you want to run
record_path – a directory where to record the results of the simulation. We accept str as well as Path.
refresh_view – how often the progress window is displyaed (every N seconds).
injector – A SimulationInjector or a list of them.
- Returns:
At the end of the simulation a ´ResultStore´ is returned. It is open in read only mode, so that it can be used to query your results.
- classmethod _finish_quickrun(simulation_runner: SimulationRunner) wolfgpu.results_store.ResultsStore [source]
- restart_from_record(start_rec=None)[source]
Restart a simulation from a previous record. This is useful when you want to continue a simulation that has been interrupted.
When restarting from a record, it means that the record in question will be deleted and simulation will go on from there.
- Parameters:
start_rec – the index of the record you want to start from. If None, the simulation will restart from the last record.
- results_store() wolfgpu.results_store.ResultsStore [source]
Gives a result store back. The result store will be opened in read mode.
- do_record(texture_ndx, global_state, force=False)[source]
Record current state of the simulation.
Be careful, this implies reading data from the GPU which is slow !
- texture_written_by_last_step() int [source]
After running run_one_step this gives the number of the texture that was written to (zero or one; rememeber the GPU code often uses flip-flop textures, that’s what you query here).
- run_extra_step()[source]
When a simulation run is complete, this allows to run an additional step. This is useful in debugging.
FIXME The way the reporting is updated is not clear right now.
- _read_simulation_global_state() wolfgpu.glsimulation.GLSimulationGlobalState [source]
Read the current global state of the simulation.
The raison d’être of this method is to allow to to cache the result of the query if the global state because it is expensive.
- _handle_data_injector(proxy: wolfgpu.injector.SimulationProxy, data_injector_wrapper: InjectorWrapper, sim_finished_step: int, sim_finished_step_time: float, source_quantity: int, infiltration_chronology) wolfgpu.injector.SimulationProxy [source]
- _run_all_injectors(source_quantity: int, triggered_timers: set[wolfgpu.sampled_timer.TimeSampler], global_state: wolfgpu.glsimulation.GLSimulationGlobalState) wolfgpu.injector.SimulationProxy [source]
- _apply_changes_in_proxy(proxy: wolfgpu.injector.SimulationProxy, source_quantity: int)[source]
- run_one_step(dont_close_results: bool = False)[source]
Run only one step of the simulation.
- Globally, this method does the following:
Run the GLSimulation for one step with the correct source_quantity
Record the results if needed
Inverse the source_quantity index
Perform some estimation of the next stop time
- Parameters:
dont_close_results – If True, the results store will not be closed
- full_run(refresh_view: int = 1, dont_close_results: bool = False, refresh_colormap: int = 10)[source]
Perform a full simulation run.
- Parameters:
refresh_view – Refresh the view every refresh_view seconds
dont_close_results – Leave the result store open
refresh_colormap – Refresh the colormap every refresh_colormap * refresh_view seconds
- _admin_tasks(iteration_times: numpy.ndarray, triggered_timers: set, taqadum: tqdm.tqdm)[source]
Perform administrative tasks such as updating the progress bar, compute indicators or reload bathymetry.
- _must_continue_event() bool [source]
Check if the simulation was cancelled early by the user or by an early-out condition.
- Return bool:
True if the simulation should continue, False if it should stop.