WarpX
Loading...
Searching...
No Matches
IntervalsParser.H
Go to the documentation of this file.
1/* Copyright 2022 Andrew Myers, Burlen Loring, Luca Fedeli
2 * Maxence Thevenet, Remi Lehe, Revathi Jambunathan
3 *
4 * This file is part of WarpX.
5 *
6 * License: BSD-3-Clause-LBNL
7 */
8
9#ifndef WARPX_UTILS_PARSER_INTERVALSPARSER_H_
10#define WARPX_UTILS_PARSER_INTERVALSPARSER_H_
11
12#include <limits>
13#include <string>
14#include <vector>
15
17{
18
24 {
25 public:
36 SliceParser (const std::string& instr, bool isBTD=false);
37
45 [[nodiscard]] bool contains (int n) const;
46
53 [[nodiscard]] int nextContains (int n) const;
54
61 [[nodiscard]] int previousContains (int n) const;
62
67 [[nodiscard]] int getPeriod () const;
68
73 [[nodiscard]] int getStart () const;
74
79 [[nodiscard]] int getStop () const;
80
85 [[nodiscard]] int numContained() const;
86
87 private:
88 bool m_isBTD = false;
89 int m_start = 0;
90 int m_stop = std::numeric_limits<int>::max();
91 int m_period = 1;
92 std::string m_separator = ":";
93
94 };
95
96
103 {
104 public:
108 IntervalsParser () = default;
109
117 IntervalsParser (const std::vector<std::string>& instr_vec);
118
125 [[nodiscard]] bool contains (int n) const;
126
133 [[nodiscard]] int nextContains (int n) const;
134
141 [[nodiscard]] int previousContains (int n) const;
142
149 [[nodiscard]] int previousContainsInclusive (int n) const;
150
157 [[nodiscard]] int localPeriod (int n) const;
158
163 [[nodiscard]] bool isActivated () const;
164
165 private:
166 std::vector<SliceParser> m_slices;
167 std::string m_separator = ",";
168 bool m_activated = false;
169 };
170
177 {
178 public:
182 BTDIntervalsParser () = default;
183
191 BTDIntervalsParser (const std::vector<std::string>& instr_vec);
192
196 [[nodiscard]] int NumSnapshots () const;
197
203 [[nodiscard]] int GetBTDIteration(int i_buffer) const;
204
209 [[nodiscard]] int GetFinalIteration() const;
210
215 [[nodiscard]] bool isActivated () const;
216
217 private:
218 std::vector<int> m_btd_iterations;
219 std::vector<SliceParser> m_slices;
221 static constexpr char m_separator = ',';
222 bool m_activated = false;
223 };
224}
225
226#endif // WARPX_UTILS_PARSER_INTERVALSPARSER_H_
BTDIntervalsParser()=default
Default constructor of the BTDIntervalsParser class.
static constexpr char m_separator
Definition IntervalsParser.H:221
bool isActivated() const
A method that returns true if any of the slices contained by the IntervalsParser has a strictly posit...
Definition IntervalsParser.cpp:277
int GetFinalIteration() const
Return the final BTD iteration.
Definition IntervalsParser.cpp:271
std::vector< SliceParser > m_slices
Definition IntervalsParser.H:219
int GetBTDIteration(int i_buffer) const
Return the iteration number stored at index i_buffer.
Definition IntervalsParser.cpp:265
int NumSnapshots() const
Return the total number of unique labframe snapshots.
Definition IntervalsParser.cpp:259
std::vector< int > m_slice_starting_i_buffer
Definition IntervalsParser.H:220
std::vector< int > m_btd_iterations
Definition IntervalsParser.H:218
bool m_activated
Definition IntervalsParser.H:222
int nextContains(int n) const
A method that returns the smallest integer strictly greater than n such that contains(n) is true....
Definition IntervalsParser.cpp:119
std::vector< SliceParser > m_slices
Definition IntervalsParser.H:166
std::string m_separator
Definition IntervalsParser.H:167
bool m_activated
Definition IntervalsParser.H:168
IntervalsParser()=default
Default constructor of the IntervalsParser class.
int previousContainsInclusive(int n) const
A method that returns the greatest integer smaller than or equal to n such that contains(n) is true....
Definition IntervalsParser.cpp:139
int localPeriod(int n) const
A method the local period (in timesteps) of the IntervalsParser at timestep n. The period is defined ...
Definition IntervalsParser.cpp:147
int previousContains(int n) const
A method that returns the greatest integer strictly smaller than n such that contains(n) is true....
Definition IntervalsParser.cpp:129
bool isActivated() const
A method that returns true if any of the slices contained by the IntervalsParser has a strictly posit...
Definition IntervalsParser.cpp:153
bool contains(int n) const
A method that returns true if the input integer is contained in any of the slices contained by the In...
Definition IntervalsParser.cpp:112
int nextContains(int n) const
A method that returns the smallest integer strictly greater than n such that contains(n) is true....
Definition IntervalsParser.cpp:62
int getStop() const
A method that returns the slice stop.
Definition IntervalsParser.cpp:87
int previousContains(int n) const
A method that returns the greatest integer strictly smaller than n such that contains(n) is true....
Definition IntervalsParser.cpp:72
int m_period
Definition IntervalsParser.H:91
int numContained() const
A method that returns the number of integers contained by the slice.
Definition IntervalsParser.cpp:90
bool contains(int n) const
A method that returns true if the input integer is contained in the slice. (e.g. if the list is initi...
Definition IntervalsParser.cpp:55
int m_start
Definition IntervalsParser.H:89
bool m_isBTD
Definition IntervalsParser.H:88
int m_stop
Definition IntervalsParser.H:90
int getPeriod() const
A method that returns the slice period.
Definition IntervalsParser.cpp:81
std::string m_separator
Definition IntervalsParser.H:92
SliceParser(const std::string &instr, bool isBTD=false)
Constructor of the SliceParser class.
Definition IntervalsParser.cpp:19
int getStart() const
A method that returns the slice start.
Definition IntervalsParser.cpp:84
Definition IntervalsParser.H:17