16 #ifndef OPM_GPUISTL_MINIVECTOR_HPP 17 #define OPM_GPUISTL_MINIVECTOR_HPP 22 #include <initializer_list> 24 #include <type_traits> 26 #include <opm/common/ErrorMacros.hpp> 27 #include <opm/common/utility/gpuDecorators.hpp> 29 #include <dune/common/fvector.hh> 48 template <
class T,
int Dimension>
51 static_assert(Dimension > 0,
"Dimension must be positive");
63 using iterator =
typename std::array<T, Dimension>::iterator;
70 OPM_HOST_DEVICE constexpr
MiniVector() noexcept(std::is_nothrow_default_constructible<
value_type>::value) = default;
85 explicit MiniVector(
const Dune::FieldVector<T, Dimension>& fv)
87 for (
size_type i = 0; i < Dimension; ++i) {
104 OPM_HOST_DEVICE
MiniVector(std::initializer_list<value_type> init)
106 if (init.size() != Dimension) {
107 OPM_THROW(std::runtime_error,
"Opm::MiniVector – initializer‑list size mismatch");
109 std::copy_n(init.begin(), Dimension, data_.begin());
132 if (idx >= Dimension) {
133 OPM_THROW(std::out_of_range,
"Opm::MiniVector::at – index out of range");
140 if (idx >= Dimension) {
141 OPM_THROW(std::out_of_range,
"Opm::MiniVector::at – index out of range");
149 return data_.begin();
154 return data_.begin();
159 return data_.cbegin();
191 for (
auto& x : data_) {
199 for (
size_type i = 0; i < Dimension; ++i) {
200 if (data_[i] != other.data_[i]) {
210 return !(*
this == other);
223 for (
auto& x : result.data_) {
231 for (
size_type i = 0; i < Dimension; ++i) {
232 data_[i] += other.data_[i];
247 for (
size_type i = 0; i < Dimension; ++i) {
248 result.data_[i] -= other.data_[i];
255 for (
size_type i = 0; i < Dimension; ++i) {
256 data_[i] -= other.data_[i];
264 for (
auto& x : data_) {
272 std::array<value_type, Dimension> data_ {};
277 #endif // OPM_GPUISTL_MINIVECTOR_HPP OPM_HOST_DEVICE constexpr iterator end() noexcept
Definition: MiniVector.hpp:163
OPM_HOST_DEVICE constexpr const_iterator begin() const noexcept
Definition: MiniVector.hpp:152
OPM_HOST_DEVICE constexpr iterator begin() noexcept
Definition: MiniVector.hpp:147
static OPM_HOST_DEVICE constexpr size_type size() noexcept
Definition: MiniVector.hpp:179
OPM_HOST_DEVICE constexpr reference operator[](size_type idx) noexcept
Definition: MiniVector.hpp:115
OPM_HOST_DEVICE reference at(size_type idx)
Safe element access with bounds checking (throws on host).
Definition: MiniVector.hpp:130
OPM_HOST_DEVICE constexpr const_reference operator[](size_type idx) const noexcept
Definition: MiniVector.hpp:121
OPM_HOST_DEVICE bool operator==(const MiniVector &other) const noexcept
Definition: MiniVector.hpp:197
OPM_HOST_DEVICE const_reference at(size_type idx) const
Safe element access with bounds checking (throws on host).
Definition: MiniVector.hpp:138
OPM_HOST_DEVICE MiniVector & operator=(const value_type &value)
Definition: MiniVector.hpp:214
OPM_HOST_DEVICE constexpr MiniVector() noexcept(std::is_nothrow_default_constructible< value_type >::value)=default
Default‑constructs the MiniVector; elements are value‑initialized.
OPM_HOST_DEVICE constexpr const_iterator cbegin() const noexcept
Definition: MiniVector.hpp:157
OPM_HOST_DEVICE constexpr const_iterator end() const noexcept
Definition: MiniVector.hpp:168
T value_type
Element type.
Definition: MiniVector.hpp:55
value_type & reference
Mutable element reference.
Definition: MiniVector.hpp:59
OPM_HOST_DEVICE MiniVector & operator*=(const value_type &value)
Definition: MiniVector.hpp:262
typename std::array< T, Dimension >::const_iterator const_iterator
Immutable iterator.
Definition: MiniVector.hpp:65
const value_type & const_reference
Immutable element reference.
Definition: MiniVector.hpp:61
OPM_HOST_DEVICE constexpr void fill(const value_type &value)
Fill every component with the supplied value.
Definition: MiniVector.hpp:189
MiniVector(const Dune::FieldVector< T, Dimension > &fv)
Conversion constructor from Dune::FieldVector.
Definition: MiniVector.hpp:85
OPM_HOST_DEVICE bool operator!=(const MiniVector &other) const noexcept
Definition: MiniVector.hpp:208
A small, fixed‑dimension MiniVector class backed by std::array that can be used in both host and CUD...
Definition: AmgxInterface.hpp:37
OPM_HOST_DEVICE MiniVector(std::initializer_list< value_type > init)
Initializer‑list constructor.
Definition: MiniVector.hpp:104
std::size_t size_type
Index/size type.
Definition: MiniVector.hpp:57
OPM_HOST_DEVICE constexpr const_iterator cend() const noexcept
Definition: MiniVector.hpp:173
typename std::array< T, Dimension >::iterator iterator
Mutable iterator.
Definition: MiniVector.hpp:63
Definition: MiniVector.hpp:49