wolfgpu.glsimulation
Module Contents
- wolfgpu.glsimulation.debug_framebuffer(framebuffer_id, color_attachment, width, height, format_, type_, title='', component=0)[source]
- class wolfgpu.glsimulation.TileOptimisation[source]
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- wolfgpu.glsimulation.shrink_array_by_two(a)[source]
Cut array in 2. A 5x5 array will be cut to a 3x3 (notiece the rounding)
- wolfgpu.glsimulation.find_stripes(a, rw, rh, tile_w, tile_h, with_dilatation=True)[source]
Find stripes on a. Elements of a different than zero are the ones taken into account.
There’s one stripe per line of the array !
Please note that the stripes coordinates will be in NDC (normalized device coordinate, see OpenGL) over the array (that is, they’re in [-1,+1] regardless of the size of the array)
- wolfgpu.glsimulation.find_non_empty_tiles_on_nap(nap: wolfgpu.gl_utils.np.ndarray, n: int)[source]
Tiles on NAP are used to guide the first level of computation, that is at the maximum detail level. After that level, one uses stripes which will be dynamically adjusted to water coverage. Tiles on NAP are not meant to change over the course of the simulation.
- class wolfgpu.glsimulation.GLSimulationGlobalState(simulation_time, time_step, active_infiltration_line, nb_dryup_iterations, nb_active_tiles, status_code, total_active_tiles, infiltration_zones)[source]
- class wolfgpu.glsimulation.GLSimulation(width, height, ponderation_runge_kutta: float = 0.3, dx: float = 1.0, dy: float = 1.0, courant: float = 0.1, froude_max: float = 10.0, time_step_strategy=TimeStepStrategy.OPTIMIZED_TIME_STEP, time_step: float = 1.0, max_steps=SimulationDuration.from_seconds(10), report_frequency=SimulationDuration.from_steps(10), basefilename: str = 'simul', tile_size=DEFAULT_TILE_SIZE, shader_log_path: wolfgpu.gl_utils.Path = None, tile_packing_mode: wolfgpu.tile_packer.TilePackingMode = TilePackingMode.REGULAR, optimized_indirection: bool = False)[source]
- property infiltration_interpolation: wolfgpu.simple_simulation.InfiltrationInterpolation[source]
- set_params(width, height, ponderation_runge_kutta: float = 0.3, dx: float = 1.0, dy: float = 1.0, courant: float = 0.1, froude_max: float = 10.0, time_step_strategy=TimeStepStrategy.OPTIMIZED_TIME_STEP, time_step: float = None, simulation_duration=SimulationDuration.from_seconds(10), report_frequency=SimulationDuration.from_steps(10), basefilename: str = 'simul', tile_size=DEFAULT_TILE_SIZE, infiltration_interpolation: wolfgpu.simple_simulation.InfiltrationInterpolation = InfiltrationInterpolation.NONE, tile_packing_mode: wolfgpu.tile_packer.TilePackingMode = TilePackingMode.REGULAR, optimized_indirection=False, track_flows_at_borders=False)[source]
- force_max_step_size(s: float)[source]
Prevents the max step size computation. Pass None to re-enable the computation. Used in test/debug.
- set_ensure_positive_height(b: bool)[source]
Enable or disable positive height enforcment. Used in debugging/testing
- set_report_frequency(d: wolfgpu.simple_simulation.SimulationDuration)[source]
- set_simulation_duration(d: wolfgpu.simple_simulation.SimulationDuration)[source]
- set_infiltration_interpolation(lerp: wolfgpu.simple_simulation.InfiltrationInterpolation)[source]
- set_tiles_packing_mode(mode: wolfgpu.tile_packer.TilePackingMode)[source]
- complete_textures()[source]
After having set several data textures, call this to upload blank texture replacement for those you didn’t set. and to recompute the framebuffers and create additional textures necessary to the computation.
- set_buffers(max_step_size=None, strong_bc_array=None, strong_bc_values_array=None, quantity_arrays=None, bathymetry_array=None, manning_array=None, active_meshes_array=None, weak_bc_array=None, bc_cells_array=None, infiltration_zones_array=None, infiltration_timings=None)[source]
- simulation_step(source_quantity)[source]
Perform a full simulation step (with all substeps: euler, RK,…)
source_quantity is 0 or 1 and tells in which of the ping/pong textures we’ll read information. Consequently, we’ll write into 1 - source_quantity.
- detect_wet_tiles2(current_quantity)[source]
Detect wet tiles
FIXME we also call them active but that a misnomer because active also means NAP-active…
- compute_derivative_with_dry_up_and_euler(current_quantity_tex_ndx: int, euler_base_quantity_tex_ndx: int, quantity_out_tex_ndx: int, current_alpha_tex_ndx=0, ignore_alpha=False)[source]
- set_total_number_of_dry_up_outer_loops(n)[source]
Configure the number of desired iterations to solve all or some of the dry ups.
- Parameters:
n (None or int.) – Number of iterations: * n == 0 means no dry up (only Euler/RK) * n > 0 means a fixed number of dry up iterations * None means as many dry up iterations as needed to solve all dry ups
- compute_derivative_with_dry_up_and_rk(current_quantity_tex_ndx: int, euler_base_quantity_tex_ndx: int, quantity_out_tex_ndx: int, current_alpha_tex_ndx=0, ignore_alpha=False)[source]
- tile_packer() wolfgpu.tile_packer.TilePacker [source]
- read_flows_on_borders(which: int)[source]
Read flows on borders. Each cell of the returned arrays contains: (q_left, q_right, q_top, q_bottom).
Used only while debugging
- param which:
0 for Euler, 1 for Runge Kutta.
- read_rhs()[source]
Read RHS at Euler step or RK step (make sure you know which one is valid when). Each cell of the returned arrays contains: (q_left, q_right, q_top, q_bottom).
Used only while debugging
- read_quantity_result(current_quantity) wolfgpu.gl_utils.np.array [source]
Returns the matrix of quantities (h,qx,qy), unpacked. Used for debugging. Prefer the ResultStore.
- Parameters:
current_quantity – is 0,1 for the flip flop textures and 2
for the intermediate euler resul (if one uses Runge-Kutta).
- read_tile_packed_quantity_result(current_quantity)[source]
Returns the matrix of quantities (h,qx,qy), “tile-packed”.
- read_alpha(current_quantity)[source]
Returns the matrix of alpha-correction (dry ups), “tile-_un_packed”.
- read_tile_packed_alpha(current_quantity)[source]
Returns the matrix of alpha-correction (dry ups), “tile-packed”.
- read_active_cells_map()[source]
Read active cells map.
NOTE ! Be ware that this map is “packed” (as in tile packing)
- read_global_state() GLSimulationGlobalState [source]
Read the global state variables of the simulation, as reported by the shaders in the GPU.
Be aware that this implies reading information from the GPU which usually leads to a huge drop in performance (up to 50% !!!).
- Returns:
simulation_time, time_step, active_infiltration_line, nb_dryup_iterations, nb_active_tiles, status_code
- wolfgpu.glsimulation.convert_wolf_rk_ponderation(wolf2d: wolfhece.mesh2d.wolf2dprev.prev_sim2D)[source]
Convert the ponderation value from prev_sim2D to the one used in the GLSimulation.
- wolfgpu.glsimulation.get_epsilon(wolf2d: wolfhece.mesh2d.wolf2dprev.prev_sim2D)[source]
Get the epsilon value used in the GLSimulation.
Based on the spatial resolution of the simulation, we take the minimum of dx and dy to the power of 4. The result is then compared to 0.000_001 and the minimum of the two values is returned.
- wolfgpu.glsimulation.get_report_frequency(m: wolfhece.mesh2d.wolf2dprev.prev_sim2D) wolfgpu.simple_simulation.SimulationDuration [source]
- wolfgpu.glsimulation.plot_evolution_of_simulation_base(sim: wolfgpu.simple_simulation.SimpleSimulation, rs: wolfgpu.results_store.ResultsStore)[source]