NeoN
A framework for CFD software
Loading...
Searching...
No Matches
include
NeoN
linearAlgebra
sparsityView.hpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2025 - 2026 NeoN authors
2
//
3
// SPDX-License-Identifier: MIT
4
5
#pragma once
6
7
#include "
NeoN/core/view.hpp
"
8
9
namespace
NeoN::la
10
{
11
16
struct
Dimensions
17
{
18
localIdx
rows
;
19
localIdx
cols
;
20
};
21
29
template
<
typename
IndexType>
30
struct
SparsityView
31
{
32
SparsityView
(
View<const IndexType>
colIdxsView,
View<const IndexType>
rowOffsView)
33
:
colIdxs
(colIdxsView),
rowOffs
(rowOffsView) {};
34
35
42
KOKKOS_INLINE_FUNCTION
43
IndexType
entry
(
const
IndexType i,
const
IndexType j)
const
44
{
45
const
IndexType rowSize =
rowOffs
[i + 1] -
rowOffs
[i];
46
for
(std::remove_const_t<IndexType> ic = 0; ic < rowSize; ++ic)
47
{
48
const
IndexType localCol =
rowOffs
[i] + ic;
49
if
(
colIdxs
[localCol] == j)
50
{
51
return
localCol;
52
}
53
if
(
colIdxs
[localCol] > j)
break
;
54
}
55
Kokkos::abort(
"Memory not allocated for CSR matrix component."
);
56
return
0;
// compiler warning suppression.
57
}
58
59
View<const IndexType>
colIdxs
;
60
View<const IndexType>
rowOffs
;
61
};
62
63
}
// namespace NeoN::la
NeoN::View
Definition
view.hpp:29
NeoN::la
Definition
cooSparsityPattern.hpp:13
NeoN::localIdx
int32_t localIdx
Definition
label.hpp:50
NeoN::la::Dimensions
hold the number of rows and columns of a matrix
Definition
sparsityView.hpp:17
NeoN::la::Dimensions::cols
localIdx cols
Definition
sparsityView.hpp:19
NeoN::la::Dimensions::rows
localIdx rows
Definition
sparsityView.hpp:18
NeoN::la::SparsityView::colIdxs
View< const IndexType > colIdxs
Definition
sparsityView.hpp:59
NeoN::la::SparsityView::SparsityView
SparsityView(View< const IndexType > colIdxsView, View< const IndexType > rowOffsView)
Definition
sparsityView.hpp:32
NeoN::la::SparsityView::entry
KOKKOS_INLINE_FUNCTION IndexType entry(const IndexType i, const IndexType j) const
Retrieve a reference to the matrix element at position (i,j).
Definition
sparsityView.hpp:43
NeoN::la::SparsityView::rowOffs
View< const IndexType > rowOffs
Definition
sparsityView.hpp:60
view.hpp
Generated by
1.15.0