slm: OpenCL code base  0.1
Functions
Runge-Kutta integration step functions

Functions used to compute Runge-Kutta integration down and up streamlines. More...

Functions

static bool runge_kutta_step_record (float *dt, float *dl, float *l_trajectory, float2 *dxy1_vec, float2 *dxy2_vec, float2 *vec, float2 *prev_vec, float2 *next_vec, uint *n_steps, uint *idx, uint *prev_idx, __global char2 *trajectory_vec)
 Compute a single step of 2nd-order Runge-Kutta numerical integration of a streamline given precomputed 1st and 2nd order step vectors. More...
 
static void euler_step_record (float *dt, float *dl, float *l_trajectory, const float2 uv_vec, float2 *vec, const float2 prev_vec, uint *n_steps, __global char2 *trajectory_vec)
 Compute a single Euler integration step of of a streamline. More...
 
static bool runge_kutta_step_write_sl_data (float *dt, float *dl, float *l_trajectory, float2 *dxy1_vec, float2 *dxy2_vec, float2 *vec, float2 *prev_vec, const float2 next_vec, uint *n_steps, uint *idx, uint *prev_idx, __global const bool *mask_array, __global uint *slt_array, __global uint *slc_array)
 Compute a single step of 2nd-order Runge-Kutta numerical integration of a streamline given precomputed 1st and 2nd order step vectors. More...
 
static void euler_step_write_sl_data (float *dt, float *dl, float *l_trajectory, const float2 uv_vec, float2 *vec, const float2 prev_vec, uint *n_steps, uint *idx, uint *prev_idx, __global const bool *mask_array, __global uint *slt_array, __global uint *slc_array)
 Compute a single Euler integration step of of a streamline. More...
 
static bool connect_runge_kutta_step_record (float *dt, float *dl, float *l_trajectory, float2 *dxy1_vec, float2 *dxy2_vec, float2 *vec, float2 *prev_vec, float2 *next_vec, uint *n_steps, uint *idx, uint *prev_idx, __private char2 *trajectory_vec)
 Compute a single step of 2nd-order Runge-Kutta numerical integration of a streamline given precomputed 1st and 2nd order step vectors. More...
 
static void channelheads_runge_kutta_step (float *dt, float *dl, float2 *dxy1_vec, float2 *dxy2_vec, float2 *vec, float2 *next_vec, uint *n_steps, uint *idx)
 Compute a single step of 2nd-order Runge-Kutta numerical integration of a streamline given precomputed 1st and 2nd order step vectors. More...
 
static bool countlink_runge_kutta_step (float *dt, float *dl, float2 *dxy1_vec, float2 *dxy2_vec, float2 *vec, float2 *next_vec, uint *idx, __global uint *mapping_array)
 Compute a single step of 2nd-order Runge-Kutta numerical integration of a streamline given precomputed 1st and 2nd order step vectors. More...
 
static bool segment_runge_kutta_step (float *dt, float *dl, float2 *dxy1_vec, float2 *dxy2_vec, float2 *vec, float2 *next_vec, uint *n_steps, uint *idx)
 Compute a single step of 2nd-order Runge-Kutta numerical integration of a streamline given precomputed 1st and 2nd order step vectors. More...
 
static bool lengths_runge_kutta_step (float *dt, float *dl, float *l_trajectory, float2 *dxy1_vec, float2 *dxy2_vec, float2 *vec, float2 *prev_vec, float2 *next_vec, uint *n_steps, uint *idx)
 Compute a single step of 2nd-order Runge-Kutta numerical integration of a streamline given precomputed 1st and 2nd order step vectors. More...
 

Detailed Description

Functions used to compute Runge-Kutta integration down and up streamlines.

Function Documentation

◆ channelheads_runge_kutta_step()

static void channelheads_runge_kutta_step ( float *  dt,
float *  dl,
float2 *  dxy1_vec,
float2 *  dxy2_vec,
float2 *  vec,
float2 *  next_vec,
uint *  n_steps,
uint *  idx 
)
inlinestatic

Compute a single step of 2nd-order Runge-Kutta numerical integration of a streamline given precomputed 1st and 2nd order step vectors.

Increment the step counter n_steps and update the idx of the new vec.

Compiled if KERNEL_INTEGRATE_TRAJECTORY is defined.

