diff options
author | 2022-10-10 20:36:14 +0200 | |
---|---|---|
committer | 2022-10-10 11:36:14 -0700 | |
commit | e9cc65ffeb0684a97618b67c2164d95ea497226c (patch) | |
tree | ed65f7ac86cc4e8945021dc36a79c8bc246c150d /Source/Utils/IntervalsParser.H | |
parent | 56e04c1b911f9399662c4ff9ecf6630d686cc220 (diff) | |
download | WarpX-e9cc65ffeb0684a97618b67c2164d95ea497226c.tar.gz WarpX-e9cc65ffeb0684a97618b67c2164d95ea497226c.tar.zst WarpX-e9cc65ffeb0684a97618b67c2164d95ea497226c.zip |
Partial refactoring of the utils directory (#3404)
* initial work to clean WarpX Utils
* remove AMRCore from Ionization tables
* progress
* refactoring of a part of the utils directory
* fix bug
* fixed bug
* fixed bug
* remove debug line accidentally slipped into the code
* remove debug line accidentally slipped into the code
* remove debug line accidentally slipped into the code
* cleaning
* fixed bug
Diffstat (limited to 'Source/Utils/IntervalsParser.H')
-rw-r--r-- | Source/Utils/IntervalsParser.H | 207 |
1 files changed, 0 insertions, 207 deletions
diff --git a/Source/Utils/IntervalsParser.H b/Source/Utils/IntervalsParser.H deleted file mode 100644 index 06258b109..000000000 --- a/Source/Utils/IntervalsParser.H +++ /dev/null @@ -1,207 +0,0 @@ -#ifndef WARPX_INTERVALSPARSER_H_ -#define WARPX_INTERVALSPARSER_H_ - -#include <limits> -#include <string> -#include <vector> - -/** - * \brief This class is a parser for slices of the form i:j:k where i, j and k are integers - * representing respectively the starting point, the stopping point and the period. - */ -class SliceParser -{ -public: - /** - * \brief Constructor of the SliceParser class. - * - * @param[in] instr an input string of the form "i:j:k", "i:j" or "k" where i, j and k are - * integers representing respectively the starting point, the stopping point and the period. - * Any of these integers may be omitted in which case it will be equal to their default value - * (0 for the starting point, std::numeric_limits<int>::max() for the stopping point and 1 for - * the period). For example SliceParser(":1000:") is equivalent to SliceParser("0:1000:1"). - */ - SliceParser (const std::string& instr, bool isBTD=false); - - /** - * \brief A method that returns true if the input integer is contained in the slice. (e.g. if - * the list is initialized with "300:500:100", this method returns true if and only if n is - * 300, 400 or 500). If the period is negative or 0, the function always returns false. - * - * @param[in] n the input integer - */ - bool contains (const int n) const; - - /** - * \brief A method that returns the smallest integer strictly greater than n such that - * contains(n) is true. Returns std::numeric_limits<int>::max() if there is no such integer. - * - * @param[in] n the input integer - */ - int nextContains (const int n) const; - - /** - * \brief A method that returns the greatest integer strictly smaller than n such that - * contains(n) is true. Returns 0 if there is no such integer. - * - * @param[in] n the input integer - */ - int previousContains (const int n) const; - - /** - * \brief A method that returns the slice period. - * - */ - int getPeriod () const; - - /** - * \brief A method that returns the slice start. - * - */ - int getStart () const; - - /** - * \brief A method that returns the slice stop. - * - */ - int getStop () const; - - /** - * @brief A method that returns the number of integers contained by the slice. - * - */ - int numContained() const; - -private: - bool m_isBTD = false; - int m_start = 0; - int m_stop = std::numeric_limits<int>::max(); - int m_period = 1; - std::string m_separator = ":"; - -}; - -/** - * \brief This class is a parser for multiple slices of the form x,y,z,... where x, y and z are - * slices of the form i:j:k, as defined in the SliceParser class. This class contains a vector of - * SliceParsers. - */ -class IntervalsParser -{ -public: - /** - * \brief Default constructor of the IntervalsParser class. - */ - IntervalsParser () = default; - - /** - * \brief Constructor of the IntervalsParser class. - * - * @param[in] instr_vec an input vector string, which when concatenated is of the form - * "x,y,z,...". This will call the constructor of SliceParser using x, y and z as input - * arguments. - */ - IntervalsParser (const std::vector<std::string>& instr_vec); - - /** - * \brief A method that returns true if the input integer is contained in any of the slices - * contained by the IntervalsParser. - * - * @param[in] n the input integer - */ - bool contains (const int n) const; - - /** - * \brief A method that returns the smallest integer strictly greater than n such that - * contains(n) is true. Returns std::numeric_limits<int>::max() if there is no such integer. - * - * @param[in] n the input integer - */ - int nextContains (const int n) const; - - /** - * \brief A method that returns the greatest integer strictly smaller than n such that - * contains(n) is true. Returns 0 if there is no such integer. - * - * @param[in] n the input integer - */ - int previousContains (const int n) const; - - /** - * \brief A method that returns the greatest integer smaller than or equal to n such that - * contains(n) is true. Returns 0 if there is no such integer. - * - * @param[in] n the input integer - */ - int previousContainsInclusive (const int n) const; - - /** - * \brief A method the local period (in timesteps) of the IntervalsParser at timestep n. - * The period is defined by nextContains(n) - previousContainsInclusive(n) - * - * @param[in] n the input integer - */ - int localPeriod (const int n) const; - -/** - * \brief A method that returns true if any of the slices contained by the IntervalsParser - * has a strictly positive period. - */ - bool isActivated () const; - -private: - std::vector<SliceParser> m_slices; - std::string m_separator = ","; - bool m_activated = false; -}; - -/** - * \brief This class is a parser for multiple slices of the form x,y,z,... where x, y and z are - * slices of the form i:j:k, as defined in the SliceParser class. This class contains a vector of - * SliceParsers. The supported function set differs from the IntervalsParser - */ -class BTDIntervalsParser -{ -public: - /** - * \brief Default constructor of the BTDIntervalsParser class. - */ - BTDIntervalsParser () = default; - - /** - * \brief Constructor of the BTDIntervalsParser class. - * - * @param[in] instr_vec an input vector string, which when concatenated is of the form - * "x,y,z,...". This will call the constructor of SliceParser using x, y and z as input - * arguments. - */ - BTDIntervalsParser (const std::vector<std::string>& instr_vec); - - /** - * @brief Return the total number of unique labframe snapshots - */ - int NumSnapshots (); - - /** - * @brief Return the iteration number stored at index i_buffer - * - * @param i_buffer buffer or iteration index, between 0 and NumSnapshots - */ - int GetBTDIteration(int i_buffer); - - /** - * \brief A method that returns true if any of the slices contained by the IntervalsParser - * has a strictly positive period. - */ - bool isActivated () const; - -private: - std::vector<int> m_btd_iterations; - std::vector<SliceParser> m_slices; - std::vector<int> m_slice_starting_i_buffer; - int m_n_snapshots; - static constexpr char m_separator = ','; - bool m_activated = false; -}; - -#endif // WARPX_INTERVALSPARSER_H_ |