SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt > Class Template Reference

SPADES API: spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt > Class Template Reference
SPADES API
spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt > Class Template Referenceabstract

Main SPADES particle container. More...

#include <SpadesParticleContainer.H>

Inheritance diagram for spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >:
[legend]
Collaboration diagram for spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >:
[legend]

Public Types

using ParticleType
 
using ParticleTileType
 
using IntVector
 
using RealVector
 

Public Member Functions

 SpadesParticleContainer (amrex::AmrParGDB *par_gdb, int ngrow=0)
 Constructor.
 
 SpadesParticleContainer (const amrex::Vector< amrex::Geometry > &geom, const amrex::Vector< amrex::DistributionMapping > &dmap, const amrex::Vector< amrex::BoxArray > &ba, int ngrow=0)
 Constructor.
 
void initialize_state ()
 Initialize particle states (counts and offsets)
 
void clear_state ()
 Delete particle states (counts and offsets)
 
void update_counts ()
 Update the particle counts and offsets.
 
void count_particles ()
 Update the particle counts.
 
void count_offsets ()
 Update the particle offsets.
 
const amrex::iMultiFab & counts () const
 Get the particle counts.
 
const amrex::iMultiFab & offsets () const
 Get the particle offsets.
 
amrex::Long total_count (const int typ) const
 Get the total number of particles of typ.
 
amrex::Long min_count (const int typ) const
 Get the minimum number of particles of typ.
 
amrex::Long max_count (const int typ) const
 Get the maximum number of particles of typ.
 
void check_sort (const amrex::MFIter &mfi)
 Check the result of the sort operation.
 
virtual void sort ()=0
 Sort the particles.
 
template<typename CompareFunctor >
void sort_impl (const CompareFunctor &compare)
 Sort the particles implementation.
 
template<typename CompareFunctor >
void nonencoded_sort_impl (const CompareFunctor &compare)
 Non-encoded sort the particles implementation.
 
void encoded_sort_impl ()
 Encoded sort the particles implementation.
 
void print_messages (const std::string &header)
 Print all the particles to screen.
 
void reposition_particles ()
 Reposition the particles inside a cell for visualization.
 
virtual void write_plot_file (const std::string &plt_filename)=0
 Write the particles to file.
 
int ngrow () const
 Number of grow cells.
 
virtual void initialize_variable_names ()=0
 Initialize variable names.
 
void write_plot_file_impl (const std::string &plt_filename, const std::string &name)
 Write the particles to file (implementation)
 
virtual void read_parameters ()
 Read user parameters.
 
void check_sort_type (const std::string &sort_type)
 Check valid sort type.
 
ParticleArrays< NArrayReal, NArrayInt, ParticleType, RealVector, IntVectorparticle_arrays (ParticleTileType &pti) const
 
template<typename CompareFunc >
void sort_impl (const CompareFunc &compare)
 
template<typename CompareFunc >
void nonencoded_sort_impl (const CompareFunc &compare)
 
template<typename CompareFunc >
void sort_impl (const CompareFunc &compare)
 
template<typename CompareFunc >
void nonencoded_sort_impl (const CompareFunc &compare)
 

Static Public Member Functions

static std::string identifier ()
 Class identifier name.
 

Static Public Attributes

static constexpr int LEV {0}
 Level index.
 

Protected Attributes

int m_ngrow
 Number of grow cells.
 
amrex::Vector< int > m_writeflags_real
 Flags for real data to write to file.
 
amrex::Vector< int > m_writeflags_int
 Flags for int data to write to file.
 
amrex::Vector< std::string > m_real_data_names
 Names for real data to write to file.
 
amrex::Vector< std::string > m_int_data_names
 Names for int data to write to file.
 
std::string m_sort_type {"nonencoded"}
 Sort type.
 
amrex::iMultiFab m_counts
 Count of particles in each cell.
 
amrex::iMultiFab m_offsets
 Offsets of particles in each cell.
 
amrex::MultiFab m_min_timestamp
 Minimum timestamp in each cell for each type.
 
amrex::MultiFab m_max_timestamp
 Maximum timestamp in each cell for each type.
 

Detailed Description

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
class spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >

Main SPADES particle container.

Member Typedef Documentation

◆ IntVector

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
using spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::IntVector
Initial value:
typename amrex::NeighborParticleContainer<
NStructReal,
NStructInt,
NArrayReal,
NArrayInt>::IntVector
typename amrex::NeighborParticleContainer< NStructReal, NStructInt, NArrayReal, NArrayInt >::IntVector IntVector
Definition SpadesParticleContainer.H:47

◆ ParticleTileType

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
using spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::ParticleTileType
Initial value:
typename amrex::NeighborParticleContainer<
NStructReal,
NStructInt,
NArrayReal,
typename amrex::NeighborParticleContainer< NStructReal, NStructInt, NArrayReal, NArrayInt >::ParticleTileType ParticleTileType
Definition SpadesParticleContainer.H:42

◆ ParticleType

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
using spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::ParticleType
Initial value:
typename amrex::NeighborParticleContainer<
NStructReal,
NStructInt,
NArrayReal,
NArrayInt>::ParticleType
typename amrex::NeighborParticleContainer< NStructReal, NStructInt, NArrayReal, NArrayInt >::ParticleType ParticleType
Definition SpadesParticleContainer.H:37

◆ RealVector

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
using spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::RealVector
Initial value:
typename amrex::NeighborParticleContainer<
NStructReal,
NStructInt,
NArrayReal,
NArrayInt>::RealVector
typename amrex::NeighborParticleContainer< NStructReal, NStructInt, NArrayReal, NArrayInt >::RealVector RealVector
Definition SpadesParticleContainer.H:52

Constructor & Destructor Documentation

◆ SpadesParticleContainer() [1/2]

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
SpadesParticleContainer::SpadesParticleContainer ( amrex::AmrParGDB * par_gdb,
int ngrow = 0 )
explicit

Constructor.

