chombo-discharge
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ParticleManagement::NNCellBudget Class Reference

The per-cell particle count this merge drains each cell down to. More...

#include <CD_NearestNeighborParticleMerge.H>

Public Member Functions

 NNCellBudget (const int a_uniform) noexcept
 Construct a uniform budget. Deliberately implicit – a bare count is the common case.
 
void reserveOne (const int a_level, const IntVect &a_cell)
 Reserve one slot in a cell, lowering that cell's budget by one.
 
void reserveOne (const int a_level, const RealVect &a_position, const RealVect &a_probLo, const RealVect &a_dx)
 Reserve one slot in the cell a position falls in.
 
int operator() (const detail::NNCellKey &a_key) const noexcept
 The budget for one cell: the uniform count less that cell's reservations, floored at 0.
 
int minimum () const noexcept
 The smallest budget any cell has.
 

Detailed Description

The per-cell particle count this merge drains each cell down to.

Every crowding decision in this algorithm asks the same question – "does this cell hold more particles than it is allowed to?" – so this type is the single place that answers it. The plain case is one uniform count for every cell, and an implicit constructor from int provides it, so a caller with nothing special to say simply passes the count.

A caller may additionally RESERVE slots in individual cells. A reserved slot is one already spoken for by particles this call cannot see, which must nonetheless count against the cell's total. The budget such a cell is drained to is the uniform count minus its reservations, floored at zero. The motivating case is a two-container merge in which one container has already been reduced and its results must still occupy room in the shared per-cell target.

Reservations are keyed by (level, cell), not by cell alone, for the reason given in detail::NNCellKey: a coarse and a fine cell can share a bare IntVect.

Note
Lookup is a single branch when nothing is reserved, so the uniform case costs no more than the bare integer it replaces.

Constructor & Destructor Documentation

◆ NNCellBudget()

ParticleManagement::NNCellBudget::NNCellBudget ( const int  a_uniform)
inlinenoexcept

Construct a uniform budget. Deliberately implicit – a bare count is the common case.

Parameters
[in]a_uniformParticle count every cell is drained down to.

Member Function Documentation

◆ minimum()

int ParticleManagement::NNCellBudget::minimum ( ) const
inlinenoexcept

The smallest budget any cell has.

For use where a cell's own budget cannot be looked up – a conservative stand-in, since no cell is drained to fewer particles than this. Equals the uniform count when nothing is reserved.

Returns
The minimum over every cell's budget.

◆ operator()()

int ParticleManagement::NNCellBudget::operator() ( const detail::NNCellKey a_key) const
inlinenoexcept

The budget for one cell: the uniform count less that cell's reservations, floored at 0.

Parameters
[in]a_keyCell to look up.
Returns
Particle count this cell is drained down to.

◆ reserveOne() [1/2]

void ParticleManagement::NNCellBudget::reserveOne ( const int  a_level,
const IntVect &  a_cell 
)
inline

Reserve one slot in a cell, lowering that cell's budget by one.

Call once per particle that is invisible to this merge but still occupies the cell.

Parameters
[in]a_levelAMR level the cell lives on.
[in]a_cellCell index, in the convention of detail::cellKeyOf().

◆ reserveOne() [2/2]

void ParticleManagement::NNCellBudget::reserveOne ( const int  a_level,
const RealVect &  a_position,
const RealVect &  a_probLo,
const RealVect &  a_dx 
)
inline

Reserve one slot in the cell a position falls in.

Preferred over the IntVect overload for a caller holding positions: the cell index is derived here, so it cannot disagree with the convention this algorithm buckets particles under.

Parameters
[in]a_levelAMR level the position's particle lives on.
[in]a_positionPhysical position of the particle occupying the slot.
[in]a_probLoPhysical position of the domain's low corner.
[in]a_dxCell spacing (per direction) of that particle's OWN level.

The documentation for this class was generated from the following file: