WarpX
Namespaces | Functions
WarpXUtil.cpp File Reference
#include "WarpX.H"
#include "WarpXAlgorithmSelection.H"
#include "WarpXConst.H"
#include "WarpXProfilerWrapper.H"
#include "WarpXUtil.H"
#include <AMReX.H>
#include <AMReX_Array.H>
#include <AMReX_Array4.H>
#include <AMReX_BLassert.H>
#include <AMReX_Box.H>
#include <AMReX_Config.H>
#include <AMReX_FArrayBox.H>
#include <AMReX_FabArray.H>
#include <AMReX_GpuControl.H>
#include <AMReX_GpuLaunch.H>
#include <AMReX_MFIter.H>
#include <AMReX_MultiFab.H>
#include <AMReX_ParmParse.H>
#include <AMReX_Parser.H>
#include <algorithm>
#include <array>
#include <cmath>
#include <cstring>
#include <fstream>
#include <set>
#include <string>
#include <limits>

Namespaces

 WarpXUtilIO
 
 WarpXUtilMsg
 
 WarpXUtilStr
 

Functions

void PreparseAMReXInputIntArray (amrex::ParmParse &a_pp, char const *const input_str, const bool replace)
 
void ParseGeometryInput ()
 
void ReadBoostedFrameParameters (Real &gamma_boost, Real &beta_boost, Vector< int > &boost_direction)
 
void ConvertLabParamsToBoost ()
 
void NullifyMF (amrex::MultiFab &mf, int lev, amrex::Real zmin, amrex::Real zmax)
 
bool WarpXUtilIO::WriteBinaryDataOnFile (std::string filename, const amrex::Vector< char > &data)
 
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...
 
int safeCastToInt (const 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...
 
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)
 
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...
 
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...
 
int queryArrWithParser (const amrex::ParmParse &a_pp, char const *const str, std::vector< amrex::Real > &val, const int start_ix, const int num_val)
 
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)
 
int queryWithParser (const amrex::ParmParse &a_pp, char const *const str, int &val)
 
void getWithParser (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 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 CheckGriddingForRZSpectral ()
 Ensures that the blocks are setup correctly for the RZ spectral solver When using the RZ spectral solver, the Hankel transform cannot be divided among multiple blocks. Each block must extend over the entire radial extent. The grid can be divided up along z, but the number of blocks must be >= the number of processors. More...
 
void ReadBCParams ()
 
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)
 

Function Documentation

◆ CheckGriddingForRZSpectral()

void CheckGriddingForRZSpectral ( )

Ensures that the blocks are setup correctly for the RZ spectral solver When using the RZ spectral solver, the Hankel transform cannot be divided among multiple blocks. Each block must extend over the entire radial extent. The grid can be divided up along z, but the number of blocks must be >= the number of processors.

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

◆ 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()

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

◆ PreparseAMReXInputIntArray()

void PreparseAMReXInputIntArray ( amrex::ParmParse &  a_pp,
char const *const  input_str,
const bool  replace 
)

◆ 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 ( Real &  gamma_boost,
Real &  beta_boost,
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