Skip to content

File ReadInput.cu

FileList > src > ReadInput.cu

Go to the source code of this file

  • #include "ReadInput.h"

Public Functions

Type Name
void InitialiseToutput (T_output & Toutput_loc, Param XParam)
Initialise the Toutput structure with output times. This function reads the output times from a specified input string and ensures that the times are within the simulation time range. If no valid times are provided, it defaults to using the total time and end time.
std::vector< double > ReadTRangestr (std::vector< std::string > timestr, double start, double end, std::string reftime)
Read and interpret a time range string, converting it to a vector of doubles within specified bounds. This function interprets a time range string formatted as "t_init:t_step:t_end", where each component can be a specific time value or a keyword representing the start or end of the overall time range. It converts the range into a vector of double values representing discrete time steps, ensuring all values fall within the provided start and end bounds.
std::vector< std::string > ReadToutSTR (std::string paramstr)
Split a comma-separated parameter string into a vector of strings.
std::vector< double > ReadToutput (std::vector< std::string > paramstr, Param XParam)
Read and interpret output time specifications from a vector of parameter strings. This function processes a vector of parameter strings that specify output times, which can include individual time values or ranges defined by a start, step, and end. It converts these specifications into a vector of double values representing the output times, ensuring all times fall within the simulation's total time and end time.
double ReadTvalstr (std::string timestr, double start, double end, std::string reftime)
Read and interpret a time value string, converting it to a double within specified bounds. This function interprets a time value string, which can represent specific keywords ("start", "end"), relative times, or absolute date-time strings. It converts the string to a double value representing time, ensuring it falls within the provided start and end bounds.
void Readparamfile (Param & XParam, Forcing< float > & XForcing, std::string Paramfile)
Read and parse the parameter file. Opens the specified parameter file (default: BG_param.txt file), reads its contents, and updates the provided parameter structures: Param class (XParam) andForcing class (XForcing).
std::size_t case_insensitive_compare (std::string s1, std::string s2)
Perform a non case-insensitive comparison between two strings or a string and a vector of strings. This function converts both strings to lowercase and compares them. If a vector of strings is provided, it compares the first string against each string in the vector.
std::size_t case_insensitive_compare (std::string s1, std::vector< std::string > vecstr)
Perform a non case-insensitive comparison between a string and a vector of strings. This function converts the first string to lowercase and compares it against each string in the vector.
void checkparamsanity (Param & XParam, Forcing< float > & XForcing)
Check and adjust the sanity of model parameters and forcing data. This function checks the sanity of the model parameters and forcing data. It adjusts parameters as needed, ensuring they are within acceptable ranges and consistent with each other.
std::string findparameter (std::vector< std::string > parameterstr, std::string line)
Find and extract the value of a specified parameter from a configuration line. This function searches for a specified parameter in a given line of text, and extracts its associated value if found. It handles comments and whitespace appropriately.
std::string findparameter (std::string parameterstr, std::string line)
Find and extract the value of a specified parameter from a configuration line. This function searches for a specified parameter in a given line of text, and extracts its associated value if found. It handles comments and whitespace appropriately.
double readApproxtimestr (std::string input)
Convert an approximate time string to a double value in seconds. This function interprets a time string that may include a numeric value followed by a time unit (e.g., "seconds", "minutes", "hours", "days", "months", "years") and converts it to a double value representing the equivalent time in seconds. If the unit is not recognized, it defaults to seconds.
bndsegment readbndline (std::string parametervalue)
Read boundary segment information from a parameter value string. This function parses a parameter value string to extract boundary segment information, including type, input file, and polygon file. It also reads file information and sets the expected type of input based on the file extension.
bndsegment readbndlineside (std::string parametervalue, std::string side)
Read boundary segment information from a parameter value string for a specific side. This function parses a parameter value string to extract boundary segment information, including type, input file, and polygon file for a specified side. It also reads file information and sets the expected type of input based on the file extension.
T readfileinfo (std::string input, T outinfo)
Parse a parameter string and update the parameter structure. Parses a line from the parameter file and updates the given parameter structure. Convert file name into name and extension. This is used for various input classes template inputmap readfileinfo<inputmap>(std::string input, inputmap outinfo); template forcingmap readfileinfo<forcingmap>(std::string input, forcingmap outinfo); template StaticForcingP<float> readfileinfo<StaticForcingP<float>>(std::string input, StaticForcingP<float> outinfo); template DynForcingP<float> readfileinfo<DynForcingP<float>>(std::string input, DynForcingP<float> outinfo); template deformmap<float> readfileinfo<deformmap<float>>(std::string input, deformmap<float> outinfo);.
template DynForcingP< float > readfileinfo< DynForcingP< float > > (std::string input, DynForcingP< float > outinfo)
template StaticForcingP< float > readfileinfo< StaticForcingP< float > > (std::string input, StaticForcingP< float > outinfo)
template deformmap< float > readfileinfo< deformmap< float > > (std::string input, deformmap< float > outinfo)
template forcingmap readfileinfo< forcingmap > (std::string input, forcingmap outinfo)
template inputmap readfileinfo< inputmap > (std::string input, inputmap outinfo)
bool readparambool (std::string paramstr, bool defaultval)
Convert a parameter string to a boolean value, with a default fallback. This function interprets a parameter string as a boolean value, returning true for recognized true values and false for recognized false values. If the string does not match any known values, it returns a specified default value. __
Param readparamstr (std::string line, Param param)
Parse a parameter string and update the parameter structure.
Forcing< T > readparamstr (std::string line, Forcing< T > forcing)
Parse a parameter string and update the forcing structure. Parses a line from the parameter file and updates the given forcing structure. Read BG_param.txt line and convert parameter to the right parameter in the class Return an updatedForcing class.
double setendtime (Param XParam, Forcing< float > XForcing)
Adjust the simulation "endtime" based on maximum time in forcings. This function checks the end times of boundary forcing data and adjusts the simulation end time if any boundary forcing ends before the specified end time. A warning is logged if the end time is reduced.
void split (const std::string & s, char delim, std::vector< std::string > & elems)
Split a string into tokens based on a specified delimiter, skipping empty tokens. This function takes a string and splits it into a vector of substrings using the specified delimiter. Empty tokens resulting from consecutive delimiters are skipped.
std::vector< std::string > split (const std::string & s, char delim)
Split a string into tokens based on a specified character delimiter, skipping empty tokens. This function takes a string and splits it into a vector of substrings using the specified delimiter. Empty tokens resulting from consecutive delimiters are skipped.
std::vector< std::string > split (const std::string s, const std::string delim)
Split a string into tokens based on a specified substring delimiter. This function takes a string and splits it into a vector of substrings using the specified substring delimiter.
void split_full (const std::string & s, char delim, std::vector< std::string > & elems)
Split a string into tokens based on a specified delimiter, preserving empty tokens. This function takes a string and splits it into a vector of substrings using the specified delimiter. Unlike the standard split function, this version preserves empty tokens that result from consecutive delimiters. __
std::vector< std::string > split_full (const std::string & s, char delim)
Split a string into tokens based on a specified character delimiter, preserving empty tokens. This function takes a string and splits it into a vector of substrings using the specified delimiter. Unlike the standard split function, this version preserves empty tokens that result from consecutive delimiters. __
std::string trim (const std::string & str, const std::string & whitespace)
Trim leading and trailing whitespace from a string. This function removes all leading and trailing characters from the input string that are present in the specified whitespace string.

Public Functions Documentation

function InitialiseToutput

Initialise the Toutput structure with output times. This function reads the output times from a specified input string and ensures that the times are within the simulation time range. If no valid times are provided, it defaults to using the total time and end time.

void InitialiseToutput (
    T_output & Toutput_loc,
    Param XParam
) 

Parameters:

  • Toutput_loc Reference to the T_output structure to be initialised.
  • XParam The Param structure containing simulation parameters.

function ReadTRangestr

Read and interpret a time range string, converting it to a vector of doubles within specified bounds. This function interprets a time range string formatted as "t_init:t_step:t_end", where each component can be a specific time value or a keyword representing the start or end of the overall time range. It converts the range into a vector of double values representing discrete time steps, ensuring all values fall within the provided start and end bounds.

std::vector< double > ReadTRangestr (
    std::vector< std::string > timestr,
    double start,
    double end,
    std::string reftime
) 

Parameters:

  • timestr A vector of strings representing the time range components: [t_init, t_step, t_end].
  • start The start time bound.
  • end The end time bound.
  • reftime The reference time for interpreting absolute date-time strings.

Returns:

A vector of double values representing the interpreted time steps within the specified range.


function ReadToutSTR

Split a comma-separated parameter string into a vector of strings.

std::vector< std::string > ReadToutSTR (
    std::string paramstr
) 

