NeoN
A framework for CFD software
Loading...
Searching...
No Matches
csrSparsityPattern.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
21template<typename IndexType>
22class CsrSparsityPattern : public NeoN::SupportsCopyTo<CsrSparsityPattern<IndexType>>
23{
24
25 void validate() const;
26
27public:
28
29 using SparsityIndexType = IndexType;
30
31 /* @brief create an "empty" SparsityPattern with a given size */
33
35
36 [[nodiscard]] CsrSparsityPattern copyToExecutor(Executor dstExec) const override
37 {
39 colIdxs_.copyToExecutor(dstExec), rowOffs_.copyToExecutor(dstExec), dimensions_
40 );
41 }
42
44
45 /*@brief getter for executor */
46 const Executor& exec() const { return rowOffs_.exec(); }
47
48 /*@brief getter for colIdxs */
49 [[nodiscard]] const Vector<IndexType>& colIdxs() const { return colIdxs_; };
50
51 [[nodiscard]] Vector<IndexType>& colIdxs() { return colIdxs_; };
52
53 /*@brief getter for rowOffs */
54 [[nodiscard]] const Vector<IndexType>& rowOffs() const { return rowOffs_; };
55
56 /*@brief getter for non-const rowOffs */
57 [[nodiscard]] Vector<IndexType>& rowOffs() { return rowOffs_; };
58
59 [[nodiscard]] localIdx rows() const { return dimensions_.rows; };
60
61 [[nodiscard]] localIdx nnz() const { return colIdxs_.size(); };
62
63 [[nodiscard]] Dimensions dimension() const { return dimensions_; };
68 [[nodiscard]] SparsityView<IndexType> view() const
69 {
70 return SparsityView<IndexType>(colIdxs_.view(), rowOffs_.view());
71 }
72
73private:
74
75 Dimensions dimensions_;
76
77 Vector<IndexType> rowOffs_;
78
79 Vector<IndexType> colIdxs_;
80};
81
82} // 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
const Vector< IndexType > & rowOffs() const
CsrSparsityPattern(const CsrSparsityPattern &sp)
CsrSparsityPattern(Vector< IndexType > &&colIdx, Vector< IndexType > &&rowOffs, Dimensions dim)
const Vector< IndexType > & colIdxs() const
Vector< IndexType > & colIdxs()
Vector< IndexType > & rowOffs()
SparsityView< IndexType > view() const
Get a view representation of the matrix's data.
CsrSparsityPattern copyToExecutor(Executor dstExec) const override
const Executor & exec() const
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.