chombo-discharge
Loading...
Searching...
No Matches
EBAMRParticleMesh Class Reference

AMR driver that deposits/interpolates ParticleContainer particles across the hierarchy. More...

#include <CD_EBAMRParticleMesh.H>

Public Member Functions

Construction and lifetime
 EBAMRParticleMesh ()
 Default constructor. Leaves the object undefined; call define().
 ~EBAMRParticleMesh ()=default
 Destructor.
 EBAMRParticleMesh (const EBAMRParticleMesh &)=delete
 Copy construction is deleted (shared RefCountedPtr state).
EBAMRParticleMesh & operator= (const EBAMRParticleMesh &)=delete
 Copy assignment is deleted.
void define (const Vector< RefCountedPtr< EBLevelGrid > > &a_eblgs, const Vector< int > &a_refRat, const Vector< Real > &a_dx, const RealVect &a_probLo, const int a_ghost, const int a_finestLevel)
 Define the per-level leaves, coarse-fine mesh operators, and halo/transition masks.
Interpolation
template<auto... Members, typename P, typename Traits>
void interpolate (ParticleContainer< P, Traits > &a_particles, const EBAMRCellData &a_meshData, const DepositionType a_interpType, const bool a_forceIrregNGP) const
 Interpolate a mesh field onto one or more payload columns, across all levels.
template<typename P, typename Traits>
void interpolateWeight (ParticleContainer< P, Traits > &a_particles, const EBAMRCellData &a_meshData, const DepositionType a_interpType, const bool a_forceIrregNGP) const
 Interpolate a mesh field onto the container-owned weight column, across all levels.
Deposition (all coarse-fine strategies)
template<typename P, typename Traits>
void depositWeight (EBAMRCellData &a_meshData, const ParticleContainer< P, Traits > &a_particles, const DepositionType a_depositionType, const CoarseFineDeposition a_coarseFineDeposition, const IrregularDeposition a_irregularDeposition)
 Deposit the container-owned weight onto the AMR mesh.
template<typename P, typename Traits, typename CellGather>
void depositGathered (EBAMRCellData &a_meshData, const ParticleContainer< P, Traits > &a_particles, const DepositionType a_depositionType, const CoarseFineDeposition a_coarseFineDeposition, const IrregularDeposition a_irregularDeposition, CellGather a_cellGather)
 Deposit a custom per-particle scalar (computed by a_cellGather) onto the AMR mesh.
template<auto... Members, typename P, typename Traits>
void deposit (EBAMRCellData &a_meshData, const ParticleContainer< P, Traits > &a_particles, const DepositionType a_depositionType, const CoarseFineDeposition a_coarseFineDeposition, const IrregularDeposition a_irregularDeposition)
 Deposit one or more payload columns onto the AMR mesh.

Protected Member Functions

void errorUnsupported () const
 Abort on an unrecognized coarse-fine deposition strategy.
void defineEBParticleMesh ()
 Build the per-level per-patch EBParticleMesh leaves (valid grids + refined-coarse grids).
void defineLevelMotion ()
 Build the per-level valid+ghost -> valid Copiers.
void defineCoarseFineMotion ()
 Build the per-level coarse-fine mesh operators (null on level 0).
template<typename Container, typename PatchDeposit>
void depositInterpCore (EBAMRCellData &a_meshData, const Container &a_particles, const int a_numComp, PatchDeposit a_patchDeposit) const
 The CoarseFineDeposition::Interp deposition algorithm, parameterized by the per-patch deposit.
void defineOuterHaloMasks ()
 Build the per-width outer-halo masks: per level, the coarse cells just outside the fine patch.
template<int NCOMP, typename Container, typename PatchDeposit>
void depositHaloCore (EBAMRCellData &a_meshData, const Container &a_particles, PatchDeposit a_patchDeposit) const
 The CoarseFineDeposition::Halo deposition algorithm.
template<int NCOMP, typename Container, typename PatchDeposit, typename PatchDepositNGP>
void depositHaloNGPCore (EBAMRCellData &a_meshData, const Container &a_particles, PatchDeposit a_patch, PatchDepositNGP a_patchNGP) const
 The CoarseFineDeposition::HaloNGP deposition algorithm.
int getTransitionMaskWidth (const DepositionType a_depositionType, const int a_refRat) const
 Transition-mask width for a kernel: CIC -> refRat/2, TSC -> refRat (NGP is handled upstream).
void defineTransitionMasks ()
 Build the per-width transition masks: the fine-side transition band, on the refined-coarse grid.
