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