WarpX
Namespaces | Functions
WarpXUtil.H File Reference
#include <AMReX_Extension.H>
#include <AMReX_GpuQualifiers.H>
#include <AMReX_Parser.H>
#include <AMReX_REAL.H>
#include <AMReX_Utility.H>
#include <AMReX_Vector.H>
#include <AMReX_BaseFwd.H>
#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>

Go to the source code of this file.

Namespaces

 WarpXUtilIO
 
 WarpXUtilAlgo
 
 WarpXUtilMsg
 
 WarpXUtilStr
 

Functions

void ParseGeometryInput ()
 
void ReadBoostedFrameParameters (amrex::Real &gamma_boost, amrex::Real &beta_boost, amrex::Vector< int > &boost_direction)
 
void ConvertLabParamsToBoost ()
 
void ReadBCParams ()
 
void CheckGriddingForRZSpectral ()
 Ensures that the blocks are setup correctly for the RZ spectral solver. More...
 
void NullifyMF (amrex::MultiFab &mf, int lev, amrex::Real zmin, amrex::Real zmax)
 
void Store_parserString (const amrex::ParmParse &pp, std::string query_string, std::string &stored_string)
 Parse a string (typically a mathematical expression) from the input file and store it into a variable. More...
 
bool WarpXUtilIO::WriteBinaryDataOnFile (std::string filename, const amrex::Vector< char > &data)
 
constexpr uint64_t WarpXUtilIO::localIDtoGlobal (int const id, int const cpu)
 
template<typename T >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE const T * WarpXUtilAlgo::upper_bound (const T *first, const T *last, const T &val)
 Returns a pointer to the first element in the range [first, last) that is greater than val. More...
 
template<typename T >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE T WarpXUtilAlgo::linear_interp (T x0, T x1, T f0, T f1, T x)
 Performs a linear interpolation. More...
 
template<typename T >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE T WarpXUtilAlgo::bilinear_interp (T x0, T x1, T y0, T y1, T f00, T f01, T f10, T f11, T x, T y)
 Performs a bilinear interpolation. More...
 
template<typename T >
AMREX_GPU_DEVICE AMREX_FORCE_INLINE T WarpXUtilAlgo::trilinear_interp (T x0, T x1, T y0, T y1, T z0, T z1, T f000, T f001, T f010, T f011, T f100, T f101, T f110, T f111, T x, T y, T z)
 Performs a trilinear interpolation. More...
 
int safeCastToInt (amrex::Real x, const std::string &real_name)
 Do a safe cast of a real to an int This ensures that the float value is within the range of ints and if not, raises an exception. More...
 
amrex::Parser makeParser (std::string const &parse_function, amrex::Vector< std::string > const &varnames)
 Initialize an amrex::Parser object from a string containing a math expression. More...
 
amrex::Real parseStringtoReal (std::string str)
 
int parseStringtoInt (std::string str, std::string name)
 
template<int N>
amrex::ParserExecutor< N > compileParser (amrex::Parser const *parser)
 
int queryWithParser (const amrex::ParmParse &a_pp, char const *const str, amrex::Real &val)
 Similar to amrex::ParmParse::query, but also supports math expressions for the value. More...
 
int queryArrWithParser (const amrex::ParmParse &a_pp, char const *const str, std::vector< amrex::Real > &val, const int start_ix, const int num_val)
 
int queryWithParser (const amrex::ParmParse &a_pp, char const *const str, int &val)
 
int queryArrWithParser (const amrex::ParmParse &a_pp, char const *const str, std::vector< int > &val, const int start_ix, const int num_val)
 
void getWithParser (const amrex::ParmParse &a_pp, char const *const str, amrex::Real &val)
 Similar to amrex::ParmParse::get, but also supports math expressions for the value. More...
 
void getArrWithParser (const amrex::ParmParse &a_pp, char const *const str, std::vector< amrex::Real > &val)
 
void getArrWithParser (const amrex::ParmParse &a_pp, char const *const str, std::vector< amrex::Real > &val, const int start_ix, const int num_val)
 
void getWithParser (const amrex::ParmParse &a_pp, char const *const str, int &val)
 
void getArrWithParser (const amrex::ParmParse &a_pp, char const *const str, std::vector< int > &val)
 
void getArrWithParser (const amrex::ParmParse &a_pp, char const *const str, std::vector< int > &val, const int start_ix, const int num_val)
 
void WarpXUtilMsg::AlwaysAssert (bool is_expression_true, const std::string &msg)
 If is_expression_true is false, this function prints msg and calls amrex::abort() More...
 
bool WarpXUtilStr::is_in (const std::vector< std::string > &vect, const std::string &elem)
 
bool WarpXUtilStr::is_in (const std::vector< std::string > &vect, const std::vector< std::string > &elems)
 
