35 return *(
reinterpret_cast<const SimdVector*
>(
this));
58 KOKKOS_INLINE_FUNCTION
bool is_active(
int i_simd)
const{
59 return (
gid[i_simd]>0);
63 return (
gid[i_simd]<=0);
69 for (
int i_simd = 0; i_simd<SIMD_SIZE; i_simd++){
107 long long int gid[VEC_LEN];
109 long long int flag[VEC_LEN];
113 return (
gid[i_vec]>0);
117 return (
gid[i_vec]<=0);
142 template<
class Device>
152 template<
class Device>
172 template<
class Device>
189 template <
typename T>
191 long long int n =
static_cast<long long int>(n_ptl);
192 long long int vec =
static_cast<long long int>(VEC_LEN);
197 #include <Cabana_AoSoA.hpp>
198 #include <Cabana_DeepCopy.hpp>
202 using ParticleDataTypes = Cabana::MemberTypes<double[PTL_NPHASE],double[PTL_NCONST],long long int, long long int>;
204 using ParticleDataTypes = Cabana::MemberTypes<double[PTL_NPHASE],double[PTL_NCONST],long long int>;
228 template<
class DataType,
class Device>
using Array =
typename Cabana::AoSoA<DataType,Device,VEC_LEN>;
230 template<
class DataType,
class Device,
class Device2>
235 template<
class DataType>
237 return sizeof( Cabana::Tuple<DataType> );
240 template<
int SliceInd,
typename T>
241 typename T::template member_slice_type<SliceInd>
slice(
const T& ptl){
242 return Cabana::slice<SliceInd>(ptl);
247 template<
class DataType,
class Device>
258 View<vec_data_type*,CLayout,Device>
view;
262 Array(
const std::string& label,
size_t n_in)
283 size_t n_vec =
view.size();
286 if(n_vec_reserve>n_vec){
288 View<vec_data_type*,CLayout,Device> resized_view(
NoInit(
view.label()), n_vec_reserve);
293 Kokkos::subview(resized_view, Kokkos::pair<size_t, size_t>( 0, vecs_in_use)),
294 Kokkos::subview(
view, Kokkos::pair<size_t, size_t>( 0, vecs_in_use)) );
309 template<
class DataType,
class Device,
class Device2>
312 printf(
"Error in Particles::deep_copy: %s.n=(%d) must equal %s.n=(%d).\n", dest.
view.label().c_str(), dest.
n, src.
view.label().c_str(), src.
n);
314 exit_XGC(
"Error: Size mismatch in Particles::deep_copy\n");
318 Kokkos::subview(dest.
view, Kokkos::pair<size_t, size_t>( 0, vecs_in_use)),
319 Kokkos::subview(src.
view, Kokkos::pair<size_t, size_t>( 0, vecs_in_use)) );
332 template<
int SliceInd,
class DataType,
class Device>
class Slice;
337 template<
class Device>
344 KOKKOS_INLINE_FUNCTION
double& operator ()(
int ip,
int j)
const{
345 int ivec = ip/VEC_LEN;
346 double* ptr = (
double*)(&array.
view(ivec));
347 int istr = ip%VEC_LEN;
348 return ptr[j*VEC_LEN + istr];
352 template<
class Device>
359 KOKKOS_INLINE_FUNCTION
double& operator ()(
int ip,
int j)
const{
360 int ivec = ip/VEC_LEN;
361 double* ptr = (
double*)(&array.
view(ivec).ph);
362 int istr = ip%VEC_LEN;
363 return ptr[j*VEC_LEN + istr];
367 template<
class Device>
374 KOKKOS_INLINE_FUNCTION
double& operator ()(
int ip,
int j)
const{
375 int ivec = ip/VEC_LEN;
376 double* ptr = (
double*)(&array.
view(ivec).ct);
377 int istr = ip%VEC_LEN;
378 return ptr[j*VEC_LEN + istr];
382 template<
class Device>
389 KOKKOS_INLINE_FUNCTION
long long int& operator ()(
int ip)
const{
390 int ivec = ip/VEC_LEN;
391 long long int* ptr = (
long long int*)(&array.
view(ivec).gid);
392 int istr = ip%VEC_LEN;
398 template<
class Device>
400 static constexpr
int ind = PtlSlice::Flag;
401 using ArrayType = Array<ParticleDataTypes, Device>;
402 const ArrayType array;
404 Slice(
const ArrayType& array_in) : array(array_in) {}
405 KOKKOS_INLINE_FUNCTION
long long int& operator ()(
int ip)
const{
406 int ivec = ip/VEC_LEN;
407 long long int* ptr = (
long long int*)(&array.view(ivec).flag);
408 int istr = ip%VEC_LEN;
414 template<
int SliceInd,
class DataType,
class Device>
Definition: particles.hpp:248
void reserve(size_t n_reserve)
Definition: particles.hpp:278
size_t n
Definition: particles.hpp:256
Array()
Definition: particles.hpp:260
KOKKOS_INLINE_FUNCTION vec_data_type & access(size_t ind) const
Definition: particles.hpp:274
Array(const std::string &label, size_t n_in)
Definition: particles.hpp:262
size_t size() const
Definition: particles.hpp:266
vec_data_type soa_type
Definition: particles.hpp:254
std::conditional_t< std::is_same_v< DataType, ParticleDataTypes >, VecParticles, VecPhase > vec_data_type
Definition: particles.hpp:251
void resize(size_t new_n_ptl)
Definition: particles.hpp:301
View< vec_data_type *, CLayout, Device > view
Definition: particles.hpp:258
vec_data_type * data() const
Definition: particles.hpp:270
const ArrayType array
Definition: particles.hpp:371
Slice(const ArrayType &array_in)
Definition: particles.hpp:373
const ArrayType array
Definition: particles.hpp:386
Slice(const ArrayType &array_in)
Definition: particles.hpp:388
Slice(const ArrayType &array_in)
Definition: particles.hpp:358
const ArrayType array
Definition: particles.hpp:356
Slice(const ArrayType &array_in)
Definition: particles.hpp:343
const ArrayType array
Definition: particles.hpp:341
Definition: particles.hpp:332
void exit_XGC(std::string msg)
Definition: globals.hpp:38
KOKKOS_INLINE_FUNCTION int divide_and_round_up(int a, int b)
Definition: globals.hpp:249
Definition: particles.hpp:224
constexpr size_t sizeof_ptl< ParticleDataTypes >()
Definition: particles.hpp:327
Slice< SliceInd, DataType, Device > slice(const Array< DataType, Device > &array)
Definition: particles.hpp:415
constexpr size_t sizeof_ptl()
constexpr size_t sizeof_ptl< PhaseDataTypes >()
Definition: particles.hpp:329
void deep_copy(const Array< DataType, Device > &dest, const Array< DataType, Device2 > &src)
Definition: particles.hpp:310
Definition: particles.hpp:215
@ Ph
Definition: particles.hpp:219
@ Gid
Definition: particles.hpp:219
@ Ct
Definition: particles.hpp:219
KOKKOS_INLINE_FUNCTION void update_phases(SimdPhase &ph_new, const SimdPhase &ph, double local_dt, const SimdPhase &dph)
Definition: particles.tpp:6
long long int add_vec_buffer(T n_ptl)
Definition: particles.hpp:190
int p_range< DeviceType >(int num_particle)
Definition: particles.hpp:182
KOKKOS_INLINE_FUNCTION void update_dphm(SimdPhase &dphm, const SimdPhase &dpht)
Definition: particles.tpp:21
KOKKOS_INLINE_FUNCTION void simd_2_AoSoA(VecParticles *part, const SimdParticles &part_one, int a_vec, int s_vec)
Definition: particles.tpp:54
int p_range(int num_particle)
Definition: particles.hpp:173
KOKKOS_INLINE_FUNCTION void update_dpht(SimdPhase &dpht, const SimdPhase &dph, const SimdPhase &dphm)
Definition: particles.tpp:37
KOKKOS_INLINE_FUNCTION void AoSoA_2_simd(SimdParticles &part_one, const VecParticles *part, int a_vec, int s_vec)
Definition: particles.tpp:83
Kokkos::ViewAllocateWithoutInitializing NoInit
Definition: space_settings.hpp:69
Definition: particles.hpp:143
KOKKOS_INLINE_FUNCTION AoSoAIndices(int idx)
Definition: particles.hpp:153
int s
The index in the outer array of the AoSoA.
Definition: particles.hpp:144
int a
The index in the inner array of the AoSoA.
Definition: particles.hpp:145
Definition: particles.hpp:128
double data[T]
Definition: particles.hpp:129
Definition: particles.hpp:40
Simd< double > w0
Full-f weight.
Definition: particles.hpp:42
Simd< double > mu
m*v_perp^2/(2B)
Definition: particles.hpp:41
Simd< double > f0
w0*(marker density)
Definition: particles.hpp:43
Definition: particles.hpp:50
KOKKOS_INLINE_FUNCTION bool is_inactive(int i_simd) const
Definition: particles.hpp:62
Simd< long long int > gid
Definition: particles.hpp:53
SimdPhase ph
Definition: particles.hpp:51
SimdConstants ct
Definition: particles.hpp:52
KOKKOS_INLINE_FUNCTION bool is_active(int i_simd) const
Definition: particles.hpp:58
KOKKOS_INLINE_FUNCTION void deactivate(int i_simd)
Definition: particles.hpp:77
KOKKOS_INLINE_FUNCTION void deactivate(const Simd< bool > &mask)
Definition: particles.hpp:68
Definition: particles.hpp:6
Simd< double > w2
(1 - background distribution)/f0
Definition: particles.hpp:12
KOKKOS_INLINE_FUNCTION SimdVector2D & x()
Definition: particles.hpp:16
Simd< double > w1
delta-f weight
Definition: particles.hpp:11
Simd< double > rho
m*v_para/(q*B) - A_para^h/B (should it be plus or minus?)
Definition: particles.hpp:10
KOKKOS_INLINE_FUNCTION const SimdVector2D & x() const
Definition: particles.hpp:22
Simd< double > z
Cylindrical coordinate Z.
Definition: particles.hpp:8
Simd< double > r
Cylindrical coordinate R (major radial direction)
Definition: particles.hpp:7
Simd< double > phi
Cylindrical coordinate phi (toroidal direction)
Definition: particles.hpp:9
KOKKOS_INLINE_FUNCTION const SimdVector & v() const
Definition: particles.hpp:34
KOKKOS_INLINE_FUNCTION SimdVector & v()
Definition: particles.hpp:28
Definition: particles.hpp:94
double f0[VEC_LEN]
Definition: particles.hpp:97
double mu[VEC_LEN]
Definition: particles.hpp:95
double w0[VEC_LEN]
Definition: particles.hpp:96
Definition: particles.hpp:123
double data[T *VEC_LEN]
Definition: particles.hpp:124
Definition: particles.hpp:104
KOKKOS_INLINE_FUNCTION bool is_active(int i_vec) const
Definition: particles.hpp:112
VecPhase ph
Definition: particles.hpp:105
long long int gid[VEC_LEN]
Definition: particles.hpp:107
VecConstants ct
Definition: particles.hpp:106
KOKKOS_INLINE_FUNCTION bool is_inactive(int i_vec) const
Definition: particles.hpp:116
Definition: particles.hpp:84
double r[VEC_LEN]
Definition: particles.hpp:85
double w2[VEC_LEN]
Definition: particles.hpp:90
double phi[VEC_LEN]
Definition: particles.hpp:87
double rho[VEC_LEN]
Definition: particles.hpp:88
double w1[VEC_LEN]
Definition: particles.hpp:89
double z[VEC_LEN]
Definition: particles.hpp:86