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)
 

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>
spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::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>
spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::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 spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::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
259#include "SpadesParticleContainer.tpp"
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 spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::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 spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::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 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
void write_plot_file_impl(const std::string &plt_filename, const std::string &name)
Write the particles to file (implementation)
Definition SpadesParticleContainer.H:760

◆ count_particles()

template<int NType, int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
void spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::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 spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::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
681#include "SpadesParticleContainer.tpp"
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 encoded_sort_impl()
Encoded sort the particles implementation.
Definition SpadesParticleContainer.H:423
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
amrex::Vector< int > m_writeflags_int
Flags for int data to write to file.
Definition SpadesParticleContainer.H:235
void print_messages(const std::string &header)
Print all the particles to screen.
Definition SpadesParticleContainer.H:658
void reposition_particles()
Reposition the particles inside a cell for visualization.
Definition SpadesParticleContainer.H:691
void count_offsets()
Update the particle offsets.
Definition SpadesParticleContainer.H:167
void initialize_state()
Initialize particle states (counts and offsets)
Definition SpadesParticleContainer.H:65
amrex::Long total_count(const int typ) const
Get the total number of particles of typ.
Definition SpadesParticleContainer.H:116
void count_particles()
Update the particle counts.
Definition SpadesParticleContainer.H:123
void update_counts()
Update the particle counts and offsets.
Definition SpadesParticleContainer.H:218
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 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
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 spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::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/2]

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
353//! Main SPADES particle container
354template <
355 int NType,
356 int NStructReal,
357 int NStructInt,
358 int NArrayReal,
359 int NArrayInt>
360class SpadesParticleContainer
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
389 /**
390 @brief Class identifier name
391 @return class identifier
392 **/
393 static std::string identifier() { return "spades_particles"; }
394
395 /**
396 @brief Constructor
397 @param par_gdb [in] particle database
398 @param ngrow [in] number of grow cells
399 **/
400 explicit SpadesParticleContainer(amrex::AmrParGDB* par_gdb, int ngrow = 0);
401
402 /**
403 @brief Constructor
404 @param geom [in] geometry
405 @param dmap [in] distribution map
406 @param ba [in] box array
407 @param ngrow [in] number of grow cells
408 **/
409 explicit SpadesParticleContainer(
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
415 //! Initialize particle states (counts and offsets)
416 void initialize_state();
417
418 //! Delete particle states (counts and offsets)
419 void clear_state();
420
421 //! Update the particle counts and offsets
422 void update_counts();
423
424 //! Update the particle counts
425 void count_particles();
426
427 //! Update the particle offsets
428 void count_offsets();
429
430 /**
431 @brief Get the particle counts
432 @return particle counts
433 **/
434 const amrex::iMultiFab& counts() const { return m_counts; };
435
436 /**
437 @brief Get the particle offsets
438 @return particle offsets
439 **/
440 const amrex::iMultiFab& offsets() const { return m_offsets; };
441
442 /**
443 @brief Get the total number of particles of \p typ
444 @param typ [in] particle type
445 @return particle counts
446 **/
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
453 /**
454 @brief Get the minimum number of particles of \p typ
455 @param typ [in] particle type
456 @return particle counts min
457 **/
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
464 /**
465 @brief Get the maximum number of particles of \p typ
466 @param typ [in] particle type
467 @return particle counts min
468 **/
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
475 //! Check the result of the sort operation
476 void check_sort(const amrex::MFIter& mfi);
477
478 //! Sort the particles
479 virtual void sort() = 0;
480
481 /**
482 @brief Sort the particles implementation
483 @param compare [in] comparison functor
484 **/
485 template <typename CompareFunctor>
486 void sort_impl(const CompareFunctor& compare);
487
488 /**
489 @brief Non-encoded sort the particles implementation
490 @param compare [in] comparison functor
491 **/
492 template <typename CompareFunctor>
493 void nonencoded_sort_impl(const CompareFunctor& compare);
494
495 //! Encoded sort the particles implementation
496 void encoded_sort_impl();
497
498 //! Print all the particles to screen
499 void print_messages(const std::string& header);
500
501 //! Reposition the particles inside a cell for visualization
502 void reposition_particles();
503
504 /**
505 @brief Write the particles to file
506 @param plt_filename [in] file name for the plot file
507 **/
508 virtual void write_plot_file(const std::string& plt_filename) = 0;
509
510 //! Number of grow cells
511 int ngrow() const { return m_ngrow; }
512
513 //! Level index
514 static constexpr int LEV{0};
515
516 //! Initialize variable names
517 virtual void initialize_variable_names() = 0;
518
519 /**
520 @brief Write the particles to file (implementation)
521 @param plt_filename [in] file name for the plot file
522 @param name [in] file name for the particle file
523 **/
524 void write_plot_file_impl(
525 const std::string& plt_filename, const std::string& name);
526
527 //! Read user parameters
528 virtual void read_parameters()
529 {
530 {
531 amrex::ParmParse pp("spades");
532 pp.query("sort_type", m_sort_type);
533 check_sort_type(m_sort_type);
534 }
535 }
536
537 //! Check valid sort type
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>
549 particle_arrays(ParticleTileType& pti) const
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:
559 //! Number of grow cells
560 int m_ngrow;
561
562 //! Flags for real data to write to file
563 amrex::Vector<int> m_writeflags_real;
564
565 //! Flags for int data to write to file
566 amrex::Vector<int> m_writeflags_int;
567
568 //! Names for real data to write to file
569 amrex::Vector<std::string> m_real_data_names;
570
571 //! Names for int data to write to file
572 amrex::Vector<std::string> m_int_data_names;
573
574 //! Sort type
575 std::string m_sort_type{"nonencoded"};
576
577 //! Count of particles in each cell
578 amrex::iMultiFab m_counts;
579
580 //! Offsets of particles in each cell
581 amrex::iMultiFab m_offsets;
582
583 //! Minimum timestamp in each cell for each type
584 amrex::MultiFab m_min_timestamp;
585
586 //! Maximum timestamp in each cell for each type
587 amrex::MultiFab m_max_timestamp;
588};
589
590#include "SpadesParticleContainer.tpp"
591
592} // namespace spades::particles
593#endif

