Skip to content

File InitialConditions.cu

FileList > src > InitialConditions.cu

Go to the source code of this file

  • #include "InitialConditions.h"
  • #include "Input.h"

Public Functions

Type Name
void Calcbndblks (Param & XParam, Forcing< float > & XForcing, BlockP< T > XBlock)
Calculates the number of blocks on each boundary of the domain.
void FindTSoutNodes (Param & XParam, BlockP< T > XBlock, BndblockP< T > & bnd)
Finds and assigns output nodes to blocks for time series output.
template void FindTSoutNodes< double > (Param & XParam, BlockP< double > XBlock, BndblockP< double > & bnd)
template void FindTSoutNodes< float > (Param & XParam, BlockP< float > XBlock, BndblockP< float > & bnd)
void Findbndblks (Param XParam, Model< T > XModel, Forcing< float > & XForcing)
Finds which blocks on the model edge belong to a side boundary.
void Findoutzoneblks (Param & XParam, BlockP< T > & XBlock)
Finds and assigns blocks to output zones based on user-defined rectangular areas.
template void Findoutzoneblks< double > (Param & XParam, BlockP< double > & XBlock)
template void Findoutzoneblks< float > (Param & XParam, BlockP< float > & XBlock)
std::vector< double > GetTimeOutput (T_output time_info)
Creates a vector of output times from the input time structure.
void InitRivers (Param XParam, Forcing< float > & XForcing, Model< T > & XModel)
Initializes river discharge areas and assigns river information to model blocks.
template void InitRivers< double > (Param XParam, Forcing< float > & XForcing, Model< double > & XModel)
template void InitRivers< float > (Param XParam, Forcing< float > & XForcing, Model< float > & XModel)
void InitTSOutput (Param XParam)
Initializes time series output files for specified nodes.
void Initbndblks (Param & XParam, Forcing< float > & XForcing, BlockP< T > XBlock)
Initializes boundary block assignments and segment information.
void InitialConditions (Param & XParam, Forcing< float > & XForcing, Model< T > & XModel)
Initializes model parameters, bathymetry, friction, initial conditions, and output variables.
template void InitialConditions< double > (Param & XParam, Forcing< float > & XForcing, Model< double > & XModel)
template void InitialConditions< float > (Param & XParam, Forcing< float > & XForcing, Model< float > & XModel)
void Initmaparray (Model< T > & XModel)
Initializes output variable maps and metadata for the simulation.
template void Initmaparray< double > (Model< double > & XModel)
template void Initmaparray< float > (Model< float > & XModel)
void Initoutzone (Param & XParam, BlockP< T > & XBlock)
Initializes output zones for the simulation domain.
template void Initoutzone< double > (Param & XParam, BlockP< double > & XBlock)
template void Initoutzone< float > (Param & XParam, BlockP< float > & XBlock)
void InitzbgradientCPU (Param XParam, Model< T > XModel)
Initializes bathymetry gradient and halo on CPU.
template void InitzbgradientCPU< double > (Param XParam, Model< double > XModel)
template void InitzbgradientCPU< float > (Param XParam, Model< float > XModel)
void InitzbgradientGPU (Param XParam, Model< T > XModel)
Initializes bathymetry gradient and halo on GPU.
template void InitzbgradientGPU< double > (Param XParam, Model< double > XModel)
template void InitzbgradientGPU< float > (Param XParam, Model< float > XModel)
void RectCornerBlk (Param & XParam, BlockP< T > & XBlock, double xo, double yo, double xmax, double ymax, bool isEps, std::vector< int > & cornerblk)
Finds the blocks containing the corners of a rectangular box (for output zone definition).
void calcactiveCellCPU (Param XParam, BlockP< T > XBlock, Forcing< float > & XForcing, T * zb)
Calculates active cells in the domain based on mask elevation and area of interest.
__global__ void calcactiveCellGPU (Param XParam, BlockP< T > XBlock, T * zb)
CUDA kernel to calculate active cells on the GPU based on mask elevation.
void initOutputTimes (Param XParam, std::vector< double > & OutputT, BlockP< T > & XBlock)
Compiles and sorts output times for map outputs, including zone outputs.
void initinfiltration (Param XParam, BlockP< T > XBlock, T * h, T * initLoss, T * hgw)
Initializes infiltration loss array for each cell.
void initoutput (Param & XParam, Model< T > & XModel)
Initializes output arrays and maps for the simulation.

Public Functions Documentation

function Calcbndblks

Calculates the number of blocks on each boundary of the domain.

template<class T>
void Calcbndblks (
    Param & XParam,
    Forcing < float > & XForcing,
    BlockP < T > XBlock
) 