Parameters
par_gdb[in] particle database
ngrow[in] number of grow cells
20 {
21
23template <
24 int NType,
25 int NStructReal,

◆ SpadesParticleContainer() [2/2]

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
SpadesParticleContainer::SpadesParticleContainer ( const amrex::Vector< amrex::Geometry > & geom,
const amrex::Vector< amrex::DistributionMapping > & dmap,
const amrex::Vector< amrex::BoxArray > & ba,
int ngrow = 0 )
explicit

Constructor.

Parameters
geom[in] geometry
dmap[in] distribution map
ba[in] box array
ngrow[in] number of grow cells
35{
36public:
37 using ParticleType = typename amrex::NeighborParticleContainer<
38 NStructReal,
39 NStructInt,
40 NArrayReal,
41 NArrayInt>::ParticleType;
42 using ParticleTileType = typename amrex::NeighborParticleContainer<
43 NStructReal,
44 NStructInt,
45 NArrayReal,
46 NArrayInt>::ParticleTileType;
47 using IntVector = typename amrex::NeighborParticleContainer<
48 NStructReal,
49 NStructInt,
50 NArrayReal,
51 NArrayInt>::IntVector;
52 using RealVector = typename amrex::NeighborParticleContainer<

Member Function Documentation

◆ check_sort()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
void SpadesParticleContainer::check_sort ( const amrex::MFIter & mfi)

Check the result of the sort operation.

244 {"nonencoded"};
245
247 amrex::iMultiFab m_counts;
248
250 amrex::iMultiFab m_offsets;
251
253 amrex::MultiFab m_min_timestamp;
254
256 amrex::MultiFab m_max_timestamp;
257};
258
260
261} // namespace spades::particles
262#endif
amrex::iMultiFab m_offsets
Offsets of particles in each cell.
Definition SpadesParticleContainer.H:250
amrex::MultiFab m_max_timestamp
Maximum timestamp in each cell for each type.
Definition SpadesParticleContainer.H:256
amrex::MultiFab m_min_timestamp
Minimum timestamp in each cell for each type.
Definition SpadesParticleContainer.H:253
amrex::iMultiFab m_counts
Count of particles in each cell.
Definition SpadesParticleContainer.H:247

◆ check_sort_type()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
void spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::check_sort_type ( const std::string & sort_type)
inline

Check valid sort type.

208 {
209 const amrex::Vector<std::string> valid_types = {
210 "nonencoded", "encoded"};
211 if (std::find(valid_types.cbegin(), valid_types.cend(), sort_type) ==
212 valid_types.cend()) {
213 amrex::Abort("Invalid sort type. Must be nonencoded or encoded");
214 }
215 }
Here is the caller graph for this function:

◆ clear_state()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
void SpadesParticleContainer::clear_state ( )

Delete particle states (counts and offsets)

109 { return m_offsets; };
110

◆ count_offsets()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
void SpadesParticleContainer::count_offsets ( )

Update the particle offsets.

180 { return m_ngrow; }
181
183 static constexpr int LEV{0};
184
186 virtual void initialize_variable_names() = 0;
187
194 const std::string& plt_filename, const std::string& name);
195
197 virtual void read_parameters()
198 {
199 {
200 amrex::ParmParse pp("spades");
201 pp.query("sort_type", m_sort_type);
203 }
204 }
205
virtual void read_parameters()
Read user parameters.
Definition SpadesParticleContainer.H:197
std::string m_sort_type
Sort type.
Definition SpadesParticleContainer.H:244
static constexpr int LEV
Level index.
Definition SpadesParticleContainer.H:183
void write_plot_file_impl(const std::string &plt_filename, const std::string &name)
Write the particles to file (implementation)
Definition SpadesParticleContainer.H:760
void check_sort_type(const std::string &sort_type)
Check valid sort type.
Definition SpadesParticleContainer.H:207
virtual void initialize_variable_names()=0
Initialize variable names.
int m_ngrow
Number of grow cells.
Definition SpadesParticleContainer.H:229

◆ count_particles()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
void SpadesParticleContainer::count_particles ( )

Update the particle counts.

128 {
129 BL_PROFILE("spades::SpadesParticleContainer::min_count()");
130 return m_counts.min(typ);
131 }
132
138 amrex::Long max_count(const int typ) const
139 {
140 BL_PROFILE("spades::SpadesParticleContainer::max_count()");
141 return m_counts.max(typ);
142 }
143
145 void check_sort(const amrex::MFIter& mfi);
146
148 virtual void sort() = 0;
149
154 template <typename CompareFunctor>
amrex::Long max_count(const int typ) const
Get the maximum number of particles of typ.
Definition SpadesParticleContainer.H:138
void check_sort(const amrex::MFIter &mfi)
Check the result of the sort operation.
Definition SpadesParticleContainer.H:236
virtual void sort()=0
Sort the particles.

◆ counts()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
const amrex::iMultiFab & spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::counts ( ) const
inline

Get the particle counts.

Returns
particle counts
103{ return m_counts; };

◆ encoded_sort_impl()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
void SpadesParticleContainer::encoded_sort_impl ( )

Encoded sort the particles implementation.

