NeoN
A framework for CFD software
Loading...
Searching...
No Matches
sparsityPattern.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2025 NeoN authors
3
4#pragma once
5
6#include "NeoN/core/array.hpp"
9
10namespace NeoN::la
11{
12
13/* @class SparsityPattern
14 * @brief row and column index representation of a mesh
15 *
16 * This class implements the finite volume 3/5/7 pt stencil specific generation
17 * of sparsity patterns from a given unstructured mesh
18 *
19 */
21{
22public:
23
24 /* @brief create an SparsityPattern from existing mesh */
26
27 /* @brief create an "empty" SparsityPattern with a given size */
29
36 );
37
38 /*@brief getter for ownerOffset */
40
41 /*@brief getter for neighbourOffset */
43
44 /*@brief getter for diagOffset */
45 const Array<uint8_t>& diagOffset() const;
46
47 /*@brief getter for ownerOffset */
49
50 /*@brief getter for neighbourOffset */
52
53 /*@brief getter for diagOffset */
55
56 /*@brief getter for diagOffset */
57 const Executor& exec() const { return exec_; };
58
59 /*@brief getter for colIdxs */
60 [[nodiscard]] const Vector<localIdx>& colIdxs() const { return colIdxs_; };
61
62 [[nodiscard]] Vector<localIdx>& colIdxs() { return colIdxs_; };
63
64 /*@brief getter for rowOffs */
65 [[nodiscard]] const Vector<localIdx>& rowOffs() const { return rowOffs_; };
66
67 /*@brief getter for rowOffs */
68 [[nodiscard]] Vector<localIdx>& rowOffs() { return rowOffs_; };
69
70 [[nodiscard]] localIdx rows() const { return diagOffset_.size(); };
71
72 [[nodiscard]] localIdx nnz() const { return colIdxs_.size(); };
73
74 // TODO add selection mechanism via dictionary later
75 static const SparsityPattern& readOrCreate(const UnstructuredMesh& mesh);
76
77private:
78
79 Executor exec_;
80
81 Vector<localIdx> rowOffs_;
82
83 Vector<localIdx> colIdxs_;
84
85 Array<uint8_t> ownerOffset_;
86
87 Array<uint8_t> neighbourOffset_;
88
89 Array<uint8_t> diagOffset_;
90};
91
93
95
96} // namespace NeoN::la
A class to contain the data and executors for a field and define some basic operations.
Definition array.hpp:29
localIdx size() const
Gets the size of the field.
Definition array.hpp:270
Represents an unstructured mesh in NeoN.
A class to contain the data and executors for a field and define some basic operations.
Definition vector.hpp:28
localIdx size() const
Gets the size of the field.
Definition vector.hpp:233
const Array< uint8_t > & ownerOffset() const
const Array< uint8_t > & neighbourOffset() const
const Vector< localIdx > & colIdxs() const
const Vector< localIdx > & rowOffs() const
const Array< uint8_t > & diagOffset() const
const Executor & exec() const
Array< uint8_t > & diagOffset()
Array< uint8_t > & neighbourOffset()
static const SparsityPattern & readOrCreate(const UnstructuredMesh &mesh)
SparsityPattern(const UnstructuredMesh &mesh)
Vector< localIdx > & colIdxs()
SparsityPattern(Executor exec, localIdx nRows, localIdx nnzs)
Vector< localIdx > & rowOffs()
Array< uint8_t > & ownerOffset()
SparsityPattern(Array< uint8_t > &&rowOffs, Array< uint8_t > &&colIdxs, Array< uint8_t > &&ownerOffset, Vector< localIdx > &&neighbourOffset, Vector< localIdx > &&diagOffset)
SparsityPattern updateSparsity(const UnstructuredMesh &mesh, SparsityPattern &in)
SparsityPattern createSparsity(const UnstructuredMesh &mesh)
int32_t localIdx
Definition label.hpp:30
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:16