wolfgpu.glsimulation

Module Contents

wolfgpu.glsimulation.FINISH = False[source]
wolfgpu.glsimulation.TIME_SAMPLING_RESOLUTION = 100[source]
wolfgpu.glsimulation.DEFAULT_TILE_SIZE = 16[source]
wolfgpu.glsimulation.STRIPES_ON_NAP = True[source]
wolfgpu.glsimulation.WET_TILES_DETECT_THREAD_WIDTH = 4[source]
wolfgpu.glsimulation.GLOBALS_STRUCT_PACK_FORMAT = 'dfLLLLLL'[source]
wolfgpu.glsimulation.GLOBALS_BUFFER_SIZE[source]
wolfgpu.glsimulation.MAXIMUM_TIME_STEP = 1.0[source]
wolfgpu.glsimulation.MESH_WITHOUT_INFILTRATION[source]
wolfgpu.glsimulation.ALPHA_VALUE_NDX = 0[source]
wolfgpu.glsimulation.ALPHA_FLAGS_NDX = 1[source]
wolfgpu.glsimulation.PARTS_QUADS = 1[source]
wolfgpu.glsimulation.PARTS_STRIPES = 2[source]
wolfgpu.glsimulation.MEM_TRACKING[source]
wolfgpu.glsimulation.MEM_TRACKING = False[source]
wolfgpu.glsimulation._root_dir[source]
wolfgpu.glsimulation._perf_counters[source]
wolfgpu.glsimulation.time_it(msg: str = None) Iterator[None][source]
wolfgpu.glsimulation._gl_perf_counters[source]
wolfgpu.glsimulation._timers[source]
wolfgpu.glsimulation.time_it_gl(msg: str = None) Iterator[None][source]
wolfgpu.glsimulation._query_id[source]
wolfgpu.glsimulation.test_query_timer()[source]
wolfgpu.glsimulation.test_query_timer_end()[source]
wolfgpu.glsimulation._gl_queries_full[source]
wolfgpu.glsimulation.time_it_full(msg: str = None) Iterator[None][source]
wolfgpu.glsimulation.finish_timings()[source]
wolfgpu.glsimulation._perf_counters_full[source]
wolfgpu.glsimulation.finish_timings_full()[source]
wolfgpu.glsimulation.gl_timings_results(figname)[source]
wolfgpu.glsimulation.gl_timings_results_full()[source]
wolfgpu.glsimulation.log_mem_used(msg=None)[source]
wolfgpu.glsimulation.debug_framebuffer(framebuffer_id, color_attachment, width, height, format_, type_, title='', component=0)[source]
class wolfgpu.glsimulation.TileOptimisation[source]

Bases: enum.Enum

Inheritance diagram of wolfgpu.glsimulation.TileOptimisation

Generic enumeration.

Derive from this class to define new enumerations.

COMPUTE_SHADER = 1[source]
REGULAR_SHADER = 2[source]
wolfgpu.glsimulation.SHADER_PATH[source]
wolfgpu.glsimulation.make_quad_fast(xmin, xmax, ymin, ymax)[source]
wolfgpu.glsimulation.round_to_tile(x, round_func, tsize: int)[source]
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.divide_shape(shape)[source]
wolfgpu.glsimulation.integer_div(a, b)[source]
wolfgpu.glsimulation.find_active_tiles(a, tile_size=DEFAULT_TILE_SIZE)[source]
wolfgpu.glsimulation.isPowerOfTwo(x)[source]
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]
property nb_active_tiles[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]
property nbx[source]
property nby[source]
property tile_size[source]
property optimize_tile_indirection[source]
property total_number_of_dry_up_outer_loops[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]
set_track_flows_at_borders(v)[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_g(g)[source]
set_froude_limit(l)[source]

l = Froude max. If l is none, then we turn of froude limitation.

set_fixed_time_step(d)[source]
set_report_frequency(d: wolfgpu.simple_simulation.SimulationDuration)[source]
set_simulation_duration(d: wolfgpu.simple_simulation.SimulationDuration)[source]
set_courant(c)[source]
set_euler_ponderation()[source]

Disable Runge Kutta and let Euler be the scheme to use.

set_rk_ponderation(p)[source]
set_infiltration_interpolation(lerp: wolfgpu.simple_simulation.InfiltrationInterpolation)[source]
set_debug(dbg: bool)[source]
set_tiles_packing_mode(mode: wolfgpu.tile_packer.TilePackingMode)[source]
set_optim_geom_shaders(enable)[source]
_load_shaders()[source]
compute_time_step_for_tiles_phase1(current_quantity)[source]
compute_time_step_for_tiles_phase2(current_quantity)[source]
drop_gl_resources()[source]
reset_size(width: int, height: int)[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.

_create_debugging_textures()[source]
_gen_single_quad()[source]
_draw_active_parts_deprecated(program, x=None, y=None, w=None, h=None, zoom=None)[source]
_has_good_shape(a: wolfgpu.gl_utils.np.ndarray)[source]
set_tile_size(tile_size: int)[source]
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…

_tiles_ndc_dims()[source]
_draw_active_tiles(program, uniforms: dict, textures: dict, viewport=None)[source]
read_euler_step_result(tex=2)[source]

Returns a 3D array (q, qu, qv)

apply_strong_boundary_conditions(tex_out)[source]
active_infiltration_line(t: float) int[source]
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

set_no_dry(dummy)[source]

DEPRECATED !!!

emergency_save()[source]
dry_up_disabled()[source]
_handle_dry_up_iterations(program)[source]
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_debug_texture(tex=0)[source]
read_infiltration_map()[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_bathymetry()[source]
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

_clear_global_variables_buffer(sim_time, time_step)[source]
reset_globals(sim_time, time_step, step_num, h, qx, qy)[source]
Parameters:
  • time_step – the duration of the time step (in case you have a fixed time step)

  • step_num – The step number of the next computed simulation step.

compute_max_step_size2()[source]
plot_progress(current_quantity, zoom=1.0, mean=0.5, flip=True, gl_window_viewport=(0, 0, 100, 100))[source]
wolfgpu.glsimulation.set_border(array, value)[source]
wolfgpu.glsimulation.swimming_pool_with_hole_in_water()[source]
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]
wolfgpu.glsimulation.plot_evolution_of_simulation(path_to_model: wolfgpu.gl_utils.Path, path_to_results_store: wolfgpu.gl_utils.Path)[source]