chombo-discharge
Loading...
Searching...
No Matches
CD_CutCellFaceOverrides.H
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021-2026 SINTEF Energy Research
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
12
13#ifndef CD_CUTCELLFACEOVERRIDES_H
14#define CD_CUTCELLFACEOVERRIDES_H
15
16// Std includes
17#include <vector>
18
19// Chombo includes
20#include <IntVect.H>
21#include <RealVect.H>
22
23// Our includes
24#include <CD_NamespaceHeader.H>
25
26namespace PolyhedralEB {
27
48{
49public:
53 static constexpr int s_finer = 0;
54
58 static constexpr int s_closed = 1;
59
64 static constexpr int s_closedLowHalf = 2;
65
69 static constexpr int s_closedHighHalf = 3;
70
74 CutCellFaceOverrides() noexcept;
75
79 ~CutCellFaceOverrides() noexcept = default;
80
84 void
85 clear() noexcept;
86
92 void
93 beginCell(const IntVect& a_cell);
94
100 void
101 beginFace(const int a_face, const int a_reason);
102
109 void
110 addPolygon(const RealVect* a_vertices, const int* a_vertexEdges, const int a_numVertices);
111
115 void
116 endCell() noexcept;
117
122 int
123 numCells() const noexcept;
124
130 int
131 find(const IntVect& a_cell) const noexcept;
132
138 const IntVect&
139 cell(const int a_index) const noexcept;
140
147 void
148 faces(const int a_index, int& a_begin, int& a_end) const noexcept;
149
155 int
156 face(const int a_face) const noexcept;
157
163 int
164 reason(const int a_face) const noexcept;
165
172 void
173 polygons(const int a_face, int& a_begin, int& a_end) const noexcept;
174
181 void
182 vertices(const int a_polygon, int& a_begin, int& a_end) const noexcept;
183
189 const RealVect&
190 vertex(const int a_vertex) const noexcept;
191
197 int
198 vertexEdge(const int a_vertex) const noexcept;
199
205 int
206 linearSize(const int a_index) const noexcept;
207
214 void
215 linearOut(void* a_buffer, const int a_index) const noexcept;
216
224 int
225 linearIn(const void* a_buffer, const IntVect& a_cell);
226
233 static bool
234 precedes(const IntVect& a_first, const IntVect& a_second) noexcept;
235
241 bool
242 equals(const CutCellFaceOverrides& a_other) const noexcept;
243
244protected:
248 std::vector<IntVect> m_cells;
249
253 std::vector<int> m_cellFaces;
254
258 std::vector<int> m_face;
259
263 std::vector<int> m_reason;
264
268 std::vector<int> m_facePolygons;
269
273 std::vector<int> m_polygonVertices;
274
278 std::vector<RealVect> m_vertices;
279
283 std::vector<int> m_vertexEdges;
284};
285
286} // namespace PolyhedralEB
287
288#include <CD_NamespaceFooter.H>
289
290#endif
void polygons(const int a_face, int &a_begin, int &a_end) const noexcept
The polygons of a face entry, as a range of polygon indices.
Definition CD_CutCellFaceOverrides.cpp:146
const RealVect & vertex(const int a_vertex) const noexcept
A vertex position, in its cell's frame.
Definition CD_CutCellFaceOverrides.cpp:160
void clear() noexcept
Drop every entry.
Definition CD_CutCellFaceOverrides.cpp:32
std::vector< int > m_reason
Reason of every face entry.
Definition CD_CutCellFaceOverrides.H:263
static constexpr int s_closedLowHalf
Why a face is overridden, in two dimensions: the half of it below its midpoint is closed,...
Definition CD_CutCellFaceOverrides.H:64
std::vector< int > m_facePolygons
First polygon of every face entry, and one past the last polygon of the last.
Definition CD_CutCellFaceOverrides.H:268
const IntVect & cell(const int a_index) const noexcept
The cell at an index.
Definition CD_CutCellFaceOverrides.cpp:117
int find(const IntVect &a_cell) const noexcept
A cell's position among the cells with entries.
Definition CD_CutCellFaceOverrides.cpp:105
static constexpr int s_closedHighHalf
Why a face is overridden, in two dimensions: the half of it above its midpoint is closed.
Definition CD_CutCellFaceOverrides.H:69
void vertices(const int a_polygon, int &a_begin, int &a_end) const noexcept
The vertices of a polygon, as a range of vertex indices.
Definition CD_CutCellFaceOverrides.cpp:153
std::vector< RealVect > m_vertices
Every vertex position.
Definition CD_CutCellFaceOverrides.H:278
int linearSize(const int a_index) const noexcept
Bytes one cell's entries occupy in a linear buffer.
Definition CD_CutCellFaceOverrides.cpp:192
std::vector< int > m_polygonVertices
First vertex of every polygon, and one past the last vertex of the last.
Definition CD_CutCellFaceOverrides.H:273
std::vector< IntVect > m_cells
The cells with entries, in increasing order.
Definition CD_CutCellFaceOverrides.H:248
static constexpr int s_closed
Why a face is overridden: closed onto a covered cell.
Definition CD_CutCellFaceOverrides.H:58
int face(const int a_face) const noexcept
Which face of its cell a face entry is.
Definition CD_CutCellFaceOverrides.cpp:134
bool equals(const CutCellFaceOverrides &a_other) const noexcept
Whether two sets of entries are the same, bit for bit.
Definition CD_CutCellFaceOverrides.cpp:172
void faces(const int a_index, int &a_begin, int &a_end) const noexcept
The faces of a cell, as a range of face indices.
Definition CD_CutCellFaceOverrides.cpp:125
std::vector< int > m_cellFaces
First face of every cell, and one past the last face of the last.
Definition CD_CutCellFaceOverrides.H:253
void beginFace(const int a_face, const int a_reason)
Open a face of the cell last begun.
Definition CD_CutCellFaceOverrides.cpp:55
CutCellFaceOverrides() noexcept
Constructor. Holds no cell.
Definition CD_CutCellFaceOverrides.cpp:26
int vertexEdge(const int a_vertex) const noexcept
The cell edge a vertex came from.
Definition CD_CutCellFaceOverrides.cpp:166
void linearOut(void *a_buffer, const int a_index) const noexcept
Write one cell's entries into a linear buffer: its faces, each with its polygons, each with its verti...
Definition CD_CutCellFaceOverrides.cpp:213
std::vector< int > m_face
Face index of every face entry.
Definition CD_CutCellFaceOverrides.H:258
int numCells() const noexcept
Number of cells with entries.
Definition CD_CutCellFaceOverrides.cpp:99
static constexpr int s_finer
Why a face is overridden: restricted to the finer level's chords.
Definition CD_CutCellFaceOverrides.H:53
std::vector< int > m_vertexEdges
Cell edge every vertex came from, or -1.
Definition CD_CutCellFaceOverrides.H:283
int linearIn(const void *a_buffer, const IntVect &a_cell)
Read one cell's entries from a buffer written by linearOut, and add them for a cell.
Definition CD_CutCellFaceOverrides.cpp:248
void beginCell(const IntVect &a_cell)
Open the entries of a cell.
Definition CD_CutCellFaceOverrides.cpp:46
void addPolygon(const RealVect *a_vertices, const int *a_vertexEdges, const int a_numVertices)
Add a polygon to the face last begun.
Definition CD_CutCellFaceOverrides.cpp:69
int reason(const int a_face) const noexcept
Why a face entry overrides its face.
Definition CD_CutCellFaceOverrides.cpp:140
void endCell() noexcept
Drop the cell last begun if no face was added to it.
Definition CD_CutCellFaceOverrides.cpp:86
static bool precedes(const IntVect &a_first, const IntVect &a_second) noexcept
Whether one cell comes before another in the order the cells are kept in.
Definition CD_CutCellFaceOverrides.cpp:297