File ReadForcing.cu
FileList > src > ReadForcing.cu
Go to the source code of this file
#include "ReadForcing.h"
Public Functions
| Type | Name |
|---|---|
| std::vector< std::string > | DelimLine (std::string line, int n, char delim) Split a string into a vector of substrings based on a specified delimiter. |
| std::vector< std::string > | DelimLine (std::string line, int n) Split a string into a vector of substrings based on common delimiters (tab, space, comma). Tries tab, space, and comma as delimiters and returns the first successful split with the expected number of elements. |
| void | InitDynforcing (bool gpgpu, Param & XParam, DynForcingP< float > & Dforcing) Initialize dynamic forcing data (Rain, wind, Atm pressure). |
| void | clampedges (int nx, int ny, T clamp, T * z) Clamp the edges of a 2D array to a specified value. Sets the values at the edges of a 2D array to a specified clamp value. |
| void | denan (int nx, int ny, float denanval, T * z) Replace NaN values in a 2D array with a specified value. Iterates through a 2D array and replaces any NaN values with the specified denanval. |
| void | denan (int nx, int ny, float denanval, int * z) |
| template void | denan< double > (int nx, int ny, float denanval, double * z) |
| template void | denan< float > (int nx, int ny, float denanval, float * z) |
| std::string | readCRSfrombathy (std::string crs_ref, StaticForcingP< float > & Sforcing) Read CRS information from bathymetry file metadata (last one read). Reads CRS information from the metadata of the specified bathymetry file. |
| void | readDynforcing (bool gpgpu, double totaltime, DynForcingP< float > & Dforcing) Deprecated function (!!!) to read dynamic forcing data for a given time. |
| std::vector< Flowin > | readFlowfile (std::string Flowfilename, std::string & refdate) Read flow data from a specified file, for river forcing for example. Reads flow data from a specified file and extracts time and flow rate information. Applies reference date adjustment if provided. |
| std::vector< Windin > | readINfileUNI (std::string filename, std::string & refdate) Read rain/atmospheric pressure data from a specified file for spatially uniform forcing. Reads rain/atmospheric pressure data from a specified file and extracts time and wind speed information. Applies reference date adjustment if provided. |
| std::vector< SLTS > | readNestfile (std::string ncfile, std::string varname, int hor, double eps, double bndxo, double bndxmax, double bndy) Read boundary nesting data from a NetCDF file. Reads boundary nesting data from a specified NetCDF file and variable name. Supports both horizontal and vertical boundaries. |
| Polygon | readPolygon (std::string filename) Read polygon from a specified file. Reads polygon vertices from a specified file and ensures the polygon is closed. Calculates bounding box of the polygon. |
| std::vector< SLTS > | readWLfile (std::string WLfilename, std::string & refdate) Read water level boundary file. Reads water level boundary file and extracts time and water level data. Applies reference date adjustment if provided. |
| std::vector< Windin > | readWNDfileUNI (std::string filename, std::string & refdate, double grdalpha) Read wind data from a specified file for spatially uniform forcing. Reads wind data from a specified file and extracts time, wind speed, wind direction, and calculates u and v wind components. Applies reference date adjustment if provided. __ |
| void | readXBbathy (std::string filename, int nx, int ny, T *& zb) Read bathymetry data from an XBeach-style .bot/.dep file into a provided array. Parses the file format and fills the provided array with bathymetry values. |
| template void | readXBbathy< float > (std::string filename, int nx, int ny, float *& zb) |
| template void | readXBbathy< int > (std::string filename, int nx, int ny, int *& zb) |
| void | readbathyASCHead (std::string filename, int & nx, int & ny, double & dx, double & xo, double & yo, double & grdalpha) Read header information from an ASC (bathymetry) file. Extracts grid size (nx, ny), grid spacing (dx), origin (xo, yo), and grid rotation angle (grdalpha). Adjusts origin if the file uses corner registration. |
| void | readbathyASCzb (std::string filename, int nx, int ny, T *& zb) Read (bathymetry) data from an ASC file into a provided array. Parses the ASC file format and fills the provided array with bathymetry values. |
| template void | readbathyASCzb< float > (std::string filename, int nx, int ny, float *& zb) |
| template void | readbathyASCzb< int > (std::string filename, int nx, int ny, int *& zb) |
| void | readbathyHeadMD (std::string filename, int & nx, int & ny, double & dx, double & grdalpha) Read header information from an MD bathymetry file (or other MD input map). Extracts grid size (nx, ny), grid spacing (dx), and grid rotation angle (grdalpha). |
| void | readbathyMD (std::string filename, T *& zb) Read bathymetry data from an MD file into a provided array. Parses the MD file format and fills the provided array with bathymetry values. __ |
| template void | readbathyMD< float > (std::string filename, float *& zb) |
| template void | readbathyMD< int > (std::string filename, int *& zb) |
| void | readbathydata (int posdown, StaticForcingP< float > & Sforcing) Read bathymetry data and apply corrections if needed. |
| std::vector< SLTS > | readbndfile (std::string filename, Param & XParam) Read boundary forcing files (water levels or nest files). |
| Polygon | readbndpolysegment (bndsegment bnd, Param XParam) Read boundary polygon segment and create polygon structure. |
| void | readforcing (Param & XParam, Forcing< T > & XForcing) Wrapping function for reading all the forcing data. |
| template void | readforcing< float > (Param & XParam, Forcing< float > & XForcing) |
| void | readforcingdata (int step, T forcing) Read static forcing data from various file formats based on the file extension. Supports reading from .md, .nc, .bot/.dep, and .asc files. |
| void | readforcingdata (double totaltime, DynForcingP< float > & forcing) Read dynamic forcing data from a NetCDF file based on the current simulation time. Interpolates between time steps to obtain the current forcing values. Handles NaN values and clamps edges if specified. |
| template void | readforcingdata< StaticForcingP< float > > (int step, StaticForcingP< float > forcing) |
| template void | readforcingdata< StaticForcingP< int > > (int step, StaticForcingP< int > forcing) |
| template void | readforcingdata< deformmap< float > > (int step, deformmap< float > forcing) |
| DynForcingP< float > | readforcinghead (DynForcingP< float > Fmap, Param XParam) Read dynamic forcing metadata/header from a NetCDF file. Extracts grid size, spacing, origin, and time information. |
| T | readforcinghead (T ForcingParam) Read static forcing metadata/header from various file formats based on the file extension. Supports reading from .md, .nc, .bot/.dep, and .asc files. Extracts grid size, spacing, origin, and other relevant information. __ |
| template StaticForcingP< float > | readforcinghead< StaticForcingP< float > > (StaticForcingP< float > ForcingParam) |
| template forcingmap | readforcinghead< forcingmap > (forcingmap BathyParam) |
| template inputmap | readforcinghead< inputmap > (inputmap BathyParam) |
| void | readstaticforcing (T & Sforcing) Single parameter version of readstaticforcing(int step, T& Sforcing). |
| void | readstaticforcing (int step, T & Sforcing) Allocate and read static (i.e. not varying in time) forcing data. Used for Bathymetry, roughness, deformation, etc. |
| template void | readstaticforcing< StaticForcingP< float > > (StaticForcingP< float > & Sforcing) |
| template void | readstaticforcing< StaticForcingP< float > > (int step, StaticForcingP< float > & Sforcing) |
| template void | readstaticforcing< StaticForcingP< int > > (StaticForcingP< int > & Sforcing) |
| template void | readstaticforcing< StaticForcingP< int > > (int step, StaticForcingP< int > & Sforcing) |
| template void | readstaticforcing< deformmap< float > > (deformmap< float > & Sforcing) |
| template void | readstaticforcing< deformmap< float > > (int step, deformmap< float > & Sforcing) |
Public Functions Documentation
function DelimLine
Split a string into a vector of substrings based on a specified delimiter.
Parameters:
sThe input string to be splitdelimThe delimiter character used for splitting
Returns:
Vector of substrings
function DelimLine
Split a string into a vector of substrings based on common delimiters (tab, space, comma). Tries tab, space, and comma as delimiters and returns the first successful split with the expected number of elements.
Parameters:
lineThe input string to be splitnThe expected number of elements after splitting
Returns:
Vector of substrings if successful; empty vector otherwise
function InitDynforcing
Initialize dynamic forcing data (Rain, wind, Atm pressure).
Reads dynamic forcing header and allocates memory for dynamic forcing arrays.
Parameters:
gpgpuUse GPU accelerationXParamModel parametersDforcingDynamic forcing structure
function clampedges
Clamp the edges of a 2D array to a specified value. Sets the values at the edges of a 2D array to a specified clamp value.
Parameters:
nxNumber of grid points in the x-directionnyNumber of grid points in the y-directionclampValue to set at the edgeszPointer to the 2D array (flattened as 1D) to be modified
function denan
Replace NaN values in a 2D array with a specified value. Iterates through a 2D array and replaces any NaN values with the specified denanval.
Parameters:
nxNumber of grid points in the x-directionnyNumber of grid points in the y-directiondenanvalValue to replace NaN values withzPointer to the 2D array (flattened as 1D) to be modified
function denan
function denan< double >
function denan< float >
function readCRSfrombathy
Read CRS information from bathymetry file metadata (last one read). Reads CRS information from the metadata of the specified bathymetry file.
Parameters:
crs_refReference to the CRS stringSforcingStatic forcing structure
Returns:
CRS WKT string
function readDynforcing
Deprecated function (!!!) to read dynamic forcing data for a given time.
Reads and allocates dynamic forcing arrays for the specified time.
Parameters:
gpgpuUse GPU accelerationtotaltimeCurrent simulation timeDforcingDynamic forcing structure
This is a deprecated function! See InitDynforcing() instead
function readFlowfile
Read flow data from a specified file, for river forcing for example. Reads flow data from a specified file and extracts time and flow rate information. Applies reference date adjustment if provided.
Parameters:
FlowfilenameName of the flow data filerefdateReference date for time adjustment
Returns:
Vector of Flowin structures containing time and flow rate data
function readINfileUNI
Read rain/atmospheric pressure data from a specified file for spatially uniform forcing. Reads rain/atmospheric pressure data from a specified file and extracts time and wind speed information. Applies reference date adjustment if provided.
Parameters:
filenameName of the rain/atmospheric pressure data filerefdateReference date for time adjustment
Returns:
Vector of Windin structures containing time and wind speed data
function readNestfile
Read boundary nesting data from a NetCDF file. Reads boundary nesting data from a specified NetCDF file and variable name. Supports both horizontal and vertical boundaries.
std::vector< SLTS > readNestfile (
std::string ncfile,
std::string varname,
int hor,
double eps,
double bndxo,
double bndxmax,
double bndy
)
Parameters:
ncfileName of the NetCDF filevarnameName of the variable to readhorIf 1, read horizontal boundary (top/bottom); if 0 read vertical boundary (left/right)epsSmall value to avoid numerical issuesbndxoStarting coordinate of the boundarybndxmaxEnding coordinate of the boundarybndyFixed coordinate of the boundary
Returns:
Vector of SLTS structures containing time and water level data
function readPolygon
Read polygon from a specified file. Reads polygon vertices from a specified file and ensures the polygon is closed. Calculates bounding box of the polygon.
Parameters:
filenameName of the polygon file
Returns:
Polygon structure containing vertices and bounding box information
function readWLfile
Read water level boundary file. Reads water level boundary file and extracts time and water level data. Applies reference date adjustment if provided.
Parameters:
WLfilenameName of the water level boundary filerefdateReference date for time adjustment
Returns:
Vector of SLTS structures containing time and water level data
function readWNDfileUNI
Read wind data from a specified file for spatially uniform forcing. Reads wind data from a specified file and extracts time, wind speed, wind direction, and calculates u and v wind components. Applies reference date adjustment if provided. __
std::vector< Windin > readWNDfileUNI (
std::string filename,
std::string & refdate,
double grdalpha
)
Parameters:
filenameName of the wind data filerefdateReference date for time adjustmentgrdalphaGrid rotation angle in radians
Returns:
Vector of Windin structures containing time, wind speed, wind direction, and u/v components
function readXBbathy
Read bathymetry data from an XBeach-style .bot/.dep file into a provided array. Parses the file format and fills the provided array with bathymetry values.
Parameters:
filenameName of the XBeach-style bathymetry filenxNumber of grid points in the x-directionnyNumber of grid points in the y-directionzbReference to the array to store bathymetry values
function readXBbathy< float >
function readXBbathy< int >
function readbathyASCHead
Read header information from an ASC (bathymetry) file. Extracts grid size (nx, ny), grid spacing (dx), origin (xo, yo), and grid rotation angle (grdalpha). Adjusts origin if the file uses corner registration.
void readbathyASCHead (
std::string filename,
int & nx,
int & ny,
double & dx,
double & xo,
double & yo,
double & grdalpha
)
Parameters:
filenameName of the ASC bathymetry filenxReference to store the number of grid points in the x-directionnyReference to store the number of grid points in the y-directiondxReference to store the grid spacing in the x-directionxoReference to store the x-coordinate of the grid originyoReference to store the y-coordinate of the grid origingrdalphaReference to store the grid rotation angle in radians
function readbathyASCzb
Read (bathymetry) data from an ASC file into a provided array. Parses the ASC file format and fills the provided array with bathymetry values.
Parameters:
filenameName of the ASC bathymetry filenxNumber of grid points in the x-directionnyNumber of grid points in the y-directionzbReference to the array to store bathymetry values
function readbathyASCzb< float >
function readbathyASCzb< int >
function readbathyHeadMD
Read header information from an MD bathymetry file (or other MD input map). Extracts grid size (nx, ny), grid spacing (dx), and grid rotation angle (grdalpha).
Parameters:
filenameName of the MD bathymetry filenxReference to store the number of grid points in the x-directionnyReference to store the number of grid points in the y-directiondxReference to store the grid spacinggrdalphaReference to store the grid rotation angle in radians
function readbathyMD
Read bathymetry data from an MD file into a provided array. Parses the MD file format and fills the provided array with bathymetry values. __
Parameters:
filenameName of the MD bathymetry filezbReference to the array to store bathymetry values
function readbathyMD< float >
function readbathyMD< int >
function readbathydata
Read bathymetry data and apply corrections if needed.
Reads static bathymetry data and applies correction for positive-down convention (special case of readstaticforcing(Sforcing)).
Parameters:
posdownIf 1, apply positive-down correctionSforcingStatic forcing structure
function readbndfile
Read boundary forcing files (water levels or nest files).
Reads boundary forcing files based on their extension (.nc for nest files, others for water level files). Applies zsoffset correction if specified in model parameters.
Parameters:
filenameName of the boundary forcing fileXParamModel parameters
Returns:
Vector of SLTS structures containing boundary information
function readbndpolysegment
Read boundary polygon segment and create polygon structure.
Reads boundary polygon segment based on specified keywords or file input.
Parameters:
bndBoundary segment structureXParamModel parameters
Returns:
Polygon structure representing the boundary segment
function readforcing
Wrapping function for reading all the forcing data.
Reads bathymetry and other forcing data into the provided Forcing structure.
Template parameters:
TData type
Parameters:
wrapping function for reading all the forcing data
function readforcing< float >
function readforcingdata
Read static forcing data from various file formats based on the file extension. Supports reading from .md, .nc, .bot/.dep, and .asc files.
Template parameters:
TType of the forcing parameter structure (e.g., StaticForcingP<float>, deformmap<float>, etc.)
Parameters:
stepCurrent time step for reading time-dependent data (if applicable)forcingForcing parameter structure containing file information and data storage
function readforcingdata
Read dynamic forcing data from a NetCDF file based on the current simulation time. Interpolates between time steps to obtain the current forcing values. Handles NaN values and clamps edges if specified.
Parameters:
totaltimeCurrent simulation timeforcingDynamic forcing parameter structure containing file information and data storage
function readforcingdata< StaticForcingP< float > >
template void readforcingdata< StaticForcingP< float > > (
int step,
StaticForcingP < float > forcing
)
function readforcingdata< StaticForcingP< int > >
function readforcingdata< deformmap< float > >
function readforcinghead
Read dynamic forcing metadata/header from a NetCDF file. Extracts grid size, spacing, origin, and time information.
Parameters:
FmapDynamic forcing parameter structure containing file informationXParamSimulation parameters (used for reference date)
Returns:
Updated dynamic forcing parameter structure with metadata
function readforcinghead
Read static forcing metadata/header from various file formats based on the file extension. Supports reading from .md, .nc, .bot/.dep, and .asc files. Extracts grid size, spacing, origin, and other relevant information. __
Template parameters:
TType of the forcing parameter structure (e.g., StaticForcingP<float>, deformmap<float>, etc.)
Parameters:
ForcingParamForcing parameter structure containing file information
Returns:
Updated forcing parameter structure with metadata
function readforcinghead< StaticForcingP< float > >
template StaticForcingP < float > readforcinghead< StaticForcingP< float > > (
StaticForcingP < float > ForcingParam
)
function readforcinghead< forcingmap >
function readforcinghead< inputmap >
function readstaticforcing
Single parameter version of readstaticforcing(int step, T& Sforcing).
Calls readstaticforcing with step set to 0.
Template parameters:
TData type
Parameters:
SforcingStatic forcing structure to be read and allocated
single parameter version of readstaticforcing(int step,T& Sforcing) readstaticforcing(0, Sforcing);
function readstaticforcing
Allocate and read static (i.e. not varying in time) forcing data. Used for Bathymetry, roughness, deformation, etc.
Parameters:
stepTime step (usually 0 for static data)SforcingStatic forcing structure to be read and allocated
Allocate and read static (i.e. not varying in time) forcing Used for Bathy, roughness, deformation
function readstaticforcing< StaticForcingP< float > >
function readstaticforcing< StaticForcingP< float > >
template void readstaticforcing< StaticForcingP< float > > (
int step,
StaticForcingP < float > & Sforcing
)
function readstaticforcing< StaticForcingP< int > >
function readstaticforcing< StaticForcingP< int > >
template void readstaticforcing< StaticForcingP< int > > (
int step,
StaticForcingP < int > & Sforcing
)
function readstaticforcing< deformmap< float > >
function readstaticforcing< deformmap< float > >
The documentation for this class was generated from the following file src/ReadForcing.cu