1 #ifndef COL_SPECIES_HPP 
    2 #define COL_SPECIES_HPP 
    5 #include <Kokkos_Core.hpp> 
    6 #include <Kokkos_DualView.hpp> 
   16     KOKKOS_INLINE_FUNCTION constexpr 
MomentSet() : 
n(0.0), 
w(0.0), 
p(0.0) {}
 
   18     KOKKOS_INLINE_FUNCTION 
MomentSet(
double n_in, 
double w_in, 
double p_in) : 
n(n_in), 
w(w_in), 
p(p_in) {}
 
   62                                 - sqrt(std::abs(1e-5 + pow(log(
T_avg)-2,2)/16));
 
   64                 double ti_ev,massi,densi,chargei,te_ev,masse,dense;
 
   83                 if(ti_ev*masse/massi<te_ev){
 
   84                     if(te_ev<1e1*(chargei*chargei)){
 
   85                         lambda = 2.3e1 - log(chargei*sqrt(dense*1e-6/(te_ev*te_ev*te_ev)));
 
   87                         lambda = 2.4e1 - log(sqrt(dense*1e-6)/te_ev);
 
   90                     lambda = 3e1-log((chargei*chargei)*sqrt(densi*1e-6/(ti_ev*ti_ev*ti_ev))*
PROTON_MASS/massi);
 
  104 template<
class Device>
 
  109     Kokkos::DualView<CollisionSpeciesScalars**,Device> 
s;
 
  125     View<double****,CLayout,HostType> 
pdf_h;    
 
  126     View<double****,CLayout,Device> 
pdf;    
 
  127     View<double****,CLayout,HostType> 
pdf1_h;  
 
  128     View<double****,CLayout,Device> 
pdf1;  
 
  134           s(
"s", 
f.n_species(), mb_n_nodes),
 
  143           pdf(
"pdf", mb_n_nodes, 
f.n_species(), 
f.n_vz(), 
f.n_vr()),
 
  144           pdf1(
"pdf1", mb_n_nodes, 
f.n_species(), 
f.n_vz(), 
f.n_vr()) 
 
  147         Kokkos::deep_copy(
f.
f, f_in.
f);
 
  149         std::vector<double> inv_mass;
 
  150         int col_species_cnt=0;
 
  151         for (
int isp = 0; isp<all_species.size(); isp++){
 
  152             if (!all_species[isp].is_adiabatic){
 
  153                 for (
int mesh_ind = 0; mesh_ind<mb_n_nodes; mesh_ind++){
 
  154                     s.h_view(col_species_cnt, mesh_ind).gid = isp;
 
  155                     s.h_view(col_species_cnt, mesh_ind).is_electron = all_species[isp].is_electron;
 
  156                     s.h_view(col_species_cnt,mesh_ind).mass = all_species[isp].mass;
 
  157                     s.h_view(col_species_cnt,mesh_ind).charge_eu = all_species[isp].charge/
UNIT_CHARGE;
 
  159                 grid_index_h(col_species_cnt) = all_species[isp].collision_grid_index;
 
  160                 moments_index(col_species_cnt) = all_species[isp].nonadiabatic_idx;
 
  163                 inv_mass.push_back(1.0/all_species[isp].mass);
 
  174         pdf_h = View<double****,CLayout,HostType>(
"pdf_h",
pdf.layout());
 
  175         pdf1_h = View<double****,CLayout,HostType>(
"pdf1_h",
pdf1.layout());
 
  194           pdf(
"pdf", col_spall_in.
pdf.extent(0), 
f.n_species(), 
f.n_vz(), 
f.n_vr()),
 
  195           pdf1(
"pdf1", col_spall_in.
pdf1.extent(0), 
f.n_species(), 
f.n_vz(), 
f.n_vr())
 
  203         pdf_h = View<double****,CLayout,HostType>(
"pdf_h",
pdf.layout());
 
  204         pdf1_h = View<double****,CLayout,HostType>(
"pdf1_h",
pdf1.layout());
 
  215     void setup_one(
int isp, 
int mesh_ind, 
int local_node_ind)
 const{
 
  219         s.h_view(isp,mesh_ind).den_lambda_gamma = 
den_moment(local_node_ind, moment_isp);
 
  220         s.h_view(isp,mesh_ind).T_avg = 
temp_moment(local_node_ind, moment_isp);
 
  223         double conv_fac_temp = 
fg_temp_ev_all[moment_isp](local_node_ind);
 
  224         conv_factor(isp,mesh_ind) = sqrt(conv_fac_temp*(conv_inv_mass*conv_inv_mass*conv_inv_mass));
 
  225         double inv_conv_factor = 1.0/
conv_factor(isp,mesh_ind);
 
  228         for (
int imu = 0; imu < 
pdf_h.extent(3); imu++){
 
  229             double vnorm_to_SI = inv_conv_factor/
f.
get_smu_n(imu);
 
  230             for (
int ivp = 0; ivp<
pdf_h.extent(2); ivp++){
 
  231                 double& var = 
pdf_h(mesh_ind,isp,ivp,imu);
 
  234                 var = 
f(moment_isp, imu,local_node_ind,ivp);
 
  237                 var = std::max(var,0.0);
 
  245     void setup_all(Kokkos::View<int*,HostType>& mesh_nodes, 
int mb_n_nodes)
 const{
 
  246         Kokkos::parallel_for(
"col_sp_setup", Kokkos::RangePolicy<HostExSpace>( 0, mb_n_nodes ), [=] (
const int mesh_ind){
 
  247             for (
int isp = 0; isp < 
s.extent(0); isp++){
 
  248                 setup_one(isp, mesh_ind, mesh_nodes(mesh_ind));
 
  254         Kokkos::deep_copy(
s.d_view, 
s.h_view);
 
  259     void lambda_gamma_pair(
const View<double*,CLayout,HostType>& dt, Kokkos::View<double***,Device>& gammac, 
int mb_n_nodes)
 const{
 
  262         auto gammac_h = Kokkos::create_mirror_view(gammac);
 
  264         for (
int mesh_ind = 0; mesh_ind<mb_n_nodes; mesh_ind++){
 
  266             for (
int isp = 0; isp < 
s.extent(0); isp++){
 
  267                 for (
int jsp = 0; jsp < 
s.extent(0); jsp++){
 
  268                     gammac_h(mesh_ind,jsp,isp) = dt(mesh_ind)*
s.h_view(isp,mesh_ind).lambda_gamma_pair(
s.h_view(jsp,mesh_ind));
 
  272         Kokkos::deep_copy(gammac, gammac_h);
 
  275     inline int n()
 const{
 
void array_deep_copy(T *array, const Kokkos::View< T *, Kokkos::LayoutRight, Device > &view)
Definition: array_deep_copy.hpp:11
 
Definition: col_species.hpp:105
 
void setup_one(int isp, int mesh_ind, int local_node_ind) const
Definition: col_species.hpp:215
 
void lambda_gamma_pair(const View< double *, CLayout, HostType > &dt, Kokkos::View< double ***, Device > &gammac, int mb_n_nodes) const
Definition: col_species.hpp:259
 
void setup_all(Kokkos::View< int *, HostType > &mesh_nodes, int mb_n_nodes) const
Definition: col_species.hpp:245
 
View< double **, CLayout, HostType > den_moment
Definition: col_species.hpp:119
 
View< double ****, CLayout, HostType > pdf_h
Definition: col_species.hpp:125
 
View< double *, CLayout, DeviceType > inv_mass_d
Definition: col_species.hpp:122
 
View< int *, CLayout, DeviceType > grid_index_d
Definition: col_species.hpp:112
 
int n() const
Definition: col_species.hpp:275
 
View< double ****, CLayout, Device > pdf
Definition: col_species.hpp:126
 
View< MomentSet **, CLayout, HostType > moments
Definition: col_species.hpp:114
 
View< double **, CLayout, HostType > conv_factor
Definition: col_species.hpp:115
 
View< int *, CLayout, HostType > moments_index
Definition: col_species.hpp:117
 
View< double ****, CLayout, Device > pdf1
Definition: col_species.hpp:128
 
View< double ****, CLayout, HostType > pdf1_h
Definition: col_species.hpp:127
 
View< double **, CLayout, HostType > temp_moment
Definition: col_species.hpp:120
 
View< int *, CLayout, HostType > grid_index_h
Definition: col_species.hpp:113
 
const VGridDistribution< HostType > f
Definition: col_species.hpp:107
 
std::vector< View< double *, CLayout, HostType > > fg_temp_ev_all
Definition: col_species.hpp:123
 
Kokkos::DualView< CollisionSpeciesScalars **, Device > s
Definition: col_species.hpp:109
 
Definition: species.hpp:75
 
KOKKOS_INLINE_FUNCTION int n_species() const
Definition: vgrid_distribution.hpp:187
 
double get_smu_n(int imu) const
Definition: vgrid_distribution.hpp:208
 
View< double ****, CLayout, Device > f
Definition: vgrid_distribution.hpp:23
 
constexpr double PI
Definition: constants.hpp:9
 
constexpr double UNIT_CHARGE
Charge of an electron (C)
Definition: constants.hpp:4
 
constexpr double TWOPI
Definition: constants.hpp:10
 
constexpr double PROTON_MASS
Definition: constants.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
 
real(kind=8), dimension(:,:), pointer den_local
density,  local to compute node [Nsp,Nlocalnode]
Definition: mom_module.F90:4
 
real(kind=8), dimension(:,:), pointer temp_local
temperature, , local to compute node [Nsp,Nlocalnode]
Definition: mom_module.F90:7
 
Kokkos::ViewAllocateWithoutInitializing NoInit
Definition: space_settings.hpp:69
 
Definition: col_species.hpp:43
 
double charge_eu
Definition: col_species.hpp:48
 
KOKKOS_INLINE_FUNCTION double lambda_gamma_pair(const CollisionSpeciesScalars &sp_b) const
Definition: col_species.hpp:52
 
double den_lambda_gamma
Definition: col_species.hpp:49
 
int gid
Definition: col_species.hpp:44
 
double mass
Definition: col_species.hpp:47
 
double T_avg
Definition: col_species.hpp:46
 
bool is_electron
Definition: col_species.hpp:45
 
Definition: col_species.hpp:11
 
constexpr KOKKOS_INLINE_FUNCTION MomentSet()
Definition: col_species.hpp:16
 
double p
Definition: col_species.hpp:14
 
double w
Definition: col_species.hpp:13
 
KOKKOS_INLINE_FUNCTION MomentSet(double n_in, double w_in, double p_in)
Definition: col_species.hpp:18
 
double n
Definition: col_species.hpp:12
 
KOKKOS_INLINE_FUNCTION void operator+=(const MomentSet &other)
Definition: col_species.hpp:21
 
Definition: moments.hpp:9
 
VGridDistributionOption
Definition: vgrid_distribution.hpp:12