NeoN
A framework for CFD software
Loading...
Searching...
No Matches
cooSparsityPattern.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
11
12namespace NeoN::la
13{
14
15
22template<typename IndexType>
23class CooSparsityPattern : public NeoN::SupportsCopyTo<CooSparsityPattern<IndexType>>
24{
25
26 void validate() const;
27
28public:
29
30 using SparsityIndexType = IndexType;
31
34
36
37 [[nodiscard]] CooSparsityPattern copyToExecutor(Executor dstExec) const override
38 {
40 colIdxs_.copyToExecutor(dstExec), rowIdxs_.copyToExecutor(dstExec), dimensions_
41 );
42 }
43
45
47 const Executor& exec() const { return rowOffs_.exec(); }
48
50 [[nodiscard]] const Vector<IndexType>& colIdxs() const { return colIdxs_; };
51
53 [[nodiscard]] Vector<IndexType>& colIdxs() { return colIdxs_; };
54
56 [[nodiscard]] const Vector<IndexType>& rowIdxs() const { return rowIdxs_; };
57
59 [[nodiscard]] Vector<IndexType>& rowIdxs() { return rowIdxs_; };
60
62 [[nodiscard]] const Vector<IndexType>& rowOffs() const { return rowOffs_; };
63
65 [[nodiscard]] Vector<IndexType>& rowOffs() { return rowOffs_; };
66
67 [[nodiscard]] localIdx rows() const { return dimensions_.rows; };
68
69 [[nodiscard]] localIdx nnz() const { return colIdxs_.size(); };
70
71 [[nodiscard]] Dimensions dimension() const { return dimensions_; };
72
77 [[nodiscard]] SparsityView<IndexType> view() const
78 {
79 return SparsityView<IndexType>(colIdxs_.view(), rowIdxs_.view());
80 }
81
82private:
83
84 Dimensions dimensions_;
85
86 Vector<IndexType> rowIdxs_;
87
88 Vector<IndexType> colIdxs_;
89
90 // NOTE for now the rowOffsets are kept since it is required for face based
91 // matrix assembly.
92 Vector<IndexType> rowOffs_;
93};
94
95} // namespace NeoN::la
MixinClass signaling copyTo is supported.
Definition copyTo.hpp:20
A class to contain the data and executors for a field and define some basic operations.
Definition vector.hpp:27
localIdx size() const
Gets the size of the field.
Definition vector.hpp:268
Vector< ValueType > copyToExecutor(Executor dstExec) const
Copies the data to a new field on a specific executor.
const Executor & exec() const
Gets the executor associated with the field.
Definition vector.hpp:262
View< ValueType > view() &&=delete
row and column index representation of a mesh
Vector< IndexType > & rowOffs()
returns the non-const COO per-entry row indices (one per nnz)
SparsityView< IndexType > view() const
Get a view representation of the matrix's data.
Vector< IndexType > & rowIdxs()
returns the non-const COO per-entry row indices (one per nnz)
const Vector< IndexType > & rowOffs() const
returns the COO per-entry row indices (one per nnz)
CooSparsityPattern(const CooSparsityPattern &sp)
create an "empty" SparsityPattern with a given size
const Vector< IndexType > & colIdxs() const
const getter for colIdxs
CooSparsityPattern(Vector< IndexType > &&colIdx, Vector< IndexType > &&rowIdxs, Dimensions dim)
Vector< IndexType > & colIdxs()
getter for colIdxs
CooSparsityPattern copyToExecutor(Executor dstExec) const override
const Executor & exec() const
getter for executor
const Vector< IndexType > & rowIdxs() const
returns the COO per-entry row indices (one per nnz)
int32_t localIdx
Definition label.hpp:50
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:20
hold the number of rows and columns of a matrix
A view struct to allow easy read/write on all executors.