20#ifndef PAVE_DYNAMIC_SOURCE_DATA_HPP
21#define PAVE_DYNAMIC_SOURCE_DATA_HPP
28#include <unordered_map>
61 using ElmT = std::remove_cv_t<T>;
69 return this->begin_[this->index(i)];
79 template <
typename Ret = SourceDataSpan&>
80 constexpr std::enable_if_t<! std::is_const_v<T>, Ret>
83 this->begin_[this->index(i)] = value;
94 template <
typename U,
typename Ret = SourceDataSpan&>
95 constexpr std::enable_if_t<! std::is_const_v<T>, Ret>
98 std::copy_n(src.begin_, NumItems, this->begin_);
104 static constexpr auto NumItems =
105 static_cast<std::size_t
>(Item::Last_Do_Not_Use);
114 explicit SourceDataSpan(T* begin)
122 constexpr std::size_t index(
const Item i)
const
124 const auto ix =
static_cast<std::size_t
>(i);
125 if (ix >= NumItems) {
126 throw std::invalid_argument {
127 "Index out of bounds"
157 [[nodiscard]] SourceDataSpan<double>
170 [[nodiscard]] SourceDataSpan<const double>
190 [[nodiscard]] SourceDataSpan<double>
191 sourceTerm(
const std::size_t ix, std::vector<double>& src);
202 void reconstruct(
const std::vector<std::size_t>& sourceLocations);
218 std::unordered_map<std::size_t, std::vector<double>::size_type> ix_{};
228 void buildLocationMapping(
const std::vector<std::size_t>& sourceLocations);
235 [[nodiscard]] std::optional<std::vector<double>::size_type>
236 index(
const std::size_t source)
const;
247 [[nodiscard]]
virtual std::vector<double>::size_type
248 storageIndex(std::vector<double>::size_type elemIndex)
const
Ad hoc implementation of fixed-width span/view of an underlying contiguous range of elements.
Definition PAvgDynamicSourceData.hpp:44
constexpr ElmT operator[](const Item i) const
Read-only access to numerical value of specified item.
Definition PAvgDynamicSourceData.hpp:67
constexpr std::enable_if_t<! std::is_const_v< T >, Ret > operator=(const SourceDataSpan< U > src)
Assign all items.
Definition PAvgDynamicSourceData.hpp:96
constexpr std::enable_if_t<! std::is_const_v< T >, Ret > set(const Item i, const ElmT value)
Assign specified item.
Definition PAvgDynamicSourceData.hpp:81
Item
Supported items of dynamic data per source location.
Definition PAvgDynamicSourceData.hpp:51
Dynamic source data for block-average pressure calculations.
Definition PAvgDynamicSourceData.hpp:35
virtual ~PAvgDynamicSourceData()
Destructor.
Definition PAvgDynamicSourceData.hpp:145
SourceDataSpan< double > operator[](const std::size_t source)
Acquire read/write span of data items corresponding to a single source location.
Definition PAvgDynamicSourceData.cpp:40
static constexpr std::size_t numSpanItems() noexcept
Provide number of span items using function syntax.
Definition PAvgDynamicSourceData.hpp:210
void reconstruct(const std::vector< std::size_t > &sourceLocations)
Reconstruct Source Data backing storage and internal mapping tables.
Definition PAvgDynamicSourceData.cpp:73
PAvgDynamicSourceData(const std::vector< std::size_t > &sourceLocations)
Constructor.
Definition PAvgDynamicSourceData.cpp:33
SourceDataSpan< double > sourceTerm(const std::size_t ix, std::vector< double > &src)
Form mutable data span into non-default backing store.
Definition PAvgDynamicSourceData.cpp:66
std::vector< double > src_
Contiguous array of data items for all source locations.
Definition PAvgDynamicSourceData.hpp:178
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30