1#ifndef AMREX_NEIGHBORPARTICLES_H_
2#define AMREX_NEIGHBORPARTICLES_H_
3#include <AMReX_Config.H>
32template <
int NStructReal,
int NStructInt,
int NArrayReal=0,
int NArrayInt=0>
63 int slevel,
int sgrid,
int stile,
int sindex,
int tnum)
75 amrex::Error(
"operator<<(ostream&, const NeighborIndexMap& nim) failed");
129 amrex::Error(
"operator<<(ostream&, const NeighborCopyTag&) failed");
147 amrex::Error(
"operator<<(ostream&, const InverseCopyTag&) failed");
187 amrex::Error(
"operator<<(ostream&, const NeighborCommTag&) failed");
240 void sumNeighbors (
int real_start_comp,
int real_num_comp,
241 int int_start_comp,
int int_num_comp);
256 template <
class CheckPair>
262 template <
class CheckPair,
class OtherPCType>
270 template <
class CheckPair>
271 void buildNeighborList (CheckPair
const& check_pair,
int type_ind,
int* ref_ratio,
272 int num_bin_types=1,
bool sort=
false);
274 template <
class CheckPair>
284 return neighbors[lev][std::make_pair(grid,tile)];
289 return neighbors[lev][std::make_pair(grid,tile)];
292 template <
typename T,
293 std::enable_if_t<std::is_same_v<T,bool>,
int> = 0>
302 template <
typename T,
303 std::enable_if_t<std::is_same_v<T,bool>,
int> = 0>
312 void Redistribute (
int lev_min=0,
int lev_max=-1,
int nGrow=0,
int local=0,
313 bool remove_negative=
true)
322 const int lev_min = 0;
323 const int lev_max = 0;
327 this->
Redistribute(lev_min, lev_max, nGrow, local, remove_negative);
335 void fillNeighborsCPU ();
336 void sumNeighborsCPU (
int real_start_comp,
int real_num_comp,
337 int int_start_comp,
int int_num_comp);
338 void updateNeighborsCPU (
bool reuse_rcv_counts=
true);
339 void clearNeighborsCPU ();
384 int real_start_comp,
int real_num_comp,
385 int int_start_comp,
int int_num_comp);
394 int nGrow,
const NeighborCopyTag& src_tag,
const MyParIter& pti);
398 const IntVect& nGrow,
const NeighborCopyTag& src_tag,
const MyParIter& pti);
445 { return periodic_shift[0] < other.periodic_shift[0]; },
447 { return periodic_shift[1] < other.periodic_shift[1]; },
449 { return periodic_shift[2] < other.periodic_shift[2]; }
459 std::map<int, std::vector<std::vector<NeighborCode> > >
m_grid_map;
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:129
if(!(yy_init))
Definition amrex_iparser.lex.nolint.H:935
A collection of Boxes stored in an Array.
Definition AMReX_BoxArray.H:550
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:41
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:73
Definition AMReX_NeighborList.H:247
Definition AMReX_NeighborParticles.H:35
bool m_has_neighbors
Definition AMReX_NeighborParticles.H:483
void setRealCommComp(int i, bool value)
Definition AMReX_NeighborParticlesI.H:60
size_t cdata_size
Definition AMReX_NeighborParticles.H:408
std::pair< int, int > PairIndex
Definition AMReX_NeighborParticles.H:196
std::unique_ptr< amrex::iMultiFab > m_neighbor_mask_ptr
Definition AMReX_NeighborParticles.H:457
const ParticleTile & GetNeighbors(int lev, int grid, int tile) const
Definition AMReX_NeighborParticles.H:287
bool enableInverse()
Definition AMReX_NeighborParticles.H:348
void selectActualNeighbors(CheckPair const &check_pair, int num_cells=1)
Definition AMReX_NeighborParticlesI.H:985
IntVect computeRefFac(int src_lev, int lev)
Definition AMReX_NeighborParticlesI.H:248
void getNeighborTags(Vector< NeighborCopyTag > &tags, const ParticleType &p, int nGrow, const NeighborCopyTag &src_tag, const MyParIter &pti)
Definition AMReX_NeighborParticlesI.H:537
typename ParticleContainerType::SuperParticleType SuperParticleType
Definition AMReX_NeighborParticles.H:39
void GetNeighborCommTags()
Definition AMReX_NeighborParticlesI.H:192
Gpu::PinnedVector< char > pinned_snd_buffer
Definition AMReX_NeighborParticles.H:473
void getRcvCountsMPI()
Definition AMReX_NeighborParticlesCPUImpl.H:448
Vector< std::map< PairIndex, ParticleTile > > neighbors
Definition AMReX_NeighborParticles.H:403
void printNeighborList()
Definition AMReX_NeighborParticlesI.H:1095
ParticleTile & GetNeighbors(int lev, int grid, int tile)
Definition AMReX_NeighborParticles.H:282
void calcCommSize()
Definition AMReX_NeighborParticlesI.H:76
Vector< NeighborCommTag > local_neighbors
Definition AMReX_NeighborParticles.H:410
void AddRealComp(T communicate=true)
Definition AMReX_NeighborParticles.H:294
void sumNeighborsMPI(std::map< int, Vector< char > > ¬_ours, int real_start_comp, int real_num_comp, int int_start_comp, int int_num_comp)
Definition AMReX_NeighborParticlesCPUImpl.H:110
bool areMasksValid()
Definition AMReX_NeighborParticlesI.H:129
ParticleCopyPlan neighbor_copy_plan
Definition AMReX_NeighborParticles.H:468
typename ParticleContainer< NStructReal, NStructInt, NArrayReal, NArrayInt >::AoS AoS
Definition AMReX_NeighborParticles.H:198
ParticleCopyOp neighbor_copy_op
Definition AMReX_NeighborParticles.H:467
static bool enable_inverse
Definition AMReX_NeighborParticles.H:428
friend std::ostream & operator<<(std::ostream &os, const InverseCopyTag &tag)
Definition AMReX_NeighborParticles.H:143
void AddIntComp(T communicate=true)
Definition AMReX_NeighborParticles.H:304
~NeighborParticleContainer() override=default
ParIter< NStructReal, NStructInt, NArrayReal, NArrayInt > MyParIter
Definition AMReX_NeighborParticles.H:195
Gpu::PinnedVector< char > pinned_rcv_buffer
Definition AMReX_NeighborParticles.H:474
std::map< int, Vector< char > > send_data
Definition AMReX_NeighborParticles.H:421
bool hasNeighbors() const
Definition AMReX_NeighborParticles.H:481
void initializeCommComps()
Definition AMReX_NeighborParticlesI.H:47
typename ParticleContainer< NStructReal, NStructInt, NArrayReal, NArrayInt >::IntVector IntVector
Definition AMReX_NeighborParticles.H:201
Vector< int > ghost_int_comp
Definition AMReX_NeighborParticles.H:424
void resizeContainers(int num_levels)
Definition AMReX_NeighborParticlesI.H:1114
Vector< std::map< PairIndex, IntVector > > neighbor_list
Definition AMReX_NeighborParticles.H:404
void GetCommTagsBox(Vector< NeighborCommTag > &tags, int lev, const Box &in_box)
Definition AMReX_NeighborParticlesI.H:267
bool m_neighbor_mask_initialized
Definition AMReX_NeighborParticles.H:456
std::map< int, std::vector< std::vector< NeighborCode > > > m_grid_map
Definition AMReX_NeighborParticles.H:459
Vector< Long > rcvs
Definition AMReX_NeighborParticles.H:419
static bool use_mask
Definition AMReX_NeighborParticles.H:426
void buildNeighborList(CheckPair const &check_pair, bool sort=false)
Definition AMReX_NeighborParticlesI.H:695
Vector< int > neighbor_procs
Definition AMReX_NeighborParticles.H:418
Vector< std::map< std::pair< int, int >, amrex::Gpu::DeviceVector< int > > > m_boundary_particle_ids
Definition AMReX_NeighborParticles.H:479
NeighborListContainerType m_neighbor_list
Definition AMReX_NeighborParticles.H:477
void Regrid(const DistributionMapping &dmap, const BoxArray &ba)
Definition AMReX_NeighborParticlesI.H:95
Vector< std::map< PairIndex, Vector< Vector< NeighborCopyTag > > > > buffer_tag_cache
Definition AMReX_NeighborParticles.H:413
void fillNeighborsMPI(bool reuse_rcv_counts)
Definition AMReX_NeighborParticlesCPUImpl.H:509
void RedistributeLocal(bool remove_negative=true)
Definition AMReX_NeighborParticles.H:320
typename ParticleContainer< NStructReal, NStructInt, NArrayReal, NArrayInt >::ParticleTileType ParticleTile
Definition AMReX_NeighborParticles.H:200
void updateNeighbors(bool boundary_neighbors_only=false)
Definition AMReX_NeighborParticlesI.H:664
std::map< int, amrex::Gpu::DeviceVector< Box > > m_isec_boxes
Definition AMReX_NeighborParticles.H:464
NeighborParticleContainer(NeighborParticleContainer &&)=default
amrex::PODVector< char, PolymorphicArenaAllocator< char > > snd_buffer
Definition AMReX_NeighborParticles.H:470
void sumNeighbors(int real_start_comp, int real_num_comp, int int_start_comp, int int_num_comp)
Definition AMReX_NeighborParticlesI.H:651
void BuildMasks()
Definition AMReX_NeighborParticlesI.H:153
static constexpr size_t pdata_size
Definition AMReX_NeighborParticles.H:405
Long num_snds
Definition AMReX_NeighborParticles.H:420
int m_num_neighbor_cells
Definition AMReX_NeighborParticles.H:409
void setEnableInverse(bool flag)
Definition AMReX_NeighborParticles.H:342
void clearNeighborsGPU()
Definition AMReX_NeighborParticlesGPUImpl.H:303
void cacheNeighborInfo()
Definition AMReX_NeighborParticlesI.H:314
Vector< std::map< PairIndex, Vector< InverseCopyTag > > > inverse_tags
Definition AMReX_NeighborParticles.H:402
typename ParticleContainerType::ParticleType ParticleType
Definition AMReX_NeighborParticles.H:38
void clearNeighbors()
Definition AMReX_NeighborParticlesI.H:681
void buildNeighborCopyOp(bool use_boundary_neighbor=false)
Definition AMReX_NeighborParticlesGPUImpl.H:122
Vector< int > ghost_real_comp
Definition AMReX_NeighborParticles.H:423
Vector< std::map< PairIndex, int > > local_neighbor_sizes
Definition AMReX_NeighborParticles.H:414
void updateNeighborsGPU(bool boundary_neighbors_only=false)
Definition AMReX_NeighborParticlesGPUImpl.H:247
void fillNeighbors()
Definition AMReX_NeighborParticlesI.H:639
NeighborParticleContainer & operator=(const NeighborParticleContainer &)=delete
void Redistribute(int lev_min=0, int lev_max=-1, int nGrow=0, int local=0, bool remove_negative=true)
Definition AMReX_NeighborParticles.H:312
Vector< std::unique_ptr< iMultiFab > > mask_ptr
Definition AMReX_NeighborParticles.H:411
void setIntCommComp(int i, bool value)
Definition AMReX_NeighborParticlesI.H:68
std::map< int, amrex::Gpu::DeviceVector< int > > m_code_offsets
Definition AMReX_NeighborParticles.H:465
std::map< int, amrex::Gpu::DeviceVector< NeighborCode > > m_code_array
Definition AMReX_NeighborParticles.H:462
typename ParticleContainer< NStructReal, NStructInt, NArrayReal, NArrayInt >::ParticleVector ParticleVector
Definition AMReX_NeighborParticles.H:199
NeighborParticleContainer(const NeighborParticleContainer &)=delete
void buildNeighborMask()
Definition AMReX_NeighborParticlesGPUImpl.H:53
std::map< NeighborCommTag, Vector< char > > NeighborCommMap
Definition AMReX_NeighborParticles.H:197
static constexpr int num_mask_comps
grid, tile, level
Definition AMReX_NeighborParticles.H:407
amrex::PODVector< char, PolymorphicArenaAllocator< char > > rcv_buffer
Definition AMReX_NeighborParticles.H:471
void fillNeighborsGPU()
Definition AMReX_NeighborParticlesGPUImpl.H:227
Definition AMReX_PODVector.H:262
Definition AMReX_ParGDB.H:13
Definition AMReX_ParIter.H:113
A distributed container for Particles sorted onto the levels, grids, and tiles of a block-structured ...
Definition AMReX_ParticleContainer.H:146
void AddIntComp(std::string const &name, int communicate=1)
Definition AMReX_ParticleContainer.H:1294
Particle< NStructReal+NArrayReal, NStructInt+NArrayInt > SuperParticleType
The type of the "SuperParticle" which stored all components in AoS form.
Definition AMReX_ParticleContainer.H:171
typename ParticleTileType::AoS AoS
Definition AMReX_ParticleContainer.H:188
typename AoS::ParticleVector ParticleVector
Definition AMReX_ParticleContainer.H:193
typename SoA::IntVector IntVector
Definition AMReX_ParticleContainer.H:192
void AddRealComp(std::string const &name, int communicate=1)
Definition AMReX_ParticleContainer.H:1261
T_ParticleType ParticleType
Definition AMReX_ParticleContainer.H:148
Definition AMReX_Amr.cpp:49
IntVectND< AMREX_SPACEDIM > IntVect
Definition AMReX_BaseFwd.H:30
void Error(const std::string &msg)
Print out message to cerr and exit via amrex::Abort().
Definition AMReX.cpp:224
Definition AMReX_NeighborParticles.H:16
IntVect periodic_shift
Definition AMReX_NeighborParticles.H:18
int grid_id
Definition AMReX_NeighborParticles.H:17
Definition AMReX_NeighborParticles.H:136
int src_level
Definition AMReX_NeighborParticles.H:140
int src_index
Definition AMReX_NeighborParticles.H:139
int src_tile
Definition AMReX_NeighborParticles.H:138
int src_grid
Definition AMReX_NeighborParticles.H:137
Definition AMReX_NeighborParticles.H:43
@ tile
Definition AMReX_NeighborParticles.H:46
@ level
Definition AMReX_NeighborParticles.H:47
@ grid
Definition AMReX_NeighborParticles.H:45
Definition AMReX_NeighborParticles.H:152
bool operator<(const NeighborCommTag &other) const
Definition AMReX_NeighborParticles.H:163
NeighborCommTag(int pid, int lid, int gid, int tid)
Definition AMReX_NeighborParticles.H:154
int level_id
Definition AMReX_NeighborParticles.H:159
int tile_id
Definition AMReX_NeighborParticles.H:161
friend std::ostream & operator<<(std::ostream &os, const NeighborCommTag &tag)
Definition AMReX_NeighborParticles.H:183
bool operator==(const NeighborCommTag &other) const
Definition AMReX_NeighborParticles.H:176
int grid_id
Definition AMReX_NeighborParticles.H:160
int proc_id
Definition AMReX_NeighborParticles.H:158
Definition AMReX_NeighborParticles.H:82
bool operator==(const NeighborCopyTag &other) const
Definition AMReX_NeighborParticles.H:111
bool operator<(const NeighborCopyTag &other) const
Definition AMReX_NeighborParticles.H:96
int src_index
Definition AMReX_NeighborParticles.H:86
NeighborCopyTag(int a_level, int a_grid, int a_tile)
Definition AMReX_NeighborParticles.H:92
int dst_index
Definition AMReX_NeighborParticles.H:87
NeighborCopyTag()=default
int tile
Definition AMReX_NeighborParticles.H:85
bool operator!=(const NeighborCopyTag &other) const
Definition AMReX_NeighborParticles.H:120
int grid
Definition AMReX_NeighborParticles.H:84
friend std::ostream & operator<<(std::ostream &os, const NeighborCopyTag &tag)
Definition AMReX_NeighborParticles.H:125
int level
Definition AMReX_NeighborParticles.H:83
IntVect periodic_shift
Definition AMReX_NeighborParticles.H:88
Definition AMReX_NeighborParticles.H:51
int thread_num
Definition AMReX_NeighborParticles.H:60
friend std::ostream & operator<<(std::ostream &os, const NeighborIndexMap &nim)
Definition AMReX_NeighborParticles.H:69
int src_level
Definition AMReX_NeighborParticles.H:56
int src_index
Definition AMReX_NeighborParticles.H:59
int dst_tile
Definition AMReX_NeighborParticles.H:54
int src_grid
Definition AMReX_NeighborParticles.H:57
int dst_index
Definition AMReX_NeighborParticles.H:55
int dst_grid
Definition AMReX_NeighborParticles.H:53
NeighborIndexMap(int dlevel, int dgrid, int dtile, int dindex, int slevel, int sgrid, int stile, int sindex, int tnum)
Definition AMReX_NeighborParticles.H:62
int dst_level
Definition AMReX_NeighborParticles.H:52
int src_tile
Definition AMReX_NeighborParticles.H:58
Definition AMReX_NeighborParticles.H:432
bool operator<(const NeighborTask &other) const
Definition AMReX_NeighborParticles.H:440
IntVect periodic_shift
Definition AMReX_NeighborParticles.H:435
Box box
Definition AMReX_NeighborParticles.H:434
int grid_id
Definition AMReX_NeighborParticles.H:433
NeighborTask(int a_grid_id, const Box &a_box, const IntVect &a_periodic_shift)
Definition AMReX_NeighborParticles.H:437
Definition AMReX_ParticleCommunication.H:58
Definition AMReX_ParticleCommunication.H:81
Definition AMReX_ParticleTile.H:702