Parameters
[in,out]dtdelta time step
[in,out]dlstep distance
[in,out]dxy1_vecR-K first order delta step vector
[in,out]dxy2_vecR-K second order delta step vector
[in,out]veccurrent (x,y) coordinate vector at tip of streamline trajectory
[in,out]next_vecnext (x,y) coordinate vector on streamline trajectory
[in,out]n_stepsnumber of integration steps so far in streamline trajectory
[in,out]idxarray index of pixel at current (x,y) position
Return values
booltrue if stuck (step length less than INTEGRATION_HALT_THRESHOLD); false otherwise aka step computed well

Definition at line 335 of file integrationfns.cl.

◆ connect_runge_kutta_step_record()

static bool connect_runge_kutta_step_record ( float *  dt,
float *  dl,
float *  l_trajectory,
float2 *  dxy1_vec,
float2 *  dxy2_vec,
float2 *  vec,
float2 *  prev_vec,
float2 *  next_vec,
uint *  n_steps,
uint *  idx,
uint *  prev_idx,
__private char2 *  trajectory_vec 
)
inlinestatic

Compute a single step of 2nd-order Runge-Kutta numerical integration of a streamline given precomputed 1st and 2nd order step vectors.

If the step is deemed too small, return true = stuck; otherwise return false = ok. Record this step in the private trajectory_vec (array of step vectors). Also update the total streamline length l_trajectory and increment the step counter n_steps. In addition, push the current vec to the prev_vec, push the current idx to the prev_idx, and update the idx of the current vec.

Compiled if KERNEL_CONNECT_CHANNELS is defined.

Parameters
[in,out]dtdelta time step
[in,out]dlstep distance
[in,out]l_trajectorytotal streamline distance so far
[in,out]dxy1_vecR-K first order delta step vector
[in,out]dxy2_vecR-K second order delta step vector
[in,out]veccurrent (x,y) coordinate vector at tip of streamline trajectory
[in,out]prev_vecprevious (x,y) coordinate vector on streamline trajectory
[in,out]next_vecnext (x,y) coordinate vector on streamline trajectory
[in,out]n_stepsnumber of integration steps so far in streamline trajectory
[in,out]idxarray index of pixel at current (x,y) position
[in,out]prev_idxarray index of pixel at previous (x,y) position
[in,out]trajectory_vecstreamline trajectory record (2d array of compressed (x,y) vectors)
Return values
booltrue if stuck (step length less than INTEGRATION_HALT_THRESHOLD); false otherwise aka step computed well

Definition at line 280 of file integrationfns.cl.

◆ countlink_runge_kutta_step()

static bool countlink_runge_kutta_step ( float *  dt,
float *  dl,
float2 *  dxy1_vec,
float2 *  dxy2_vec,
float2 *  vec,
float2 *  next_vec,
uint *  idx,
__global uint *  mapping_array 
)
inlinestatic

Compute a single step of 2nd-order Runge-Kutta numerical integration of a streamline given precomputed 1st and 2nd order step vectors.

If the step is deemed too small, return true = stuck; otherwise return false = ok. In addition, flag the mapping_array pixel as IS_STUCK. Update the idx of the current (new) vec.

Compiled if KERNEL_COUNT_DOWNCHANNELS or KERNEL_LINK_HILLSLOPES is defined.

Parameters
[in,out]dtdelta time step
[in,out]dlstep distance
[in,out]dxy1_vecR-K first order delta step vector
[in,out]dxy2_vecR-K second order delta step vector
[in,out]veccurrent (x,y) coordinate vector at tip of streamline trajectory
[in,out]next_vecnext (x,y) coordinate vector on streamline trajectory
[in,out]idxarray index of pixel at current (x,y) position
[in,out]mapping_arrayflag grid recording status of each pixel (padded)
Return values
booltrue if stuck (step length less than INTEGRATION_HALT_THRESHOLD); false otherwise aka step computed well

Definition at line 382 of file integrationfns.cl.

◆ euler_step_record()

static void euler_step_record ( float *  dt,
float *  dl,
float *  l_trajectory,
const float2  uv_vec,
float2 *  vec,
const float2  prev_vec,
uint *  n_steps,
__global char2 *  trajectory_vec 
)
inlinestatic

Compute a single Euler integration step of of a streamline.

Record this step in the global trajectory_vec (array of step vectors). Also update the total streamline length l_trajectory and increment the step counter n_steps.

Compiled if KERNEL_INTEGRATE_TRAJECTORY is defined.

