Skip to content
Snippets Groups Projects
Commit 2e7efc95 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add NodeByCellData::SubViewConst

parent a9561274
No related branches found
No related tags found
1 merge request!6Feature/crs
...@@ -58,6 +58,42 @@ class NodeByCellData ...@@ -58,6 +58,42 @@ class NodeByCellData
} }
}; };
class SubViewConst
{
private:
KOKKOS_RESTRICT const DataType* const m_sub_values;
const size_t m_size;
public:
KOKKOS_INLINE_FUNCTION
const DataType& operator[](const size_t& i) const
{
Assert(i<m_size);
return m_sub_values[i];
}
KOKKOS_INLINE_FUNCTION
const size_t& size() const
{
return m_size;
}
SubViewConst(const SubViewConst&) = delete;
KOKKOS_INLINE_FUNCTION
SubViewConst(SubViewConst&&) = default;
KOKKOS_INLINE_FUNCTION
SubViewConst(const Kokkos::View<DataType*>& values,
const size_t& begin,
const size_t& end)
: m_sub_values(&(values[begin])),
m_size(end-begin)
{
Assert(begin<=end);
Assert(end<=values.extent(0));
}
};
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
DataType& operator()(const size_t& j, const size_t& r) DataType& operator()(const size_t& j, const size_t& r)
{ {
...@@ -108,6 +144,14 @@ class NodeByCellData ...@@ -108,6 +144,14 @@ class NodeByCellData
return SubView(m_values, cell_begin, cell_end); return SubView(m_values, cell_begin, cell_end);
} }
KOKKOS_INLINE_FUNCTION
SubViewConst cellValues(const size_t& i_cell) const
{
const ConnectivityMatrix::size_type& cell_begin = m_node_id_per_cell_matrix.row_map[i_cell];
const ConnectivityMatrix::size_type& cell_end = m_node_id_per_cell_matrix.row_map[i_cell+1];
return SubViewConst(m_values, cell_begin, cell_end);
}
NodeByCellData(const ConnectivityMatrix& node_id_per_cell_matrix) NodeByCellData(const ConnectivityMatrix& node_id_per_cell_matrix)
: m_node_id_per_cell_matrix(node_id_per_cell_matrix), : m_node_id_per_cell_matrix(node_id_per_cell_matrix),
m_values("values", m_node_id_per_cell_matrix.entries.extent(0)) m_values("values", m_node_id_per_cell_matrix.entries.extent(0))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment