chombo-discharge
Loading...
Searching...
No Matches
CD_CutCellSurfaceImplem.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_CUTCELLSURFACEIMPLEM_H
14#define CD_CUTCELLSURFACEIMPLEM_H
15
16// Std includes
17#include <cstring>
18
19// Our includes
20#include <CD_CutCellSurface.H>
21#include <CD_NamespaceHeader.H>
22
23namespace PolyhedralEB {
24
26{
27 for (int edge = 0; edge < s_numEdges; edge++) {
29 }
30
31 for (int corner = 0; corner < s_numCorners; corner++) {
32 m_corner[corner] = 0.0;
33 }
34
35 m_fluidJoined = 0;
37}
38
39inline bool
40CutCellSurface::hasCrossing(const int a_edge) const noexcept
41{
42 return m_crossing[a_edge] != s_noCrossing;
43}
44
45inline int
47{
48 return static_cast<int>(sizeof(m_crossing) + sizeof(m_corner) + sizeof(m_fluidJoined) + sizeof(m_role));
49}
50
51inline void
52CutCellSurface::linearOut(void* a_buffer) const noexcept
53{
54 char* buffer = static_cast<char*>(a_buffer);
55
56 std::memcpy(buffer, m_crossing, sizeof(m_crossing));
57 std::memcpy(buffer + sizeof(m_crossing), m_corner, sizeof(m_corner));
58 std::memcpy(buffer + sizeof(m_crossing) + sizeof(m_corner), &m_fluidJoined, sizeof(m_fluidJoined));
59 std::memcpy(buffer + sizeof(m_crossing) + sizeof(m_corner) + sizeof(m_fluidJoined), &m_role, sizeof(m_role));
60}
61
62inline void
63CutCellSurface::linearIn(const void* a_buffer) noexcept
64{
65 const char* buffer = static_cast<const char*>(a_buffer);
66
67 std::memcpy(m_crossing, buffer, sizeof(m_crossing));
68 std::memcpy(m_corner, buffer + sizeof(m_crossing), sizeof(m_corner));
69 std::memcpy(&m_fluidJoined, buffer + sizeof(m_crossing) + sizeof(m_corner), sizeof(m_fluidJoined));
70 std::memcpy(&m_role, buffer + sizeof(m_crossing) + sizeof(m_corner) + sizeof(m_fluidJoined), sizeof(m_role));
71}
72
73} // namespace PolyhedralEB
74
75#include <CD_NamespaceFooter.H>
76
77#endif
Declaration of the data a cut cell's embedded boundary is reconstructed from.
static constexpr int s_native
Role of a stored surface: the cell's body is built from the surface alone.
Definition CD_CutCellSurface.H:61
void linearIn(const void *a_buffer) noexcept
Read the surface from a linear buffer written by linearOut.
Definition CD_CutCellSurfaceImplem.H:63
int linearSize() const noexcept
Number of bytes the surface occupies in a linear buffer, as Chombo's containers ask of their payload.
Definition CD_CutCellSurfaceImplem.H:46
bool hasCrossing(const int a_edge) const noexcept
Whether the edge carries a crossing.
Definition CD_CutCellSurfaceImplem.H:40
int m_role
How the cell's body is built from this surface: s_native, s_overridden or s_invalid.
Definition CD_CutCellSurface.H:140
Real m_corner[s_numCorners]
Implicit function at the cell corners, ordered so that corner c has offset ((c >> d) & 1) in directio...
Definition CD_CutCellSurface.H:126
int m_fluidJoined
Which faces join their fluid corners, one bit per face whose corners alternate in sign.
Definition CD_CutCellSurface.H:135
static constexpr int s_numEdges
Number of cell edges a crossing can sit on.
Definition CD_CutCellSurface.H:46
static constexpr Real s_noCrossing
Marks an edge whose endpoints lie on the same side of the interface.
Definition CD_CutCellSurface.H:56
static constexpr int s_numCorners
Number of cell corners.
Definition CD_CutCellSurface.H:51
Real m_crossing[s_numEdges]
Position along an edge where the implicit function changes sign.
Definition CD_CutCellSurface.H:120
CutCellSurface() noexcept
Constructor. Leaves every edge without a crossing, every corner at zero, no face joining its fluid co...
Definition CD_CutCellSurfaceImplem.H:25
void linearOut(void *a_buffer) const noexcept
Write the surface into a linear buffer, as Chombo's containers ask of their payload.
Definition CD_CutCellSurfaceImplem.H:52