442 {
443
445template <
446 int NType,
447 int NStructReal,
448 int NStructInt,
449 int NArrayReal,
450 int NArrayInt>
452 : public amrex::NeighborParticleContainer<
453 NStructReal,
454 NStructInt,
455 NArrayReal,
456 NArrayInt>
457{
458public:
459 using ParticleType = typename amrex::NeighborParticleContainer<
460 NStructReal,
461 NStructInt,
462 NArrayReal,
463 NArrayInt>::ParticleType;
464 using ParticleTileType = typename amrex::NeighborParticleContainer<
465 NStructReal,
466 NStructInt,
467 NArrayReal,
468 NArrayInt>::ParticleTileType;
469 using IntVector = typename amrex::NeighborParticleContainer<
470 NStructReal,
471 NStructInt,
472 NArrayReal,
473 NArrayInt>::IntVector;
474 using RealVector = typename amrex::NeighborParticleContainer<
475 NStructReal,
476 NStructInt,
477 NArrayReal,
478 NArrayInt>::RealVector;
479
484 static std::string identifier() { return "spades_particles"; }
485
491 explicit SpadesParticleContainer(amrex::AmrParGDB* par_gdb, int ngrow = 0);
492
501 const amrex::Vector<amrex::Geometry>& geom,
502 const amrex::Vector<amrex::DistributionMapping>& dmap,
503 const amrex::Vector<amrex::BoxArray>& ba,
504 int ngrow = 0);
505
507 void initialize_state();
508
510 void clear_state();
511
513 void update_counts();
514
516 void count_particles();
517
519 void count_offsets();
520
525 const amrex::iMultiFab& counts() const { return m_counts; };
526
531 const amrex::iMultiFab& offsets() const { return m_offsets; };
532
538 amrex::Long total_count(const int typ) const
539 {
540 BL_PROFILE("spades::SpadesParticleContainer::total_count()");
541 return m_counts.sum(typ);
542 }
543
549 amrex::Long min_count(const int typ) const
550 {
551 BL_PROFILE("spades::SpadesParticleContainer::min_count()");
552 return m_counts.min(typ);
553 }
554
560 amrex::Long max_count(const int typ) const
561 {
562 BL_PROFILE("spades::SpadesParticleContainer::max_count()");
563 return m_counts.max(typ);
564 }
565
567 void check_sort(const amrex::MFIter& mfi);
568
570 virtual void sort() = 0;
571
576 template <typename CompareFunctor>
577 void sort_impl(const CompareFunctor& compare);
578
583 template <typename CompareFunctor>
584 void nonencoded_sort_impl(const CompareFunctor& compare);
585
587 void encoded_sort_impl();
588
590 void print_messages(const std::string& header);
591
594
599 virtual void write_plot_file(const std::string& plt_filename) = 0;
600
602 int ngrow() const { return m_ngrow; }
603
605 static constexpr int LEV{0};
606
608 virtual void initialize_variable_names() = 0;
609
616 const std::string& plt_filename, const std::string& name);
617
619 virtual void read_parameters()
620 {
621 {
622 amrex::ParmParse pp("spades");
623 pp.query("sort_type", m_sort_type);
625 }
626 }
627
629 void check_sort_type(const std::string& sort_type)
630 {
631 const amrex::Vector<std::string> valid_types = {
632 "nonencoded", "encoded"};
633 if (std::find(valid_types.cbegin(), valid_types.cend(), sort_type) ==
634 valid_types.cend()) {
635 amrex::Abort("Invalid sort type. Must be nonencoded or encoded");
636 }
637 }
638
639 ParticleArrays<NArrayReal, NArrayInt, ParticleType, RealVector, IntVector>
641 {
642 auto& aos = pti.GetArrayOfStructs();
643 auto& soa = pti.GetStructOfArrays();
644 return ParticleArrays<
645 NArrayReal, NArrayInt, ParticleType, RealVector, IntVector>(
646 aos.dataPtr(), soa.GetRealData(), soa.GetIntData());
647 }
648
649protected:
651 int m_ngrow;
652
654 amrex::Vector<int> m_writeflags_real;
655
657 amrex::Vector<int> m_writeflags_int;
658
660 amrex::Vector<std::string> m_real_data_names;
661
663 amrex::Vector<std::string> m_int_data_names;
664
666 std::string m_sort_type{"nonencoded"};
667
669 amrex::iMultiFab m_counts;
670
672 amrex::iMultiFab m_offsets;
673
675 amrex::MultiFab m_min_timestamp;
676
678 amrex::MultiFab m_max_timestamp;
679};
680
682
683} // namespace spades::particles
684#endif
static std::string identifier()
Class identifier name.
Definition SpadesParticleContainer.H:62
virtual void write_plot_file(const std::string &plt_filename)=0
Write the particles to file.
void sort_impl(const CompareFunctor &compare)
Sort the particles implementation.
amrex::Vector< std::string > m_int_data_names
Names for int data to write to file.
Definition SpadesParticleContainer.H:241
ParticleArrays< NArrayReal, NArrayInt, ParticleType, RealVector, IntVector > particle_arrays(ParticleTileType &pti) const
Definition SpadesParticleContainer.H:218
void clear_state()
Delete particle states (counts and offsets)
Definition SpadesParticleContainer.H:105
amrex::Vector< std::string > m_real_data_names
Names for real data to write to file.
Definition SpadesParticleContainer.H:238
amrex::Vector< int > m_writeflags_real
Flags for real data to write to file.
Definition SpadesParticleContainer.H:232
void print_messages(const std::string &header)
Print all the particles to screen.
Definition SpadesParticleContainer.H:658
void count_offsets()
Update the particle offsets.
Definition SpadesParticleContainer.H:167
amrex::Vector< int > m_writeflags_int
Flags for int data to write to file.
Definition SpadesParticleContainer.H:235
void initialize_state()
Initialize particle states (counts and offsets)
Definition SpadesParticleContainer.H:65
void count_particles()
Update the particle counts.
Definition SpadesParticleContainer.H:123
amrex::Long total_count(const int typ) const
Get the total number of particles of typ.
Definition SpadesParticleContainer.H:116
SpadesParticleContainer(amrex::AmrParGDB *par_gdb, int ngrow=0)
Constructor.
Definition SpadesParticleContainer.H:9
int ngrow() const
Number of grow cells.
Definition SpadesParticleContainer.H:180
const amrex::iMultiFab & offsets() const
Get the particle offsets.
Definition SpadesParticleContainer.H:109
void encoded_sort_impl()
Encoded sort the particles implementation.
Definition SpadesParticleContainer.H:423
void nonencoded_sort_impl(const CompareFunctor &compare)
Non-encoded sort the particles implementation.
const amrex::iMultiFab & counts() const
Get the particle counts.
Definition SpadesParticleContainer.H:103
void update_counts()
Update the particle counts and offsets.
Definition SpadesParticleContainer.H:218
void reposition_particles()
Reposition the particles inside a cell for visualization.
Definition SpadesParticleContainer.H:691
amrex::Long min_count(const int typ) const
Get the minimum number of particles of typ.
Definition SpadesParticleContainer.H:127

◆ identifier()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
static std::string spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::identifier ( )
inlinestatic

Class identifier name.

Returns
class identifier
62{ return "spades_particles"; }

◆ initialize_state()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
void SpadesParticleContainer::initialize_state ( )

Initialize particle states (counts and offsets)

◆ initialize_variable_names()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
virtual void spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::initialize_variable_names ( )
pure virtual

◆ max_count()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
amrex::Long spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::max_count ( const int typ) const
inline

Get the maximum number of particles of typ.

Parameters
typ[in] particle type
Returns
particle counts min
139 {
140 BL_PROFILE("spades::SpadesParticleContainer::max_count()");
141 return m_counts.max(typ);
142 }

◆ min_count()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
amrex::Long spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::min_count ( const int typ) const
inline

Get the minimum number of particles of typ.