Updates counts for left, right, top, and bottom boundaries and stores them in the forcing and parameter structures.

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • XForcing Forcing data (float)
  • XBlock Block parameters

function FindTSoutNodes

Finds and assigns output nodes to blocks for time series output.

template<class T>
void FindTSoutNodes (
    Param & XParam,
    BlockP < T > XBlock,
    BndblockP < T > & bnd
) 

Determines which block each output node belongs to and updates the boundary block structure.

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • XBlock Block parameters
  • bnd Boundary block structure

function FindTSoutNodes< double >

template void FindTSoutNodes< double > (
    Param & XParam,
    BlockP < double > XBlock,
    BndblockP < double > & bnd
) 

function FindTSoutNodes< float >

template void FindTSoutNodes< float > (
    Param & XParam,
    BlockP < float > XBlock,
    BndblockP < float > & bnd
) 

function Findbndblks

Finds which blocks on the model edge belong to a side boundary.

template<class T>
void Findbndblks (
    Param XParam,
    Model < T > XModel,
    Forcing < float > & XForcing
) 

Populates arrays for blocks on each side boundary and updates the forcing structure.

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • XModel Model data
  • XForcing Forcing data (float)

Find which block on the model edge belongs to a "side boundary"


function Findoutzoneblks

Finds and assigns blocks to output zones based on user-defined rectangular areas.

template<class T>
void Findoutzoneblks (
    Param & XParam,
    BlockP < T > & XBlock
) 

Determines which blocks belong to each output zone, computes zone boundaries, and updates the block structure. Initialise all storage involving parameters of the outzone objects

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • XBlock Block parameters

function Findoutzoneblks< double >

template void Findoutzoneblks< double > (
    Param & XParam,
    BlockP < double > & XBlock
) 

function Findoutzoneblks< float >

template void Findoutzoneblks< float > (
    Param & XParam,
    BlockP < float > & XBlock
) 

function GetTimeOutput

Creates a vector of output times from the input time structure.

std::vector< double > GetTimeOutput (
    T_output time_info
) 

Combines independent values and time steps from the input structure.

Parameters:

  • time_info Time output structure

Returns:

Vector of output times


function InitRivers

Initializes river discharge areas and assigns river information to model blocks.

template<class T>
void InitRivers (
    Param XParam,
    Forcing < float > & XForcing,
    Model < T > & XModel
) 

Identifies grid cells affected by river discharge, calculates discharge areas, and sets up river-block relationships.

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • XForcing Forcing data (float)
  • XModel Model data

function InitRivers< double >

template void InitRivers< double > (
    Param XParam,
    Forcing < float > & XForcing,
    Model < double > & XModel
) 

function InitRivers< float >

template void InitRivers< float > (
    Param XParam,
    Forcing < float > & XForcing,
    Model < float > & XModel
) 

function InitTSOutput

Initializes time series output files for specified nodes.

void InitTSOutput (
    Param XParam
) 

Creates and overwrites output files for each node in the time series output list.

Parameters:

  • XParam Simulation parameters

function Initbndblks

Initializes boundary block assignments and segment information.

template<class T>
void Initbndblks (
    Param & XParam,
    Forcing < float > & XForcing,
    BlockP < T > XBlock
) 

Finds boundary blocks, assigns them to segments, and allocates arrays for segment sides and flow.

  • Initialise bnd blk assign block to their relevant segment allocate memory...

  • Find all the boundary blocks(block with themselves as neighbours)

  • make an array to store which segment they belong to

If any bnd segment was specified * scan each block and find which (if any) segment they belong to For each segment Calculate bbox if inbbox calc inpoly if inpoly overwrite assingned segment with new one * Calculate nblk per segment & allocate (do for each segment) * fill segment and side arrays for each segments

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • XForcing Forcing data (float)
  • XBlock Block parameters

function InitialConditions

Initializes model parameters, bathymetry, friction, initial conditions, and output variables.

template<class T>
void InitialConditions (
    Param & XParam,
    Forcing < float > & XForcing,
    Model < T > & XModel
) 

Sets up the initial state of the simulation, including bathymetry, friction maps, evolving variables, river forcing, boundary blocks, active cells, and output arrays.

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • XForcing Forcing data (float)
  • XModel Model data

function InitialConditions< double >

template void InitialConditions< double > (
    Param & XParam,
    Forcing < float > & XForcing,
    Model < double > & XModel
) 

function InitialConditions< float >

template void InitialConditions< float > (
    Param & XParam,
    Forcing < float > & XForcing,
    Model < float > & XModel
) 

function Initmaparray

Initializes output variable maps and metadata for the simulation.

template<class T>
void Initmaparray (
    Model < T > & XModel
) 

Sets up output variable names, units, and long names for all tracked quantities in the model.