Parameters
[in,out]dtdelta time step
[in,out]dlstep distance
[in,out]l_trajectorytotal streamline distance so far
[in]uv_vecflow velocity vector interpolated to current position
[in,out]veccurrent (x,y) coordinate vector at tip of streamline trajectory
[in]prev_vecprevious (x,y) coordinate vector on streamline trajectory
[in,out]n_stepsnumber of integration steps so far in streamline trajectory
[in,out]trajectory_vecstreamline trajectory record (2d array of compressed (x,y) vectors)
Return values
booltrue if stuck (step length less than INTEGRATION_HALT_THRESHOLD); false otherwise aka step computed well

Definition at line 103 of file integrationfns.cl.

◆ euler_step_write_sl_data()

static void euler_step_write_sl_data ( float *  dt,
float *  dl,
float *  l_trajectory,
const float2  uv_vec,
float2 *  vec,
const float2  prev_vec,
uint *  n_steps,
uint *  idx,
uint *  prev_idx,
__global const bool *  mask_array,
__global uint *  slt_array,
__global uint *  slc_array 
)
inlinestatic

Compute a single Euler integration step of of a streamline.

Record this step in the global trajectory_vec (array of step vectors). Also update the total streamline length l_trajectory and increment the step counter n_steps.

Compiled if KERNEL_INTEGRATE_TRAJECTORY is defined.

Parameters
[in,out]dtdelta time step
[in,out]dlstep distance
[in,out]l_trajectorytotal streamline distance so far
[in]uv_vecflow velocity vector interpolated to current position
[in,out]veccurrent (x,y) coordinate vector at tip of streamline trajectory
[in]prev_vecprevious (x,y) coordinate vector on streamline trajectory
[in,out]n_stepsnumber of integration steps so far in streamline trajectory
[in,out]idxarray index of pixel at current (x,y) position
[in,out]prev_idxarray index of pixel at previous (x,y) position
[in]mask_arraygrid pixel mask (padded), with true = masked, false = good
[in,out]slc_arraygrid recording accumulated count of streamline integration steps across each pixel (padded)
[in,out]slt_arraygrid recording accumulated count of streamline segment lengths crossing each pixel (padded)
Return values
booltrue if stuck (step length less than INTEGRATION_HALT_THRESHOLD); false otherwise aka step computed well

Definition at line 219 of file integrationfns.cl.

◆ lengths_runge_kutta_step()

static bool lengths_runge_kutta_step ( float *  dt,
float *  dl,
float *  l_trajectory,
float2 *  dxy1_vec,
float2 *  dxy2_vec,
float2 *  vec,
float2 *  prev_vec,
float2 *  next_vec,
uint *  n_steps,
uint *  idx 
)
inlinestatic

Compute a single step of 2nd-order Runge-Kutta numerical integration of a streamline given precomputed 1st and 2nd order step vectors.

If the step is deemed too small, return true = stuck; otherwise return false = ok. Also update the total streamline length l_trajectory and increment the step counter n_steps. In addition, push the current vec to the prev_vec and update the idx of the current vec.

Compiled if KERNEL_HILLSLOPE_LENGTHS is defined.

Parameters
[in,out]dtdelta time step
[in,out]dlstep distance
[in,out]l_trajectorytotal streamline distance so far
[in,out]dxy1_vecR-K first order delta step vector
[in,out]dxy2_vecR-K second order delta step vector
[in,out]veccurrent (x,y) coordinate vector at tip of streamline trajectory
[in,out]prev_vecprevious (x,y) coordinate vector on streamline trajectory
[in,out]next_vecnext (x,y) coordinate vector on streamline trajectory
[in,out]n_stepsnumber of integration steps so far in streamline trajectory
[in,out]idxarray index of pixel at current (x,y) position
Return values
booltrue if stuck (step length less than INTEGRATION_HALT_THRESHOLD); false otherwise aka step computed well

Definition at line 487 of file integrationfns.cl.

◆ runge_kutta_step_record()

static bool runge_kutta_step_record ( float *  dt,
float *  dl,
float *  l_trajectory,
float2 *  dxy1_vec,
float2 *  dxy2_vec,
float2 *  vec,
float2 *  prev_vec,
float2 *  next_vec,
uint *  n_steps,
uint *  idx,
uint *  prev_idx,
__global char2 *  trajectory_vec 
)
inlinestatic

Compute a single step of 2nd-order Runge-Kutta numerical integration of a streamline given precomputed 1st and 2nd order step vectors.

If the step is deemed too small, return true = stuck; otherwise return false = ok. Record this step in the global trajectory_vec (array of step vectors). Also update the total streamline length l_trajectory and increment the step counter n_steps. In addition, push the current vec to the prev_vec, push the current idx to the prev_idx, and update the idx of the current vec.

Compiled if KERNEL_INTEGRATE_TRAJECTORY is defined.

