20#ifndef OPM_WINDOWED_ARRAY_HPP
21#define OPM_WINDOWED_ARRAY_HPP
30#include <boost/range/iterator_range.hpp>
37namespace Opm {
namespace RestartIO {
namespace Helpers {
54 typename std::vector<T>::iterator>;
58 typename std::vector<T>::const_iterator>;
60 using Idx =
typename std::vector<T>::size_type;
75 : x_ (n.value * sz.value)
76 , windowSize_(sz.value)
79 throw std::invalid_argument(
"Window array with windowsize==0 is not permitted");
90 return this->x_.size() / this->windowSize_;
96 return this->windowSize_;
106 "Window ID Out of Bounds");
108 auto b = std::begin(this->x_) + window*this->windowSize_;
109 auto e = b + this->windowSize_;
121 "Window ID Out of Bounds");
123 auto b = std::begin(this->x_) + window*this->windowSize_;
124 auto e = b + this->windowSize_;
131 const std::vector<T>&
data()
const
141 return std::move(this->x_);
162 template <
typename T>
172 using Idx =
typename WindowedArray<T>::Idx;
189 const WindowSize& sz)
190 : data_ (NumWindows{ nRows.value * nCols.value }, sz)
191 , numCols_(nCols.value)
193 if (nCols.value == 0)
194 throw std::invalid_argument(
"Window matrix with columns==0 is not permitted");
200 return this->numCols_;
206 return this->data_.numWindows() / this->
numCols();
212 return this->data_.windowSize();
226 return this->data_[ this->i(row, col) ];
240 return this->data_[ this->i(row, col) ];
248 return this->data_.data();
255 ->
decltype(std::declval<WindowedArray<T>>()
258 return this->data_.getDataDestructively();
267 Idx i(
const Idx row,
const Idx col)
const
269 return row*this->
numCols() + col;
Provide read-only and read/write access to constantly sized portions/windows of a linearised buffer w...
Definition WindowedArray.hpp:50
std::vector< T > getDataDestructively()
Extract full, linearised data items for all windows.
Definition WindowedArray.hpp:139
Idx numWindows() const
Retrieve number of windows allocated for this array.
Definition WindowedArray.hpp:88
Idx windowSize() const
Retrieve number of data items per windows.
Definition WindowedArray.hpp:94
boost::iterator_range< typename std::vector< T >::const_iterator > ReadWindow
Read-only access.
Definition WindowedArray.hpp:58
const std::vector< T > & data() const
Get read-only access to full, linearised data items for all windows.
Definition WindowedArray.hpp:131
WriteWindow operator[](const Idx window)
Request read/write access to individual window.
Definition WindowedArray.hpp:103
boost::iterator_range< typename std::vector< T >::iterator > WriteWindow
Read/write access.
Definition WindowedArray.hpp:54
WindowedArray(const NumWindows n, const WindowSize sz)
Constructor.
Definition WindowedArray.hpp:74
ReadWindow operator[](const Idx window) const
Request read-only access to individual window.
Definition WindowedArray.hpp:118
Provide read-only and read/write access to constantly sized portions/windows of a linearised buffer w...
Definition WindowedArray.hpp:164
ReadWindow operator()(const Idx row, const Idx col) const
Request read-only access to individual window.
Definition WindowedArray.hpp:238
WriteWindow operator()(const Idx row, const Idx col)
Request read/write access to individual window.
Definition WindowedArray.hpp:224
auto getDataDestructively() -> decltype(std::declval< WindowedArray< T > >() .getDataDestructively())
Extract full, linearised data items for all windows.
Definition WindowedArray.hpp:254
WindowedMatrix(const NumRows &nRows, const NumCols &nCols, const WindowSize &sz)
Constructor.
Definition WindowedArray.hpp:187
Idx windowSize() const
Retrieve number of data items per windows.
Definition WindowedArray.hpp:210
Idx numRows() const
Retrieve number of rows allocated for this matrix.
Definition WindowedArray.hpp:204
Idx numCols() const
Retrieve number of columns allocated for this matrix.
Definition WindowedArray.hpp:198
auto data() const -> decltype(std::declval< const WindowedArray< T > >().data())
Get read-only access to full, linearised data items for all windows.
Definition WindowedArray.hpp:245
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Distinct compile-time type for number of windows in underlying storage.
Definition WindowedArray.hpp:64
Distinct compile-time type for size of windows (number of data items per window.)
Definition WindowedArray.hpp:68
Distinct compile-time type for number of matrix columns in underlying storage.
Definition WindowedArray.hpp:180
Distinct compile-time type for number of matrix rows in underlying storage.
Definition WindowedArray.hpp:176