◆ nonencoded_sort_impl() [2/2]

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 spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::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
916#include "SpadesParticleContainer.tpp"
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 spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::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
949#include "SpadesParticleContainer.tpp"
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/2]

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
328//! Main SPADES particle container
329template <
330 int NType,
331 int NStructReal,
332 int NStructInt,
333 int NArrayReal,
334 int NArrayInt>
335class SpadesParticleContainer
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
364 /**
365 @brief Class identifier name
366 @return class identifier
367 **/
368 static std::string identifier() { return "spades_particles"; }
369
370 /**
371 @brief Constructor
372 @param par_gdb [in] particle database
373 @param ngrow [in] number of grow cells
374 **/
375 explicit SpadesParticleContainer(amrex::AmrParGDB* par_gdb, int ngrow = 0);
376
377 /**
378 @brief Constructor
379 @param geom [in] geometry
380 @param dmap [in] distribution map
381 @param ba [in] box array
382 @param ngrow [in] number of grow cells
383 **/
384 explicit SpadesParticleContainer(
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
390 //! Initialize particle states (counts and offsets)
391 void initialize_state();
392
393 //! Delete particle states (counts and offsets)
394 void clear_state();
395
396 //! Update the particle counts and offsets
397 void update_counts();
398
399 //! Update the particle counts
400 void count_particles();
401
402 //! Update the particle offsets
403 void count_offsets();
404
405 /**
406 @brief Get the particle counts
407 @return particle counts
408 **/
409 const amrex::iMultiFab& counts() const { return m_counts; };
410
411 /**
412 @brief Get the particle offsets
413 @return particle offsets
414 **/
415 const amrex::iMultiFab& offsets() const { return m_offsets; };
416
417 /**
418 @brief Get the total number of particles of \p typ
419 @param typ [in] particle type
420 @return particle counts
421 **/
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
428 /**
429 @brief Get the minimum number of particles of \p typ
430 @param typ [in] particle type
431 @return particle counts min
432 **/
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
439 /**
440 @brief Get the maximum number of particles of \p typ
441 @param typ [in] particle type
442 @return particle counts min
443 **/
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
450 //! Check the result of the sort operation
451 void check_sort(const amrex::MFIter& mfi);
452
453 //! Sort the particles
454 virtual void sort() = 0;
455
456 /**
457 @brief Sort the particles implementation
458 @param compare [in] comparison functor
459 **/
460 template <typename CompareFunctor>
461 void sort_impl(const CompareFunctor& compare);
462
463 /**
464 @brief Non-encoded sort the particles implementation
465 @param compare [in] comparison functor
466 **/
467 template <typename CompareFunctor>
468 void nonencoded_sort_impl(const CompareFunctor& compare);
469
470 //! Encoded sort the particles implementation
471 void encoded_sort_impl();
472
473 //! Print all the particles to screen
474 void print_messages(const std::string& header);
475
476 //! Reposition the particles inside a cell for visualization
477 void reposition_particles();
478
479 /**
480 @brief Write the particles to file
481 @param plt_filename [in] file name for the plot file
482 **/
483 virtual void write_plot_file(const std::string& plt_filename) = 0;
484
485 //! Number of grow cells
486 int ngrow() const { return m_ngrow; }
487
488 //! Level index
489 static constexpr int LEV{0};
490
491 //! Initialize variable names
492 virtual void initialize_variable_names() = 0;
493
494 /**
495 @brief Write the particles to file (implementation)
496 @param plt_filename [in] file name for the plot file
497 @param name [in] file name for the particle file
498 **/
499 void write_plot_file_impl(
500 const std::string& plt_filename, const std::string& name);
501
502 //! Read user parameters
503 virtual void read_parameters()
504 {
505 {
506 amrex::ParmParse pp("spades");
507 pp.query("sort_type", m_sort_type);
508 check_sort_type(m_sort_type);
509 }
510 }
511
512 //! Check valid sort type
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>
524 particle_arrays(ParticleTileType& pti) const
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:
534 //! Number of grow cells
535 int m_ngrow;
536
537 //! Flags for real data to write to file
538 amrex::Vector<int> m_writeflags_real;
539
540 //! Flags for int data to write to file
541 amrex::Vector<int> m_writeflags_int;
542
543 //! Names for real data to write to file
544 amrex::Vector<std::string> m_real_data_names;
545
546 //! Names for int data to write to file
547 amrex::Vector<std::string> m_int_data_names;
548
549 //! Sort type
550 std::string m_sort_type{"nonencoded"};
551
552 //! Count of particles in each cell
553 amrex::iMultiFab m_counts;
554
555 //! Offsets of particles in each cell
556 amrex::iMultiFab m_offsets;
557
558 //! Minimum timestamp in each cell for each type
559 amrex::MultiFab m_min_timestamp;
560
561 //! Maximum timestamp in each cell for each type
562 amrex::MultiFab m_max_timestamp;
563};
564
565#include "SpadesParticleContainer.tpp"
566
567} // namespace spades::particles
568#endif

◆ sort_impl() [2/2]

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 spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::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 spades::particles::SpadesParticleContainer< NType, NStructReal, NStructInt, NArrayReal, NArrayInt >::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
1018#include "SpadesParticleContainer.tpp"
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 file: