1 #ifndef VGRID_DISTRIBUTION_HPP
2 #define VGRID_DISTRIBUTION_HPP
12 template<
class Device>
18 View<double****,CLayout, Device>
f;
21 View<double*,CLayout, Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>
f_1D;
36 :
f(
"f", maxwellians.
size(), vgrid.nvr, pol_decomp.nnodes, vgrid.nvz),
44 for (
int i=0; i<
f.extent(0); i++){
45 for (
int imu=0; imu<
f.extent(1); imu++){
46 double vperp = imu*
dsmu;
47 for (
int inode=0; inode<
f.extent(2); inode++){
48 for (
int ivp=0; ivp<
f.extent(3); ivp++){
50 f(i,imu,inode,ivp) = maxwellians[i].get_f(vpara, vperp);
58 :
f(
"f", nsp, vgrid.nvr, pol_decomp.nnodes, vgrid.nvz),
68 KOKKOS_INLINE_FUNCTION
double&
operator()(
int isp,
int ivr,
int inode,
int ivz)
const {
return f(isp, ivr, inode, ivz);}
73 double*
data()
const {
return f.data();}
92 Kokkos::parallel_for(label, Kokkos::MDRangePolicy<Kokkos::Rank<4>,
exec_space>({0, 0, 0, 0}, {
f.extent(0),
f.extent(1),
f.extent(2),
f.extent(3)}), lambda_func);
98 constexpr
int ISP_ZERO = 0;
99 Kokkos::atomic_add(&(
f(ISP_ZERO, wt.
i_vr+0,i_node,wt.
i_vz+0)),value*wt.
w_00);
100 Kokkos::atomic_add(&(
f(ISP_ZERO, wt.
i_vr+0,i_node,wt.
i_vz+1)),value*wt.
w_01);
101 Kokkos::atomic_add(&(
f(ISP_ZERO, wt.
i_vr+1,i_node,wt.
i_vz+0)),value*wt.
w_10);
102 Kokkos::atomic_add(&(
f(ISP_ZERO, wt.
i_vr+1,i_node,wt.
i_vz+1)),value*wt.
w_11);
106 KOKKOS_INLINE_FUNCTION
static void scatter(
const View<double***,CLayout,Device>& view,
int i_node,
const VGridWeights& wt,
double value){
107 Kokkos::atomic_add(&(view(wt.
i_vr+0,i_node,wt.
i_vz+0)),value*wt.
w_00);
108 Kokkos::atomic_add(&(view(wt.
i_vr+0,i_node,wt.
i_vz+1)),value*wt.
w_01);
109 Kokkos::atomic_add(&(view(wt.
i_vr+1,i_node,wt.
i_vz+0)),value*wt.
w_10);
110 Kokkos::atomic_add(&(view(wt.
i_vr+1,i_node,wt.
i_vz+1)),value*wt.
w_11);
114 KOKKOS_INLINE_FUNCTION
static void scatter(
const View<double****,CLayout,Device>& view,
int i_node,
const VGridWeights& wt,
double value){
115 constexpr
int ISP_ZERO = 0;
116 Kokkos::atomic_add(&(view(ISP_ZERO,wt.
i_vr+0,i_node,wt.
i_vz+0)),value*wt.
w_00);
117 Kokkos::atomic_add(&(view(ISP_ZERO,wt.
i_vr+0,i_node,wt.
i_vz+1)),value*wt.
w_01);
118 Kokkos::atomic_add(&(view(ISP_ZERO,wt.
i_vr+1,i_node,wt.
i_vz+0)),value*wt.
w_10);
119 Kokkos::atomic_add(&(view(ISP_ZERO,wt.
i_vr+1,i_node,wt.
i_vz+1)),value*wt.
w_11);
124 constexpr
int ISP_ZERO = 0;
155 KOKKOS_INLINE_FUNCTION
int n_vr()
const {
163 KOKKOS_INLINE_FUNCTION
int n_vz()
const{
167 KOKKOS_INLINE_FUNCTION
int size()
const{
178 return (ivr==0 || ivr==
n_vr()-1) ? 0.5 : 1.0;
KOKKOS_INLINE_FUNCTION int n_vr() const
Definition: vgrid_distribution.hpp:155
double * data() const
Definition: vgrid_distribution.hpp:73
KOKKOS_INLINE_FUNCTION int size() const
Definition: vgrid_distribution.hpp:167
UniformRange vz_range() const
Definition: vgrid_distribution.hpp:185
double w_00
Definition: vgrid_weights.hpp:10
Definition: velocity_grid.hpp:8
double get_smu_n(int imu) const
Definition: vgrid_distribution.hpp:172
UniformRange vr_range() const
Definition: vgrid_distribution.hpp:181
VGridDistribution(const VelocityGrid &vgrid, const DomainDecomposition< DeviceType > &pol_decomp, const std::vector< Maxwellian > &maxwellians)
Definition: vgrid_distribution.hpp:35
KOKKOS_INLINE_FUNCTION double gather(int i_node, const VGridWeights &wt) const
Definition: vgrid_distribution.hpp:123
double smu_max
max mu
Definition: vgrid_distribution.hpp:28
static KOKKOS_INLINE_FUNCTION double gather(const T &view, int i_node, const VGridWeights &wt)
Definition: vgrid_distribution.hpp:133
double dvp
grid spacing in parallel velocity
Definition: vgrid_distribution.hpp:27
double w_01
Definition: vgrid_weights.hpp:11
View< double ****, CLayout, Device > f
Definition: vgrid_distribution.hpp:18
KOKKOS_INLINE_FUNCTION int n_species() const
Definition: vgrid_distribution.hpp:151
KOKKOS_INLINE_FUNCTION double & operator()(int isp, int ivr, int inode, int ivz) const
Definition: vgrid_distribution.hpp:68
static KOKKOS_INLINE_FUNCTION void scatter(const View< double ***, CLayout, Device > &view, int i_node, const VGridWeights &wt, double value)
Definition: vgrid_distribution.hpp:106
double inv_mu0_factor
Definition: vgrid_distribution.hpp:30
double w_11
Definition: vgrid_weights.hpp:13
VGridDistribution()
Definition: vgrid_distribution.hpp:32
KOKKOS_INLINE_FUNCTION int n_vz() const
Definition: vgrid_distribution.hpp:163
View< double *, CLayout, Device, Kokkos::MemoryTraits< Kokkos::Unmanaged > > f_1D
Definition: vgrid_distribution.hpp:21
VGridDistribution(int nsp, const VelocityGrid &vgrid, const DomainDecomposition< DeviceType > &pol_decomp)
Definition: vgrid_distribution.hpp:57
static KOKKOS_INLINE_FUNCTION void scatter(const View< double ****, CLayout, Device > &view, int i_node, const VGridWeights &wt, double value)
Definition: vgrid_distribution.hpp:114
typename HostType::execution_space exec_space
Definition: vgrid_distribution.hpp:16
Definition: vgrid_distribution.hpp:13
int i_vr
Definition: vgrid_weights.hpp:8
int i_vz
Definition: vgrid_weights.hpp:9
double dsmu
grid spacing in mu
Definition: vgrid_distribution.hpp:29
void for_each_element(const std::string label, F lambda_func) const
Definition: vgrid_distribution.hpp:91
Definition: vgrid_weights.hpp:7
void parallel_for(const std::string name, int n_ptl, Function func, Option option, HostAoSoA aosoa_h, DeviceAoSoA aosoa_d)
Definition: streamed_parallel_for.hpp:252
KOKKOS_INLINE_FUNCTION int n_nodes() const
Definition: vgrid_distribution.hpp:159
static KOKKOS_INLINE_FUNCTION double normed_gather(const T &view, int i_node, const VGridWeights &wt, const T &norm_view)
Definition: vgrid_distribution.hpp:143
void for_all_elements(const std::string label, F lambda_func) const
Definition: vgrid_distribution.hpp:81
KOKKOS_INLINE_FUNCTION double & operator[](int i) const
Definition: vgrid_distribution.hpp:71
double w_10
Definition: vgrid_weights.hpp:12
KOKKOS_INLINE_FUNCTION double mu_vol_fac(int ivr) const
Definition: vgrid_distribution.hpp:177
double vp_max
max parallel velocity
Definition: vgrid_distribution.hpp:26
KOKKOS_INLINE_FUNCTION void scatter(int i_node, const VGridWeights &wt, double value) const
Definition: vgrid_distribution.hpp:97