NeoN
A framework for CFD software
Loading...
Searching...
No Matches
meshIterationStrategies.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#include <cstddef>
8#include <memory>
9#include <string>
10#include <utility>
11
13
18
19namespace NeoN::la
20{
21
28{
29
30protected:
31public:
32
34 virtual std::string name() const = 0;
35
37 virtual size_t size() const = 0;
38
40};
41
48{
49
50 std::shared_ptr<MeshIterationStrategy> strategy {};
51
52public:
53
55 void setStrategy(std::shared_ptr<MeshIterationStrategy> strategy);
56
58 std::shared_ptr<MeshIterationStrategy> get() const;
59
61 std::string name() const;
62};
63
64
71{
72
73public:
74
75 std::string name() const override { return "FaceBased"; }
76
77 size_t size() const override { return 0; }
78
79 ~FaceBasedIterator() override {}
80};
81
82
90{
91
92
93public:
94
96
104 {
105 CellBasedData() = delete;
106
122 template<
123 typename CellFaces,
124 typename FaceNeighbour,
125 typename FaceSign,
126 typename MatrixColumnIdx>
128 localIdx sizeIn,
129 CellFaces&& cellFacesIn,
130 FaceNeighbour&& faceNeighbourIn,
131 FaceSign&& faceSignIn,
132 MatrixColumnIdx&& matrixColumnIdxIn
133 )
134 : size(sizeIn), cellFaces(std::forward<CellFaces>(cellFacesIn)),
135 faceNeighbour(std::forward<FaceNeighbour>(faceNeighbourIn)),
136 faceSign(std::forward<FaceSign>(faceSignIn)),
137 matrixColumnIdx(std::forward<MatrixColumnIdx>(matrixColumnIdxIn))
138 {}
139
141
144
147
148 // TODO scalar is unreasonable large here
151
154 };
155
156 std::string name() const override;
157
158 size_t size() const override;
159
160 ~CellBasedIterator() override {}
161
163 std::shared_ptr<CellBasedData> getCellBasedData();
164
173 template<typename SparsityType>
175 const UnstructuredMesh& mesh,
176 std::shared_ptr<const SparsityType> sparsityPattern,
177 std::shared_ptr<const la::FaceToMatrixAddress> faceToMatrixAddress
178 );
179
193 template<typename SparsityType>
194 std::shared_ptr<CellBasedData> computeCellBasedData(
195 const UnstructuredMesh& mesh,
196 std::shared_ptr<const SparsityType> sparsityPattern,
197 const std::shared_ptr<const la::FaceToMatrixAddress> faceToMatrixAddress
198 );
199
200 std::shared_ptr<CellBasedData> cellBasedIteratorData_;
201};
202
203}
Data structure that stores a segmented fields or a vector of vectors.
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:27
Iteration strategy that traverses cells and their face stencils.
std::shared_ptr< CellBasedData > cellBasedIteratorData_
std::shared_ptr< CellBasedData > getCellBasedData()
Returns the pre-computed connectivity data, or nullptr if not yet initialised.
std::string name() const override
Returns the strategy name.
std::shared_ptr< CellBasedData > computeCellBasedData(const UnstructuredMesh &mesh, std::shared_ptr< const SparsityType > sparsityPattern, const std::shared_ptr< const la::FaceToMatrixAddress > faceToMatrixAddress)
Builds and returns cell-based connectivity data without storing it.
size_t size() const override
Returns the number of iteration elements (cells or faces).
void setComputeCellBasedData(const UnstructuredMesh &mesh, std::shared_ptr< const SparsityType > sparsityPattern, std::shared_ptr< const la::FaceToMatrixAddress > faceToMatrixAddress)
Computes and stores the cell-based connectivity data.
Iteration strategy that traverses internal faces.
size_t size() const override
Returns the number of iteration elements (cells or faces).
std::string name() const override
Returns the strategy name.
Abstract base class defining the interface for mesh iteration strategies.
virtual std::string name() const =0
Returns the strategy name.
virtual size_t size() const =0
Returns the number of iteration elements (cells or faces).
Holds and exposes the active MeshIterationStrategy.
void setStrategy(std::shared_ptr< MeshIterationStrategy > strategy)
Replaces the active strategy.
std::string name() const
Returns the name of the active strategy, or an empty string if none is set.
std::shared_ptr< MeshIterationStrategy > get() const
Returns the active strategy, or nullptr if none has been set.
int32_t localIdx
Definition label.hpp:50
Pre-computed connectivity required for cell-based assembly.
SegmentedVector< localIdx, localIdx > cellFaces
Cell-to-face stencil; segments correspond to cells, values are face indices.
CellBasedData(localIdx sizeIn, CellFaces &&cellFacesIn, FaceNeighbour &&faceNeighbourIn, FaceSign &&faceSignIn, MatrixColumnIdx &&matrixColumnIdxIn)
Construct from pre-computed connectivity arrays.
Vector< scalar > faceSign
Sign of the face contribution: +1 if this cell owns the face, -1 otherwise.
Vector< localIdx > faceNeighbour
For each stencil entry: the cell on the other side of the face.
Vector< localIdx > matrixColumnIdx
Flat index into the CSR matrix values array for each stencil entry.