Template parameters:

  • T Data type

Parameters:


function Initmaparray< double >

template void Initmaparray< double > (
    Model < double > & XModel
) 

function Initmaparray< float >

template void Initmaparray< float > (
    Model < float > & XModel
) 

function Initoutzone

Initializes output zones for the simulation domain.

template<class T>
void Initoutzone (
    Param & XParam,
    BlockP < T > & XBlock
) 

Sets up output zones based on user input or defaults to the full domain if none specified.

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • XBlock Block parameters

function Initoutzone< double >

template void Initoutzone< double > (
    Param & XParam,
    BlockP < double > & XBlock
) 

function Initoutzone< float >

template void Initoutzone< float > (
    Param & XParam,
    BlockP < float > & XBlock
) 

function InitzbgradientCPU

Initializes bathymetry gradient and halo on CPU.

template<class T>
void InitzbgradientCPU (
    Param XParam,
    Model < T > XModel
) 

Computes gradients and refines bathymetry for the model blocks on the CPU.

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • XModel Model data

function InitzbgradientCPU< double >

template void InitzbgradientCPU< double > (
    Param XParam,
    Model < double > XModel
) 

function InitzbgradientCPU< float >

template void InitzbgradientCPU< float > (
    Param XParam,
    Model < float > XModel
) 

function InitzbgradientGPU

Initializes bathymetry gradient and halo on GPU.

template<class T>
void InitzbgradientGPU (
    Param XParam,
    Model < T > XModel
) 

Computes gradients and refines bathymetry for the model blocks using CUDA streams and kernels.

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • XModel Model data

function InitzbgradientGPU< double >

template void InitzbgradientGPU< double > (
    Param XParam,
    Model < double > XModel
) 

function InitzbgradientGPU< float >

template void InitzbgradientGPU< float > (
    Param XParam,
    Model < float > XModel
) 

function RectCornerBlk

Finds the blocks containing the corners of a rectangular box (for output zone definition).

template<class T>
void RectCornerBlk (
    Param & XParam,
    BlockP < T > & XBlock,
    double xo,
    double yo,
    double xmax,
    double ymax,
    bool isEps,
    std::vector< int > & cornerblk
) 

Returns indices of blocks through "cornerblk" at the corners of the rectangle, starting from bottom left and turning clockwise.

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • XBlock Block parameters
  • xo X start
  • yo Y start
  • xmax X end
  • ymax Y end
  • isEps Whether to use epsilon margin
  • cornerblk Vector to store corner block indices

Find the block containing the border of a rectangular box (used for the defining the output zones) The indice of the blocks are returned through "cornerblk" from bottom left turning in the clockwise direction


function calcactiveCellCPU

Calculates active cells in the domain based on mask elevation and area of interest.

template<class T>
void calcactiveCellCPU (
    Param XParam,
    BlockP < T > XBlock,
    Forcing < float > & XForcing,
    T * zb
) 

Sets the active cell flag for each cell, removing rain from masked and boundary cells as needed.

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • XBlock Block parameters
  • XForcing Forcing data (float)
  • zb Bathymetry array

function calcactiveCellGPU

CUDA kernel to calculate active cells on the GPU based on mask elevation.

template<class T>
__global__ void calcactiveCellGPU (
    Param XParam,
    BlockP < T > XBlock,
    T * zb
) 

Sets the active cell flag for each cell in the block using GPU parallelism.

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • XBlock Block parameters
  • zb Bathymetry array

function initOutputTimes

Compiles and sorts output times for map outputs, including zone outputs.

template<class T>
void initOutputTimes (
    Param XParam,
    std::vector< double > & OutputT,
    BlockP < T > & XBlock
) 

Combines times from the main output structure and all zone outputs, sorts and removes duplicates, and assigns to output arrays.

Creation of a vector for times requiering a map output Compilations of vectors and independent times from the general input and the different zones outputs

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • OutputT Output times vector
  • XBlock Block parameters

function initinfiltration

Initializes infiltration loss array for each cell.

template<class T>
void initinfiltration (
    Param XParam,
    BlockP < T > XBlock,
    T * h,
    T * initLoss,
    T * hgw
) 

Sets initial infiltration loss to zero for wet cells.

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • XBlock Block parameters
  • h Water depth array
  • initLoss Initial loss array
  • hgw Groundwater head array

function initoutput

Initializes output arrays and maps for the simulation.

template<class T>
void initoutput (
    Param & XParam,
    Model < T > & XModel
) 

Sets up storage for evolving parameters, output zones, and output files.

Template parameters:

  • T Data type

Parameters:

  • XParam Simulation parameters
  • XModel Model data


The documentation for this class was generated from the following file src/InitialConditions.cu