template<typename Container >
auto WarpXUtilStr::split (std::string const &instr, std::string const &separator, bool const trim=false, std::string const &trim_space=" \)
 Splits a string using a string separator. This is somewhat similar to amrex::Tokenize. The main difference is that, if the separator ":" is used, amrex::Tokenize will split ":3::2" into ["3","2"] while this functio will split ":3::2" into ["","3","","2"]. This function can also perform a trimming to remove whitespaces (or any other arbitrary string) from the split string. More...
 

Function Documentation

◆ CheckGriddingForRZSpectral()

void CheckGriddingForRZSpectral ( )

Ensures that the blocks are setup correctly for the RZ spectral solver.

Ensures that the blocks are setup correctly for the RZ spectral solver.

◆ compileParser()

template<int N>
amrex::ParserExecutor<N> compileParser ( amrex::Parser const *  parser)

◆ ConvertLabParamsToBoost()

void ConvertLabParamsToBoost ( )

◆ getArrWithParser() [1/4]

void getArrWithParser ( const amrex::ParmParse &  a_pp,
char const *const  str,
std::vector< amrex::Real > &  val 
)

◆ getArrWithParser() [2/4]

void getArrWithParser ( const amrex::ParmParse &  a_pp,
char const *const  str,
std::vector< amrex::Real > &  val,
const int  start_ix,
const int  num_val 
)

◆ getArrWithParser() [3/4]

void getArrWithParser ( const amrex::ParmParse &  a_pp,
char const *const  str,
std::vector< int > &  val 
)

◆ getArrWithParser() [4/4]

void getArrWithParser ( const amrex::ParmParse &  a_pp,
char const *const  str,
std::vector< int > &  val,
const int  start_ix,
const int  num_val 
)

◆ getWithParser() [1/2]

void getWithParser ( const amrex::ParmParse &  a_pp,
char const *const  str,
amrex::Real &  val 
)

Similar to amrex::ParmParse::get, but also supports math expressions for the value.

amrex::ParmParse::get reads a name and a value from the input file. This function does the same, and applies the Parser to the value, so the user has the choice to specify a value or a math expression (including user-defined constants). Works for amrex::Real numbers and integers.

Parameters
[in]a_ppamrex::ParmParse object
[in]strname of the parameter to read
[out]valwhere the value queried and parsed is stored
[in]start_ixstart index in the list of inputs values (optional with arrays)
[in]num_valnumber of input values to use (optional with arrays)

◆ getWithParser() [2/2]

void getWithParser ( const amrex::ParmParse &  a_pp,
char const *const  str,
int &  val 
)

◆ makeParser()

amrex::Parser makeParser ( std::string const &  parse_function,
amrex::Vector< std::string > const &  varnames 
)

Initialize an amrex::Parser object from a string containing a math expression.

Parameters
parse_functionString to read to initialize the parser.
varnamesA list of predefined independent variables

◆ NullifyMF()

void NullifyMF ( amrex::MultiFab &  mf,
int  lev,
amrex::Real  zmin,
amrex::Real  zmax 
)

◆ ParseGeometryInput()

void ParseGeometryInput ( )

◆ parseStringtoInt()

int parseStringtoInt ( std::string  str,
std::string  name 
)

Parse a string and return an int

In case the string cannot be interpreted as Real, this function ... <throws an exception? aborts with error message?>

Parameters
strThe string to be parsed
nameFor integers, the name, to be used in error messages
Returns
rounded closest integer

◆ parseStringtoReal()

amrex::Real parseStringtoReal ( std::string  str)

Parse a string and return as a real

In case the string cannot be interpreted as Real, this function ... <throws an exception? aborts with error message?>

Parameters
strThe string to be parsed
Returns
representation as real

◆ queryArrWithParser() [1/2]

int queryArrWithParser ( const amrex::ParmParse &  a_pp,
char const *const  str,
std::vector< amrex::Real > &  val,
const int  start_ix,
const int  num_val 
)

◆ queryArrWithParser() [2/2]

int queryArrWithParser ( const amrex::ParmParse &  a_pp,
char const *const  str,
std::vector< int > &  val,
const int  start_ix,
const int  num_val 
)

◆ queryWithParser() [1/2]

int queryWithParser ( const amrex::ParmParse &  a_pp,
char const *const  str,
amrex::Real &  val 
)

Similar to amrex::ParmParse::query, but also supports math expressions for the value.

amrex::ParmParse::query reads a name and a value from the input file. This function does the same, and applies the amrex::Parser to the value, so the user has the choice to specify a value or a math expression (including user-defined constants). Works for amrex::Real numbers and integers.

Parameters
[in]a_ppamrex::ParmParse object
[in]strname of the parameter to read
[out]valwhere the value queried and parsed is stored, either a scalar or vector
[in]start_ixstart index in the list of inputs values (optional with arrays)
[in]num_valnumber of input values to use (optional with arrays)

◆ queryWithParser() [2/2]

int queryWithParser ( const amrex::ParmParse &  a_pp,
char const *const  str,
int &  val 
)

◆ ReadBCParams()

void ReadBCParams ( )

Reads the user-defined field and particle boundary condition parameters

◆ ReadBoostedFrameParameters()

void ReadBoostedFrameParameters ( amrex::Real &  gamma_boost,
amrex::Real &  beta_boost,
amrex::Vector< int > &  boost_direction 
)

◆ safeCastToInt()

int safeCastToInt ( amrex::Real  x,
const std::string &  real_name 
)

Do a safe cast of a real to an int This ensures that the float value is within the range of ints and if not, raises an exception.

Parameters
xReal value to cast
real_nameString, the name of the variable being casted to use in the error message

◆ Store_parserString()

void Store_parserString ( const amrex::ParmParse &  pp,
std::string  query_string,
std::string &  stored_string 
)

Parse a string (typically a mathematical expression) from the input file and store it into a variable.

Parameters
ParmParsepp used to read the query_string pp.<function>=string
parmparse_stringString used to initialize ParmParse
query_stringParmParse.query will look for this string
stored_stringvariable in which the string to parse is stored