wolfgpu.injector

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.injector.SimulationProxy(glsim: wolfgpu.glsimulation.GLSimulation, global_state: wolfgpu.glsimulation.GLSimulationGlobalState, zone_of_interest: Tuple[slice, slice], simulation_current_quantity: int, original_infiltration_chronology: wolfgpu.simple_simulation.InfiltrationChronology)[source]

A proxy to query and update a running simulation.

This class exists to hide the methods of the simulator from the caller because they are numerous and many of them are of no interest to the caller.

property current_sim_step: int[source]

The current step in the simulation (starting at zero).

property current_sim_time: float[source]

The current time in the simulation. Expressed in seconds (starting at zero).

_ensure_array_size(a)[source]
_set_zone_of_interest(zone_of_interest: Tuple[slice, slice])[source]
_updated_infiltration_chronology()[source]
get_bathymetry() numpy.ndarray[source]
set_bathymetry(b: numpy.ndarray)[source]

Set the bathymetry unknown over the zone of interest.

Parameters:

b – The bathymetry values to set. The array size must be equal to the size of the zone of interest.

get_infiltration_zones() numpy.ndarray[source]
set_infiltration_zones(b: numpy.ndarray)[source]
get_active_infiltration_quantities()[source]

Get the current infiltration chronology’s row: that is, the currently infiltrated quantities.

Returns:

The current infitlration chronology’s row. If none is

active (because current time is before the chronology beginning) then None is returned.

set_active_infiltration_quantities(q) None[source]

Set the current infiltration chronology’s row: that is, set the infiltrated quantities.

insert_infiltration_quantities(t: float, q: List[float]) None[source]

Insert or replace an infiltration chronology’s row.

Parameters:
  • t – Beginning time for the infiltration of the row.

  • q – Infiltrated quantities, as many as the number of infiltrated zones.

_h_qx_qy_cache()[source]
get_h()[source]
set_h(h: numpy.ndarray)[source]

Set the h unknown over the zone of interest.

Parameters:

h – The h values to set. The array size must be equal to the size of the zone of interest.

get_qx()[source]
set_qx(qx: numpy.ndarray)[source]

Set the Qx unknown over the zone of interest.

Parameters:

qx – The Qx values to set. The array size must be equal to the size of the zone of interest.

get_qy()[source]
set_qy(qy: numpy.ndarray)[source]

Set the Qy unknown over the zone of interest.

Parameters:

qy – The Qy values to set. The array size must be equal to the size of the zone of interest.

class wolfgpu.injector.SimulationInjector[source]

Bases: abc.ABC

Inheritance diagram of wolfgpu.injector.SimulationInjector

Injectors allow small python scripts to be run at several point in time during the simulation. The goal of these script should be to update the simulation in real time, potentially affecting the simulation outcome.

Inkjectors are called between simulation steps (that is after the end of a step and before the beginning of the next step).

abstract active_zone() tuple[slice, slice][source]

The zone that this injector wants to update expressed as a tuple of two slices. The first slice gives the columns span, the second gives the rows span.

This zone must be constant across the simulation. In particular, it must be evaluable before the simulation has started.

We limit the region where updates are necessary to avoid downloading/uploading potentially big textures to the GPU.

time_to_new_injection(current_step: int, current_time: float) wolfgpu.simple_simulation.SimulationDuration[source]

How long the simulator must wait before calling None means the injector should not be called anymore.

This method is independent because it will be called once at the beginning of the simulation to get the time of the first update.

Parameters:
  • current_step – The current step in the simulation.

  • current_time – The current time in the simulation, expressed in seconds.

Returns:

A SimulationDuration. None means the injector should not be called anymore.

do_updates(sim_proxy: SimulationProxy) None[source]

This method will be called after the time_to_first_injection or after the time it itself returned.

Returns:

Return the time the simulator must wait before calling this method again. Return None if you don’t want to be called anymore.

Return type:

SimulationDuration