This function takes a parameter string containing values separated by commas and splits it into a vector of individual strings.

Parameters:

  • paramstr The parameter string to be split.

Returns:

A vector of strings obtained by splitting the input string at commas.


function ReadToutput

Read and interpret output time specifications from a vector of parameter strings. This function processes a vector of parameter strings that specify output times, which can include individual time values or ranges defined by a start, step, and end. It converts these specifications into a vector of double values representing the output times, ensuring all times fall within the simulation's total time and end time.

std::vector< double > ReadToutput (
    std::vector< std::string > paramstr,
    Param XParam
) 

Parameters:

  • paramstr A vector of strings specifying output times or ranges.
  • XParam The Param structure containing simulation parameters, including total time and end time.

Returns:

A vector of double values representing the interpreted output times.


function ReadTvalstr

Read and interpret a time value string, converting it to a double within specified bounds. This function interprets a time value string, which can represent specific keywords ("start", "end"), relative times, or absolute date-time strings. It converts the string to a double value representing time, ensuring it falls within the provided start and end bounds.

double ReadTvalstr (
    std::string timestr,
    double start,
    double end,
    std::string reftime
) 

Parameters:

  • timestr The time value string to be interpreted.
  • start The start time bound.
  • end The end time bound.
  • reftime The reference time for interpreting absolute date-time strings.

Returns:

A double value representing the interpreted time, constrained within the start and end bounds.


function Readparamfile

Read and parse the parameter file. Opens the specified parameter file (default: BG_param.txt file), reads its contents, and updates the provided parameter structures: Param class (XParam) andForcing class (XForcing).

void Readparamfile (
    Param & XParam,
    Forcing < float > & XForcing,
    std::string Paramfile
) 

Parameters:

  • XParam Reference to the parameter structure to be updated
  • XForcing Reference to the forcing structure to be updated
  • Paramfile Name of the parameter file to read

function case_insensitive_compare

Perform a non case-insensitive comparison between two strings or a string and a vector of strings. This function converts both strings to lowercase and compares them. If a vector of strings is provided, it compares the first string against each string in the vector.

std::size_t case_insensitive_compare (
    std::string s1,
    std::string s2
) 

Parameters:

  • s1 The first string to compare.
  • s2 The second string to compare, or a vector of strings to compare against

function case_insensitive_compare

Perform a non case-insensitive comparison between a string and a vector of strings. This function converts the first string to lowercase and compares it against each string in the vector.

std::size_t case_insensitive_compare (
    std::string s1,
    std::vector< std::string > vecstr
) 

Parameters:

  • s1 The first string to compare.
  • vecstr The vector of strings to compare against.

function checkparamsanity

Check and adjust the sanity of model parameters and forcing data. This function checks the sanity of the model parameters and forcing data. It adjusts parameters as needed, ensuring they are within acceptable ranges and consistent with each other.

void checkparamsanity (
    Param & XParam,
    Forcing < float > & XForcing
) 

Parameters:

  • XParam Reference to the model parameters structure to be checked and adjusted.
  • XForcing Reference to the forcing data structure to be checked and adjusted.

function findparameter

Find and extract the value of a specified parameter from a configuration line. This function searches for a specified parameter in a given line of text, and extracts its associated value if found. It handles comments and whitespace appropriately.

std::string findparameter (
    std::vector< std::string > parameterstr,
    std::string line
) 

Parameters:

  • parameterstr The parameter name to search for.
  • line The line of text to search within.

Returns:

The extracted parameter value as a string, or an empty string if the parameter is not found.


function findparameter

Find and extract the value of a specified parameter from a configuration line. This function searches for a specified parameter in a given line of text, and extracts its associated value if found. It handles comments and whitespace appropriately.

std::string findparameter (
    std::string parameterstr,
    std::string line
) 

Parameters:

  • parameterstr The parameter name to search for.
  • line The line of text to search within.

Returns:

The extracted parameter value as a string, or an empty string if the parameter is not found.


function readApproxtimestr

Convert an approximate time string to a double value in seconds. This function interprets a time string that may include a numeric value followed by a time unit (e.g., "seconds", "minutes", "hours", "days", "months", "years") and converts it to a double value representing the equivalent time in seconds. If the unit is not recognized, it defaults to seconds.

double readApproxtimestr (
    std::string input
) 

Parameters:

  • input The approximate time string to be converted (e.g., "10 minutes", "2.5 hours").

Returns:

A double value representing the time in seconds.


function readbndline

Read boundary segment information from a parameter value string. This function parses a parameter value string to extract boundary segment information, including type, input file, and polygon file. It also reads file information and sets the expected type of input based on the file extension.

bndsegment readbndline (
    std::string parametervalue
) 

Parameters:

  • parametervalue The parameter value string containing boundary segment information.

function readbndlineside

Read boundary segment information from a parameter value string for a specific side. This function parses a parameter value string to extract boundary segment information, including type, input file, and polygon file for a specified side. It also reads file information and sets the expected type of input based on the file extension.

bndsegment readbndlineside (
    std::string parametervalue,
    std::string side
) 

Parameters:

  • parametervalue The parameter value string containing boundary segment information.
  • side The side (e.g., "left", "right", "top", "bot") for which the boundary segment is defined.

function readfileinfo

Parse a parameter string and update the parameter structure. Parses a line from the parameter file and updates the given parameter structure. Convert file name into name and extension. This is used for various input classes template inputmap readfileinfo<inputmap>(std::string input, inputmap outinfo); template forcingmap readfileinfo<forcingmap>(std::string input, forcingmap outinfo); template StaticForcingP<float> readfileinfo<StaticForcingP<float>>(std::string input, StaticForcingP<float> outinfo); template DynForcingP<float> readfileinfo<DynForcingP<float>>(std::string input, DynForcingP<float> outinfo); template deformmap<float> readfileinfo<deformmap<float>>(std::string input, deformmap<float> outinfo);.

template<class T>
T readfileinfo (
    std::string input,
    T outinfo
) 

Parameters:

  • line Input line from parameter file
  • param Parameter structure to update

Returns:

Updated parameter structure

convert file name into name and extension This is used for various input classes

template inputmap readfileinfo<inputmap>(std::string input, inputmap outinfo); template forcingmap readfileinfo<forcingmap>(std::string input, forcingmap outinfo); template StaticForcingP<float> readfileinfo<StaticForcingP<float>>(std::string input, StaticForcingP<float> outinfo); template DynForcingP<float> readfileinfo<DynForcingP<float>>(std::string input, DynForcingP<float> outinfo); template deformmap<float> readfileinfo<deformmap<float>>(std::string input, deformmap<float> outinfo);


function readfileinfo< DynForcingP< float > >

template DynForcingP < float > readfileinfo< DynForcingP< float > > (
    std::string input,
    DynForcingP < float > outinfo
) 

function readfileinfo< StaticForcingP< float > >

template StaticForcingP < float > readfileinfo< StaticForcingP< float > > (
    std::string input,
    StaticForcingP < float > outinfo
) 

function readfileinfo< deformmap< float > >

template deformmap < float > readfileinfo< deformmap< float > > (
    std::string input,
    deformmap < float > outinfo
) 

function readfileinfo< forcingmap >

template forcingmap readfileinfo< forcingmap > (
    std::string input,
    forcingmap outinfo
) 

function readfileinfo< inputmap >

template inputmap readfileinfo< inputmap > (
    std::string input,
    inputmap outinfo
) 

function readparambool

Convert a parameter string to a boolean value, with a default fallback. This function interprets a parameter string as a boolean value, returning true for recognized true values and false for recognized false values. If the string does not match any known values, it returns a specified default value. __

