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

Define NodeValuePerFace

Also removed SubItemValuePerItem::SubViewConst to conform to Kokkos policy
One should allow constructions as SubItemValuePerItem<IT0, IT2, const DT>
following Kokkos
parent 71a0343d
Branches
Tags
1 merge request!6Feature/crs
......@@ -403,6 +403,14 @@ Connectivity<3>::itemToItemMatrix<TypeOfItem::face,
{
return m_face_to_cell_matrix;
}
template <>
template <>
inline const ConnectivityMatrix&
Connectivity<3>::itemToItemMatrix<TypeOfItem::face,
TypeOfItem::node>() const
{
return m_face_to_node_matrix;
}
template <>
template <>
......@@ -443,6 +451,15 @@ Connectivity<2>::itemToItemMatrix<TypeOfItem::face,
return m_face_to_cell_matrix;
}
template <>
template <>
inline const ConnectivityMatrix&
Connectivity<2>::itemToItemMatrix<TypeOfItem::face,
TypeOfItem::node>() const
{
return m_face_to_node_matrix;
}
template <>
template <>
inline const ConnectivityMatrix&
......@@ -483,6 +500,16 @@ Connectivity<1>::itemToItemMatrix<TypeOfItem::face,
return m_face_to_cell_matrix;
}
template <>
template <>
inline const ConnectivityMatrix&
Connectivity<1>::itemToItemMatrix<TypeOfItem::face,
TypeOfItem::node>() const
{
#warning in 1d, faces and node are the same
return m_face_to_node_matrix;
}
template <>
template <>
inline const ConnectivityMatrix&
......@@ -519,6 +546,9 @@ itemToItemMatrix(const TypeOfItem& item_type_0,
case TypeOfItem::cell: {
return itemToItemMatrix<TypeOfItem::face, TypeOfItem::cell>();
}
case TypeOfItem::node: {
return itemToItemMatrix<TypeOfItem::face, TypeOfItem::node>();
}
default: {
std::cerr << __FILE__ << ":" << __LINE__ << ": NIY " << int(item_type_1) << "\n";
std::exit(1);
......
......@@ -61,42 +61,6 @@ class SubItemValuePerItem
}
};
class SubViewConst
{
private:
KOKKOS_RESTRICT const DataType* const m_sub_values;
const size_t m_size;
public:
KOKKOS_FORCEINLINE_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));
}
};
SubItemValuePerItem& operator=(const SubItemValuePerItem&) = default;
KOKKOS_FORCEINLINE_FUNCTION
......@@ -105,8 +69,10 @@ class SubItemValuePerItem
return m_values[m_host_row_map(j)+r];
}
// Following Kokkos logic, these classes are view and const view does allow
// changes in data
KOKKOS_FORCEINLINE_FUNCTION
const DataType& operator()(const size_t& j, const size_t& r) const
DataType& operator()(const size_t& j, const size_t& r) const
{
return m_values[m_host_row_map(j)+r];
}
......@@ -123,8 +89,10 @@ class SubItemValuePerItem
return m_values[i];
}
// Following Kokkos logic, these classes are view and const view does allow
// changes in data
KOKKOS_FORCEINLINE_FUNCTION
const DataType& operator[](const size_t & i) const
DataType& operator[](const size_t & i) const
{
return m_values[i];
}
......@@ -132,7 +100,7 @@ class SubItemValuePerItem
KOKKOS_INLINE_FUNCTION
size_t numberOfItems() const
{
Assert(m_host_row_map.extent(0) != 0>0);
Assert(m_host_row_map.extent(0) != 0);
return m_host_row_map.extent(0);
}
......@@ -150,12 +118,14 @@ class SubItemValuePerItem
return SubView(m_values, cell_begin, cell_end);
}
// Following Kokkos logic, these classes are view and const view does allow
// changes in data
KOKKOS_INLINE_FUNCTION
SubViewConst itemValues(const size_t& i_cell) const
SubView itemValues(const size_t& i_cell) const
{
const auto& cell_begin = m_host_row_map(i_cell);
const auto& cell_end = m_host_row_map(i_cell+1);
return SubViewConst(m_values, cell_begin, cell_end);
return SubView(m_values, cell_begin, cell_end);
}
SubItemValuePerItem() = default;
......@@ -174,6 +144,9 @@ class SubItemValuePerItem
template <typename DataType>
using NodeValuePerCell = SubItemValuePerItem<DataType, TypeOfItem::node, TypeOfItem::cell>;
template <typename DataType>
using NodeValuePerFace = SubItemValuePerItem<DataType, TypeOfItem::node, TypeOfItem::face>;
template <typename DataType>
using FaceValuePerCell = SubItemValuePerItem<DataType, TypeOfItem::face, TypeOfItem::cell>;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment