EntityParticleContainer Class Reference
SPADES API
|
spades::particles::EntityParticleContainer Class Reference
Main SPADES entity container. More...
#include <EntityParticleContainer.H>
Inheritance diagram for spades::particles::EntityParticleContainer:
Collaboration diagram for spades::particles::EntityParticleContainer:
Public Member Functions | |
EntityParticleContainer (amrex::AmrParGDB *par_gdb, int ngrow=0) | |
Constructor. | |
EntityParticleContainer (const amrex::Vector< amrex::Geometry > &geom, const amrex::Vector< amrex::DistributionMapping > &dmap, const amrex::Vector< amrex::BoxArray > &ba, int ngrow=0) | |
Constructor. | |
template<typename Model > | |
void | initialize_entities (const Model &model) |
Initialize the entities. | |
void | sort () override |
Sort the entities. | |
void | write_plot_file (const std::string &plt_filename) override |
Write the particles to file. | |
void | read_parameters () override |
Read user parameters. | |
void | initialize_variable_names () override |
Initialize variable names. | |
![]() | |
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. | |
void | sort_impl (const CompareFunctor &compare) |
Sort the particles implementation. | |
void | sort_impl (const CompareFunc &compare) |
void | nonencoded_sort_impl (const CompareFunctor &compare) |
Non-encoded sort the particles implementation. | |
void | nonencoded_sort_impl (const CompareFunc &compare) |
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. | |
int | ngrow () const |
Number of grow cells. | |
void | write_plot_file_impl (const std::string &plt_filename, const std::string &name) |
Write the particles to file (implementation) | |
void | check_sort_type (const std::string &sort_type) |
Check valid sort type. | |
ParticleArrays< NArrayReal, NArrayInt, ParticleType, RealVector, IntVector > | particle_arrays (ParticleTileType &pti) const |
Static Public Member Functions | |
static std::string | identifier () |
Class identifier name. | |
![]() | |
static std::string | identifier () |
Class identifier name. | |
Additional Inherited Members | |
![]() | |
using | ParticleType |
using | ParticleTileType |
using | IntVector |
using | RealVector |
![]() | |
static constexpr int | LEV |
Level index. | |
![]() | |
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 |
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
Main SPADES entity container.
Constructor & Destructor Documentation
◆ EntityParticleContainer() [1/2]
|
explicit |
Constructor.
- Parameters
-
par_gdb [in] particle database ngrow [in] number of grow cells
10 0,
11 0,
14{}
SpadesParticleContainer(amrex::AmrParGDB *par_gdb, int ngrow=0)
Definition SpadesParticleContainer.H:9
int ngrow() const
Definition SpadesParticleContainer.H:180
static constexpr int NTYPES
Number of different entity types.
Definition EntityData.H:31
◆ EntityParticleContainer() [2/2]
|
explicit |
Constructor.
- Parameters
-
geom [in] geometry dmap [in] distribution map ba [in] box array ngrow [in] number of grow cells
Member Function Documentation
◆ identifier()
|
inlinestatic |
Class identifier name.
- Returns
- class identifier
31{ return "entities"; }
Here is the caller graph for this function:
◆ initialize_entities()
template<typename Model >
void spades::particles::EntityParticleContainer::initialize_entities | ( | const Model & | model | ) |
Initialize the entities.
74{
75 BL_PROFILE("spades::EntityParticleContainer::initialize_entities()");
76
80 const auto init_entity_op = model.init_entity_op();
81 const auto entities_per_lp = init_entity_op.m_entities_per_lp;
82
84 DefineAndReturnParticleTile(LEV, mfi);
85 }
86
87 amrex::iMultiFab num_particles(
89 amrex::MFInfo());
90 amrex::iMultiFab init_offsets(
92 amrex::MFInfo());
93 num_particles.setVal(entities_per_lp);
94 init_offsets.setVal(0);
95
97 const amrex::Box& box = mfi.tilebox();
98
99 const auto ncells = static_cast<int>(box.numPts());
100 const int* in = num_particles[mfi].dataPtr();
101 int* out = init_offsets[mfi].dataPtr();
102 const auto np = amrex::Scan::PrefixSum<int>(
103 ncells, [=] AMREX_GPU_DEVICE(int i) -> int { return in[i]; },
104 [=] AMREX_GPU_DEVICE(int i, int const& xi) { out[i] = xi; },
105 amrex::Scan::Type::exclusive, amrex::Scan::retSum);
106
107 const amrex::Long pid = ParticleType::NextID();
108 ParticleType::NextID(pid + np);
109 AMREX_ALWAYS_ASSERT_WITH_MESSAGE(
110 static_cast<amrex::Long>(pid + np) < amrex::LastParticleID,
111 "Error: overflow on particle id numbers!");
112
113 const auto my_proc = amrex::ParallelDescriptor::MyProc();
114 const auto& offset_arr = init_offsets[mfi].const_array();
115 const auto& num_particles_arr = num_particles[mfi].const_array();
116 const auto index = std::make_pair(mfi.index(), mfi.LocalTileIndex());
118 pti.resize(np);
120
121 amrex::ParallelFor(
122 box, [=] AMREX_GPU_DEVICE(
123 int i, int j, int AMREX_D_PICK(, , k)) noexcept {
124 const amrex::IntVect iv(AMREX_D_DECL(i, j, k));
125 const int start = offset_arr(iv);
126 for (int n = start; n < start + num_particles_arr(iv); n++) {
127 auto& p = parrs.m_aos[n];
128 p.id() = pid + n;
129 p.cpu() = my_proc;
130
131 MarkEntityUndefined()(n, parrs);
132 parrs.m_idata[EntityIntData::owner][n] =
133 static_cast<int>(dom.index(iv));
134
135 AMREX_D_TERM(
136 p.pos(0) = plo[0] + (iv[0] + constants::HALF) * dx[0];
137 , p.pos(1) = plo[1] + (iv[1] + constants::HALF) * dx[1];
138 ,
139 p.pos(2) = plo[2] + (iv[2] + constants::HALF) * dx[2];)
140
141 AMREX_D_TERM(parrs.m_idata[CommonIntData::i][n] = iv[0];
142 , parrs.m_idata[CommonIntData::j][n] = iv[1];
143 , parrs.m_idata[CommonIntData::k][n] = iv[2];)
144 }
145
146 for (int n = start; n < start + entities_per_lp; n++) {
147 init_entity_op(parrs, n);
148 }
149 });
150
151 // This is necessary
152 amrex::Gpu::streamSynchronize();
153 }
154 Redistribute();
155
156 // Sanity check all initial particles
157#ifdef AMREX_USE_OMP
158#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
159#endif
161 const size_t np = pti.numParticles();
163
164 amrex::ParallelFor(np, [=] AMREX_GPU_DEVICE(long pidx) noexcept {
165 bool valid_type = false;
167 valid_type = parrs.m_idata[CommonIntData::type_id][pidx] == typ;
168 if (valid_type) {
169 break;
170 }
171 }
172 AMREX_ASSERT(valid_type);
173 AMREX_ASSERT(parrs.m_aos[pidx].id() >= 0);
174 });
175 }
176}
ParticleArrays< NArrayReal, NArrayInt, ParticleType, RealVector, IntVector > particle_arrays(ParticleTileType &pti) const
Definition SpadesParticleContainer.H:218
static constexpr int LEV
Definition SpadesParticleContainer.H:183
Here is the call graph for this function:
◆ initialize_variable_names()
|
overridevirtual |
Initialize variable names.
35{
36 BL_PROFILE("spades::EntityParticleContainer::initialize_variable_names()");
37
42
45
46 AMREX_D_TERM(
48 m_writeflags_int[CommonIntData::i] = 1;
50 m_writeflags_int[CommonIntData::j] = 1;
52 m_writeflags_int[CommonIntData::k] = 1;)
57}
amrex::Vector< std::string > m_int_data_names
Definition SpadesParticleContainer.H:241
amrex::Vector< std::string > m_real_data_names
Definition SpadesParticleContainer.H:238
amrex::Vector< int > m_writeflags_real
Definition SpadesParticleContainer.H:232
amrex::Vector< int > m_writeflags_int
Definition SpadesParticleContainer.H:235
◆ read_parameters()
|
overridevirtual |
Read user parameters.
Reimplemented from spades::particles::SpadesParticleContainer< EntityTypes::NTYPES, 0, 0, EntityRealData::ncomps, EntityIntData::ncomps >.
30{
32}
virtual void read_parameters()
Read user parameters.
Definition SpadesParticleContainer.H:197
Here is the call graph for this function:
◆ sort()
|
overridevirtual |
Sort the entities.
60{
61 BL_PROFILE("spades::EntityParticleContainer::sort()");
62
63 sort_impl(CompareParticle());
64}
void sort_impl(const CompareFunctor &compare)
Here is the call graph for this function:
◆ write_plot_file()
|
inlineoverridevirtual |
Write the particles to file.
- Parameters
-
plt_filename [in] file name for the plot file
61 {
63 };
static std::string identifier()
Class identifier name.
Definition EntityParticleContainer.H:31
void write_plot_file_impl(const std::string &plt_filename, const std::string &name)
Definition SpadesParticleContainer.H:760
Here is the call graph for this function:
The documentation for this class was generated from the following files:
- /home/runner/work/spades/spades/Source/EntityParticleContainer.H
- /home/runner/work/spades/spades/Source/EntityParticleContainer.cpp
Generated by