1 #ifndef VGRID_DISTRIBUTION_HPP
2 #define VGRID_DISTRIBUTION_HPP
17 template<
class Device>
23 View<double****,CLayout, Device>
f;
26 View<double*,CLayout, Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>>
f_1D;
41 :
f(
"f", maxwellians.
size(), vgrid.nvr, pol_decomp.nnodes, vgrid.nvz),
49 for (
int i=0; i<
f.extent(0); i++){
50 for (
int imu=0; imu<
f.extent(1); imu++){
51 double vperp = imu*
dsmu;
52 for (
int inode=0; inode<
f.extent(2); inode++){
53 for (
int ivp=0; ivp<
f.extent(3); ivp++){
55 f(i,imu,inode,ivp) = maxwellians[i].get_f(vpara, vperp);
63 :
f(
NoInit(
"f"), nsp, vgrid.nvr, pol_decomp.nnodes, vgrid.nvz),
74 template<
class Device2>
88 KOKKOS_INLINE_FUNCTION
double&
operator()(
int isp,
int ivr,
int inode,
int ivz)
const {
return f(isp, ivr, inode, ivz);}
93 double*
data()
const {
return f.data();}
112 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);
118 constexpr
int ISP_ZERO = 0;
119 Kokkos::atomic_add(&(
f(ISP_ZERO, wt.
i_vr+0,i_node,wt.
i_vz+0)),value*wt.
w_00);
120 Kokkos::atomic_add(&(
f(ISP_ZERO, wt.
i_vr+0,i_node,wt.
i_vz+1)),value*wt.
w_01);
121 Kokkos::atomic_add(&(
f(ISP_ZERO, wt.
i_vr+1,i_node,wt.
i_vz+0)),value*wt.
w_10);
122 Kokkos::atomic_add(&(
f(ISP_ZERO, wt.
i_vr+1,i_node,wt.
i_vz+1)),value*wt.
w_11);
126 KOKKOS_INLINE_FUNCTION
static void scatter(
const View<double***,CLayout,Device>& view,
int i_node,
const VGridWeights& wt,
double value){
127 Kokkos::atomic_add(&(view(wt.
i_vr+0,i_node,wt.
i_vz+0)),value*wt.
w_00);
128 Kokkos::atomic_add(&(view(wt.
i_vr+0,i_node,wt.
i_vz+1)),value*wt.
w_01);
129 Kokkos::atomic_add(&(view(wt.
i_vr+1,i_node,wt.
i_vz+0)),value*wt.
w_10);
130 Kokkos::atomic_add(&(view(wt.
i_vr+1,i_node,wt.
i_vz+1)),value*wt.
w_11);
134 KOKKOS_INLINE_FUNCTION
static void scatter(
const View<double****,CLayout,Device>& view,
int i_node,
const VGridWeights& wt,
double value){
135 constexpr
int ISP_ZERO = 0;
136 Kokkos::atomic_add(&(view(ISP_ZERO,wt.
i_vr+0,i_node,wt.
i_vz+0)),value*wt.
w_00);
137 Kokkos::atomic_add(&(view(ISP_ZERO,wt.
i_vr+0,i_node,wt.
i_vz+1)),value*wt.
w_01);
138 Kokkos::atomic_add(&(view(ISP_ZERO,wt.
i_vr+1,i_node,wt.
i_vz+0)),value*wt.
w_10);
139 Kokkos::atomic_add(&(view(ISP_ZERO,wt.
i_vr+1,i_node,wt.
i_vz+1)),value*wt.
w_11);
144 constexpr
int ISP_ZERO = 0;
175 KOKKOS_INLINE_FUNCTION
int n_vr()
const {
183 KOKKOS_INLINE_FUNCTION
int n_vz()
const{
187 KOKKOS_INLINE_FUNCTION
int size()
const{
198 return (ivr==0 || ivr==
n_vr()-1) ? 0.5 : 1.0;
213 int itmp = ip/
n_vz();
214 int imu = itmp%
n_vr();
215 int isp = itmp/
n_vr();
216 return f(isp,imu,inode,ivp);
KOKKOS_INLINE_FUNCTION int n_vr() const
Definition: vgrid_distribution.hpp:175
VGridDistribution(int nsp, const VelocityGrid &vgrid, const DomainDecomposition< DeviceType > &pol_decomp, VGridDistributionOption option=VGridDistributionOption::ViewInit)
Definition: vgrid_distribution.hpp:62
double * data() const
Definition: vgrid_distribution.hpp:93
KOKKOS_INLINE_FUNCTION int size() const
Definition: vgrid_distribution.hpp:187
UniformRange vz_range() const
Definition: vgrid_distribution.hpp:205
double w_00
Definition: vgrid_weights.hpp:10
Definition: velocity_grid.hpp:8
double get_smu_n(int imu) const
Definition: vgrid_distribution.hpp:192
UniformRange vr_range() const
Definition: vgrid_distribution.hpp:201
VGridDistribution(const VelocityGrid &vgrid, const DomainDecomposition< DeviceType > &pol_decomp, const std::vector< Maxwellian > &maxwellians)
Definition: vgrid_distribution.hpp:40
KOKKOS_INLINE_FUNCTION double gather(int i_node, const VGridWeights &wt) const
Definition: vgrid_distribution.hpp:143
double smu_max
max mu
Definition: vgrid_distribution.hpp:33
static KOKKOS_INLINE_FUNCTION double gather(const T &view, int i_node, const VGridWeights &wt)
Definition: vgrid_distribution.hpp:153
double dvp
grid spacing in parallel velocity
Definition: vgrid_distribution.hpp:32
double w_01
Definition: vgrid_weights.hpp:11
View< double ****, CLayout, Device > f
Definition: vgrid_distribution.hpp:23
KOKKOS_INLINE_FUNCTION int n_species() const
Definition: vgrid_distribution.hpp:171
KOKKOS_INLINE_FUNCTION double & operator()(int isp, int ivr, int inode, int ivz) const
Definition: vgrid_distribution.hpp:88
static KOKKOS_INLINE_FUNCTION void scatter(const View< double ***, CLayout, Device > &view, int i_node, const VGridWeights &wt, double value)
Definition: vgrid_distribution.hpp:126
double inv_mu0_factor
Definition: vgrid_distribution.hpp:35
double w_11
Definition: vgrid_weights.hpp:13
VGridDistribution()
Definition: vgrid_distribution.hpp:37
KOKKOS_INLINE_FUNCTION int n_vz() const
Definition: vgrid_distribution.hpp:183
View< double *, CLayout, Device, Kokkos::MemoryTraits< Kokkos::Unmanaged > > f_1D
Definition: vgrid_distribution.hpp:26
static KOKKOS_INLINE_FUNCTION void scatter(const View< double ****, CLayout, Device > &view, int i_node, const VGridWeights &wt, double value)
Definition: vgrid_distribution.hpp:134
typename HostType::execution_space exec_space
Definition: vgrid_distribution.hpp:21
Definition: vgrid_distribution.hpp:18
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:34
void for_each_element(const std::string label, F lambda_func) const
Definition: vgrid_distribution.hpp:111
VGridDistribution(int nsp, const VGridDistribution< Device2 > &dist_in, VGridDistributionOption option=VGridDistributionOption::ViewInit)
Definition: vgrid_distribution.hpp:75
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:179
KOKKOS_INLINE_FUNCTION double & pull_node_index(int inode, int ip) const
Definition: vgrid_distribution.hpp:211
static KOKKOS_INLINE_FUNCTION double normed_gather(const T &view, int i_node, const VGridWeights &wt, const T &norm_view)
Definition: vgrid_distribution.hpp:163
void for_all_elements(const std::string label, F lambda_func) const
Definition: vgrid_distribution.hpp:101
VGridDistributionOption
Definition: vgrid_distribution.hpp:12
KOKKOS_INLINE_FUNCTION double & operator[](int i) const
Definition: vgrid_distribution.hpp:91
Kokkos::ViewAllocateWithoutInitializing NoInit
Definition: space_settings.hpp:69
double w_10
Definition: vgrid_weights.hpp:12
KOKKOS_INLINE_FUNCTION double mu_vol_fac(int ivr) const
Definition: vgrid_distribution.hpp:197
double vp_max
max parallel velocity
Definition: vgrid_distribution.hpp:31
KOKKOS_INLINE_FUNCTION void scatter(int i_node, const VGridWeights &wt, double value) const
Definition: vgrid_distribution.hpp:117