Context type to hold velocity function pointers (eliminates trampoline need)
Abstract interface for velocity functions
Module-level context for current velocity functions (thread-unsafe but trampoline-free)
Module-level wrapper functions to eliminate trampolines
          
      
      
        
          Derived Types
              
    
    
      
        Components
          
    
      
        | Type | Visibility | Attributes |  | Name |  | Initial |  | 
    
        
            | procedure(velocity_function_interface), | public, | pointer, nopass | :: | u_func | => | null() |  | 
        
            | procedure(velocity_function_interface), | public, | pointer, nopass | :: | v_func | => | null() |  | 
        
            | logical, | public |  | :: | negate_functions | = | .false. | For backward integration | 
    
  
     
   
        
        
        
          Subroutines
              
    
    
          
  
  Arguments
      
    
      
        | Type | Intent | Optional | Attributes |  | Name |  | 
    
        
            | real, | intent(in), |  | dimension(:) | :: | x |  | 
        
            | real, | intent(in), |  | dimension(:) | :: | y |  | 
        
            | real, | intent(in) |  |  | :: | density |  | 
        
            | real, | intent(out), |  | allocatable | :: | seed_x(:) |  | 
        
            | real, | intent(out), |  | allocatable | :: | seed_y(:) |  | 
        
            | integer, | intent(out) |  |  | :: | n_seeds |  | 
    
  
     
   
              
    
    
          
  
  Arguments
      
    
      
        | Type | Intent | Optional | Attributes |  | Name |  | 
    
        
            | real, | intent(in) |  |  | :: | x0 |  | 
        
            | real, | intent(in) |  |  | :: | y0 |  | 
        
            | 
    private  function u_func(x, y)  
    Arguments
    
      
        | Type | Intent | Optional | Attributes |  | Name |  |  
            | real, | intent(in) |  |  | :: | x |  |  
            | real, | intent(in) |  |  | :: | y |  |  
    Return Value
    real
     | 
        
            | 
    private  function v_func(x, y)  
    Arguments
    
      
        | Type | Intent | Optional | Attributes |  | Name |  |  
            | real, | intent(in) |  |  | :: | x |  |  
            | real, | intent(in) |  |  | :: | y |  |  
    Return Value
    real
     | 
        
            | real, | intent(in) |  |  | :: | dt |  | 
        
            | integer, | intent(in) |  |  | :: | max_steps |  | 
        
            | real, | intent(out), |  | allocatable | :: | path_x(:) |  | 
        
            | real, | intent(out), |  | allocatable | :: | path_y(:) |  | 
        
            | integer, | intent(out) |  |  | :: | n_points |  | 
    
  
     
   
              
    
    
          
  High-accuracy streamline integration using DOPRI5 method
Provides adaptive step size control and superior accuracy
  Arguments
      
    
      
        | Type | Intent | Optional | Attributes |  | Name |  | 
    
        
            | real, | intent(in) |  |  | :: | x0 |  | 
        
            | real, | intent(in) |  |  | :: | y0 |  | 
        
            | 
    private  function u_func(x, y)  
    Arguments
    
      
        | Type | Intent | Optional | Attributes |  | Name |  |  
            | real, | intent(in) |  |  | :: | x |  |  
            | real, | intent(in) |  |  | :: | y |  |  
    Return Value
    real
     | 
        
            | 
    private  function v_func(x, y)  
    Arguments
    
      
        | Type | Intent | Optional | Attributes |  | Name |  |  
            | real, | intent(in) |  |  | :: | x |  |  
            | real, | intent(in) |  |  | :: | y |  |  
    Return Value
    real
     | 
        
            | type(integration_params_t), | intent(in), | optional |  | :: | params |  | 
        
            | real, | intent(in), | optional |  | :: | max_time |  | 
        
            | real, | intent(out), |  | allocatable | :: | path_x(:) |  | 
        
            | real, | intent(out), |  | allocatable | :: | path_y(:) |  | 
        
            | integer, | intent(out) |  |  | :: | n_points |  | 
    
  
     
   
              
    
    
          
  Calculate seed points using matplotlib-compatible spiral algorithm
