chombo-discharge
Loading...
Searching...
No Matches
CD_CutCellBody.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
13#ifndef CD_CUTCELLBODY_H
14#define CD_CUTCELLBODY_H
15
16// Chombo includes
17#include <RealVect.H>
18#include <LoHiSide.H>
19
20// Our includes
21#include <CD_CutCellSurface.H>
23#include <CD_NamespaceHeader.H>
24
25namespace PolyhedralEB {
26
45{
46public:
50 enum class Kind
51 {
52 Regular,
53 Covered,
54 Cut
55 };
56
60 CutCellBody() noexcept;
61
65 ~CutCellBody() noexcept = default;
66
75 bool
76 define(const CutCellSurface& a_surface) noexcept;
77
91 static Kind
92 classify(const CutCellSurface& a_surface) noexcept;
93
104 static int
105 numSheets(const CutCellSurface& a_surface) noexcept;
106
119 bool
120 isConnected() const noexcept;
121
133 bool
134 interfaceIsPlanar() const noexcept;
135
155 bool
156 subdivide(CutCellBody* a_children) const noexcept;
157
178 bool
179 hasMultiValuedChildren(const int a_refRat) const noexcept;
180
185 Real
186 volumeFraction() const noexcept;
187
192 const RealVect&
193 volumeCentroid() const noexcept;
194
201 Real
202 areaFraction(const int a_dir, const Side::LoHiSide a_side) const noexcept;
203
210 const RealVect&
211 faceCentroid(const int a_dir, const Side::LoHiSide a_side) const noexcept;
212
220 Real
221 boundaryArea() const noexcept;
222
229 Real
230 trueBoundaryArea() const noexcept;
231
236 const RealVect&
237 normal() const noexcept;
238
243 const RealVect&
244 boundaryCentroid() const noexcept;
245
253 Real
254 closureResidual() const noexcept;
255
256#if CH_SPACEDIM == 3
269 void
270 appendInterfaceFacets(Vector<Real>& a_facets,
271 const IntVect& a_cell,
272 const RealVect& a_probLo,
273 const Real a_dx) const noexcept;
274
279 void
280 printPolygons(std::ostream& a_out) const noexcept;
281
294 bool
295 restrictFace(const CutCellSurface* a_children, const int a_dir, const int a_side) noexcept;
296
304 bool
305 closeInterface() noexcept;
306
316 bool
317 closeBoundary(const int a_face) noexcept;
318
336 bool
337 snapFace(const int a_dir, const int a_side, const bool a_neighbourIsFluid) noexcept;
338
350 bool
351 weldTJunctions() noexcept;
352
353#endif
354
359 int
360 numPolygons() const noexcept;
361
366 int
367 widestPolygon() const noexcept;
368
378 Real
379 divergenceResidual() const noexcept;
380
381protected:
385 static constexpr int s_numFaces = 2 * SpaceDim;
386
390 static constexpr int s_maxPolygons = 20;
391
407 static constexpr int s_maxVertices = 20;
408
415 static constexpr Real s_edgeTolerance = 1.0E-12;
416
423 static constexpr Real s_nullArea = 1.0E-18;
427 struct Polygon
428 {
432 RealVect m_vertex[s_maxVertices];
433
437 int m_vertexEdge[s_maxVertices];
438
443
448
457 int m_segmentFace[s_maxVertices];
458 };
459
467 void
468 defineDegenerate(const CutCellSurface& a_surface, const Kind a_kind) noexcept;
469
476 bool
477 defineCut(const CutCellSurface& a_surface) noexcept;
478
479#if CH_SPACEDIM == 3
493 bool
494 mergeCoplanar(const Polygon* a_in, const int a_num, Polygon* a_out, const int a_maxOut, int& a_numOut) const noexcept;
495
508 int
509 faceWalk(const int a_dir, const int a_side, const CutCellSurface& a_surface, Polygon* a_out) const noexcept;
510
517 void
518 orientOutward(Polygon& a_polygon, const int a_dir, const int a_side) const noexcept;
519#endif
520
537 bool
538 partitions(const CutCellBody* a_children) const noexcept;
539
546 void
547 accumulateMoments() noexcept;
548
553
558
563
568
573
578
583
588
592 RealVect m_normal;
593
598
602 RealVect m_closure;
603};
604
605} // namespace PolyhedralEB
606
607#include <CD_NamespaceFooter.H>
608
609#endif
Declaration of the data a cut cell's embedded boundary is reconstructed from.
Declaration of the cell topology and polygon geometry the polyhedral cut cells are built from.
The closed polyhedron bounding the fluid in one cut cell, and its moments.
Definition CD_CutCellBody.H:45
bool weldTJunctions() noexcept
Split every polygon edge at the vertices of other polygons that lie on it.
Definition CD_CutCellBody.cpp:717
bool partitions(const CutCellBody *a_children) const noexcept
Whether a set of children partitions this body, in every moment that has to add up.
Definition CD_CutCellBody.cpp:1958
bool hasMultiValuedChildren(const int a_refRat) const noexcept
Whether cutting this body for a refinement asks for a child whose fluid is in more than one piece.
Definition CD_CutCellBody.cpp:1916
RealVect m_boundaryCentroid
Interface centroid.
Definition CD_CutCellBody.H:597
bool define(const CutCellSurface &a_surface) noexcept
Build the body from the values the surface is reconstructed from.
Definition CD_CutCellBody.cpp:1458
void accumulateMoments() noexcept
Take the moments of the assembled polygons.
Definition CD_CutCellBody.cpp:1083
bool closeBoundary(const int a_face) noexcept
Close the body over the edges no polygon carries in reverse, with a patch lying in a given face.
Definition CD_CutCellBody.cpp:840
static Kind classify(const CutCellSurface &a_surface) noexcept
How the cell relates to the interface.
Definition CD_CutCellBody.cpp:46
bool subdivide(CutCellBody *a_children) const noexcept
Cut this body into the bodies of the 2^SpaceDim cells one refinement finer that fill its cell.
Definition CD_CutCellBody.cpp:1486
bool mergeCoplanar(const Polygon *a_in, const int a_num, Polygon *a_out, const int a_maxOut, int &a_numOut) const noexcept
Merge coplanar polygons into the boundary of their union.
Definition CD_CutCellBody.cpp:359
const RealVect & faceCentroid(const int a_dir, const Side::LoHiSide a_side) const noexcept
Centroid of one cell face, relative to the face centre, in units of the cell size.
Definition CD_CutCellBody.cpp:2057
bool interfaceIsPlanar() const noexcept
Whether every polygon of the interface lies in one plane.
Definition CD_CutCellBody.cpp:1814
bool closeInterface() noexcept
Rebuild the interface from the face polygons this body holds.
Definition CD_CutCellBody.cpp:834
Real m_areaFraction[s_numFaces]
Area fraction of each cell face, indexed 2*dir + side.
Definition CD_CutCellBody.H:567
RealVect m_closure
Sum of the outward area vectors over every polygon.
Definition CD_CutCellBody.H:602
static constexpr int s_maxVertices
Largest number of vertices one of those polygons can carry.
Definition CD_CutCellBody.H:407
Real m_trueBoundaryArea
Area of the interface itself.
Definition CD_CutCellBody.H:577
static constexpr Real s_edgeTolerance
Distance by which a crossing is held off an edge's endpoints.
Definition CD_CutCellBody.H:415
void orientOutward(Polygon &a_polygon, const int a_dir, const int a_side) const noexcept
Reverse a face polygon if its area vector points into the fluid.
Definition CD_CutCellBody.cpp:92
Real m_boundaryArea
Magnitude of the interface's area vector.
Definition CD_CutCellBody.H:572
static int numSheets(const CutCellSurface &a_surface) noexcept
How many separate sheets of interface the surface enters the cell as.
Definition CD_CutCellBody.cpp:68
const RealVect & volumeCentroid() const noexcept
Volume centroid, relative to the cell centre, in units of the cell size.
Definition CD_CutCellBody.cpp:2043
Real trueBoundaryArea() const noexcept
Area of the interface itself, as the sum of its triangles' areas.
Definition CD_CutCellBody.cpp:2071
bool restrictFace(const CutCellSurface *a_children, const int a_dir, const int a_side) noexcept
Replace one face's chord with the chords of the children that cover it.
Definition CD_CutCellBody.cpp:566
Polygon m_polygon[s_maxPolygons]
The polygons bounding the fluid.
Definition CD_CutCellBody.H:552
CutCellBody() noexcept
Constructor. Leaves the body empty; call define before reading any moment.
Definition CD_CutCellBody.cpp:28
Kind
How a cell relates to the interface.
Definition CD_CutCellBody.H:51
Real m_volumeFraction
Volume fraction.
Definition CD_CutCellBody.H:562
bool isConnected() const noexcept
Whether the fluid this body holds is one connected region.
Definition CD_CutCellBody.cpp:1754
Real boundaryArea() const noexcept
Magnitude of the interface's area vector.
Definition CD_CutCellBody.cpp:2065
RealVect m_normal
Unit normal to the interface, into the fluid.
Definition CD_CutCellBody.H:592
bool snapFace(const int a_dir, const int a_side, const bool a_neighbourIsFluid) noexcept
Make one face agree with a neighbour that holds no solid, or none that holds no fluid,...
Definition CD_CutCellBody.cpp:659
Real areaFraction(const int a_dir, const Side::LoHiSide a_side) const noexcept
Area fraction of one cell face.
Definition CD_CutCellBody.cpp:2049
int m_numPolygons
Number of polygons in use.
Definition CD_CutCellBody.H:557
RealVect m_volumeCentroid
Volume centroid.
Definition CD_CutCellBody.H:582
void appendInterfaceFacets(Vector< Real > &a_facets, const IntVect &a_cell, const RealVect &a_probLo, const Real a_dx) const noexcept
Append this body's interface, as triangles in physical coordinates.
Definition CD_CutCellBody.cpp:1025
int numPolygons() const noexcept
How many polygons this body holds.
Definition CD_CutCellBody.cpp:1065
const RealVect & boundaryCentroid() const noexcept
Interface centroid, relative to the cell centre, in units of the cell size.
Definition CD_CutCellBody.cpp:2083
Real divergenceResidual() const noexcept
Residual in the identity the moments must satisfy among themselves.
Definition CD_CutCellBody.cpp:2095
static constexpr Real s_nullArea
Area below which a polygon carries no moment and is dropped.
Definition CD_CutCellBody.H:423
RealVect m_faceCentroid[s_numFaces]
Centroid of each cell face, indexed 2*dir + side.
Definition CD_CutCellBody.H:587
static constexpr int s_maxPolygons
Largest number of polygons a single cut cell's body can need.
Definition CD_CutCellBody.H:390
int widestPolygon() const noexcept
Largest number of vertices any of this body's polygons holds.
Definition CD_CutCellBody.cpp:1071
void printPolygons(std::ostream &a_out) const noexcept
Print every polygon this body holds, in the cell's own frame, for inspection.
Definition CD_CutCellBody.cpp:1007
const RealVect & normal() const noexcept
Unit normal to the interface, pointing into the fluid.
Definition CD_CutCellBody.cpp:2077
Real volumeFraction() const noexcept
Volume fraction.
Definition CD_CutCellBody.cpp:2037
bool defineCut(const CutCellSurface &a_surface) noexcept
Assemble the polygons of a cell the interface passes through.
Definition CD_CutCellBody.cpp:1334
Real closureResidual() const noexcept
How far the assembled polygons are from enclosing a volume.
Definition CD_CutCellBody.cpp:2089
int faceWalk(const int a_dir, const int a_side, const CutCellSurface &a_surface, Polygon *a_out) const noexcept
The fluid part of one cell face, as outward-oriented polygons.
Definition CD_CutCellBody.cpp:118
void defineDegenerate(const CutCellSurface &a_surface, const Kind a_kind) noexcept
Moments of a cell the interface only touches, never enters.
Definition CD_CutCellBody.cpp:292
static constexpr int s_numFaces
Number of cell faces.
Definition CD_CutCellBody.H:385
The values a cut cell's embedded boundary is reconstructed from.
Definition CD_CutCellSurface.H:41
One polygon of the body, in the cell's own frame.
Definition CD_CutCellBody.H:428
int m_numVertices
Number of vertices in use.
Definition CD_CutCellBody.H:442
int m_face
Cell face this polygon lies in, or -1 if it is part of the interface.
Definition CD_CutCellBody.H:447