23template<
typename ValueType,
typename SparsityViewType>
46 KOKKOS_INLINE_FUNCTION
57 KOKKOS_INLINE_FUNCTION
70template<
typename ValueType,
typename SparsityType>
76 NF_ASSERT(values_.exec() == sparsityPattern_->exec(),
"Executors are not the same");
79 toLocalIdx(values_.size()) == sparsityPattern_->nnz(),
80 "Matrix values and columns mismatch"
95 : values_(
values), sparsityPattern_(sp)
132 std::shared_ptr<const SparsityType>
sparsity,
135 requires std::is_same_v<typename SparsityType::SparsityIndexType, localIdx>
164 void reset() { values_ = ValueType {}; }
179 return sparsityPattern_->colIdxs();
188 return sparsityPattern_->rowOffs();
208 [[nodiscard]] std::shared_ptr<const SparsityType>
sparsity()
const {
return sparsityPattern_; }
215 return faceToMatrixAddress_;
226 values_.view(), sparsityPattern_->view()
254 std::shared_ptr<const SparsityType> sparsityPattern_;
256 std::shared_ptr<const FaceToMatrixAddress> faceToMatrixAddress_;
260template<
typename ValueType,
typename IndexType>
263template<
typename ValueType,
typename IndexType>
269template<
typename ValueType,
typename IndexType>
312template<
unsigned int I>
MixinClass signaling copyTo is supported.
An executor-aware contiguous container for numerical data with vector-style arithmetic semantics.
Sparse matrix class with compact storage by row (CSR) format.
std::shared_ptr< const FaceToMatrixAddress > faceToMatrixAddress() const
const Vector< typename la::CsrSparsityPattern< IndexType >::SparsityIndexType > & rowOffs() const
const Vector< ValueType > & values() const
Get a const reference to values vector.
localIdx nRows() const
Get the number of rows in the matrix.
Matrix(const Vector< ValueType > &values, const Vector< typename SparsityType::SparsityIndexType > &colIdxs, const Vector< typename SparsityType::SparsityIndexType > &rowOffs, Dimensions dimensions)
Constructor for Matrix.
MatrixView< const ValueType, SparsityView< typename SparsityType::SparsityIndexType > > view() const
Get a const view representation of the matrix's data.
SparsityType MatrixSparsityType
const Executor & exec() const
Get the executor associated with this matrix.
Matrix(const Vector< ValueType > &values, std::shared_ptr< const SparsityType > sparsity, std::shared_ptr< const FaceToMatrixAddress > faceToMatrixAddress)
Constructor for Matrix with a FaceToMatrixAddress.
ValueType MatrixValueType
MatrixView< ValueType, SparsityView< typename SparsityType::SparsityIndexType > > view()
Get a view representation of the matrix's data.
Vector< ValueType > diag() const
extract the diagonal of the matrix
const Vector< typename la::CsrSparsityPattern< IndexType >::SparsityIndexType > & colIdxs() const
Vector< ValueType > & values()
std::shared_ptr< const la::CsrSparsityPattern< IndexType > > sparsity() const
Matrix< ValueType, SparsityType > copyToExecutor(Executor dstExec) const override
Copy the matrix to another executor.
localIdx nNonZeros() const
Get the number of non-zero values in the matrix.
~Matrix()=default
Default destructor.
Matrix(const Vector< ValueType > &values, std::shared_ptr< const SparsityType > sp)
Constructor for Matrix.
#define NF_ASSERT(condition, message)
Macro for asserting a condition and printing an error message if the condition is false.
Matrix< ValueType, la::CooSparsityPattern< IndexType > > COOMatrix
auto getComponent(const CSRMatrix< Vec3, localIdx > &in)
Vector< scalar > scaledInverseDiag(const CSRMatrix< Vec3, localIdx > &, const Vector< scalar > &)
computes the inverted diagonal of a matrix and scales it by a, ie. a*D^-1
void scaledInvDiagNegLUx(const CSRMatrix< Vec3, localIdx > &mtx, const Vector< Vec3 > &a, const Vector< Vec3 > &b, const Vector< scalar > &vol, Vector< scalar > &rAU, Vector< Vec3 > &out)
computes out = -(L+U) x
Matrix< ValueType, la::CsrSparsityPattern< IndexType > > CSRMatrix
void negLUx(const CSRMatrix< Vec3, localIdx > &mtx, const Vector< Vec3 > &a, const Vector< Vec3 > &b, const Vector< scalar > &rAU, const Vector< scalar > &vol, Vector< Vec3 > &out)
computes out = -(L+U) x
Vector< ValueType > upper(const CSRMatrix< ValueType, IndexType > &)
extract the upper triangular of the matrix
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
localIdx toLocalIdx(sizeType value)
hold the number of rows and columns of a matrix
A view struct to allow easy read/write on all executors.
View< ValueType > values
View to the values of the CSR matrix.
KOKKOS_INLINE_FUNCTION ValueType & entry(const localIdx i, const localIdx j) const
Retrieve a reference to the matrix element at position (i,j).
KOKKOS_INLINE_FUNCTION ValueType & entry(const localIdx offset) const
Direct access to a value given the offset.
MatrixView(const View< ValueType > valueView, SparsityViewType sparsityView)
Constructor for MatrixView.
~MatrixView()=default
Default destructor.
SparsityViewType sparsity
A view struct to allow easy read/write on all executors.