Parameters
typ[in] particle type
Returns
particle counts min
128 {
129 BL_PROFILE("spades::SpadesParticleContainer::min_count()");
130 return m_counts.min(typ);
131 }

◆ ngrow()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
int spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::ngrow ( ) const
inline

Number of grow cells.

180{ return m_ngrow; }

◆ nonencoded_sort_impl() [1/3]

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
template<typename CompareFunc >
void spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::nonencoded_sort_impl ( const CompareFunc & compare)
332{
333 // Taking inspiration from AMReX's SortParticlesByBin
334 BL_PROFILE("spades::SpadesParticleContainer::nonencoded_sort_impl()");
335
336#ifdef AMREX_USE_OMP
337#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
338#endif
339 for (amrex::MFIter mfi = this->MakeMFIter(LEV); mfi.isValid(); ++mfi) {
340 const auto index = std::make_pair(mfi.index(), mfi.LocalTileIndex());
341 auto& pti = this->GetParticles(LEV)[index];
342 const size_t np = pti.numParticles();
343
344 if (np == 0) {
345 continue;
346 }
347
348 BL_PROFILE_VAR(
349 "spades::SpadesParticleContainer::nonencoded_sort::sort_prep",
350 prep);
351 amrex::Gpu::DeviceVector<amrex::Long> cell_list(np);
352 auto* p_cell_list = cell_list.data();
353 amrex::ParallelFor(np, [=] AMREX_GPU_DEVICE(long pidx) noexcept {
354 p_cell_list[pidx] = pidx;
355 });
356 amrex::Gpu::streamSynchronize();
357 BL_PROFILE_VAR_STOP(prep);
358
359 // Sort particle indices based on the cell index
360 BL_PROFILE_VAR(
361 "spades::SpadesParticleContainer::nonencoded_sort::sort", sort);
362 const auto parrs = particle_arrays(pti);
363#ifdef AMREX_USE_GPU
364#if defined(AMREX_USE_CUDA) || defined(AMREX_USE_HIP)
365 thrust::sort(
366 thrust::device, cell_list.begin(), cell_list.end(),
367 [=] AMREX_GPU_DEVICE(
368 const amrex::Long xi, const amrex::Long yi) noexcept {
369 return compare(xi, yi, parrs);
370 });
371#else
372 // Perform sort on CPU, then copy back to device (not good)
373 amrex::Vector<amrex::Long> h_cell_list(np, 0);
374 amrex::Gpu::copy(
375 amrex::Gpu::deviceToHost, cell_list.begin(), cell_list.end(),
376 h_cell_list.begin());
377 std::sort(
378 h_cell_list.begin(), h_cell_list.end(),
379 [=](const amrex::Long xi, const amrex::Long yi) {
380 return compare(xi, yi, parrs);
381 });
382 amrex::Gpu::copy(
383 amrex::Gpu::hostToDevice, h_cell_list.begin(), h_cell_list.end(),
384 cell_list.begin());
385#endif
386#else
387 std::sort(
388 cell_list.begin(), cell_list.end(),
389 [=](const amrex::Long xi, const amrex::Long yi) {
390 return compare(xi, yi, parrs);
391 });
392#endif
393 amrex::Gpu::streamSynchronize();
394 BL_PROFILE_VAR_STOP(sort);
395
396 // Reorder the particles in memory
397 BL_PROFILE_VAR(
398 "spades::SpadesParticleContainer::nonencoded_sort::"
399 "ReorderParticles",
400 reorder);
401 this->ReorderParticles(LEV, mfi, cell_list.data());
402 amrex::Gpu::streamSynchronize();
403 BL_PROFILE_VAR_STOP(reorder);
404
405#ifdef AMREX_DEBUG
406 check_sort(mfi);
407#endif
408 }
409}

◆ nonencoded_sort_impl() [2/3]

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
template<typename CompareFunc >
void spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::nonencoded_sort_impl ( const CompareFunc & compare)
351 {
352
354template <
355 int NType,
356 int NStructReal,
357 int NStructInt,
358 int NArrayReal,
359 int NArrayInt>
361 : public amrex::NeighborParticleContainer<
362 NStructReal,
363 NStructInt,
364 NArrayReal,
365 NArrayInt>
366{
367public:
368 using ParticleType = typename amrex::NeighborParticleContainer<
369 NStructReal,
370 NStructInt,
371 NArrayReal,
372 NArrayInt>::ParticleType;
373 using ParticleTileType = typename amrex::NeighborParticleContainer<
374 NStructReal,
375 NStructInt,
376 NArrayReal,
377 NArrayInt>::ParticleTileType;
378 using IntVector = typename amrex::NeighborParticleContainer<
379 NStructReal,
380 NStructInt,
381 NArrayReal,
382 NArrayInt>::IntVector;
383 using RealVector = typename amrex::NeighborParticleContainer<
384 NStructReal,
385 NStructInt,
386 NArrayReal,
387 NArrayInt>::RealVector;
388
393 static std::string identifier() { return "spades_particles"; }
394
400 explicit SpadesParticleContainer(amrex::AmrParGDB* par_gdb, int ngrow = 0);
401
410 const amrex::Vector<amrex::Geometry>& geom,
411 const amrex::Vector<amrex::DistributionMapping>& dmap,
412 const amrex::Vector<amrex::BoxArray>& ba,
413 int ngrow = 0);
414
416 void initialize_state();
417
419 void clear_state();
420
422 void update_counts();
423
425 void count_particles();
426
428 void count_offsets();
429
434 const amrex::iMultiFab& counts() const { return m_counts; };
435
440 const amrex::iMultiFab& offsets() const { return m_offsets; };
441
447 amrex::Long total_count(const int typ) const
448 {
449 BL_PROFILE("spades::SpadesParticleContainer::total_count()");
450 return m_counts.sum(typ);
451 }
452
458 amrex::Long min_count(const int typ) const
459 {
460 BL_PROFILE("spades::SpadesParticleContainer::min_count()");
461 return m_counts.min(typ);
462 }
463
469 amrex::Long max_count(const int typ) const
470 {
471 BL_PROFILE("spades::SpadesParticleContainer::max_count()");
472 return m_counts.max(typ);
473 }
474
476 void check_sort(const amrex::MFIter& mfi);
477
479 virtual void sort() = 0;
480
485 template <typename CompareFunctor>
486 void sort_impl(const CompareFunctor& compare);
487
492 template <typename CompareFunctor>
493 void nonencoded_sort_impl(const CompareFunctor& compare);
494
496 void encoded_sort_impl();
497
499 void print_messages(const std::string& header);
500
503
508 virtual void write_plot_file(const std::string& plt_filename) = 0;
509
511 int ngrow() const { return m_ngrow; }
512
514 static constexpr int LEV{0};
515
517 virtual void initialize_variable_names() = 0;
518
525 const std::string& plt_filename, const std::string& name);
526
528 virtual void read_parameters()
529 {
530 {
531 amrex::ParmParse pp("spades");
532 pp.query("sort_type", m_sort_type);
534 }
535 }
536
538 void check_sort_type(const std::string& sort_type)
539 {
540 const amrex::Vector<std::string> valid_types = {
541 "nonencoded", "encoded"};
542 if (std::find(valid_types.cbegin(), valid_types.cend(), sort_type) ==
543 valid_types.cend()) {
544 amrex::Abort("Invalid sort type. Must be nonencoded or encoded");
545 }
546 }
547
548 ParticleArrays<NArrayReal, NArrayInt, ParticleType, RealVector, IntVector>
550 {
551 auto& aos = pti.GetArrayOfStructs();
552 auto& soa = pti.GetStructOfArrays();
553 return ParticleArrays<
554 NArrayReal, NArrayInt, ParticleType, RealVector, IntVector>(
555 aos.dataPtr(), soa.GetRealData(), soa.GetIntData());
556 }
557
558protected:
560 int m_ngrow;
561
563 amrex::Vector<int> m_writeflags_real;
564
566 amrex::Vector<int> m_writeflags_int;
567
569 amrex::Vector<std::string> m_real_data_names;
570
572 amrex::Vector<std::string> m_int_data_names;
573
575 std::string m_sort_type{"nonencoded"};
576
578 amrex::iMultiFab m_counts;
579
581 amrex::iMultiFab m_offsets;
582
584 amrex::MultiFab m_min_timestamp;
585
587 amrex::MultiFab m_max_timestamp;
588};
589
591
592} // namespace spades::particles
593#endif

