chombo-discharge
Loading...
Searching...
No Matches
CD_AMRPolyhedralEBGraph.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_AMRPOLYHEDRALEBGRAPH_H
14#define CD_AMRPOLYHEDRALEBGRAPH_H
15
16// Std includes
17#include <functional>
18#include <vector>
19
20// Chombo includes
21#include <BaseFab.H>
22#include <DisjointBoxLayout.H>
23#include <GeometryService.H>
24#include <IrregNode.H>
25#include <LayoutData.H>
26#include <ProblemDomain.H>
27#include <RefCountedPtr.H>
28
29// Our includes
32#include <CD_CutCellSurface.H>
33#include <CD_NamespaceHeader.H>
34
50{
51public:
55 static constexpr int s_unowned = 2;
56
62 static constexpr int s_ringFromCoarser = 3;
63
67 AMRPolyhedralEBGraph() noexcept;
68
72 virtual ~AMRPolyhedralEBGraph() noexcept;
73
84 void
85 define(const std::vector<DisjointBoxLayout>& a_grids,
86 const std::vector<ProblemDomain>& a_domains,
87 const std::vector<int>& a_geometryLevels,
88 const int a_numSourceLevels,
89 const int a_ghost,
90 const std::function<GeometryService::InOut(const Box&, const ProblemDomain&)>& a_classify);
91
96 bool
97 isDefined() const noexcept;
98
103 int
104 getNumLevels() const noexcept;
105
110 int
111 getNumSourceLevels() const noexcept;
112
117 int
118 getGhost() const noexcept;
119
125 const DisjointBoxLayout&
126 getGrids(const int a_level) const noexcept;
127
133 const ProblemDomain&
134 getDomain(const int a_level) const noexcept;
135
141 int
142 getGeometryLevel(const int a_level) const noexcept;
143
156 void
157 getCutCells(std::vector<PolyhedralEB::CutCellDescription>& a_cells,
158 const int a_level,
159 const DataIndex& a_dit,
160 const IntVect& a_cell) const;
161
173 int
174 getState(const int a_level, const DataIndex& a_dit, const IntVect& a_cell) const;
175
184 bool
185 holds(const int a_level, const DataIndex& a_dit, const IntVect& a_cell) const;
186
224 void
225 fillNodes(BaseFab<int>& a_regIrregCovered,
226 Vector<IrregNode>& a_nodes,
227 long long& a_numCollapsed,
228 long long& a_numFiner,
229 const int a_level,
230 const DataIndex& a_dit,
231 const BaseFab<bool>& a_compute,
232 const bool a_cutRing) const;
233
241 const std::vector<Box>&
242 getPieces(const int a_level, const DataIndex& a_dit, const int a_sourceLevel) const noexcept;
243
252 int
253 getSourceState(const int a_level, const DataIndex& a_dit, const int a_sourceLevel, const IntVect& a_sourceCell) const;
254
262 const std::vector<IntVect>&
263 getSurfaceCells(const int a_level, const DataIndex& a_dit, const int a_sourceLevel) const noexcept;
264
273 const PolyhedralEB::CutCellSurface*
274 getSourceSurface(const int a_level,
275 const DataIndex& a_dit,
276 const int a_sourceLevel,
277 const IntVect& a_sourceCell) const;
278
286 const PolyhedralEB::CutCellFaceOverrides&
287 getFaceOverrides(const int a_level, const DataIndex& a_dit, const int a_sourceLevel) const noexcept;
288
297 void
298 addPiece(const int a_level,
299 const DataIndex& a_dit,
300 const int a_sourceLevel,
301 const Box& a_region,
302 const signed char* a_states);
303
313 void
314 addSurface(const int a_level,
315 const DataIndex& a_dit,
316 const int a_sourceLevel,
317 const IntVect& a_sourceCell,
318 const PolyhedralEB::CutCellSurface& a_surface);
319
327 void
328 finish();
329
337 PolyhedralEB::CutCellFaceOverrides&
338 getFaceOverrides(const int a_level, const DataIndex& a_dit, const int a_sourceLevel) noexcept;
339
340protected:
345
350
355
359 std::function<GeometryService::InOut(const Box&, const ProblemDomain&)> m_classify;
360
364 std::vector<DisjointBoxLayout> m_grids;
365
369 std::vector<ProblemDomain> m_domains;
370
374 std::vector<int> m_geometryLevels;
375
379 std::vector<std::vector<RefCountedPtr<LayoutData<std::vector<Box>>>>> m_pieces;
380
384 std::vector<std::vector<RefCountedPtr<LayoutData<std::vector<int>>>>> m_pieceOffsets;
385
389 std::vector<std::vector<RefCountedPtr<LayoutData<std::vector<signed char>>>>> m_states;
390
394 std::vector<std::vector<RefCountedPtr<LayoutData<std::vector<IntVect>>>>> m_surfaceCells;
395
399 std::vector<std::vector<RefCountedPtr<LayoutData<std::vector<PolyhedralEB::CutCellSurface>>>>> m_surfaces;
400
404 std::vector<std::vector<RefCountedPtr<LayoutData<PolyhedralEB::CutCellFaceOverrides>>>> m_faceOverrides;
405
409 std::vector<std::vector<RefCountedPtr<LayoutData<int>>>> m_binSize;
410
414 std::vector<std::vector<RefCountedPtr<LayoutData<Box>>>> m_binBox;
415
420 std::vector<std::vector<RefCountedPtr<LayoutData<std::vector<int>>>>> m_binOffsets;
421
425 std::vector<std::vector<RefCountedPtr<LayoutData<std::vector<int>>>>> m_binPieces;
426
435 void
436 piecesNear(std::vector<int>& a_pieces,
437 const int a_level,
438 const DataIndex& a_dit,
439 const int a_sourceLevel,
440 const Box& a_region) const;
441
450 void
451 describe(std::vector<PolyhedralEB::CutCellDescription>& a_cells,
452 const int a_level,
453 const DataIndex& a_dit,
454 const int a_sourceLevel,
455 const IntVect& a_sourceCell) const;
456
457private:
464 template <class T>
465 static void
466 allocate(std::vector<std::vector<RefCountedPtr<LayoutData<T>>>>& a_data,
467 const std::vector<DisjointBoxLayout>& a_grids,
468 const int a_numSourceLevels);
469};
470
471#include <CD_NamespaceFooter.H>
472
473#endif
Declaration of everything one cut cell of the polyhedral geometry is built from.
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.
std::function< GeometryService::InOut(const Box &, const ProblemDomain &)> m_classify
Classifies the boxes no tile holds, on a given domain.
Definition CD_AMRPolyhedralEBGraph.H:359
bool holds(const int a_level, const DataIndex &a_dit, const IntVect &a_cell) const
Whether a destination box holds a cell: within its ring and the domain, and not under the next finer ...
Definition CD_AMRPolyhedralEBGraph.cpp:331
void piecesNear(std::vector< int > &a_pieces, const int a_level, const DataIndex &a_dit, const int a_sourceLevel, const Box &a_region) const
The pieces of a box that may meet a region: those of the bins the region reaches, each once.
Definition CD_AMRPolyhedralEBGraph.cpp:493
void describe(std::vector< PolyhedralEB::CutCellDescription > &a_cells, const int a_level, const DataIndex &a_dit, const int a_sourceLevel, const IntVect &a_sourceCell) const
Append the description of a cut geometry cell this box holds.
Definition CD_AMRPolyhedralEBGraph.cpp:631
std::vector< std::vector< RefCountedPtr< LayoutData< std::vector< int > > > > > m_binOffsets
Where each bin's pieces begin in m_binPieces, the bins in the order a BoxIterator meets them,...
Definition CD_AMRPolyhedralEBGraph.H:420
std::vector< std::vector< RefCountedPtr< LayoutData< Box > > > > m_binBox
The bins of each box's index, on the geometry level coarsened by the bin width.
Definition CD_AMRPolyhedralEBGraph.H:414
std::vector< ProblemDomain > m_domains
Domain of every destination level.
Definition CD_AMRPolyhedralEBGraph.H:369
static constexpr int s_unowned
State of a destination cell, or of a geometry cell, that no geometry level owns here.
Definition CD_AMRPolyhedralEBGraph.H:55
std::vector< int > m_geometryLevels
Geometry level of every destination level.
Definition CD_AMRPolyhedralEBGraph.H:374
std::vector< std::vector< RefCountedPtr< LayoutData< std::vector< PolyhedralEB::CutCellSurface > > > > > m_surfaces
Their surfaces, in the same order.
Definition CD_AMRPolyhedralEBGraph.H:399
int m_ghost
Ghost width every destination box is filled to.
Definition CD_AMRPolyhedralEBGraph.H:349
void define(const std::vector< DisjointBoxLayout > &a_grids, const std::vector< ProblemDomain > &a_domains, const std::vector< int > &a_geometryLevels, const int a_numSourceLevels, const int a_ghost, const std::function< GeometryService::InOut(const Box &, const ProblemDomain &)> &a_classify)
Set the destination hierarchy, holding nothing of the graph yet.
Definition CD_AMRPolyhedralEBGraph.cpp:59
std::vector< std::vector< RefCountedPtr< LayoutData< std::vector< signed char > > > > > m_states
The pieces' states, one piece after another, each in the order a BoxIterator meets its cells.
Definition CD_AMRPolyhedralEBGraph.H:389
void finish()
Put every box's surfaces in cell order and index its pieces, after the last addPiece and addSurface a...
Definition CD_AMRPolyhedralEBGraph.cpp:531
void fillNodes(BaseFab< int > &a_regIrregCovered, Vector< IrregNode > &a_nodes, long long &a_numCollapsed, long long &a_numFiner, const int a_level, const DataIndex &a_dit, const BaseFab< bool > &a_compute, const bool a_cutRing) const
Fill a destination box's index-space data from the copied graph: what each cell is,...
Definition CD_AMRPolyhedralEBGraph.cpp:671
static constexpr int s_ringFromCoarser
Flag fillNodes gives a cell of a box's first ghost ring that would have to be cut from a coarser ance...
Definition CD_AMRPolyhedralEBGraph.H:62
void addSurface(const int a_level, const DataIndex &a_dit, const int a_sourceLevel, const IntVect &a_sourceCell, const PolyhedralEB::CutCellSurface &a_surface)
Add the surface of a geometry cell to a destination box. Surfaces may come in any order; finish puts ...
Definition CD_AMRPolyhedralEBGraph.cpp:479
std::vector< std::vector< RefCountedPtr< LayoutData< std::vector< Box > > > > > m_pieces
The pieces of every box, per destination level and geometry level.
Definition CD_AMRPolyhedralEBGraph.H:379
std::vector< std::vector< RefCountedPtr< LayoutData< int > > > > m_binSize
Width of the bins each box's pieces are indexed by.
Definition CD_AMRPolyhedralEBGraph.H:409
int getGeometryLevel(const int a_level) const noexcept
Geometry level a destination level lives on.
Definition CD_AMRPolyhedralEBGraph.cpp:149
std::vector< std::vector< RefCountedPtr< LayoutData< std::vector< IntVect > > > > > m_surfaceCells
The cells that hold a surface, in increasing order once finish has run.
Definition CD_AMRPolyhedralEBGraph.H:394
int getGhost() const noexcept
Ghost width every destination box is filled to.
Definition CD_AMRPolyhedralEBGraph.cpp:127
const std::vector< Box > & getPieces(const int a_level, const DataIndex &a_dit, const int a_sourceLevel) const noexcept
The pieces a destination box holds of a geometry level: boxes of cells, each owned by one of its tile...
Definition CD_AMRPolyhedralEBGraph.cpp:358
int getNumLevels() const noexcept
Number of destination levels.
Definition CD_AMRPolyhedralEBGraph.cpp:115
int getState(const int a_level, const DataIndex &a_dit, const IntVect &a_cell) const
What a cell of a destination box is: cut if any geometry cell owning part of it is,...
Definition CD_AMRPolyhedralEBGraph.cpp:216
bool isDefined() const noexcept
Whether define has run.
Definition CD_AMRPolyhedralEBGraph.cpp:109
int m_numSourceLevels
Number of geometry levels.
Definition CD_AMRPolyhedralEBGraph.H:354
AMRPolyhedralEBGraph() noexcept
Constructor. Holds nothing until define.
Definition CD_AMRPolyhedralEBGraph.cpp:29
int getNumSourceLevels() const noexcept
Number of geometry levels.
Definition CD_AMRPolyhedralEBGraph.cpp:121
std::vector< std::vector< RefCountedPtr< LayoutData< std::vector< int > > > > > m_binPieces
The pieces that reach each bin, one bin after another.
Definition CD_AMRPolyhedralEBGraph.H:425
const PolyhedralEB::CutCellFaceOverrides & getFaceOverrides(const int a_level, const DataIndex &a_dit, const int a_sourceLevel) const noexcept
The face overrides of a geometry level's cells, as a destination box holds them.
Definition CD_AMRPolyhedralEBGraph.cpp:440
void getCutCells(std::vector< PolyhedralEB::CutCellDescription > &a_cells, const int a_level, const DataIndex &a_dit, const IntVect &a_cell) const
The cut cells of the geometry that intersect a cell of a destination box, each with everything its po...
Definition CD_AMRPolyhedralEBGraph.cpp:157
const std::vector< IntVect > & getSurfaceCells(const int a_level, const DataIndex &a_dit, const int a_sourceLevel) const noexcept
The geometry cells of a level that a destination box holds a surface for, in increasing order.
Definition CD_AMRPolyhedralEBGraph.cpp:409
const PolyhedralEB::CutCellSurface * getSourceSurface(const int a_level, const DataIndex &a_dit, const int a_sourceLevel, const IntVect &a_sourceCell) const
The surface of a geometry cell, as a destination box holds it.
Definition CD_AMRPolyhedralEBGraph.cpp:418
int getSourceState(const int a_level, const DataIndex &a_dit, const int a_sourceLevel, const IntVect &a_sourceCell) const
The state of a geometry cell, as a destination box holds it.
Definition CD_AMRPolyhedralEBGraph.cpp:367
std::vector< std::vector< RefCountedPtr< LayoutData< std::vector< int > > > > > m_pieceOffsets
Where each piece's states begin in m_states, and one past the last piece's end.
Definition CD_AMRPolyhedralEBGraph.H:384
const ProblemDomain & getDomain(const int a_level) const noexcept
Domain of a destination level.
Definition CD_AMRPolyhedralEBGraph.cpp:141
void addPiece(const int a_level, const DataIndex &a_dit, const int a_sourceLevel, const Box &a_region, const signed char *a_states)
Add a piece to a destination box.
Definition CD_AMRPolyhedralEBGraph.cpp:460
const DisjointBoxLayout & getGrids(const int a_level) const noexcept
Layout of a destination level.
Definition CD_AMRPolyhedralEBGraph.cpp:133
bool m_isDefined
Whether define has run.
Definition CD_AMRPolyhedralEBGraph.H:344
std::vector< DisjointBoxLayout > m_grids
Destination layout of every level.
Definition CD_AMRPolyhedralEBGraph.H:364
std::vector< std::vector< RefCountedPtr< LayoutData< PolyhedralEB::CutCellFaceOverrides > > > > m_faceOverrides
The face overrides of the cells whose surfaces are overridden.
Definition CD_AMRPolyhedralEBGraph.H:404