Skip to content
Merged
10 changes: 6 additions & 4 deletions pgens/examples/custom_particle_update/pgen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

#include "archetypes/energy_dist.h"
#include "archetypes/particle_injector.h"
#include "framework/containers/particles.h"
#include "framework/domain/domain.h"
#include "framework/domain/metadomain.h"
#include "kernels/pushers/context.h"

#include <vector>

Expand Down Expand Up @@ -134,11 +136,11 @@ namespace user {
, xmin { xmin }
, xmax { xmax } {}

Inline void operator()(index_t p,
Inline void operator()(prtlidx_t p,
const kernel::sr::PusherContext& ctx,
const kernel::sr::PusherBoundaries<M::Dim>&,
const kernel::PusherArrays& particles,
const M& metric) const {
const ntt::ParticleArrays& particles,
const M& metric) const {

const auto x_Cd = static_cast<real_t>(particles.i1(p)) +
static_cast<real_t>(particles.dx1(p));
Expand Down Expand Up @@ -242,4 +244,4 @@ namespace user {
#undef from_Xi_to_i
#undef i_di_to_Xi

#endif // PROBLEM_GENERATOR_H
#endif // PROBLEM_GENERATOR_H
8 changes: 5 additions & 3 deletions pgens/examples/piston/pgen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
#include "archetypes/energy_dist.h"
#include "archetypes/particle_injector.h"
#include "archetypes/piston.h"
#include "framework/containers/particles.h"
#include "framework/domain/domain.h"
#include "framework/domain/metadomain.h"
#include "framework/parameters/parameters.h"
#include "kernels/pushers/context.h"

namespace user {
using namespace ntt;
Expand Down Expand Up @@ -77,11 +79,11 @@ namespace user {
bool is_left;
bool massive;

Inline void operator()(index_t p,
Inline void operator()(prtlidx_t p,
const kernel::sr::PusherContext& ctx,
const kernel::sr::PusherBoundaries<M::Dim>&,
const kernel::PusherArrays& particles,
const M& metric) const {
const ParticleArrays& particles,
const M& metric) const {

real_t piston_pos;
if (x_piston > global_xmax) {
Expand Down
6 changes: 3 additions & 3 deletions pgens/examples/tutorial_cartesian_sr/pgen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace user {

template <class M>
Inline auto GetParticlePosition(const M& metric,
index_t p,
prtlidx_t p,
const array_t<int*>& i1,
const array_t<prtldx_t*>& dx1,
const array_t<int*>& i2,
Expand All @@ -77,7 +77,7 @@ namespace user {
}

template <Dimension D>
Inline void SetParticleSpeed(index_t p,
Inline void SetParticleSpeed(prtlidx_t p,
const array_t<real_t*>& ux1,
const array_t<real_t*>& ux2,
const array_t<real_t*>& ux3,
Expand Down Expand Up @@ -188,7 +188,7 @@ namespace user {
Kokkos::parallel_for(
"PurgeParticles",
species.rangeActiveParticles(),
Lambda(index_t p) {
Lambda(prtlidx_t p) {
if (tag(p) != ParticleTag::alive) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions pgens/shock/pgen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ namespace user {
}

const auto extent = domain.mesh.ExtentToRange(purge_box, incl_ghosts);
tuple_t<std::size_t, M::Dim> x_min { 0 }, x_max { 0 };
tuple_t<ncells_t, M::Dim> x_min { 0 }, x_max { 0 };
for (auto d = 0; d < M::Dim; ++d) {
x_min[d] = extent[d].first;
x_max[d] = extent[d].second;
Expand Down Expand Up @@ -277,7 +277,7 @@ namespace user {
Kokkos::parallel_for(
"RemoveParticles",
species.rangeActiveParticles(),
Lambda(index_t p) {
Lambda(prtlidx_t p) {
// check if the particle is already dead
if (tag(p) == ParticleTag::dead) {
return;
Expand Down
4 changes: 2 additions & 2 deletions pgens/turbulence/pgen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ namespace user {
Kokkos::parallel_for(
"Antenna amplitudes",
wavenumbers.size(),
ClassLambda(index_t i) {
ClassLambda(cellidx_t i) {
auto generator = random_pool.get_state();
const auto u_imag = Random<real_t>(generator) - HALF;
const auto u_real = Random<real_t>(generator) - HALF;
Expand Down Expand Up @@ -415,7 +415,7 @@ namespace user {
Kokkos::parallel_for(
"UpdatePld",
domain.species[sp].npart(),
Lambda(index_t p) {
Lambda(prtlidx_t p) {
if (tag(p) == ParticleTag::dead) {
return;
}
Expand Down
12 changes: 6 additions & 6 deletions src/archetypes/field_setter.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace arch {

~SetEMFields_kernel() = default;

Inline void operator()(index_t i1) const {
Inline void operator()(cellidx_t i1) const {
if constexpr (D == Dim::_1D) {
const auto i1_ = COORD(i1);
coord_t<Dim::_1D> x_Phys { ZERO };
Expand Down Expand Up @@ -109,7 +109,7 @@ namespace arch {
}
}

Inline void operator()(index_t i1, index_t i2) const {
Inline void operator()(cellidx_t i1, cellidx_t i2) const {
if constexpr (D == Dim::_2D) {
const auto i1_ = COORD(i1);
const auto i2_ = COORD(i2);
Expand Down Expand Up @@ -197,7 +197,7 @@ namespace arch {
}
}

Inline void operator()(index_t i1, index_t i2, index_t i3) const {
Inline void operator()(cellidx_t i1, cellidx_t i2, cellidx_t i3) const {
if constexpr (D == Dim::_3D) {
const auto i1_ = COORD(i1);
const auto i2_ = COORD(i2);
Expand Down Expand Up @@ -317,7 +317,7 @@ namespace arch {
, fields { fields }
, fieldsetter { fieldsetter } {}

Inline void operator()(index_t i1) const {
Inline void operator()(cellidx_t i1) const {
if constexpr (D == Dim::_1D) {
const auto i1_ = COORD(i1);
coord_t<D> x_Ph { ZERO };
Expand Down Expand Up @@ -417,7 +417,7 @@ namespace arch {
}
}

Inline void operator()(index_t i1, index_t i2) const {
Inline void operator()(cellidx_t i1, cellidx_t i2) const {
if constexpr (D == Dim::_2D) {
const auto i1_ = COORD(i1);
const auto i2_ = COORD(i2);
Expand Down Expand Up @@ -557,7 +557,7 @@ namespace arch {
}
}

Inline void operator()(index_t i1, index_t i2, index_t i3) const {
Inline void operator()(cellidx_t i1, cellidx_t i2, cellidx_t i3) const {
if constexpr (D == Dim::_3D) {
const auto i1_ = COORD(i1);
const auto i2_ = COORD(i2);
Expand Down
16 changes: 8 additions & 8 deletions src/archetypes/moving_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace arch {
, window_shift { window_shift }
, tags { tags } {}

Inline void operator()(index_t i1) const {
Inline void operator()(cellidx_t i1) const {
if constexpr (D == Dim::_1D) {
if (tags & BC::E) {
Fld(i1, em::ex1) = backup_Fld(i1 + window_shift, em::ex1);
Expand All @@ -56,7 +56,7 @@ namespace arch {
}
}

Inline void operator()(index_t i1, index_t i2) const {
Inline void operator()(cellidx_t i1, cellidx_t i2) const {
if constexpr (D == Dim::_2D) {
if constexpr (o == in::x1) {
if (tags & BC::E) {
Expand Down Expand Up @@ -88,7 +88,7 @@ namespace arch {
}
}

Inline void operator()(index_t i1, index_t i2, index_t i3) const {
Inline void operator()(cellidx_t i1, cellidx_t i2, cellidx_t i3) const {
if constexpr (D == Dim::_3D) {
if constexpr (o == in::x1) {
if (tags & BC::E) {
Expand Down Expand Up @@ -155,7 +155,7 @@ namespace arch {
Kokkos::parallel_for(
"MoveParticles",
species.rangeActiveParticles(),
Lambda(index_t p) {
Lambda(prtlidx_t p) {
// shift particle position back by window update frequency
i1(p) -= window_shift;
});
Expand All @@ -170,7 +170,7 @@ namespace arch {
Kokkos::parallel_for(
"MoveParticles",
species.rangeActiveParticles(),
Lambda(index_t p) {
Lambda(prtlidx_t p) {
// shift particle position back by window update frequency
i2(p) -= window_shift;
});
Expand All @@ -188,7 +188,7 @@ namespace arch {
Kokkos::parallel_for(
"MoveParticles",
species.rangeActiveParticles(),
Lambda(index_t p) {
Lambda(prtlidx_t p) {
// shift particle position back by window update frequency
i3(p) -= window_shift;
});
Expand All @@ -201,8 +201,8 @@ namespace arch {
}

// shift fields in the window back by the window size
std::vector<std::size_t> xi_min, xi_max;
const std::vector<in> all_dirs { in::x1, in::x2, in::x3 };
std::vector<ncells_t> xi_min, xi_max;
const std::vector<in> all_dirs { in::x1, in::x2, in::x3 };
for (auto d { 0u }; d < M::Dim; ++d) {
const auto dd = all_dirs[d];
if (o == dd) {
Expand Down
38 changes: 19 additions & 19 deletions src/archetypes/piston.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "traits/metric.h"

#include "kernels/pushers/context.h"
#include "framework/containers/particles.h"

/* -------------------------------------------------------------------------- */
/* Local macros (same as in particle_pusher_sr.hpp) */
Expand Down Expand Up @@ -49,13 +49,13 @@ namespace arch {
* @param is_left Is piston on the left side of the box or right side of the box
*/
template <CartesianMetricClass M>
Inline bool CrossesPiston(index_t p,
real_t dt,
const kernel::PusherArrays& particles,
const M& metric,
real_t piston_position,
real_t piston_v,
bool is_left) {
Inline bool CrossesPiston(prtlidx_t p,
real_t dt,
const ntt::ParticleArrays& particles,
const M& metric,
real_t piston_position,
real_t piston_v,
bool is_left) {
const real_t x1_Cd = i_di_to_Xi(particles.i1(p), particles.dx1(p));
// x1_Cd_wallmove is not the actual particle coordinate
// it is particle position minus how much the wall has moved in this
Expand All @@ -82,13 +82,13 @@ namespace arch {
* @param massive Whether the particle is massive or massless (e.g. photon)
*/
template <CartesianMetricClass M>
Inline void Piston(index_t p,
real_t dt,
const kernel::PusherArrays& particles,
const M& metric,
real_t piston_position,
real_t piston_v,
bool massive) {
Inline void Piston(prtlidx_t p,
real_t dt,
const ntt::ParticleArrays& particles,
const M& metric,
real_t piston_position,
real_t piston_v,
bool massive) {

// check if particle actually crosses the piston, if not return
if (!CrossesPiston<M>(p, dt, particles, metric, piston_position, piston_v, true)) {
Expand Down Expand Up @@ -142,8 +142,8 @@ namespace arch {
piston_v) *
dt_to_piston;

i_w_coll += static_cast<int>(dx_w_coll >= ONE) -
static_cast<int>(dx_w_coll < ZERO);
i_w_coll += static_cast<int>(dx_w_coll >= ONE) -
static_cast<int>(dx_w_coll < ZERO);
dx_w_coll -= static_cast<prtldx_t>(dx_w_coll >= ONE);
dx_w_coll += static_cast<prtldx_t>(dx_w_coll < ZERO);

Expand All @@ -153,8 +153,8 @@ namespace arch {
remaining_dt_inv_energy +
dx_w_coll;

particles.i1(p) += static_cast<int>(particles.dx1(p) >= ONE) -
static_cast<int>(particles.dx1(p) < ZERO);
particles.i1(p) += static_cast<int>(particles.dx1(p) >= ONE) -
static_cast<int>(particles.dx1(p) < ZERO);
particles.dx1(p) -= static_cast<prtldx_t>(particles.dx1(p) >= ONE);
particles.dx1(p) += static_cast<prtldx_t>(particles.dx1(p) < ZERO);
}
Expand Down
2 changes: 1 addition & 1 deletion src/engines/engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ namespace ntt {
::traits::pgen::HasCustomFieldOutput<decltype(m_pgen), M::Dim, Domain<S, M>>) {
auto lambda_custom_field_output = [&](const std::string& name,
ndfield_t<M::Dim, 6>& buff,
index_t idx,
cellidx_t idx,
timestep_t step,
simtime_t time,
const Domain<S, M>& dom) {
Expand Down
2 changes: 1 addition & 1 deletion src/engines/grpic/currents.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace ntt {
{ domain.mesh.i_max(in::x1), domain.mesh.i_max(in::x2) + 1 });
const auto nfilter = params.template get<unsigned short>(
"algorithms.current_filters");
tuple_t<std::size_t, M::Dim> size;
tuple_t<ncells_t, M::Dim> size;
size[0] = domain.mesh.n_active(in::x1);
size[1] = domain.mesh.n_active(in::x2);

Expand Down
4 changes: 2 additions & 2 deletions src/engines/grpic/fields_bcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ namespace ntt {
return;
}
const auto intersect_range = domain.mesh.ExtentToRange(box, incl_ghosts);
tuple_t<std::size_t, M::Dim> range_min { 0 };
tuple_t<std::size_t, M::Dim> range_max { 0 };
tuple_t<ncells_t, M::Dim> range_min { 0 };
tuple_t<ncells_t, M::Dim> range_max { 0 };

for (unsigned short d { 0 }; d < M::Dim; ++d) {
range_min[d] = intersect_range[d].first;
Expand Down
2 changes: 1 addition & 1 deletion src/engines/grpic/grpic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace ntt {
"algorithms.fieldsolver.enable");
const auto deposit_enabled = m_params.template get<bool>(
"algorithms.deposit.enable");
const auto clear_interval = m_params.template get<std::size_t>(
const auto clear_interval = m_params.template get<timestep_t>(
"particles.clear_interval");

if (step == 0) {
Expand Down
8 changes: 4 additions & 4 deletions src/engines/grpic/particle_pusher.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace ntt {
const auto pusher_boundaries = kernel::gr::PusherBoundaries<M::Dim> {
domain.mesh.prtl_bc()
};
auto pusher_arrays = species.PusherKernelArrays();
// auto pusher_arrays = species.PusherKernelArrays();

if (species.pusher() == ParticlePusher::PHOTON) {
const auto range_policy =
Expand All @@ -65,7 +65,7 @@ namespace ntt {
range_policy,
kernel::gr::Pusher_kernel<M>(pusher_ctx,
pusher_boundaries,
pusher_arrays,
species,
domain.fields.em,
domain.fields.em0,
domain.mesh.metric));
Expand All @@ -78,7 +78,7 @@ namespace ntt {
range_policy,
kernel::gr::Pusher_kernel<M>(pusher_ctx,
pusher_boundaries,
pusher_arrays,
species,
domain.fields.em,
domain.fields.em0,
domain.mesh.metric));
Expand All @@ -91,4 +91,4 @@ namespace ntt {
} // namespace grpic
} // namespace ntt

#endif // ENGINES_GRPIC_PARTICLE_PUSHER_H
#endif // ENGINES_GRPIC_PARTICLE_PUSHER_H
Loading
Loading