bool readparambool (
    std::string paramstr,
    bool defaultval
) 

Parameters:

  • paramstr The parameter string to be interpreted.
  • defaultval The default boolean value to return if the string does not match known values

function readparamstr

Parse a parameter string and update the parameter structure.

Param readparamstr (
    std::string line,
    Param param
) 

Parses a line from the parameter file and updates the given parameter structure. Read BG_param.txt line and convert parameter to the right parameter in the class Return an updated Param class

Parameters:

  • line Input line from parameter file
  • param Parameter structure to update

Returns:

Updated parameter structure

Read BG_param.txt line and convert parameter to the righ parameter in the class return an updated Param class


function readparamstr

Parse a parameter string and update the forcing structure. Parses a line from the parameter file and updates the given forcing structure. Read BG_param.txt line and convert parameter to the right parameter in the class Return an updatedForcing class.

template<class T>
Forcing < T > readparamstr (
    std::string line,
    Forcing < T > forcing
) 

Parameters:

  • line Input line from parameter file
  • forcing Forcing structure to update

Returns:

Updated forcing structure

Read BG_param.txt line and convert parameter to the righ parameter in the class return an updated Param class


function setendtime

Adjust the simulation "endtime" based on maximum time in forcings. This function checks the end times of boundary forcing data and adjusts the simulation end time if any boundary forcing ends before the specified end time. A warning is logged if the end time is reduced.

double setendtime (
    Param XParam,
    Forcing < float > XForcing
) 

Parameters:

  • XParam The Param structure containing simulation parameters, including the initial end time.
  • XForcing The Forcing structure containing boundary forcing data.

function split

Split a string into tokens based on a specified delimiter, skipping empty tokens. This function takes a string and splits it into a vector of substrings using the specified delimiter. Empty tokens resulting from consecutive delimiters are skipped.

void split (
    const std::string & s,
    char delim,
    std::vector< std::string > & elems
) 

Parameters:

  • s The input string to be split.
  • delim The character used as the delimiter for splitting the string.
  • elems A reference to a vector where the resulting substrings will be stored.

function split

Split a string into tokens based on a specified character delimiter, skipping empty tokens. This function takes a string and splits it into a vector of substrings using the specified delimiter. Empty tokens resulting from consecutive delimiters are skipped.

std::vector< std::string > split (
    const std::string & s,
    char delim
) 

Parameters:

  • s The input string to be split.
  • delim The character used as the delimiter for splitting the string.

Returns:

A vector containing the resulting substrings.


function split

Split a string into tokens based on a specified substring delimiter. This function takes a string and splits it into a vector of substrings using the specified substring delimiter.

std::vector< std::string > split (
    const std::string s,
    const std::string delim
) 

Parameters:

  • s The input string to be split.
  • delim The substring used as the delimiter for splitting the string.

Returns:

A vector containing the resulting substrings.


function split_full

Split a string into tokens based on a specified delimiter, preserving empty tokens. This function takes a string and splits it into a vector of substrings using the specified delimiter. Unlike the standard split function, this version preserves empty tokens that result from consecutive delimiters. __

void split_full (
    const std::string & s,
    char delim,
    std::vector< std::string > & elems
) 

Parameters:

  • s The input string to be split.
  • delim The character used as the delimiter for splitting the string.
  • elems A reference to a vector where the resulting substrings will be stored.

split string based in character, conserving empty item


function split_full

Split a string into tokens based on a specified character delimiter, preserving empty tokens. This function takes a string and splits it into a vector of substrings using the specified delimiter. Unlike the standard split function, this version preserves empty tokens that result from consecutive delimiters. __

std::vector< std::string > split_full (
    const std::string & s,
    char delim
) 

Parameters:

  • s The input string to be split.
  • delim The character used as the delimiter for splitting the string.

split string based in character, conserving empty items


function trim

Trim leading and trailing whitespace from a string. This function removes all leading and trailing characters from the input string that are present in the specified whitespace string.

std::string trim (
    const std::string & str,
    const std::string & whitespace
) 

Parameters:

  • str The input string to be trimmed.
  • whitespace A string containing all characters considered as whitespace.

remove leading and trailing space in a string



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