aboutsummaryrefslogtreecommitdiff
path: root/Source/Utils/IntervalsParser.H
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Utils/IntervalsParser.H')
-rw-r--r--Source/Utils/IntervalsParser.H58
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_