diff options
author | 2022-09-23 20:01:19 -0700 | |
---|---|---|
committer | 2022-09-24 03:01:19 +0000 | |
commit | cf74a5b3e6de44a030bdc004802050b9427dcdbc (patch) | |
tree | dcccba2dd3e5c9f6b020ffc1c7c9d3cfa9d57b40 /Source/Utils/IntervalsParser.H | |
parent | 6febc63b4d58e7bacc38d1a2a98d5852663d1b31 (diff) | |
download | WarpX-cf74a5b3e6de44a030bdc004802050b9427dcdbc.tar.gz WarpX-cf74a5b3e6de44a030bdc004802050b9427dcdbc.tar.zst WarpX-cf74a5b3e6de44a030bdc004802050b9427dcdbc.zip |
BTD diagnostics specified by intervals (#3367)
* BTD diagnostics specified by intervals
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* address CI errors
* refactor and test
* no duplicate or out-of-order snapshots
* update documentation and tests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* clean for CI
* still fighting CI
* Update Source/Diagnostics/BTDiagnostics.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Apply suggestions from code review
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* refactor includes
* add an explicit constexpr
* Apply suggestions from code review
Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com>
* describe algorithm for BTD intervals list
* revert to old description of num_snapshots_lab
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* preserve behavior of num_snapshots_lab
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com>
Diffstat (limited to 'Source/Utils/IntervalsParser.H')
-rw-r--r-- | Source/Utils/IntervalsParser.H | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/Source/Utils/IntervalsParser.H b/Source/Utils/IntervalsParser.H index c91fe271a..06258b109 100644 --- a/Source/Utils/IntervalsParser.H +++ b/Source/Utils/IntervalsParser.H @@ -21,7 +21,7 @@ public: * (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); + 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 @@ -66,7 +66,14 @@ public: */ 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; @@ -148,4 +155,53 @@ private: 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_ |