XGCa
scatter.hpp
Go to the documentation of this file.
1 #ifndef SCATTER_HPP
2 #define SCATTER_HPP
3 
4 #include "globals.hpp"
5 #include "sml.hpp"
6 #include "magnetic_field.hpp"
7 #include "grid.hpp"
8 #include "particles.hpp"
9 #include "plasma.hpp"
11 #include "charge.hpp"
12 #include "domain_decomposition.hpp"
13 
14 template<KinType KT>
15 void calculate_charge(const Simulation<DeviceType> &sml, const Grid<DeviceType> &grid,
18  const VelocityGrid& vgrid, const DomainDecomposition<DeviceType>& pol_decomp, bool fullf_only);
19 
22  const VelocityGrid& vgrid, const DomainDecomposition<DeviceType>& pol_decomp, Charges& charges);
23 
24 template<KinType KT, PhiInterpType PIT>
25 void scatter(const Grid<DeviceType> &grid,
27  const Species<DeviceType> &species, bool exclude_private, bool do_cv_adjustment, bool cv_full_weight, const Charge<DeviceType,KT> &charge);
28 
29 
30 // Used in regression tests
31 template<KinType KT>
32 inline void var_transpose_in_place(const View<double***,CLayout,DeviceType>& dest_view, const GridField<DeviceType, VarType::Scalar,PIT_GLOBAL, TorType::OnePlane, KT, SCATTER_TYPE_GLOBAL>& src_field){
33  int nnode = dest_view.extent(2);
34  int nrhop1 = dest_view.extent(0);
35  int nphi = dest_view.extent(1);
36 
37  // Cast input as an unmanaged view of doubles
38  View<double***,CLayout,DeviceType,Kokkos::MemoryTraits<Kokkos::Unmanaged>> src_view((double*)src_field.data(),nnode, nrhop1, nphi);
39 
40  // Copy to a temporary view so there are no conflicts in the tranpose
41  View<double***,CLayout,DeviceType> view_tmp(NoInit("view_tmp"),src_view.layout());
42  Kokkos::deep_copy(view_tmp, src_view);
43 
44  // parallellize on node index
45  Kokkos::parallel_for("var_transpose_in_place", Kokkos::RangePolicy<ExSpace>( 0, nnode), KOKKOS_LAMBDA(const int inode){
46  for(int irho=0; irho<nrhop1; irho++){
47  for(int iphi=0; iphi<nphi; iphi++){
48  dest_view(irho, iphi, inode) = view_tmp(inode, irho, iphi);
49  }
50  }
51  });
52  Kokkos::fence();
53 }
54 
55 
56 
57 #endif
Definition: charge.hpp:9
Definition: magnetic_field.hpp:12
Definition: NamelistReader.hpp:199
Definition: plasma.hpp:13
Definition: sml.hpp:10
Definition: species.hpp:63
void deep_copy(const Array< DataType, Device > &dest, const Array< DataType, Device2 > &src)
Definition: particles.hpp:310
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
Definition: magnetic_field.F90:1
subroutine plasma(grid, itr, p, dene_out, deni_out, Te_out, Ti_out, Vparai_out, ignore_vacuum)
Calculate the plasma density, temperature, and parallel velocity for a point in triangle itr using pl...
Definition: neutral_totalf.F90:1541
void scatter(const Grid< DeviceType > &grid, const MagneticField< DeviceType > &magnetic_field, const GridField< DeviceType, VarType::Scalar, PIT, TorType::OnePlane, KT > &Ah_gf, const Species< DeviceType > &species, bool exclude_private, bool do_cv_adjustment, bool cv_full_weight, const Charge< DeviceType, KT > &charge)
Definition: scatter.cpp:232
void charge_offset_fullf_setup(NLReader::NamelistReader &nlr, const Simulation< DeviceType > &sml, const Grid< DeviceType > &grid, const MagneticField< DeviceType > &magnetic_field, ElectricField< DeviceType > &electric_field, Plasma &plasma, const VelocityGrid &vgrid, const DomainDecomposition< DeviceType > &pol_decomp, Charges &charges)
Definition: scatter.cpp:103
void calculate_charge(const Simulation< DeviceType > &sml, const Grid< DeviceType > &grid, const MagneticField< DeviceType > &magnetic_field, ElectricField< DeviceType > &electric_field, Charge< DeviceType, KT > &charge, Plasma &plasma, const VelocityGrid &vgrid, const DomainDecomposition< DeviceType > &pol_decomp, bool fullf_only)
Definition: scatter.cpp:16
void var_transpose_in_place(const View< double ***, CLayout, DeviceType > &dest_view, const GridField< DeviceType, VarType::Scalar, PIT_GLOBAL, TorType::OnePlane, KT, SCATTER_TYPE_GLOBAL > &src_field)
Definition: scatter.hpp:32
Kokkos::ViewAllocateWithoutInitializing NoInit
Definition: space_settings.hpp:69
Definition: charge.hpp:66
Definition: electric_field.hpp:76
Definition: grid_field.hpp:22
Definition: velocity_grid.hpp:8