◆ nonencoded_sort_impl() [3/3]

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
template<typename CompareFunctor >
void spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::nonencoded_sort_impl ( const CompareFunctor & compare)

Non-encoded sort the particles implementation.

Parameters
compare[in] comparison functor

◆ offsets()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
const amrex::iMultiFab & spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::offsets ( ) const
inline

Get the particle offsets.

Returns
particle offsets
109{ return m_offsets; };

◆ particle_arrays()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
ParticleArrays< NArrayReal, NArrayInt, ParticleType, RealVector, IntVector > spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::particle_arrays ( ParticleTileType & pti) const
inline
219 {
220 auto& aos = pti.GetArrayOfStructs();
221 auto& soa = pti.GetStructOfArrays();
222 return ParticleArrays<
223 NArrayReal, NArrayInt, ParticleType, RealVector, IntVector>(
224 aos.dataPtr(), soa.GetRealData(), soa.GetIntData());
225 }
Here is the caller graph for this function:

◆ print_messages()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
void SpadesParticleContainer::print_messages ( const std::string & header)

Print all the particles to screen.

677 {
678
680template <
681 int NType,
682 int NStructReal,
683 int NStructInt,
684 int NArrayReal,
685 int NArrayInt>
687 : public amrex::NeighborParticleContainer<
688 NStructReal,
689 NStructInt,
690 NArrayReal,
691 NArrayInt>
692{
693public:
694 using ParticleType = typename amrex::NeighborParticleContainer<
695 NStructReal,
696 NStructInt,
697 NArrayReal,
698 NArrayInt>::ParticleType;
699 using ParticleTileType = typename amrex::NeighborParticleContainer<
700 NStructReal,
701 NStructInt,
702 NArrayReal,
703 NArrayInt>::ParticleTileType;
704 using IntVector = typename amrex::NeighborParticleContainer<
705 NStructReal,
706 NStructInt,
707 NArrayReal,
708 NArrayInt>::IntVector;
709 using RealVector = typename amrex::NeighborParticleContainer<
710 NStructReal,
711 NStructInt,
712 NArrayReal,
713 NArrayInt>::RealVector;
714
719 static std::string identifier() { return "spades_particles"; }
720
726 explicit SpadesParticleContainer(amrex::AmrParGDB* par_gdb, int ngrow = 0);
727
736 const amrex::Vector<amrex::Geometry>& geom,
737 const amrex::Vector<amrex::DistributionMapping>& dmap,
738 const amrex::Vector<amrex::BoxArray>& ba,
739 int ngrow = 0);
740
742 void initialize_state();
743
745 void clear_state();
746
748 void update_counts();
749
751 void count_particles();
752
754 void count_offsets();
755
760 const amrex::iMultiFab& counts() const { return m_counts; };
761
766 const amrex::iMultiFab& offsets() const { return m_offsets; };
767
773 amrex::Long total_count(const int typ) const
774 {
775 BL_PROFILE("spades::SpadesParticleContainer::total_count()");
776 return m_counts.sum(typ);
777 }
778
784 amrex::Long min_count(const int typ) const
785 {
786 BL_PROFILE("spades::SpadesParticleContainer::min_count()");
787 return m_counts.min(typ);
788 }
789
795 amrex::Long max_count(const int typ) const
796 {
797 BL_PROFILE("spades::SpadesParticleContainer::max_count()");
798 return m_counts.max(typ);
799 }
800
802 void check_sort(const amrex::MFIter& mfi);
803
805 virtual void sort() = 0;
806
811 template <typename CompareFunctor>
812 void sort_impl(const CompareFunctor& compare);
813
818 template <typename CompareFunctor>
819 void nonencoded_sort_impl(const CompareFunctor& compare);
820
822 void encoded_sort_impl();
823
825 void print_messages(const std::string& header);
826
829
834 virtual void write_plot_file(const std::string& plt_filename) = 0;
835
837 int ngrow() const { return m_ngrow; }
838
840 static constexpr int LEV{0};
841
843 virtual void initialize_variable_names() = 0;
844
851 const std::string& plt_filename, const std::string& name);
852
854 virtual void read_parameters()
855 {
856 {
857 amrex::ParmParse pp("spades");
858 pp.query("sort_type", m_sort_type);
860 }
861 }
862
864 void check_sort_type(const std::string& sort_type)
865 {
866 const amrex::Vector<std::string> valid_types = {
867 "nonencoded", "encoded"};
868 if (std::find(valid_types.cbegin(), valid_types.cend(), sort_type) ==
869 valid_types.cend()) {
870 amrex::Abort("Invalid sort type. Must be nonencoded or encoded");
871 }
872 }
873
874 ParticleArrays<NArrayReal, NArrayInt, ParticleType, RealVector, IntVector>
876 {
877 auto& aos = pti.GetArrayOfStructs();
878 auto& soa = pti.GetStructOfArrays();
879 return ParticleArrays<
880 NArrayReal, NArrayInt, ParticleType, RealVector, IntVector>(
881 aos.dataPtr(), soa.GetRealData(), soa.GetIntData());
882 }
883
884protected:
886 int m_ngrow;
887
889 amrex::Vector<int> m_writeflags_real;
890
892 amrex::Vector<int> m_writeflags_int;
893
895 amrex::Vector<std::string> m_real_data_names;
896
898 amrex::Vector<std::string> m_int_data_names;
899
901 std::string m_sort_type{"nonencoded"};
902
904 amrex::iMultiFab m_counts;
905
907 amrex::iMultiFab m_offsets;
908
910 amrex::MultiFab m_min_timestamp;
911
913 amrex::MultiFab m_max_timestamp;
914};
915
917
918} // namespace spades::particles
919#endif

