chombo-discharge
Loading...
Searching...
No Matches
CD_PolyhedralEBGraph.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_POLYHEDRALEBGRAPH_H
14#define CD_POLYHEDRALEBGRAPH_H
15
16// Chombo includes
17#include <BaseFab.H>
18#include <BaseIF.H>
19#include <DisjointBoxLayout.H>
20#include <IVSFAB.H>
21#include <IntVectSet.H>
22#include <LayoutData.H>
23#include <LevelData.H>
24#include <ProblemDomain.H>
25#include <RealVect.H>
26
27// Our includes
29#include <CD_CutCellSurface.H>
30#include <CD_NamespaceHeader.H>
31
52{
53public:
57 static constexpr int s_covered = -1;
58
62 static constexpr int s_cut = 0;
63
67 static constexpr int s_regular = 1;
68
72 static constexpr int s_faceClosed = 0;
73
77 static constexpr int s_faceSameLevel = 1;
78
82 static constexpr int s_faceFiner = 2;
83
87 static constexpr int s_faceCoarser = 3;
88
92 static constexpr int s_faceBoundary = 4;
93
97 static constexpr int s_notFilled = 0;
98
102 static constexpr int s_filledPieces = 1;
103
107 static constexpr int s_filledGap = 2;
108
113
117 virtual ~PolyhedralEBGraph();
118
141 virtual void
142 define(const BaseIF& a_function,
143 const Vector<Box>& a_cutTiles,
144 const ProblemDomain& a_domain,
145 const RealVect& a_probLo,
146 const Real a_dx,
147 const int a_numGhost,
148 const Vector<Box>& a_covered,
149 const PolyhedralEBGraph* a_coarser,
150 const bool a_fillSplitFluid);
151
164 virtual void
165 define(const PolyhedralEBGraph& a_source, const DisjointBoxLayout& a_grids, const BaseIF& a_function);
166
174 bool
175 equals(const PolyhedralEBGraph& a_other) const;
176
189 static void
190 link(PolyhedralEBGraph& a_coarse, const PolyhedralEBGraph& a_fine);
191
202 long long
204
214 static long long
216
220 void
222
230 long long
232
268 static void
269 findUnresolvedCells(BaseFab<signed char>& a_unresolved,
270 const BaseIF& a_function,
271 const BaseFab<Real>& a_nodeValues,
272 const Box& a_region,
273 const Vector<Box>& a_covered,
274 const RealVect& a_probLo,
275 const Real a_dx,
276 const bool a_fillSplitFluid);
277
289 static bool
290 isFilled(const BaseFab<signed char>& a_states,
291 const BaseFab<signed char>& a_refined,
292 const IntVectSet& a_withSurface,
293 const IVSFAB<PolyhedralEB::CutCellSurface>& a_surfaces,
294 const IntVect& a_cell);
295
300 bool
301 isDefined() const noexcept;
302
307 const ProblemDomain&
308 getDomain() const noexcept;
309
314 Real
315 getDx() const noexcept;
316
321 const DisjointBoxLayout&
322 getGrids() const noexcept;
323
328 const LayoutData<IntVectSet>&
329 getCutCells() const noexcept;
330
337 const LevelData<BaseFab<signed char>>&
338 getCellStates() const noexcept;
339
344 const LevelData<BaseFab<signed char>>&
345 getFaceStates() const noexcept;
346
352 const LevelData<BaseFab<signed char>>&
353 getRefinedMask() const noexcept;
354
360 const LevelData<IVSFAB<PolyhedralEB::CutCellSurface>>&
361 getSurfaces() const noexcept;
362
367 LevelData<IVSFAB<PolyhedralEB::CutCellSurface>>&
368 getSurfaces() noexcept;
369
377 const LayoutData<IntVectSet>&
378 getSurfaceCells() const noexcept;
379
385 const LayoutData<PolyhedralEB::CutCellFaceOverrides>&
386 getFaceOverrides() const noexcept;
387
392 LayoutData<PolyhedralEB::CutCellFaceOverrides>&
393 getFaceOverrides() noexcept;
394
400 void
401 markCarried(LevelData<BaseFab<signed char>>& a_carried) const;
402
412 void
413 markCoarserFilled(LevelData<BaseFab<signed char>>& a_filled,
414 const PolyhedralEBGraph& a_coarser,
415 const int a_ghost) const;
416
426 void
427 promoteToCut(const DataIndex& a_dit, const IntVect& a_cell);
428
435 void
436 markSurfaces(LevelData<BaseFab<signed char>>& a_mask) const;
437
438protected:
443
448
452 Real m_dx;
453
457 RealVect m_probLo;
458
462 ProblemDomain m_domain;
463
467 DisjointBoxLayout m_grids;
468
475 Vector<Box> m_covered;
476
480 LayoutData<IntVectSet> m_cutCells;
481
485 LevelData<BaseFab<signed char>> m_cellStates;
486
490 LevelData<BaseFab<signed char>> m_faceStates;
491
497 LevelData<BaseFab<signed char>> m_refined;
498
503 LevelData<BaseFab<signed char>> m_anchored;
504
508 LayoutData<IntVectSet> m_surfaceCells;
509
513 LevelData<IVSFAB<PolyhedralEB::CutCellSurface>> m_surfaces;
514
518 LayoutData<PolyhedralEB::CutCellFaceOverrides> m_faceOverrides;
519
524 void
526
531 void
532 defineGrids(const Vector<Box>& a_cutTiles);
533
538 void
539 defineData();
540
548 void
549 defineGhostCells(const BaseIF& a_function, const LevelData<BaseFab<signed char>>& a_carried);
550
559 void
560 beginAnchoring(const LevelData<BaseFab<signed char>>& a_carried);
561
565 void
566 markRefined();
567
577 void
578 defineCells(const BaseIF& a_function,
579 const LevelData<BaseFab<signed char>>& a_carried,
580 const LevelData<BaseFab<signed char>>* a_coarserFilled,
581 const bool a_fillSplitFluid);
582
587 void
588 defineOuterFaces(const LevelData<BaseFab<signed char>>& a_carried);
589};
590
591#include <CD_NamespaceFooter.H>
592
593#endif
Declaration of the faces of a box's cut cells that their own surfaces do not describe.
Declaration of the data a cut cell's embedded boundary is reconstructed from.
void beginAnchoring(const LevelData< BaseFab< signed char > > &a_carried)
Record which cells anchor fluid before any of it is spread, for fillSealedCells.
Definition CD_PolyhedralEBGraph.cpp:630
static constexpr int s_cut
Cell states, in the convention the polyhedral generator hands the index space.
Definition CD_PolyhedralEBGraph.H:62
void addGhostSurfaceCells()
Put into every box's surface set the ghost cells whose owning tile keeps a surface for them.
Definition CD_PolyhedralEBGraph.cpp:1471
bool isDefined() const noexcept
Whether define has run.
Definition CD_PolyhedralEBGraph.cpp:1676
void defineOuterFaces(const LevelData< BaseFab< signed char > > &a_carried)
Mark the open faces that lie in the domain boundary, and those onto cells no tile of this level carri...
Definition CD_PolyhedralEBGraph.cpp:1533
static constexpr int s_filledPieces
Why a cell was filled: its fluid falls into more than one piece, which one body cannot hold.
Definition CD_PolyhedralEBGraph.H:102
const LevelData< BaseFab< signed char > > & getRefinedMask() const noexcept
Whether the finer level carries a cell, one where it does, with two ghost cells; all zero until link ...
Definition CD_PolyhedralEBGraph.cpp:1718
const LayoutData< PolyhedralEB::CutCellFaceOverrides > & getFaceOverrides() const noexcept
The faces of every box's cut cells, own and ghost, that their surfaces do not describe.
Definition CD_PolyhedralEBGraph.cpp:1742
const DisjointBoxLayout & getGrids() const noexcept
The layout over the cut tiles.
Definition CD_PolyhedralEBGraph.cpp:1694
virtual ~PolyhedralEBGraph()
Destructor.
Definition CD_PolyhedralEBGraph.cpp:37
LevelData< BaseFab< signed char > > m_anchored
Anchoring, from beginAnchoring until fillSealedCells: one where a cell's fluid reaches a regular cell...
Definition CD_PolyhedralEBGraph.H:503
void markSurfaces(LevelData< BaseFab< signed char > > &a_mask) const
Mark the cells that hold a surface.
Definition CD_PolyhedralEBGraph.cpp:1407
const ProblemDomain & getDomain() const noexcept
The level's domain.
Definition CD_PolyhedralEBGraph.cpp:1682
bool m_isDefined
Whether define has run.
Definition CD_PolyhedralEBGraph.H:442
static constexpr int s_faceSameLevel
Face states: the face opens onto a cell of this level.
Definition CD_PolyhedralEBGraph.H:77
void defineGhostCells(const BaseIF &a_function, const LevelData< BaseFab< signed char > > &a_carried)
Classify the ghost cells no tile of this level carries from their corners, and take the ghost cut cel...
Definition CD_PolyhedralEBGraph.cpp:1006
LayoutData< IntVectSet > m_cutCells
Cut cells of every box.
Definition CD_PolyhedralEBGraph.H:480
void markCarried(LevelData< BaseFab< signed char > > &a_carried) const
Mark the cells some tile of this level carries: one in every valid cell and in every ghost cell anoth...
Definition CD_PolyhedralEBGraph.cpp:1384
virtual void define(const BaseIF &a_function, const Vector< Box > &a_cutTiles, const ProblemDomain &a_domain, const RealVect &a_probLo, const Real a_dx, const int a_numGhost, const Vector< Box > &a_covered, const PolyhedralEBGraph *a_coarser, const bool a_fillSplitFluid)
Build the graph of one level over its cut tiles.
Definition CD_PolyhedralEBGraph.cpp:43
static bool isFilled(const BaseFab< signed char > &a_states, const BaseFab< signed char > &a_refined, const IntVectSet &a_withSurface, const IVSFAB< PolyhedralEB::CutCellSurface > &a_surfaces, const IntVect &a_cell)
Whether the graph filled a cell: covered, with corners that disagree, and not carried by the finer le...
Definition CD_PolyhedralEBGraph.cpp:345
const LayoutData< IntVectSet > & getCutCells() const noexcept
The cut cells of every box, its own and those of its ghost region that some tile carries.
Definition CD_PolyhedralEBGraph.cpp:1700
bool equals(const PolyhedralEBGraph &a_other) const
Whether another graph over the same layout holds the same cells, faces, mask and surfaces,...
Definition CD_PolyhedralEBGraph.cpp:1222
static long long anchorAcrossLevels(PolyhedralEBGraph &a_coarse, PolyhedralEBGraph &a_fine)
Carry anchoring across a level boundary, both ways.
Definition CD_PolyhedralEBGraph.cpp:778
void defineCells(const BaseIF &a_function, const LevelData< BaseFab< signed char > > &a_carried, const LevelData< BaseFab< signed char > > *a_coarserFilled, const bool a_fillSplitFluid)
Reconstruct and classify every cell of every box and its ghost region, keep the cut cells' surfaces w...
Definition CD_PolyhedralEBGraph.cpp:367
ProblemDomain m_domain
Domain of the level.
Definition CD_PolyhedralEBGraph.H:462
Real m_dx
Grid spacing of the level.
Definition CD_PolyhedralEBGraph.H:452
static constexpr int s_regular
Cell states, in the convention the polyhedral generator hands the index space.
Definition CD_PolyhedralEBGraph.H:67
void markCoarserFilled(LevelData< BaseFab< signed char > > &a_filled, const PolyhedralEBGraph &a_coarser, const int a_ghost) const
Mark the cells of this level, valid and ghost, that lie under a cell the coarser level filled.
Definition CD_PolyhedralEBGraph.cpp:1300
static constexpr int s_faceCoarser
Face states: the face opens onto a cell no tile of this level carries, which the coarser level does.
Definition CD_PolyhedralEBGraph.H:87
void promoteToCut(const DataIndex &a_dit, const IntVect &a_cell)
Make a regular or covered cell of a box, own or ghost, a cut cell of this level.
Definition CD_PolyhedralEBGraph.cpp:1438
static constexpr int s_filledGap
Why a cell was filled: its one piece of fluid is the smaller part of it, a gap between pieces of soli...
Definition CD_PolyhedralEBGraph.H:107
void markRefined()
Set m_refined from m_covered, over every box and its ghost cells.
Definition CD_PolyhedralEBGraph.cpp:1503
static void link(PolyhedralEBGraph &a_coarse, const PolyhedralEBGraph &a_fine)
Mark, on the coarse level, the faces that open onto cells the fine level carries.
Definition CD_PolyhedralEBGraph.cpp:1577
LevelData< IVSFAB< PolyhedralEB::CutCellSurface > > m_surfaces
Surface of every cell of m_surfaceCells.
Definition CD_PolyhedralEBGraph.H:513
int m_numGhost
Ghost cells the cell states are kept for.
Definition CD_PolyhedralEBGraph.H:447
void anchorUncarriedCells()
Anchor every cut ghost cell no tile carries, for a level with no coarser graph to answer for them.
Definition CD_PolyhedralEBGraph.cpp:901
LayoutData< PolyhedralEB::CutCellFaceOverrides > m_faceOverrides
Faces of every box's cut cells that their surfaces do not describe.
Definition CD_PolyhedralEBGraph.H:518
PolyhedralEBGraph()
Constructor. Leaves the graph undefined.
Definition CD_PolyhedralEBGraph.cpp:31
const LevelData< BaseFab< signed char > > & getFaceStates() const noexcept
The state of every face of every cell, one of the s_face constants; component 2 * dir + side.
Definition CD_PolyhedralEBGraph.cpp:1712
void defineGrids(const Vector< Box > &a_cutTiles)
Build the layout over the tiles, load balanced by cell count.
Definition CD_PolyhedralEBGraph.cpp:90
static constexpr int s_faceClosed
Face states: the face is closed, no fluid crosses it.
Definition CD_PolyhedralEBGraph.H:72
RealVect m_probLo
Lower-left corner of the domain.
Definition CD_PolyhedralEBGraph.H:457
LayoutData< IntVectSet > m_surfaceCells
Cells of every box that hold a surface.
Definition CD_PolyhedralEBGraph.H:508
static constexpr int s_faceBoundary
Face states: the face lies in the domain boundary and is open.
Definition CD_PolyhedralEBGraph.H:92
static constexpr int s_faceFiner
Face states: the face opens onto cells the finer level carries, and is described by them.
Definition CD_PolyhedralEBGraph.H:82
long long fillSealedCells()
Fill every cut cell anchoring did not reach, and let go of the anchoring.
Definition CD_PolyhedralEBGraph.cpp:925
long long spreadAnchors()
Spread anchoring through the open faces of this level until it stops.
Definition CD_PolyhedralEBGraph.cpp:675
static constexpr int s_notFilled
Why a cell was filled: it was not.
Definition CD_PolyhedralEBGraph.H:97
LevelData< BaseFab< signed char > > m_refined
One where the finer level carries the cell, with at least two ghost cells.
Definition CD_PolyhedralEBGraph.H:497
const LevelData< IVSFAB< PolyhedralEB::CutCellSurface > > & getSurfaces() const noexcept
The surface every cell of the surface sets is reconstructed from, in the box's own cells and in its g...
Definition CD_PolyhedralEBGraph.cpp:1724
const LayoutData< IntVectSet > & getSurfaceCells() const noexcept
The cells of every box that hold a surface: every cut cell of its set, and every cell,...
Definition CD_PolyhedralEBGraph.cpp:1736
static void findUnresolvedCells(BaseFab< signed char > &a_unresolved, const BaseIF &a_function, const BaseFab< Real > &a_nodeValues, const Box &a_region, const Vector< Box > &a_covered, const RealVect &a_probLo, const Real a_dx, const bool a_fillSplitFluid)
Find the cells of a region that one body cannot describe, or that are mostly a gap of fluid.
Definition CD_PolyhedralEBGraph.cpp:141
LevelData< BaseFab< signed char > > m_faceStates
State of every face of every cell, component 2 * dir + side.
Definition CD_PolyhedralEBGraph.H:490
static constexpr int s_covered
Cell states, in the convention the polyhedral generator hands the index space.
Definition CD_PolyhedralEBGraph.H:57
void defineData()
Allocate the per-cell containers over m_grids: the cut-cell sets, the cell states,...
Definition CD_PolyhedralEBGraph.cpp:112
Vector< Box > m_covered
Cells of this level the finer level carries, coarsened onto this level.
Definition CD_PolyhedralEBGraph.H:475
LevelData< BaseFab< signed char > > m_cellStates
State of every cell, with ghost cells.
Definition CD_PolyhedralEBGraph.H:485
Real getDx() const noexcept
The level's grid spacing.
Definition CD_PolyhedralEBGraph.cpp:1688
const LevelData< BaseFab< signed char > > & getCellStates() const noexcept
The state of every cell, s_covered, s_cut or s_regular, with ghost cells filled from the geometry....
Definition CD_PolyhedralEBGraph.cpp:1706
DisjointBoxLayout m_grids
Layout over the cut tiles.
Definition CD_PolyhedralEBGraph.H:467