with collision detection for proper streamline spacing
  Arguments
      
    
      
        | Type | Intent | Optional | Attributes |  | Name |  | 
    
        
            | real, | intent(in), |  | dimension(:) | :: | x |  | 
        
            | real, | intent(in), |  | dimension(:) | :: | y |  | 
        
            | real(kind=wp), | intent(in) |  |  | :: | density |  | 
        
            | real, | intent(out), |  | allocatable | :: | seed_x(:) |  | 
        
            | real, | intent(out), |  | allocatable | :: | seed_y(:) |  | 
        
            | integer, | intent(out) |  |  | :: | n_seeds |  | 
        
            | type(stream_mask_t), | intent(inout) |  |  | :: | mask |  | 
    
  
     
   
              
    
    
          
  Bidirectional streamline integration like matplotlib
Integrates both forward and backward from seed point for complete streamlines
  Arguments
      
    
      
        | Type | Intent | Optional | Attributes |  | Name |  | 
    
        
            | real, | intent(in) |  |  | :: | x0 |  | 
        
            | real, | intent(in) |  |  | :: | y0 |  | 
        
            | 
    private  function u_func(x, y)  
    Arguments
    
      
        | Type | Intent | Optional | Attributes |  | Name |  |  
            | real, | intent(in) |  |  | :: | x |  |  
            | real, | intent(in) |  |  | :: | y |  |  
    Return Value
    real
     | 
        
            | 
    private  function v_func(x, y)  
    Arguments
    
      
        | Type | Intent | Optional | Attributes |  | Name |  |  
            | real, | intent(in) |  |  | :: | x |  |  
            | real, | intent(in) |  |  | :: | y |  |  
    Return Value
    real
     | 
        
            | type(integration_params_t), | intent(in), | optional |  | :: | params |  | 
        
            | real, | intent(in), | optional |  | :: | max_time |  | 
        
            | real, | intent(out), |  | allocatable | :: | path_x(:) |  | 
        
            | real, | intent(out), |  | allocatable | :: | path_y(:) |  | 
        
            | integer, | intent(out) |  |  | :: | n_points |  | 
    
  
     
   
              
    
    
          
  
  Arguments
      
    
      
        | Type | Intent | Optional | Attributes |  | Name |  | 
    
        
            | real, | intent(in) |  |  | :: | x |  | 
        
            | real, | intent(in) |  |  | :: | y |  | 
        
            | 
    private  function u_func(x, y)  
    Arguments
    
      
        | Type | Intent | Optional | Attributes |  | Name |  |  
            | real, | intent(in) |  |  | :: | x |  |  
            | real, | intent(in) |  |  | :: | y |  |  
    Return Value
    real
     | 
        
            | 
    private  function v_func(x, y)  
    Arguments
    
      
        | Type | Intent | Optional | Attributes |  | Name |  |  
            | real, | intent(in) |  |  | :: | x |  |  
            | real, | intent(in) |  |  | :: | y |  |  
    Return Value
    real
     | 
        
            | real, | intent(in) |  |  | :: | dt |  | 
        
            | real, | intent(out) |  |  | :: | x_new |  | 
        
            | real, | intent(out) |  |  | :: | y_new |  | 
    
  
     
   
              
    
    
          
  
  Arguments
      
    
      
        | Type | Intent | Optional | Attributes |  | Name |  | 
    
        
            | real, | intent(in), |  | dimension(:) | :: | path_x |  | 
        
            | real, | intent(in), |  | dimension(:) | :: | path_y |  | 
        
            | integer, | intent(in) |  |  | :: | n_points |  | 
        
            | real, | intent(in) |  |  | :: | arrow_density |  | 
        
            | logical, | intent(out), |  | allocatable | :: | arrow_mask(:) |  | 
    
  
     
   
              
    
    
          
  
  Arguments
      
    
      
        | Type | Intent | Optional | Attributes |  | Name |  | 
    
        
            | real, | intent(in) |  |  | :: | x |  | 
        
            | real, | intent(in) |  |  | :: | y |  | 
        
            | real, | intent(in), |  | dimension(2) | :: | x_bounds |  | 
        
            | real, | intent(in), |  | dimension(2) | :: | y_bounds |  | 
        
            | logical, | intent(out) |  |  | :: | terminate |  | 
    
  
     
   
              
    
    
          
  
  Arguments
      
    
      
        | Type | Intent | Optional | Attributes |  | Name |  | 
    
        
            | real, | intent(in), |  | dimension(:) | :: | x_grid |  | 
        
            | real, | intent(in), |  | dimension(:) | :: | y_grid |  | 
        
            | real, | intent(in), |  | dimension(:,:) | :: | values |  | 
        
            | real, | intent(in) |  |  | :: | x |  | 
        
            | real, | intent(in) |  |  | :: | y |  | 
        
            | real, | intent(out) |  |  | :: | result |  |