Utils¶
Parameter wrap¶
This class is used to facilitate parameters read.
-
class
ParametersWrap
¶ A tool to transform a map from string keys to variant parameters.
The input map is typically an input from the python interface.
Public Types
-
using
VarParam
= std::variant<real, std::vector<real>, std::vector<real2>, std::string, bool>¶ A variant that contains the possible types to represent parameters.
Public Functions
-
ParametersWrap
(const MapParams ¶ms)¶ Construct a ParametersWrap object from a MapParams.
-
template <typename T>
boolexists
(const std::string &key)¶ Check if a parameter of a given type and name exists in the map.
- Return
- true if T and key match, false otherwise.
- Template Parameters
T
: The type of the parameter
- Parameters
key
: The name of the parameter to check
-
template <typename T>
Tread
(const std::string &key)¶ Fetch a parameter value for a given key.
On success, this method will also mark internally the parameter as read. This allows to check if some parameters were never used (see
checkAllRead()).- Template Parameters
T
: the type of the parameter to read.
- Parameters
key
: the parameter name to read.
This method dies if key does not exist or if T is the wrong type.
-
using
StepRandomGen¶
-
class
StepRandomGen
¶ A random number generator that generates a different number at every time step but returns the same number while the time step is not updated.
Used to generate independant random numbers at every time step. Several calls at the same time step will return the same random number. This is used to keep the interactionssymmetric accross ranks (pairwise particle halo interactions are computed twice, once on each rank. The random seed must therefore be the same and only depend on the time step, not the rank).
Public Functions
-
StepRandomGen
(long seed)¶ construct a StepRandomGen
- Parameters
seed
: The random seed.
-