SpECTRE Documentation Coverage Report
Current view: top level - DataStructures - StripeIterator.hpp Hit Total Coverage
Commit: 9a905b0737f373631c1b8e8389b8f26e67fa5313 Lines: 6 12 50.0 %
Date: 2024-03-28 09:03:18
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include <cstddef>
       7             : #include <limits>
       8             : 
       9             : #include "Utilities/Gsl.hpp"
      10             : 
      11             : template <size_t>
      12             : class Index;
      13             : 
      14             : /*!
      15             :  * \ingroup DataStructuresGroup
      16             :  * \brief Iterates over the 1-dimensional stripes with info on how to
      17             :  * iterate over the current stripe
      18             :  */
      19           1 : class StripeIterator {
      20             :  public:
      21             :   /// Construct from the grid points in each direction and which dimension the
      22             :   /// stripes are in.
      23             :   template <size_t Dim>
      24           1 :   StripeIterator(const Index<Dim>& extents, size_t stripe_dim);
      25             : 
      26             :   /// Returns `true` if the iterator is valid
      27           1 :   explicit operator bool() const { return offset_ < size_; }
      28             : 
      29             :   /// Increment to the next stripe.
      30           1 :   StripeIterator& operator++() {
      31             :     ++offset_;
      32             :     ++stride_count_;
      33             :     if (UNLIKELY(stride_count_ == stride_)) {
      34             :       offset_ += jump_;
      35             :       stride_count_ = 0;
      36             :     }
      37             :     return *this;
      38             :   }
      39             : 
      40             :   /// Offset into DataVector for first element of stripe.
      41           1 :   size_t offset() const { return offset_; }
      42             : 
      43             :   /// Stride of elements in DataVector for the stripe.
      44           1 :   size_t stride() const { return stride_; }
      45             : 
      46             :  private:
      47           0 :   size_t offset_ = std::numeric_limits<size_t>::max();
      48           0 :   size_t size_ = std::numeric_limits<size_t>::max();
      49           0 :   size_t stride_ = std::numeric_limits<size_t>::max();
      50           0 :   size_t stride_count_ = std::numeric_limits<size_t>::max();
      51           0 :   size_t jump_ = std::numeric_limits<size_t>::max();
      52             : };

Generated by: LCOV version 1.14