13#ifndef CD_EBSTATEREDISTRIBUTION_H
14#define CD_EBSTATEREDISTRIBUTION_H
20#include <EBLevelGrid.H>
21#include <ProblemDomain.H>
26#include <LayoutData.H>
27#include <RefCountedPtr.H>
34#include <CD_NamespaceHeader.H>
112 const Vector<RefCountedPtr<EBLevelGrid>>& a_eblgCoFi,
113 const Vector<int>& a_refinementRatios,
114 const int a_finestLevel,
116 const Real a_targetVolFrac,
117 const Vector<RefCountedPtr<EBMassRedistribution>>& a_massRedistribution,
118 const Vector<RefCountedPtr<LevelData<BaseFab<bool>>>>& a_coveredByFiner,
119 const Vector<RefCountedPtr<LevelData<BaseFab<bool>>>>& a_coarseFineGhost)
noexcept;
134 redistribute(EBAMRCellData& a_divG, const EBAMRCellData& a_phi, const Real a_dt) noexcept override;
185 Vector<RefCountedPtr<EBLevelGrid>>
m_eblg;
216 Vector<RefCountedPtr<LevelData<BaseFab<
int>>>>
m_tracker;
221 Vector<RefCountedPtr<LevelData<BaseFab<
int>>>>
m_numNbhd;
226 Vector<RefCountedPtr<LevelData<FArrayBox>>>
m_alpha;
257 Vector<RefCountedPtr<LevelData<FArrayBox>>>
m_slopes;
268 Vector<RefCountedPtr<LevelData<FArrayBox>>>
m_state;
290 Vector<RefCountedPtr<LevelData<BaseIVFAB<Real>>>>
m_massDiff;
298 offset(const
int a_index) noexcept;
316 volumeFraction(const EBISBox& a_ebisbox, const ProblemDomain& a_domain, const IntVect& a_iv) noexcept;
327 cellCentroid(const EBISBox& a_ebisbox, const ProblemDomain& a_domain, const IntVect& a_iv) noexcept;
340 cellType(const BaseFab<
bool>& a_coveredByFiner,
341 const BaseFab<
bool>& a_coarseFineGhost,
342 const ProblemDomain& a_domain,
343 const IntVect& a_iv) noexcept;
365 const RealVect& a_normal,
366 const EBISBox& a_ebisbox,
367 const BaseFab<
bool>& a_coveredByFiner,
368 const BaseFab<
bool>& a_coarseFineGhost,
369 const ProblemDomain& a_domain) const noexcept;
385 const FArrayBox& a_average,
386 const FArrayBox& a_centroid,
387 const EBISBox& a_ebisbox,
388 const BaseFab<
bool>& a_coveredByFiner,
389 const BaseFab<
bool>& a_coarseFineGhost,
390 const ProblemDomain& a_domain,
391 const
int a_connected) const noexcept;
400 synchronize(EBAMRCellData& a_divG, const Real a_dt) noexcept;
403#include <CD_NamespaceFooter.H>
Declaration of a class which can perform redistribution in an EB-AMR context.
Declaration of an abstract interface for the cut-cell stabilization of explicit finite-volume updates...
Redistribution of mass from cut cells to their neighbouring cells, as in Chombo's flux redistribution...
Definition CD_EBMassRedistribution.H:50
EBRedistribution() noexcept
Default constructor.
Definition CD_EBRedistribution.cpp:20
void mergeNeighbours(std::vector< IntVect > &a_offsets, const IntVect &a_iv, const RealVect &a_normal, const EBISBox &a_ebisbox, const BaseFab< bool > &a_coveredByFiner, const BaseFab< bool > &a_coarseFineGhost, const ProblemDomain &a_domain) const noexcept
Find the neighbours that a small cut cell merges with.
Definition CD_EBStateRedistribution.cpp:555
Vector< RefCountedPtr< LevelData< FArrayBox > > > m_nbhdAverage
Scratch: neighbourhood averages Q.
Definition CD_EBStateRedistribution.H:252
static RealVect cellCentroid(const EBISBox &a_ebisbox, const ProblemDomain &a_domain, const IntVect &a_iv) noexcept
Get the centroid of a cell from the EB geometry.
Definition CD_EBStateRedistribution.cpp:157
static IntVect offset(const int a_index) noexcept
Get the cell offset that an index into the 3^D block stands for.
Definition CD_EBStateRedistribution.cpp:119
Vector< RefCountedPtr< EBLevelGrid > > m_eblgCoFi
Coarsening of the grids: entry l is the coarsening of the grids on level l + 1.
Definition CD_EBStateRedistribution.H:190
Vector< RefCountedPtr< LevelData< FArrayBox > > > m_nbhdVol
Volume of the neighbourhood of each cell.
Definition CD_EBStateRedistribution.H:231
static constexpr int s_valid
Cell type: valid cell of the level.
Definition CD_EBStateRedistribution.H:155
RealVect computeSlope(const IntVect &a_iv, const FArrayBox &a_average, const FArrayBox &a_centroid, const EBISBox &a_ebisbox, const BaseFab< bool > &a_coveredByFiner, const BaseFab< bool > &a_coarseFineGhost, const ProblemDomain &a_domain, const int a_connected) const noexcept
Compute the limited slope of the neighbourhood average at a merged cell.
Definition CD_EBStateRedistribution.cpp:742
Vector< RefCountedPtr< LevelData< FArrayBox > > > m_alpha
Weights. Component 0 is alpha_0 of the cell, component 1 is alpha_1 of the neighbourhood of the cell.
Definition CD_EBStateRedistribution.H:226
Vector< RefCountedPtr< LevelData< FArrayBox > > > m_nbhdCentroid
Centroid of the neighbourhood of each cell, relative to the cell centre in units of the cell size.
Definition CD_EBStateRedistribution.H:236
Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > m_coveredByFiner
Cells covered by the finer level, with s_numGhost ghost cells.
Definition CD_EBStateRedistribution.H:195
static constexpr int s_numOffsets
Number of cells in the 3^D block around a cell, which indexes the neighbour offsets.
Definition CD_EBStateRedistribution.H:140
Vector< RefCountedPtr< LevelData< FArrayBox > > > m_ghostMass
Scratch on the coarsening of the grids of a level, with one ghost cell, for data of the coarser level...
Definition CD_EBStateRedistribution.H:275
Vector< RefCountedPtr< EBLevelGrid > > m_eblg
Grids on each level.
Definition CD_EBStateRedistribution.H:185
Vector< RefCountedPtr< LevelData< FArrayBox > > > m_state
Scratch: the provisional state U = phi - dt*D. In the ghost cells it is U of the coarse cell under th...
Definition CD_EBStateRedistribution.H:268
Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > m_coarseFineGhost
Cells inside the domain but outside the grids of the level, with s_numGhost ghost cells.
Definition CD_EBStateRedistribution.H:200
Vector< Copier > m_coarseCopier
Copiers from the coarser level to m_ghostMass of a level, ghost cells included.
Definition CD_EBStateRedistribution.H:285
void redistribute(EBAMRCellData &a_divG, const EBAMRCellData &a_phi, const Real a_dt) noexcept override
Turn kappa*D into the right-hand side of the update stabilized by state redistribution.
Definition CD_EBStateRedistribution.cpp:921
virtual ~EBStateRedistribution() noexcept
Destructor.
Definition CD_EBStateRedistribution.cpp:113
Vector< Copier > m_ghostCopier
Copiers that add m_ghostMass of a level, ghost cells included, to m_syncMass of the coarser level.
Definition CD_EBStateRedistribution.H:280
Real m_targetVolFrac
Target volume fraction.
Definition CD_EBStateRedistribution.H:180
void synchronize(EBAMRCellData &a_divG, const Real a_dt) noexcept
Add the corrections on refinement boundaries to the right-hand side.
Definition CD_EBStateRedistribution.cpp:1388
static int offsetIndex(const IntVect &a_offset) noexcept
Get the index into the 3^D block of a cell offset.
Definition CD_EBStateRedistribution.cpp:185
int m_order
Order of the reconstruction: 0 or 2.
Definition CD_EBStateRedistribution.H:175
Vector< RefCountedPtr< LevelData< BaseFab< int > > > > m_connected
Neighbours in the 3^D block around each merged cell that are connected to it, as a bit mask over the ...
Definition CD_EBStateRedistribution.H:242
Vector< RefCountedPtr< LevelData< BaseIVFAB< Real > > > > m_massDiff
Scratch: the parts of the corrections that are redistributed with the mass redistribution,...
Definition CD_EBStateRedistribution.H:290
Vector< RefCountedPtr< LayoutData< bool > > > m_activeBox
Per box, true if the box has a cell whose state is changed by the redistribution.
Definition CD_EBStateRedistribution.H:247
int m_finestLevel
Finest grid level.
Definition CD_EBStateRedistribution.H:170
Vector< RefCountedPtr< EBMassRedistribution > > m_massRedistribution
Mass redistribution operators on each level, which redistribute the corrections on refinement boundar...
Definition CD_EBStateRedistribution.H:210
static Real volumeFraction(const EBISBox &a_ebisbox, const ProblemDomain &a_domain, const IntVect &a_iv) noexcept
Get the volume fraction of a cell from the EB geometry.
Definition CD_EBStateRedistribution.cpp:136
Vector< RefCountedPtr< LevelData< BaseFab< int > > > > m_numNbhd
Number of neighbourhoods that each cell is in, its own included.
Definition CD_EBStateRedistribution.H:221
Vector< RefCountedPtr< LevelData< FArrayBox > > > m_syncMass
Scratch: corrections of the valid cells, as mass in units of the cell volume of the level.
Definition CD_EBStateRedistribution.H:262
Vector< RefCountedPtr< LevelData< FArrayBox > > > m_slopes
Scratch: limited slopes of the merged neighbourhoods.
Definition CD_EBStateRedistribution.H:257
void defineLevel(const int a_level) noexcept
Build the neighbourhood data on one level.
Definition CD_EBStateRedistribution.cpp:201
EBStateRedistribution()=delete
Disallowed weak construction.
static constexpr int s_outside
Cell type: outside the domain, or not reachable.
Definition CD_EBStateRedistribution.H:150
static constexpr int s_ghost
Cell type: inside the domain but outside the grids of the level, over a valid cell of the coarser lev...
Definition CD_EBStateRedistribution.H:165
Vector< int > m_refinementRatios
Refinement ratios between levels.
Definition CD_EBStateRedistribution.H:205
static constexpr int s_numGhost
Number of ghost cells of the neighbourhood data and of the cell masks. Also the number of ghost cells...
Definition CD_EBStateRedistribution.H:93
Vector< RefCountedPtr< LevelData< BaseFab< int > > > > m_tracker
Neighbourhoods. Component 0 is the number of merged neighbours of the cell, components 1,...
Definition CD_EBStateRedistribution.H:216
static constexpr int s_trackerComps
Number of components of the tracker: the number of merged neighbours, and up to 2^D - 1 neighbours.
Definition CD_EBStateRedistribution.H:145
static constexpr int s_covered
Cell type: covered by the finer level.
Definition CD_EBStateRedistribution.H:160
static int cellType(const BaseFab< bool > &a_coveredByFiner, const BaseFab< bool > &a_coarseFineGhost, const ProblemDomain &a_domain, const IntVect &a_iv) noexcept
Get the type of a cell.
Definition CD_EBStateRedistribution.cpp:169