Parameters
[in,out]dtdelta time step
[in,out]dlstep distance
[in,out]l_trajectorytotal streamline distance so far
[in,out]dxy1_vecR-K first order delta step vector
[in,out]dxy2_vecR-K second order delta step vector
[in,out]veccurrent (x,y) coordinate vector at tip of streamline trajectory
[in,out]prev_vecprevious (x,y) coordinate vector on streamline trajectory
[in,out]next_vecnext (x,y) coordinate vector on streamline trajectory
[in,out]n_stepsnumber of integration steps so far in streamline trajectory
[in,out]idxarray index of pixel at current (x,y) position
[in,out]prev_idxarray index of pixel at previous (x,y) position
[in,out]trajectory_vecstreamline trajectory record (2d array of compressed (x,y) vectors)
Return values
booltrue if stuck (step length less than INTEGRATION_HALT_THRESHOLD); false otherwise aka step computed well

Definition at line 49 of file integrationfns.cl.

◆ runge_kutta_step_write_sl_data()

static bool runge_kutta_step_write_sl_data ( float *  dt,
float *  dl,
float *  l_trajectory,
float2 *  dxy1_vec,
float2 *  dxy2_vec,
float2 *  vec,
float2 *  prev_vec,
const float2  next_vec,
uint *  n_steps,
uint *  idx,
uint *  prev_idx,
__global const bool *  mask_array,
__global uint *  slt_array,
__global uint *  slc_array 
)
inlinestatic

Compute a single step of 2nd-order Runge-Kutta numerical integration of a streamline given precomputed 1st and 2nd order step vectors.

If the step is deemed too small, return true = stuck; otherwise return false = ok. Record this step in the global slt_array and slc_array (streamline length total and count total respectively) by updating both at the current pixel (using mask_array to block where masked). Also update the total streamline length l_trajectory and increment the step counter n_steps. In addition, push the current vec to the prev_vec, push the current idx to the prev_idx, and update the idx of the current vec.

Compiled if KERNEL_INTEGRATE_TRAJECTORY is defined.

Parameters
[in,out]dtdelta time step
[in,out]dlstep distance
[in,out]l_trajectorytotal streamline distance so far
[in,out]dxy1_vecR-K first order delta step vector
[in,out]dxy2_vecR-K second order delta step vector
[in,out]veccurrent (x,y) coordinate vector at tip of streamline trajectory
[in,out]prev_vecprevious (x,y) coordinate vector on streamline trajectory
[in]next_vecnext (x,y) coordinate vector on streamline trajectory
[in,out]n_stepsnumber of integration steps so far in streamline trajectory
[in,out]idxarray index of pixel at current (x,y) position
[in,out]prev_idxarray index of pixel at previous (x,y) position
[in]mask_arraygrid pixel mask (padded), with true = masked, false = good
[in,out]slc_arraygrid recording accumulated count of streamline integration steps across each pixel (padded)
[in,out]slt_arraygrid recording accumulated count of streamline segment lengths crossing each pixel (padded)
Return values
booltrue if stuck (step length less than INTEGRATION_HALT_THRESHOLD); false otherwise aka step computed well

Definition at line 162 of file integrationfns.cl.

◆ segment_runge_kutta_step()

static bool segment_runge_kutta_step ( float *  dt,
float *  dl,
float2 *  dxy1_vec,
float2 *  dxy2_vec,
float2 *  vec,
float2 *  next_vec,
uint *  n_steps,
uint *  idx 
)
inlinestatic

Compute a single step of 2nd-order Runge-Kutta numerical integration of a streamline given precomputed 1st and 2nd order step vectors.

If the step is deemed too small, return true = stuck; otherwise return false = ok. Increment the step counter n_steps and update the idx of the new (next) vec.

Compiled if KERNEL_SEGMENT_HILLSLOPES or KERNEL_SUBSEGMENT_FLANKS is defined.

Parameters
[in,out]dtdelta time step
[in,out]dlstep distance
[in,out]dxy1_vecR-K first order delta step vector
[in,out]dxy2_vecR-K second order delta step vector
[in,out]veccurrent (x,y) coordinate vector at tip of streamline trajectory
[in,out]next_vecnext (x,y) coordinate vector on streamline trajectory
[in,out]n_stepsnumber of integration steps so far in streamline trajectory
[in,out]idxarray index of pixel at current (x,y) position
Return values
booltrue if stuck (step length less than INTEGRATION_HALT_THRESHOLD); false otherwise aka step computed well

Definition at line 432 of file integrationfns.cl.