◆ read_parameters()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
virtual void spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::read_parameters ( )
inlinevirtual

Read user parameters.

Reimplemented in spades::particles::EntityParticleContainer, and spades::particles::MessageParticleContainer.

198 {
199 {
200 amrex::ParmParse pp("spades");
201 pp.query("sort_type", m_sort_type);
203 }
204 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reposition_particles()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
void SpadesParticleContainer::reposition_particles ( )

Reposition the particles inside a cell for visualization.

710 {
711
713template <
714 int NType,
715 int NStructReal,
716 int NStructInt,
717 int NArrayReal,
718 int NArrayInt>
720 : public amrex::NeighborParticleContainer<
721 NStructReal,
722 NStructInt,
723 NArrayReal,
724 NArrayInt>
725{
726public:
727 using ParticleType = typename amrex::NeighborParticleContainer<
728 NStructReal,
729 NStructInt,
730 NArrayReal,
731 NArrayInt>::ParticleType;
732 using ParticleTileType = typename amrex::NeighborParticleContainer<
733 NStructReal,
734 NStructInt,
735 NArrayReal,
736 NArrayInt>::ParticleTileType;
737 using IntVector = typename amrex::NeighborParticleContainer<
738 NStructReal,
739 NStructInt,
740 NArrayReal,
741 NArrayInt>::IntVector;
742 using RealVector = typename amrex::NeighborParticleContainer<
743 NStructReal,
744 NStructInt,
745 NArrayReal,
746 NArrayInt>::RealVector;
747
752 static std::string identifier() { return "spades_particles"; }
753
759 explicit SpadesParticleContainer(amrex::AmrParGDB* par_gdb, int ngrow = 0);
760
769 const amrex::Vector<amrex::Geometry>& geom,
770 const amrex::Vector<amrex::DistributionMapping>& dmap,
771 const amrex::Vector<amrex::BoxArray>& ba,
772 int ngrow = 0);
773
775 void initialize_state();
776
778 void clear_state();
779
781 void update_counts();
782
784 void count_particles();
785
787 void count_offsets();
788
793 const amrex::iMultiFab& counts() const { return m_counts; };
794
799 const amrex::iMultiFab& offsets() const { return m_offsets; };
800
806 amrex::Long total_count(const int typ) const
807 {
808 BL_PROFILE("spades::SpadesParticleContainer::total_count()");
809 return m_counts.sum(typ);
810 }
811
817 amrex::Long min_count(const int typ) const
818 {
819 BL_PROFILE("spades::SpadesParticleContainer::min_count()");
820 return m_counts.min(typ);
821 }
822
828 amrex::Long max_count(const int typ) const
829 {
830 BL_PROFILE("spades::SpadesParticleContainer::max_count()");
831 return m_counts.max(typ);
832 }
833
835 void check_sort(const amrex::MFIter& mfi);
836
838 virtual void sort() = 0;
839
844 template <typename CompareFunctor>
845 void sort_impl(const CompareFunctor& compare);
846
851 template <typename CompareFunctor>
852 void nonencoded_sort_impl(const CompareFunctor& compare);
853
855 void encoded_sort_impl();
856
858 void print_messages(const std::string& header);
859
862
867 virtual void write_plot_file(const std::string& plt_filename) = 0;
868
870 int ngrow() const { return m_ngrow; }
871
873 static constexpr int LEV{0};
874
876 virtual void initialize_variable_names() = 0;
877
884 const std::string& plt_filename, const std::string& name);
885
887 virtual void read_parameters()
888 {
889 {
890 amrex::ParmParse pp("spades");
891 pp.query("sort_type", m_sort_type);
893 }
894 }
895
897 void check_sort_type(const std::string& sort_type)
898 {
899 const amrex::Vector<std::string> valid_types = {
900 "nonencoded", "encoded"};
901 if (std::find(valid_types.cbegin(), valid_types.cend(), sort_type) ==
902 valid_types.cend()) {
903 amrex::Abort("Invalid sort type. Must be nonencoded or encoded");
904 }
905 }
906
907 ParticleArrays<NArrayReal, NArrayInt, ParticleType, RealVector, IntVector>
909 {
910 auto& aos = pti.GetArrayOfStructs();
911 auto& soa = pti.GetStructOfArrays();
912 return ParticleArrays<
913 NArrayReal, NArrayInt, ParticleType, RealVector, IntVector>(
914 aos.dataPtr(), soa.GetRealData(), soa.GetIntData());
915 }
916
917protected:
919 int m_ngrow;
920
922 amrex::Vector<int> m_writeflags_real;
923
925 amrex::Vector<int> m_writeflags_int;
926
928 amrex::Vector<std::string> m_real_data_names;
929
931 amrex::Vector<std::string> m_int_data_names;
932
934 std::string m_sort_type{"nonencoded"};
935
937 amrex::iMultiFab m_counts;
938
940 amrex::iMultiFab m_offsets;
941
943 amrex::MultiFab m_min_timestamp;
944
946 amrex::MultiFab m_max_timestamp;
947};
948
950
951} // namespace spades::particles
952#endif

