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:
s
The input string to be splitdelim
The 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:
line
The input string to be splitn
The 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:
gpgpu
Use GPU accelerationXParam
Model parametersDforcing
Dynamic 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:
nx
Number of grid points in the x-directionny
Number of grid points in the y-directionclamp
Value to set at the edgesz
Pointer 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:
nx
Number of grid points in the x-directionny
Number of grid points in the y-directiondenanval
Value to replace NaN values withz
Pointer 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_ref
Reference to the CRS stringSforcing
Static 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:
gpgpu
Use GPU accelerationtotaltime
Current simulation timeDforcing
Dynamic 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:
Flowfilename
Name of the flow data filerefdate
Reference 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:
filename
Name of the rain/atmospheric pressure data filerefdate
Reference 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:
ncfile
Name of the NetCDF filevarname
Name of the variable to readhor
If 1, read horizontal boundary (top/bottom); if 0 read vertical boundary (left/right)eps
Small value to avoid numerical issuesbndxo
Starting coordinate of the boundarybndxmax
Ending coordinate of the boundarybndy
Fixed 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:
filename
Name 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:
WLfilename
Name of the water level boundary filerefdate
Reference 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:
filename
Name of the wind data filerefdate
Reference date for time adjustmentgrdalpha
Grid 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:
filename
Name of the XBeach-style bathymetry filenx
Number of grid points in the x-directionny
Number of grid points in the y-directionzb
Reference 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:
filename
Name of the ASC bathymetry filenx
Reference to store the number of grid points in the x-directionny
Reference to store the number of grid points in the y-directiondx
Reference to store the grid spacing in the x-directionxo
Reference to store the x-coordinate of the grid originyo
Reference to store the y-coordinate of the grid origingrdalpha
Reference 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:
filename
Name of the ASC bathymetry filenx
Number of grid points in the x-directionny
Number of grid points in the y-directionzb
Reference 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:
filename
Name of the MD bathymetry filenx
Reference to store the number of grid points in the x-directionny
Reference to store the number of grid points in the y-directiondx
Reference to store the grid spacinggrdalpha
Reference 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:
filename
Name of the MD bathymetry filezb
Reference 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:
posdown
If 1, apply positive-down correctionSforcing
Static 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:
filename
Name of the boundary forcing fileXParam
Model 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:
bnd
Boundary segment structureXParam
Model 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:
T
Data 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:
T
Type of the forcing parameter structure (e.g., StaticForcingP<float>, deformmap<float>, etc.)
Parameters:
step
Current time step for reading time-dependent data (if applicable)forcing
Forcing 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:
totaltime
Current simulation timeforcing
Dynamic 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:
Fmap
Dynamic forcing parameter structure containing file informationXParam
Simulation 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:
T
Type of the forcing parameter structure (e.g., StaticForcingP<float>, deformmap<float>, etc.)
Parameters:
ForcingParam
Forcing 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:
T
Data type
Parameters:
Sforcing
Static 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:
step
Time step (usually 0 for static data)Sforcing
Static 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