template<typename Container>
void transferMaskParticlesTransition (Container &a_particles, const DepositionType a_depositionType) const
 Move the coarse-side transition particles into the container mask holder (using the FiCo mask).
template<int NCOMP, typename Container, typename PatchDeposit>
void depositTransitionCore (EBAMRCellData &a_meshData, const Container &a_particles, const DepositionType a_depositionType, PatchDeposit a_patch) const
 The CoarseFineDeposition::Transition deposition algorithm.

Protected Attributes

Vector< RefCountedPtr< EBLevelGrid > > m_eblgs
 Per-level EB level grids.
Vector< int > m_refRat
 Per-level refinement ratios.
Vector< Real > m_dx
 Per-level grid spacing (isotropic).
RealVect m_probLo
 Lower-left corner of the physical domain.
int m_ghost
 Number of ghost cells in the mesh data holders.
int m_finestLevel
 Finest AMR level index.
bool m_isDefined
 Whether define() has been called.
Vector< RefCountedPtr< LayoutData< EBParticleMesh > > > m_ebParticleMesh
 Per-level per-patch deposition/interpolation leaves.
Vector< Copier > m_levelCopiers
 Per-level valid+ghost -> valid Copiers (fold ghost-deposited mass into the owner patch).
Vector< RefCountedPtr< EBCoarseFineParticleMesh > > m_coarseFinePM
 Per-level coarse-fine mesh operators (null on level 0).
Vector< RefCountedPtr< LayoutData< EBParticleMesh > > > m_ebParticleMeshFiCo
 Per-level per-patch leaves on the refined-coarse (FiCo) grid (null on level 0).
std::map< int, Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > > m_outerHaloMasks
 Outer-halo masks keyed by halo width: per-level coarse cells just outside the fine patch.
std::map< int, Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > > m_transitionMasks
 Transition masks keyed by width: per-level fine-side transition band, on the refined-coarse grid.

Detailed Description

AMR driver that deposits/interpolates ParticleContainer particles across the hierarchy.

EBAMRParticleMesh deposits the particles of a ParticleContainer onto AMR mesh data and interpolates mesh data back onto particle columns, by driving the per-patch EBParticleMesh leaf on every box of every level. define() builds the per-level leaves (on the valid grids and the refined-coarse grids), the level valid+ghost -> valid Copiers, the EBCoarseFineParticleMesh operators, and the halo/transition masks; it must be called before any deposit or interpolate.

Interpolation

interpolate() and interpolateWeight() are purely per-level/per-patch: the mesh is assumed to be valid+ghosted by the caller, so no coarse-fine coupling is needed.

Deposition

deposit(), depositWeight(), and depositGathered() conserve mass across refinement boundaries, and select how the coarse-fine overlap is handled through CoarseFineDeposition:

  • Interp – move the over-boundary mass between levels with the coarse-fine mesh operators.
  • Halo – re-deposit the coarse-side halo particles on the refined-coarse grid (via the container's mask holder and the FiCo buffer) and add them to the fine level.
  • HaloNGP – deposit the near-boundary halo particles with NGP so their clouds do not spread across the boundary (no refined-coarse buffer is needed).
  • Transition – deposit the coarse-side transition particles on the refined-coarse grid at the fine-grid width, distributing the result to both levels. Halo, HaloNGP, and Transition require at least one ghost cell.

Cut cells, and what this class does NOT do

The deposition routines take an IrregularDeposition, but this class only implements the part of it that the leaf kernels can answer: NGP in a cut cell, yes or no. Everything else is the CALLER's responsibility.

  • Native, NGP – handled here. These are the two kernel behaviours.
  • Mirror – NOT handled here. It is a second pass that reflects each band particle across the embedded boundary and deposits the image, so it needs an image container, a scratch field and a collective remap, none of which this class owns. See ItoSolver::mirrorPass.
  • Redistribute, RedistributeBlended – NOT handled here. They act on the field AFTER the deposit. See ItoSolver::redistributeAMR and McPhoto::depositHybridDivergence.

The consequence is worth stating plainly, because it is silent: passing Mirror or Redistribute to a deposition routine here and then omitting the caller's half produces Native behaviour, with no error and no diagnostic. The run completes and the output is bit-for-bit what Native would have given. A caller that selects one of those values owns the rest of its meaning.

This split is deliberate but not ideal – the enum is named in one place and interpreted in three, so there is no single source of truth for what a selector means. Centralizing the mirror and the redistribution here is the natural end state; it needs ParticleContainer::define's minimum block size, level tiles, valid cells and realm name, which this class is not currently given.

Member Function Documentation

◆ define()

void EBAMRParticleMesh::define ( const Vector< RefCountedPtr< EBLevelGrid > > & a_eblgs,
const Vector< int > & a_refRat,
const Vector< Real > & a_dx,
const RealVect & a_probLo,
const int a_ghost,
const int a_finestLevel )
inline

Define the per-level leaves, coarse-fine mesh operators, and halo/transition masks.

Parameters
[in]a_eblgsPer-level EB level grids.
[in]a_refRatPer-level refinement ratio (entry l is the ratio between level l and l+1).
[in]a_dxPer-level (isotropic) grid spacing.
[in]a_probLoLower-left corner of the physical domain.
[in]a_ghostNumber of ghost cells in the mesh data holders.
[in]a_finestLevelFinest AMR level index.

◆ defineOuterHaloMasks()

void EBAMRParticleMesh::defineOuterHaloMasks ( )
inlineprotected

Build the per-width outer-halo masks: per level, the coarse cells just outside the fine patch.

For each ghost width in [1, m_ghost] and each level with a finer level, marks the coarse cells within that width of the refinement boundary (on the coarse side), excluding the coarsened-fine valid region and its neighbours. The mask drives copyMaskParticles in the Halo deposit. Storage-agnostic (operates on the grids only). Empty BaseFabs are undefined.

◆ defineTransitionMasks()

void EBAMRParticleMesh::defineTransitionMasks ( )
inlineprotected

Build the per-width transition masks: the fine-side transition band, on the refined-coarse grid.

For each width in [1, m_ghost] and each level with a finer level, builds the fine-grid coarse-fine interface band (fine ghost cells just outside the fine boxes), transfers it to the refined-coarse (FiCo) grid of the finer level, and stores it as a boolean mask there. Storage- agnostic. Empty BaseFabs are undefined.

◆ deposit()

template<auto... Members, typename P, typename Traits>
void EBAMRParticleMesh::deposit ( EBAMRCellData & a_meshData,
const ParticleContainer< P, Traits > & a_particles,
const DepositionType a_depositionType,
const CoarseFineDeposition a_coarseFineDeposition,
const IrregularDeposition a_irregularDeposition )
inline

Deposit one or more payload columns onto the AMR mesh.

See depositWeight for the coarse-fine dispatch.

Template Parameters
MembersPack of payload data-member pointers selecting the column(s) to deposit.
PPayload type (deduced).
TraitsColumn descriptor (deduced).
Parameters
[in,out]a_meshDataAMR mesh data (sizeof...(Members) components; RESET then filled).
[in]a_particlesParticles to deposit.
[in]a_depositionTypeDeposition kernel (NGP/CIC/TSC).
[in]a_coarseFineDepositionCoarse-fine handling (Interp / Halo / HaloNGP / Transition).
[in]a_irregularDepositionCut-cell deposition strategy.

◆ depositGathered()

template<typename P, typename Traits, typename CellGather>
void EBAMRParticleMesh::depositGathered ( EBAMRCellData & a_meshData,
const ParticleContainer< P, Traits > & a_particles,
const DepositionType a_depositionType,
const CoarseFineDeposition a_coarseFineDeposition,
const IrregularDeposition a_irregularDeposition,
CellGather a_cellGather )
inline

Deposit a custom per-particle scalar (computed by a_cellGather) onto the AMR mesh.

Generalizes depositWeight() to an arbitrary per-particle value (a product of columns such as weight*mobility), dispatching on the coarse-fine strategy exactly like depositWeight(). Deposits one mesh component.

Template Parameters
PPayload type (deduced).
TraitsColumn descriptor (deduced).
CellGatherCallable (const ParticleSoA<P, Traits>& a_leaf, std::size_t a_i) -> Real.
Parameters
[in,out]a_meshDataAMR mesh data (one component; RESET then filled).
[in]a_particlesParticles to deposit.
[in]a_depositionTypeDeposition kernel (NGP/CIC/TSC).
[in]a_coarseFineDepositionCoarse-fine handling (Interp / Halo / HaloNGP / Transition).
[in]a_irregularDepositionCut-cell deposition strategy.
[in]a_cellGatherPer-particle value gatherer (leaf, index) -> Real.

◆ depositHaloCore()

template<int NCOMP, typename Container, typename PatchDeposit>
void EBAMRParticleMesh::depositHaloCore ( EBAMRCellData & a_meshData,
const Container & a_particles,
PatchDeposit a_patchDeposit ) const
inlineprotected

The CoarseFineDeposition::Halo deposition algorithm.

Like Interp for the on-level deposit + fine-ghost->coarse transfer, but instead of interpolating the coarse mass under the fine grid, it re-deposits the coarse-side halo particles (selected by the width-1 outer-halo mask, copied into the container mask holder) on the refined-coarse grid with widthScale = refinement ratio, and adds that to the fine level.

Template Parameters
NCOMPNumber of mesh components (compile-time; selects the FiCo buffer).
ContainerParticleContainer type (deduced).
PatchDepositCallable (const EBParticleMesh&, EBCellFAB&, const ParticleSoA&, Real widthScale).
Parameters
[in,out]a_meshDataAMR mesh data (RESET then filled).
[in]a_particlesParticle container (its mask holder is filled then cleared).
[in]a_patchDepositPer-patch deposition functor.

◆ depositHaloNGPCore()

template<int NCOMP, typename Container, typename PatchDeposit, typename PatchDepositNGP>
void EBAMRParticleMesh::depositHaloNGPCore ( EBAMRCellData & a_meshData,
const Container & a_particles,
PatchDeposit a_patch,
PatchDepositNGP a_patchNGP ) const
inlineprotected

The CoarseFineDeposition::HaloNGP deposition algorithm.

Moves the coarse-side halo particles (width-1 mask) out of the valid holder, deposits the remaining (non-halo) particles with the requested kernel and the halo particles with NGP onto the same level mesh, folds fine-ghost mass to the coarse level, then transfers the halo particles back to the valid holder. NGP keeps the near-boundary clouds from spreading over the refinement boundary, so no refined-coarse buffer is needed.

Template Parameters
NCOMPNumber of mesh components (compile-time).
ContainerParticleContainer type (deduced).
PatchDepositPer-patch deposit with the requested kernel.
PatchDepositNGPPer-patch deposit forced to NGP.
Parameters
[in,out]a_meshDataAMR mesh data (RESET then filled).
[in]a_particlesParticle container (halo particles are moved out then back).
[in]a_patchPer-patch deposit functor (requested kernel).
[in]a_patchNGPPer-patch deposit functor (NGP).

◆ depositInterpCore()

template<typename Container, typename PatchDeposit>
void EBAMRParticleMesh::depositInterpCore ( EBAMRCellData & a_meshData,
const Container & a_particles,
const int a_numComp,
PatchDeposit a_patchDeposit ) const
inlineprotected

The CoarseFineDeposition::Interp deposition algorithm, parameterized by the per-patch deposit.

Resets the mesh, deposits each level's valid particles (via a_patchDeposit), folds ghost-deposited mass into the owner patch (level Copier + EBAddOp), then moves the over-boundary mass between levels with the coarse-fine operators. Uses only valid particles.

Template Parameters
ContainerParticleContainer type (deduced).
PatchDepositCallable (const EBParticleMesh&, EBCellFAB&, const ParticleSoA&, Real widthScale).
Parameters
[in,out]a_meshDataAMR mesh data (RESET then filled).
[in]a_particlesParticle container.
[in]a_numCompNumber of mesh components written.
[in]a_patchDepositPer-patch deposition functor.

◆ depositTransitionCore()

template<int NCOMP, typename Container, typename PatchDeposit>
void EBAMRParticleMesh::depositTransitionCore ( EBAMRCellData & a_meshData,
const Container & a_particles,
const DepositionType a_depositionType,
PatchDeposit a_patch ) const
inlineprotected

The CoarseFineDeposition::Transition deposition algorithm.

NGP short-circuits to the Interp result. Otherwise: moves the coarse-side transition particles out of the valid holder; deposits the remaining particles with the kernel and folds fine-ghost mass to coarse; then deposits the transition particles on the refined-coarse grid with the fine-grid width and distributes that buffer to both the fine level (addFiCoDataToFine + exchangeAndAddFiCoData) and the coarse level (restrictAndAddFiCoDataToCoar); finally returns the transition particles to the valid holder.

Template Parameters
NCOMPNumber of mesh components (compile-time).
ContainerParticleContainer type (deduced).
PatchDepositPer-patch deposit with the requested kernel.
Parameters
[in,out]a_meshDataAMR mesh data (RESET then filled).
[in]a_particlesParticle container.
[in]a_depositionTypeDeposition kernel.
[in]a_patchPer-patch deposit functor (requested kernel).

◆ depositWeight()

template<typename P, typename Traits>
void EBAMRParticleMesh::depositWeight ( EBAMRCellData & a_meshData,
const ParticleContainer< P, Traits > & a_particles,
const DepositionType a_depositionType,
const CoarseFineDeposition a_coarseFineDeposition,
const IrregularDeposition a_irregularDeposition )
inline

Deposit the container-owned weight onto the AMR mesh.

Dispatches on the coarse-fine strategy (Interp / Halo / HaloNGP / Transition); see the class documentation. Halo/HaloNGP/Transition need ghost >= 1.

Template Parameters
PPayload type (deduced).
TraitsColumn descriptor (deduced).
Parameters
[in,out]a_meshDataAMR mesh data (one component; RESET then filled).
[in]a_particlesParticles to deposit.
[in]a_depositionTypeDeposition kernel (NGP/CIC/TSC).
[in]a_coarseFineDepositionCoarse-fine handling (Interp / Halo / HaloNGP / Transition).
[in]a_irregularDepositionCut-cell deposition strategy.

◆ getTransitionMaskWidth()

int EBAMRParticleMesh::getTransitionMaskWidth ( const DepositionType a_depositionType,
const int a_refRat ) const
inlineprotected

Transition-mask width for a kernel: CIC -> refRat/2, TSC -> refRat (NGP is handled upstream).

Parameters
[in]a_depositionTypeDeposition kernel.
[in]a_refRatRefinement ratio between the level and the finer one.
Returns
The transition band width (in fine cells).

◆ interpolate()

template<auto... Members, typename P, typename Traits>
void EBAMRParticleMesh::interpolate ( ParticleContainer< P, Traits > & a_particles,
const EBAMRCellData & a_meshData,
const DepositionType a_interpType,
const bool a_forceIrregNGP ) const
inline

Interpolate a mesh field onto one or more payload columns, across all levels.

Per level, per patch: calls EBParticleMesh::interpolate. The mesh is assumed to be valid+ghosted by the caller (no coarse-fine coupling is needed for interpolation).

Template Parameters
MembersPack of payload data-member pointers selecting the target column(s).
PPayload type (deduced).
TraitsColumn descriptor (deduced).
Parameters
[in,out]a_particlesParticles whose target columns are overwritten.
[in]a_meshDataAMR mesh data (>= sizeof...(Members) components).
[in]a_interpTypeInterpolation kernel (NGP/CIC/TSC).
[in]a_forceIrregNGPForce NGP in cut cells.

◆ interpolateWeight()

template<typename P, typename Traits>
void EBAMRParticleMesh::interpolateWeight ( ParticleContainer< P, Traits > & a_particles,
const EBAMRCellData & a_meshData,
const DepositionType a_interpType,
const bool a_forceIrregNGP ) const
inline

Interpolate a mesh field onto the container-owned weight column, across all levels.

Per level, per patch: calls EBParticleMesh::interpolateWeight. The mesh is assumed to be valid+ghosted by the caller (no coarse-fine coupling is needed for interpolation). This is the interpolation mirror of depositWeight.

Template Parameters
PPayload type (deduced).
TraitsColumn descriptor (deduced).
Parameters
[in,out]a_particlesParticles whose weight column is overwritten.
[in]a_meshDataAMR mesh data (>= 1 component).
[in]a_interpTypeInterpolation kernel (NGP/CIC/TSC).
[in]a_forceIrregNGPForce NGP in cut cells.

◆ operator=()

EBAMRParticleMesh & EBAMRParticleMesh::operator= ( const EBAMRParticleMesh & )
delete

Copy assignment is deleted.

Returns
Reference to this.

◆ transferMaskParticlesTransition()

template<typename Container>
void EBAMRParticleMesh::transferMaskParticlesTransition ( Container & a_particles,
const DepositionType a_depositionType ) const
inlineprotected

Move the coarse-side transition particles into the container mask holder (using the FiCo mask).

The transition mask lives on the refined-coarse grid, so this is done directly here (the container's transferMaskParticles works on the valid grids). Coarse particles whose fine-resolution cell is marked are moved (swap-and-pop) from the valid to the mask holder.

Template Parameters
ContainerParticleContainer type (deduced).
Parameters
[in,out]a_particlesParticle container.
[in]a_depositionTypeDeposition kernel (selects the mask width; NGP is a no-op).

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