◆ sort()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
virtual void spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::sort ( )
pure virtual

◆ sort_impl() [1/3]

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
template<typename CompareFunc >
void spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::sort_impl ( const CompareFunc & compare)
307{
308 BL_PROFILE("spades::SpadesParticleContainer::sort_impl()");
309 if (m_sort_type == "nonencoded") {
310 nonencoded_sort_impl(compare);
311 } else if (m_sort_type == "encoded") {
313 } else {
314 amrex::Abort("Invalid sort type. Must be nonencoded or encoded");
315 }
317}

◆ sort_impl() [2/3]

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
template<typename CompareFunc >
void spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::sort_impl ( const CompareFunc & compare)
326 {
327
329template <
330 int NType,
331 int NStructReal,
332 int NStructInt,
333 int NArrayReal,
334 int NArrayInt>
336 : public amrex::NeighborParticleContainer<
337 NStructReal,
338 NStructInt,
339 NArrayReal,
340 NArrayInt>
341{
342public:
343 using ParticleType = typename amrex::NeighborParticleContainer<
344 NStructReal,
345 NStructInt,
346 NArrayReal,
347 NArrayInt>::ParticleType;
348 using ParticleTileType = typename amrex::NeighborParticleContainer<
349 NStructReal,
350 NStructInt,
351 NArrayReal,
352 NArrayInt>::ParticleTileType;
353 using IntVector = typename amrex::NeighborParticleContainer<
354 NStructReal,
355 NStructInt,
356 NArrayReal,
357 NArrayInt>::IntVector;
358 using RealVector = typename amrex::NeighborParticleContainer<
359 NStructReal,
360 NStructInt,
361 NArrayReal,
362 NArrayInt>::RealVector;
363
368 static std::string identifier() { return "spades_particles"; }
369
375 explicit SpadesParticleContainer(amrex::AmrParGDB* par_gdb, int ngrow = 0);
376
385 const amrex::Vector<amrex::Geometry>& geom,
386 const amrex::Vector<amrex::DistributionMapping>& dmap,
387 const amrex::Vector<amrex::BoxArray>& ba,
388 int ngrow = 0);
389
391 void initialize_state();
392
394 void clear_state();
395
397 void update_counts();
398
400 void count_particles();
401
403 void count_offsets();
404
409 const amrex::iMultiFab& counts() const { return m_counts; };
410
415 const amrex::iMultiFab& offsets() const { return m_offsets; };
416
422 amrex::Long total_count(const int typ) const
423 {
424 BL_PROFILE("spades::SpadesParticleContainer::total_count()");
425 return m_counts.sum(typ);
426 }
427
433 amrex::Long min_count(const int typ) const
434 {
435 BL_PROFILE("spades::SpadesParticleContainer::min_count()");
436 return m_counts.min(typ);
437 }
438
444 amrex::Long max_count(const int typ) const
445 {
446 BL_PROFILE("spades::SpadesParticleContainer::max_count()");
447 return m_counts.max(typ);
448 }
449
451 void check_sort(const amrex::MFIter& mfi);
452
454 virtual void sort() = 0;
455
460 template <typename CompareFunctor>
461 void sort_impl(const CompareFunctor& compare);
462
467 template <typename CompareFunctor>
468 void nonencoded_sort_impl(const CompareFunctor& compare);
469
471 void encoded_sort_impl();
472
474 void print_messages(const std::string& header);
475
478
483 virtual void write_plot_file(const std::string& plt_filename) = 0;
484
486 int ngrow() const { return m_ngrow; }
487
489 static constexpr int LEV{0};
490
492 virtual void initialize_variable_names() = 0;
493
500 const std::string& plt_filename, const std::string& name);
501
503 virtual void read_parameters()
504 {
505 {
506 amrex::ParmParse pp("spades");
507 pp.query("sort_type", m_sort_type);
509 }
510 }
511
513 void check_sort_type(const std::string& sort_type)
514 {
515 const amrex::Vector<std::string> valid_types = {
516 "nonencoded", "encoded"};
517 if (std::find(valid_types.cbegin(), valid_types.cend(), sort_type) ==
518 valid_types.cend()) {
519 amrex::Abort("Invalid sort type. Must be nonencoded or encoded");
520 }
521 }
522
523 ParticleArrays<NArrayReal, NArrayInt, ParticleType, RealVector, IntVector>
525 {
526 auto& aos = pti.GetArrayOfStructs();
527 auto& soa = pti.GetStructOfArrays();
528 return ParticleArrays<
529 NArrayReal, NArrayInt, ParticleType, RealVector, IntVector>(
530 aos.dataPtr(), soa.GetRealData(), soa.GetIntData());
531 }
532
533protected:
535 int m_ngrow;
536
538 amrex::Vector<int> m_writeflags_real;
539
541 amrex::Vector<int> m_writeflags_int;
542
544 amrex::Vector<std::string> m_real_data_names;
545
547 amrex::Vector<std::string> m_int_data_names;
548
550 std::string m_sort_type{"nonencoded"};
551
553 amrex::iMultiFab m_counts;
554
556 amrex::iMultiFab m_offsets;
557
559 amrex::MultiFab m_min_timestamp;
560
562 amrex::MultiFab m_max_timestamp;
563};
564
566
567} // namespace spades::particles
568#endif

◆ sort_impl() [3/3]

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
template<typename CompareFunctor >
void spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::sort_impl ( const CompareFunctor & compare)

Sort the particles implementation.

Parameters
compare[in] comparison functor

◆ total_count()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
amrex::Long spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::total_count ( const int typ) const
inline

Get the total number of particles of typ.

Parameters
typ[in] particle type
Returns
particle counts
117 {
118 BL_PROFILE("spades::SpadesParticleContainer::total_count()");
119 return m_counts.sum(typ);
120 }

◆ update_counts()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
void SpadesParticleContainer::update_counts ( )

Update the particle counts and offsets.

