chombo-discharge
|
Templated class for holding particles on an AMR hierarchy with particle remapping. More...
#include <CD_ParticleContainer.H>
Public Types | |
using | ValidMask = RefCountedPtr< LevelData< BaseFab< bool > >> |
Public Member Functions | |
ParticleContainer () | |
Default constructor. Leaves object in undefined state. | |
ParticleContainer (const Vector< DisjointBoxLayout > &a_grids, const Vector< ProblemDomain > &a_domains, const Vector< Real > &a_dx, const Vector< int > &a_refRat, const Vector< ValidMask > &a_validMask, const Vector< RefCountedPtr< LevelTiles >> &a_levelTiles, const RealVect &a_probLo, const int a_blockingFactor, const int a_finestLevel, const std::string a_realm) | |
Full constructor. More... | |
virtual | ~ParticleContainer () |
Destructor ( does nothing) | |
void | define (const Vector< DisjointBoxLayout > &a_grids, const Vector< ProblemDomain > &a_domains, const Vector< Real > &a_dx, const Vector< int > &a_refRat, const Vector< ValidMask > &a_validMask, const Vector< RefCountedPtr< LevelTiles >> &a_levelTiles, const RealVect &a_probLo, const int a_blockingFactor, const int a_finestLevel, const std::string a_realm) |
Define the container. This will do a clear-out of all particles. More... | |
void | regrid (const Vector< DisjointBoxLayout > &a_grids, const Vector< ProblemDomain > &a_domains, const Vector< Real > &a_dx, const Vector< int > &a_refRat, const Vector< ValidMask > &a_validMask, const Vector< RefCountedPtr< LevelTiles >> &a_levelTiles, const int a_base, const int a_newFinestLevel) |
Regrid function. a_base is the coarsest grid level which did not change. More... | |
void | preRegrid (const int a_base) |
Cache particles before calling regrid. More... | |
void | copyMaskParticles (const Vector< RefCountedPtr< LevelData< BaseFab< bool >>>> &a_mask) const |
Copy particles to mask particle data holder. More... | |
void | copyMaskParticles (const int a_level, const LevelData< BaseFab< bool >> &a_mask) const |
Copy particles to masked particle data holder. More... | |
void | transferMaskParticles (const Vector< RefCountedPtr< LevelData< BaseFab< bool >>>> &a_mask) |
Copy particles to the mask particle data holder. More... | |
void | transferMaskParticles (const int a_level, const LevelData< BaseFab< bool >> &a_mask) |
Copy particles to masked particle data holder. More... | |
void | sortParticles () noexcept |
Sort particles according to the < operator in the particle. | |
void | clearParticles () |
Clear all particles. | |
void | clearBufferParticles () const |
Clear the buffer particles. | |
void | clearMaskParticles () const |
Clear the "mask" particles. | |
void | clearOutcast () noexcept |
Clear outcast particles. | |
void | clear (AMRParticles< P > &a_particles) const |
Clear particles on input data holder. More... | |
bool | isOrganizedByCell () const |
Is cell-sorted or not. | |
int | getFinestLevel () const |
Get finest AMR level. | |
const std::string | getRealm () const |
Get the realm where this ParticleContainer lives. | |
AMRParticles< P > & | getParticles () |
Get all particles on all levels. More... | |
const AMRParticles< P > & | getParticles () const |
Get all particles on a level. Const version. More... | |
AMRParticles< P > & | getBufferParticles () |
Get buffer particles on all levels. More... | |
const AMRParticles< P > & | getBufferParticles () const |
Get buffer particles on all levels. Const version. More... | |
AMRParticles< P > & | getMaskParticles () |
Get the mask particles. More... | |
const AMRParticles< P > & | getMaskParticles () const |
Get the mask particles. Const version. More... | |
const Vector< DisjointBoxLayout > & | getGrids () const |
Get the AMR grids. | |
const RealVect | getProbLo () const noexcept |
Get lower-left corner. More... | |
const Vector< RealVect > | getDx () const noexcept |
Get grid resolutions. More... | |
ParticleData< P > & | operator[] (const int a_level) |
Get particle data on a level. More... | |
const ParticleData< P > & | operator[] (const int a_level) const |
Get data on a level. Const version. More... | |
AMRCellParticles< P > & | getCellParticles () |
Get all cell particles. More... | |
const AMRCellParticles< P > & | getCellParticles () const |
Get cell particles, const version. More... | |
LayoutData< BinFab< P > > & | getCellParticles (const int a_level) |
Get cell particles. More... | |
const LayoutData< BinFab< P > > & | getCellParticles (const int a_level) const |
Get cell particles, const version. More... | |
BinFab< P > & | getCellParticles (const int a_level, const DataIndex a_dit) |
Get cell particles on a specific level and grid inex. More... | |
const BinFab< P > & | getCellParticles (const int a_level, const DataIndex a_dit) const |
Get cell particles, const version. More... | |
void | getCellParticles (BinFab< P > &a_cellParticles, const int a_lvl, const DataIndex a_dit) const |
Fill a cell-sorted particle data holder with all the particles in the grid patch. More... | |
void | getCellParticlesDestructive (BinFab< P > &a_cellParticles, const int a_lvl, const DataIndex a_dit) |
Fill a cell-sorted particle data holder with all the particles in the grid patch. The original particles are destroyed. More... | |
void | organizeParticlesByCell () |
Sort particles by cell. More... | |
void | organizeParticlesByPatch () |
Sort particles by cell. More... | |
void | addParticles (const List< P > &a_particles) |
Add particles to container. More... | |
void | addParticlesDestructive (List< P > &a_particles) |
Add particles to container. The input particles are destroyed by this routine. More... | |
void | addParticles (const BinFab< P > &a_particles, const int a_lvl, const DataIndex a_dit) |
Add particles to a certain level and patch. The input particles are cell-sorted. More... | |
void | addParticlesDestructive (BinFab< P > &a_particles, const int a_lvl, const DataIndex a_dit) |
Add particles to a certain level and patch. The input particles are cell-sorted (and destroyed on output). More... | |
void | addParticles (const ParticleContainer< P > &a_otherContainer) |
Add particles from other container to this one. More... | |
void | addParticlesDestructive (ParticleContainer< P > &a_otherContainer) |
Add particles from other container to this one. This destroys the particles in the other container. More... | |
void | sanityCheck () const noexcept |
Run a sanity check and make sure all particles are in their correctly assigned box. | |
void | remap () |
Remap over the entire AMR hierarchy. | |
void | transferParticles (ParticleContainer< P > &a_otherContainer) |
Move particles into this container. More... | |
void | transferParticles (AMRParticles< P > &a_otherContainer) |
Move particles into this container. More... | |
void | admitValidParticles (List< P > &a_evictedParticles, ParticleData< P > &a_particles, const int a_coarseLevel) |
Evict particles if they move out of the valid region. More... | |
template<Real &(P::*)() particleScalarField> | |
void | setValue (const Real a_value) |
Set the particle member to the input value. More... | |
template<RealVect &(P::*)() particleVectorField> | |
void | setValue (const RealVect a_value) |
Set the particle member to the input value. More... | |
unsigned long long | getNumberOfValidParticlesLocal () const |
Get local number of particles. | |
unsigned long long | getNumberOfValidParticlesGlobal () const |
Get global number of particles. | |
unsigned long long | getNumberOfOutcastParticlesLocal () const |
Get local number of particles. | |
unsigned long long | getNumberOfOutcastParticlesGlobal () const |
Get global number of particles. | |
unsigned long long | getNumberOfMaskParticlesLocal () const |
Get the number particles in the halo cells. | |
unsigned long long | getNumberOfMaskParticlesGlobal () const |
Get the number particles in the halo cells. | |
Protected Member Functions | |
void | setupGrownGrids (const int a_base, const int a_finestLevel) |
Set up grown grids. More... | |
void | setupParticleData (const int a_base, const int a_finestLevel) |
Setup function for the particle data (m_particles and m_maskParticles) More... | |
void | transferParticlesToSingleList (List< P > &a_list, AMRParticles< P > &a_particles) const noexcept |
Gather the particles onto a single list. More... | |
void | copyParticlesToSingleList (List< P > &a_list, const AMRParticles< P > &a_particles) const noexcept |
Copy the input particles onto a single list. More... | |
void | mapParticlesToAMRGrid (std::vector< std::map< std::pair< unsigned int, unsigned int >, List< P >>> &a_mappedParticles, List< P > &a_unmappedParticles) const noexcept |
Iterate through the unmapped particles and map them to proper level, grid indices, and grid ranks. More... | |
void | catenateParticleMaps (std::vector< std::map< std::pair< unsigned int, unsigned int >, List< P >>> &a_globalParticles, std::vector< std::map< std::pair< unsigned int, unsigned int >, List< P >>> &a_localParticles) const noexcept |
Catenate the particles. This is usually called within OpenMP parallel regions. More... | |
void | assignLocalParticles (std::map< std::pair< unsigned int, unsigned int >, List< P >> &a_mappedParticles, AMRParticles< P > &a_particleData) const noexcept |
Gather particles locally. More... | |
Protected Attributes | |
std::string | m_realm |
Realm on which the ParticleContainer is defined. | |
int | m_blockingFactor |
Blocking factor, aka grid size. | |
int | m_finestLevel |
Finest grid level. | |
RealVect | m_probLo |
Lower left corner of the physical domain. | |
bool | m_isDefined |
Check if particle container is defined. | |
bool | m_isOrganizedByCell |
Check if particle container is "cell sorted". | |
bool | m_profile |
Profile or not. | |
bool | m_debug |
Debug or not. | |
bool | m_verbose |
Verbose or not. | |
Vector< RefCountedPtr< LevelTiles > > | m_levelTiles |
Tiled AMR space. | |
Vector< DisjointBoxLayout > | m_grids |
AMR grids. | |
Vector< DisjointBoxLayout > | m_oldGrids |
Old AMR grids. Used during regrids. | |
Vector< ProblemDomain > | m_domains |
Problem domains. | |
Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > | m_validRegion |
Map of valid cells; evaluates to false if a cell is covered by a finer grid. | |
Vector< BoxLayout > | m_grownGrids |
Grown layouts. | |
Vector< RealVect > | m_dx |
Resolutions on each grid level. | |
Vector< int > | m_refRat |
Refinement ratios. Entry at index 'l' is the refinement between level 'l' and level 'l+1'. | |
AMRParticles< P > | m_particles |
The actual particles that this ParticleContainer represents. | |
AMRParticles< P > | m_bufferParticles |
Special data holder that holds particles on a grown grid layout. More... | |
AMRParticles< P > | m_maskParticles |
Special data holder that holds copies of particles on the coarse level that are within a specified range of the refinement boundary. Used for deposition of coarse-level particle clouds across refinement boundaries. | |
AMRParticles< P > | m_cacheParticles |
Particles stored on the old grid. More... | |
AMRCellParticles< P > | m_cellSortedParticles |
Cell particles. | |
Templated class for holding particles on an AMR hierarchy with particle remapping.
The template parameter P should derive from Chombo's BinItem.
ParticleContainer< P >::ParticleContainer | ( | const Vector< DisjointBoxLayout > & | a_grids, |
const Vector< ProblemDomain > & | a_domains, | ||
const Vector< Real > & | a_dx, | ||
const Vector< int > & | a_refRat, | ||
const Vector< ValidMask > & | a_validMask, | ||
const Vector< RefCountedPtr< LevelTiles >> & | a_levelTiles, | ||
const RealVect & | a_probLo, | ||
const int | a_blockingFactor, | ||
const int | a_finestLevel, | ||
const std::string | a_realm | ||
) |
Full constructor.
[in] | a_grids | AMR grids |
[in] | a_domains | AMR domains |
[in] | a_dx | Grid resolutions |
[in] | a_refRat | Refinement ratios |
[in] | a_validMask | Valid cells (false for cells covered by a finer grid) |
[in] | a_levelTiles | Tiled AMR grids |
[in] | a_probLo | Lower-left corner of the physical domain |
[in] | a_blockingFactor | Grid blocking factor |
[in] | a_finestLevel | Finest grid level |
[in] | a_realm | Realm where these particles live. |
void ParticleContainer< P >::addParticles | ( | const BinFab< P > & | a_particles, |
const int | a_lvl, | ||
const DataIndex | a_dit | ||
) |
Add particles to a certain level and patch. The input particles are cell-sorted.
[in] | a_particles | Input particles (cell-sorted) |
[in] | a_lvl | Grid level |
[in] | a_dit | Grid index |
void ParticleContainer< P >::addParticles | ( | const List< P > & | a_particles | ) |
Add particles to container.
[in] | a_particles | particles to add to this container. |
void ParticleContainer< P >::addParticles | ( | const ParticleContainer< P > & | a_otherContainer | ) |
Add particles from other container to this one.
[in] | a_otherContainer | Other particle container. |
void ParticleContainer< P >::addParticlesDestructive | ( | BinFab< P > & | a_particles, |
const int | a_lvl, | ||
const DataIndex | a_dit | ||
) |
Add particles to a certain level and patch. The input particles are cell-sorted (and destroyed on output).
[in,out] | a_particles | Input particles (cell-sorted). Destroyed on exit. |
[in] | a_lvl | Grid level |
[in] | a_dit | Grid index |
void ParticleContainer< P >::addParticlesDestructive | ( | List< P > & | a_particles | ) |
Add particles to container. The input particles are destroyed by this routine.
[in] | a_particles | particles to add to this container. . |
void ParticleContainer< P >::addParticlesDestructive | ( | ParticleContainer< P > & | a_otherContainer | ) |
Add particles from other container to this one. This destroys the particles in the other container.
[in,out] | a_otherContainer | Other particle container (destroyed on output). |
void ParticleContainer< P >::admitValidParticles | ( | List< P > & | a_evictedParticles, |
ParticleData< P > & | a_particles, | ||
const int | a_coarseLevel | ||
) |
Evict particles if they move out of the valid region.
[in,out] | a_evictedParticles | List that the particles are moved into. |
[in,out] | a_particles | Particles. |
[in] | a_level | Grid level. |
|
inlineprotectednoexcept |
Gather particles locally.
[in,out] | a_mappedParticles | Particles that have been mapped to this rank. |
[in,out] | a_particleData | Where to assign the mapped particles |
|
inlineprotectednoexcept |
Catenate the particles. This is usually called within OpenMP parallel regions.
[in,out] | a_globalParticles | Global particle map |
[in,out] | a_localParticles | Local particle map |
void ParticleContainer< P >::clear | ( | AMRParticles< P > & | a_particles | ) | const |
Clear particles on input data holder.
[in,out] | a_particles |
void ParticleContainer< P >::copyMaskParticles | ( | const int | a_level, |
const LevelData< BaseFab< bool >> & | a_mask | ||
) | const |
Copy particles to masked particle data holder.
[in] | a_level | Grid level |
[in] | a_mask | Mask |
void ParticleContainer< P >::copyMaskParticles | ( | const Vector< RefCountedPtr< LevelData< BaseFab< bool >>>> & | a_mask | ) | const |
Copy particles to mask particle data holder.
[in] | a_mask | Mask |
|
inlineprotectednoexcept |
Copy the input particles onto a single list.
[in,out] | a_list | List containing all the particles in a_particles |
[in,out] | a_particles | Particles to transfer to list |
void ParticleContainer< P >::define | ( | const Vector< DisjointBoxLayout > & | a_grids, |
const Vector< ProblemDomain > & | a_domains, | ||
const Vector< Real > & | a_dx, | ||
const Vector< int > & | a_refRat, | ||
const Vector< ValidMask > & | a_validMask, | ||
const Vector< RefCountedPtr< LevelTiles >> & | a_levelTiles, | ||
const RealVect & | a_probLo, | ||
const int | a_blockingFactor, | ||
const int | a_finestLevel, | ||
const std::string | a_realm | ||
) |
Define the container. This will do a clear-out of all particles.
[in] | a_grids | AMR grids |
[in] | a_domains | AMR domains |
[in] | a_dx | Grid resolutions |
[in] | a_refRat | Refinement ratios |
[in] | a_validMask | Valid cells (false for cells covered by a finer grid) |
[in] | a_levelTiles | Tiled AMR grids |
[in] | a_probLo | Lower-left corner of the physical domain |
[in] | a_blockingFactor | Grid blocking factor |
[in] | a_finestLevel | Finest grid level |
[in] | a_realm | Realm where these particles live. |
AMRParticles< P > & ParticleContainer< P >::getBufferParticles |
Get buffer particles on all levels.
const AMRParticles< P > & ParticleContainer< P >::getBufferParticles |
Get buffer particles on all levels. Const version.
AMRCellParticles< P > & ParticleContainer< P >::getCellParticles |
Get all cell particles.
const AMRCellParticles< P > & ParticleContainer< P >::getCellParticles |
Get cell particles, const version.
void ParticleContainer< P >::getCellParticles | ( | BinFab< P > & | a_cellParticles, |
const int | a_lvl, | ||
const DataIndex | a_dit | ||
) | const |
Fill a cell-sorted particle data holder with all the particles in the grid patch.
[out] | a_cellParticles | Particles in the input grid patch, sorted by cell. |
[in] | a_level | Grid level |
[in] | a_dit | Grid index |
LayoutData< BinFab< P > > & ParticleContainer< P >::getCellParticles | ( | const int | a_level | ) |
Get cell particles.
[in] | a_level | Grid level |
const LayoutData< BinFab< P > > & ParticleContainer< P >::getCellParticles | ( | const int | a_level | ) | const |
Get cell particles, const version.
[in] | a_level | Grid level |
BinFab< P > & ParticleContainer< P >::getCellParticles | ( | const int | a_level, |
const DataIndex | a_dit | ||
) |
Get cell particles on a specific level and grid inex.
[in] | a_level | Grid level |
[in] | a_dit | Grid index |
const BinFab< P > & ParticleContainer< P >::getCellParticles | ( | const int | a_level, |
const DataIndex | a_dit | ||
) | const |
Get cell particles, const version.
[in] | a_level | Grid level |
[in] | a_dit | Grid index |
void ParticleContainer< P >::getCellParticlesDestructive | ( | BinFab< P > & | a_cellParticles, |
const int | a_lvl, | ||
const DataIndex | a_dit | ||
) |
Fill a cell-sorted particle data holder with all the particles in the grid patch. The original particles are destroyed.
[out] | a_cellParticles | Particles in the input grid patch, sorted by cell. |
[in] | a_level | Grid level |
[in] | a_dit | Grid index |
|
noexcept |
Get grid resolutions.
AMRParticles< P > & ParticleContainer< P >::getMaskParticles |
Get the mask particles.
const AMRParticles< P > & ParticleContainer< P >::getMaskParticles |
Get the mask particles. Const version.
AMRParticles< P > & ParticleContainer< P >::getParticles |
Get all particles on all levels.
const AMRParticles< P > & ParticleContainer< P >::getParticles |
Get all particles on a level. Const version.
|
noexcept |
Get lower-left corner.
|
inlineprotectednoexcept |
Iterate through the unmapped particles and map them to proper level, grid indices, and grid ranks.
[in,out] | a_mappedParticles | Particles mapped according to rank ownership (vector index) and grid level and index (std::pair) |
[in,out] | a_unmappedParticles | Particles that are not mapped (yet) |
ParticleData< P > & ParticleContainer< P >::operator[] | ( | const int | a_level | ) |
Get particle data on a level.
[in] | a_level | AMR level |
const ParticleData< P > & ParticleContainer< P >::operator[] | ( | const int | a_level | ) | const |
Get data on a level. Const version.
[in] | a_level | AMR level |
void ParticleContainer< P >::organizeParticlesByCell |
Sort particles by cell.
This will fill m_cellSortedParticles and destroy the patch-sorted particles.
void ParticleContainer< P >::organizeParticlesByPatch |
Sort particles by cell.
This will fill m_particles from m_cellSortedParticles and destroy the cell-sorted particles.
void ParticleContainer< P >::preRegrid | ( | const int | a_base | ) |
Cache particles before calling regrid.
[in] | a_base | Coarsest grid level which will not change. |
void ParticleContainer< P >::regrid | ( | const Vector< DisjointBoxLayout > & | a_grids, |
const Vector< ProblemDomain > & | a_domains, | ||
const Vector< Real > & | a_dx, | ||
const Vector< int > & | a_refRat, | ||
const Vector< ValidMask > & | a_validMask, | ||
const Vector< RefCountedPtr< LevelTiles >> & | a_levelTiles, | ||
const int | a_base, | ||
const int | a_newFinestLevel | ||
) |
Regrid function. a_base is the coarsest grid level which did not change.
[in] | a_grids | AMR grids |
[in] | a_domains | AMR domains |
[in] | a_dx | Grid resolutions |
[in] | a_refRat | Refinement ratios |
[in] | a_validMask | Valid cells |
[in] | a_levelTiles | Tiled AMR grids |
[in] | a_base | Coarsest grid level that did not change. |
[in] | a_newFinestLevel | New finest grid level |
|
protected |
Set up grown grids.
[in] | a_base | Base level |
[in] | a_finestLevel | Finest AMR level |
|
protected |
Setup function for the particle data (m_particles and m_maskParticles)
[in] | a_base | Base level |
[in] | a_finestLevel | Finest AMR level |
|
inline |
Set the particle member to the input value.
This is a jack-of-all-trades kind of routine for setting a particle field. The template parameter indicates the field to be set, it must be a pointer-to-member-function that returns the field to be set. For example, if the particle class P has a field mass which one wants to set, and this field is returned by a function Real& P::mass(), one can set the quantity for all particles by calling ParticleContainer<P>::setValue<&P::mass>(Real)
[in] | a_value | Value |
|
inline |
Set the particle member to the input value.
This is a jack-of-all-trades kind of routine for setting a particle field. The template parameter indicates the field to be set, it must be a pointer-to-member-function that returns the field to be set. For example, if the particle class P has a field vector which one wants to set, and this field is returned by a function RealVect& P::velocity(), one can set the quantity for all particles by calling ParticleContainer<P>::setValue<&P::velocity>(RealVect);
[in] | a_value | Value |
void ParticleContainer< P >::transferMaskParticles | ( | const int | a_level, |
const LevelData< BaseFab< bool >> & | a_mask | ||
) |
Copy particles to masked particle data holder.
[in] | a_level | Grid level |
[in] | a_mask | Mask |
void ParticleContainer< P >::transferMaskParticles | ( | const Vector< RefCountedPtr< LevelData< BaseFab< bool >>>> & | a_mask | ) |
Copy particles to the mask particle data holder.
[in] | a_mask | Mask |
void ParticleContainer< P >::transferParticles | ( | AMRParticles< P > & | a_otherContainer | ) |
Move particles into this container.
[in,out] | a_otherContainer | Other particle container. |
void ParticleContainer< P >::transferParticles | ( | ParticleContainer< P > & | a_otherContainer | ) |
Move particles into this container.
[in,out] | a_otherContainer | Other particle container. |
|
inlineprotectednoexcept |
Gather the particles onto a single list.
[in,out] | a_list | List containing all the particles in a_particles |
[in,out] | a_particles | Particles to transfer to list |
|
mutableprotected |
Special data holder that holds particles on a grown grid layout.
This particle data holder uses grids that exceed the DisjointBoxLayout on each level (boxes are grown by m_refRat). This means that this particle data holder can store particles that are out the DisjointBoxLayout by m_refRat cells. This is very useful when one wants to deposit particles on the fine level, but where the particles live on the coarse level. In such cases one will typically copy some (or all) particles from the coarse level to this data holder and deposit from this data holder onto the fine level.
|
protected |
Particles stored on the old grid.
Populated during the preRegrid call.