219 {
220 auto& aos = pti.GetArrayOfStructs();
221 auto& soa = pti.GetStructOfArrays();
222 return ParticleArrays<
223 NArrayReal, NArrayInt, ParticleType, RealVector, IntVector>(

◆ write_plot_file()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
virtual void spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::write_plot_file ( const std::string & plt_filename)
pure virtual

Write the particles to file.

Parameters
plt_filename[in] file name for the plot file

Implemented in spades::particles::EntityParticleContainer, and spades::particles::MessageParticleContainer.

◆ write_plot_file_impl()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
void SpadesParticleContainer::write_plot_file_impl ( const std::string & plt_filename,
const std::string & name )

Write the particles to file (implementation)

Parameters
plt_filename[in] file name for the plot file
name[in] file name for the particle file
779 {
780
782template <
783 int NType,
784 int NStructReal,
785 int NStructInt,
786 int NArrayReal,
787 int NArrayInt>
789 : public amrex::NeighborParticleContainer<
790 NStructReal,
791 NStructInt,
792 NArrayReal,
793 NArrayInt>
794{
795public:
796 using ParticleType = typename amrex::NeighborParticleContainer<
797 NStructReal,
798 NStructInt,
799 NArrayReal,
800 NArrayInt>::ParticleType;
801 using ParticleTileType = typename amrex::NeighborParticleContainer<
802 NStructReal,
803 NStructInt,
804 NArrayReal,
805 NArrayInt>::ParticleTileType;
806 using IntVector = typename amrex::NeighborParticleContainer<
807 NStructReal,
808 NStructInt,
809 NArrayReal,
810 NArrayInt>::IntVector;
811 using RealVector = typename amrex::NeighborParticleContainer<
812 NStructReal,
813 NStructInt,
814 NArrayReal,
815 NArrayInt>::RealVector;
816
821 static std::string identifier() { return "spades_particles"; }
822
828 explicit SpadesParticleContainer(amrex::AmrParGDB* par_gdb, int ngrow = 0);
829
838 const amrex::Vector<amrex::Geometry>& geom,
839 const amrex::Vector<amrex::DistributionMapping>& dmap,
840 const amrex::Vector<amrex::BoxArray>& ba,
841 int ngrow = 0);
842
844 void initialize_state();
845
847 void clear_state();
848
850 void update_counts();
851
853 void count_particles();
854
856 void count_offsets();
857
862 const amrex::iMultiFab& counts() const { return m_counts; };
863
868 const amrex::iMultiFab& offsets() const { return m_offsets; };
869
875 amrex::Long total_count(const int typ) const
876 {
877 BL_PROFILE("spades::SpadesParticleContainer::total_count()");
878 return m_counts.sum(typ);
879 }
880
886 amrex::Long min_count(const int typ) const
887 {
888 BL_PROFILE("spades::SpadesParticleContainer::min_count()");
889 return m_counts.min(typ);
890 }
891
897 amrex::Long max_count(const int typ) const
898 {
899 BL_PROFILE("spades::SpadesParticleContainer::max_count()");
900 return m_counts.max(typ);
901 }
902
904 void check_sort(const amrex::MFIter& mfi);
905
907 virtual void sort() = 0;
908
913 template <typename CompareFunctor>
914 void sort_impl(const CompareFunctor& compare);
915
920 template <typename CompareFunctor>
921 void nonencoded_sort_impl(const CompareFunctor& compare);
922
924 void encoded_sort_impl();
925
927 void print_messages(const std::string& header);
928
931
936 virtual void write_plot_file(const std::string& plt_filename) = 0;
937
939 int ngrow() const { return m_ngrow; }
940
942 static constexpr int LEV{0};
943
945 virtual void initialize_variable_names() = 0;
946
953 const std::string& plt_filename, const std::string& name);
954
956 virtual void read_parameters()
957 {
958 {
959 amrex::ParmParse pp("spades");
960 pp.query("sort_type", m_sort_type);
962 }
963 }
964
966 void check_sort_type(const std::string& sort_type)
967 {
968 const amrex::Vector<std::string> valid_types = {
969 "nonencoded", "encoded"};
970 if (std::find(valid_types.cbegin(), valid_types.cend(), sort_type) ==
971 valid_types.cend()) {
972 amrex::Abort("Invalid sort type. Must be nonencoded or encoded");
973 }
974 }
975
976 ParticleArrays<NArrayReal, NArrayInt, ParticleType, RealVector, IntVector>
978 {
979 auto& aos = pti.GetArrayOfStructs();
980 auto& soa = pti.GetStructOfArrays();
981 return ParticleArrays<
982 NArrayReal, NArrayInt, ParticleType, RealVector, IntVector>(
983 aos.dataPtr(), soa.GetRealData(), soa.GetIntData());
984 }
985
986protected:
988 int m_ngrow;
989
991 amrex::Vector<int> m_writeflags_real;
992
994 amrex::Vector<int> m_writeflags_int;
995
997 amrex::Vector<std::string> m_real_data_names;
998
1000 amrex::Vector<std::string> m_int_data_names;
1001
1003 std::string m_sort_type{"nonencoded"};
1004
1006 amrex::iMultiFab m_counts;
1007
1009 amrex::iMultiFab m_offsets;
1010
1012 amrex::MultiFab m_min_timestamp;
1013
1015 amrex::MultiFab m_max_timestamp;
1016};
1017
1019
1020} // namespace spades::particles
1021#endif

Member Data Documentation

◆ LEV

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
int spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::LEV {0}
staticconstexpr

Level index.

183{0};

◆ m_counts

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
amrex::iMultiFab spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::m_counts
protected

Count of particles in each cell.

◆ m_int_data_names

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
amrex::Vector<std::string> spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::m_int_data_names
protected

Names for int data to write to file.

◆ m_max_timestamp

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
amrex::MultiFab spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::m_max_timestamp
protected

Maximum timestamp in each cell for each type.

◆ m_min_timestamp

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
amrex::MultiFab spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::m_min_timestamp
protected

Minimum timestamp in each cell for each type.

◆ m_ngrow

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
int spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::m_ngrow
protected

Number of grow cells.

◆ m_offsets

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
amrex::iMultiFab spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::m_offsets
protected

Offsets of particles in each cell.

◆ m_real_data_names

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
amrex::Vector<std::string> spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::m_real_data_names
protected

Names for real data to write to file.

◆ m_sort_type

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
std::string spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::m_sort_type {"nonencoded"}
protected

Sort type.

244{"nonencoded"};

◆ m_writeflags_int

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
amrex::Vector<int> spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::m_writeflags_int
protected

Flags for int data to write to file.

◆ m_writeflags_real

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
amrex::Vector<int> spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::m_writeflags_real
protected

Flags for real data to write to file.


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