XGC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
grid_weights.hpp
Go to the documentation of this file.
1 #ifndef GRID_WEIGHTS_HPP
2 #define GRID_WEIGHTS_HPP
3 
4 #include "globals.hpp"
5 #include "grid_structs.hpp"
6 #include "linear_weights.hpp"
7 
8 // phi weight struct - empty if phi weights are not needed
9 enum PhiWtUsage{
13 };
14 
16 
17 template<PhiWtUsage PWU>
19  KOKKOS_INLINE_FUNCTION void set(const Simd<double>& phi_in, double inv_delta_phi, int nplanes){}
20 
21  KOKKOS_INLINE_FUNCTION void set_to_midplane(){}
22 };
23 
24 template<>
27 
28  //KOKKOS_INLINE_FUNCTION void set(const Simd<double>& phi_in, double inv_delta_phi, int nplanes){}
29 };
30 
31 template<>
34 
35  KOKKOS_INLINE_FUNCTION void set(const Simd<double>& phi_in, double inv_delta_phi, int nplanes){
36  phi.set(phi_in, inv_delta_phi, nplanes);
37  }
38 
39  KOKKOS_INLINE_FUNCTION void set_to_midplane(){
40  phi.w[0] = 0.5;
41  phi.w[1] = 0.5;
42  }
43 };
44 
45 
46 template<Order OT, PhiInterpType PIT>
47 struct SimdGridWeights{};
48 
49 
50 // Weights for zero-order interpolation: just the node index
51 template<PhiInterpType PIT>
52 struct SimdGridWeights<Order::Zero, PIT>{
54 
55  // Checks whether node index is >= 0
56  KOKKOS_INLINE_FUNCTION bool is_valid(int i_simd) const{
57  return (node[i_simd]>=0);
58  }
59 
60  // Checks whether node index is >= 0
61  KOKKOS_INLINE_FUNCTION bool is_invalid(int i_simd) const{
62  return (node[i_simd]<0);
63  }
64 
65  KOKKOS_INLINE_FUNCTION void mark_as_invalid(int i_simd){
66  node[i_simd] = -1;
67  }
68 };
69 
70 
71 // Weights for first-order interpolation: the triangle index and barycentric weights
72 template<PhiInterpType PIT>
73 struct SimdGridWeights<Order::One, PIT>{
76 
78 
79  KOKKOS_INLINE_FUNCTION SimdGridWeights()
80  : itr(-1) // Initialize SimdGridWeights to invalid
81  {}
82 
83  // Checks whether itr index is >= 0
84  KOKKOS_INLINE_FUNCTION bool is_valid(int i_simd) const{
85  return (itr[i_simd]>0);
86  }
87 
88  KOKKOS_INLINE_FUNCTION bool is_invalid(int i_simd) const{
89  return (itr[i_simd]<=0);
90  }
91 
92  KOKKOS_INLINE_FUNCTION void is_not_in_grid(Simd<bool>& is_not_valid) const{
93  for (int i_simd = 0; i_simd<SIMD_SIZE; i_simd++){
94  is_not_valid[i_simd] = is_invalid(i_simd);
95  }
96  }
97 
98  KOKKOS_INLINE_FUNCTION void mark_as_invalid(){
99  itr = -1;
100  }
101 
102  // From the provided SimdGridWeights object, use its triangle as a hint for the triangle at the next grid search
103  KOKKOS_INLINE_FUNCTION void add_hint(const SimdGridWeights<Order::One, PIT>& grid_wts){
104  itr = grid_wts.itr;
105  }
106 
107  // From the provided SimdGridWeights object, use its triangle as a hint for the triangle at the next grid search
108  KOKKOS_INLINE_FUNCTION void add_hint(const SimdGridWeights<Order::One, PIT>& grid_wts, int i_simd){
109  itr[i_simd] = grid_wts.itr[i_simd];
110  }
111 };
112 
113 #endif
Definition: grid_weights.hpp:12
KOKKOS_INLINE_FUNCTION SimdGridWeights()
Definition: grid_weights.hpp:79
SimdLinearWeights phi
Definition: grid_weights.hpp:33
Definition: linear_weights.hpp:46
Simd< int > itr
Definition: grid_weights.hpp:74
Definition: grid_weights.hpp:73
Simd< int > node
Definition: grid_weights.hpp:53
Definition: grid_weights.hpp:47
KOKKOS_INLINE_FUNCTION bool is_invalid(int i_simd) const
Definition: grid_weights.hpp:88
KOKKOS_INLINE_FUNCTION bool is_invalid(int i_simd) const
Definition: grid_weights.hpp:61
KOKKOS_INLINE_FUNCTION void is_not_in_grid(Simd< bool > &is_not_valid) const
Definition: grid_weights.hpp:92
KOKKOS_INLINE_FUNCTION void set(const Simd< double > &phi_in, double inv_delta_phi, int nplanes)
Definition: grid_weights.hpp:19
KOKKOS_INLINE_FUNCTION void set(const Simd< double > &phi_in, double inv_delta_phi, int nplanes)
Definition: grid_weights.hpp:35
constexpr KOKKOS_INLINE_FUNCTION PhiWtUsage get_phi_wt_usage(PhiInterpType PIT)
Definition: grid_weights.hpp:15
SimdPhiWeights< get_phi_wt_usage(PIT)> phi_wts
Definition: grid_weights.hpp:77
Definition: grid_weights.hpp:18
Simd< int > i_phi
Definition: grid_weights.hpp:26
PhiInterpType
Definition: globals.hpp:95
Order
Definition: globals.hpp:77
KOKKOS_INLINE_FUNCTION void mark_as_invalid(int i_simd)
Definition: grid_weights.hpp:65
Definition: grid_structs.hpp:7
KOKKOS_INLINE_FUNCTION void set_to_midplane()
Definition: grid_weights.hpp:21
KOKKOS_INLINE_FUNCTION void add_hint(const SimdGridWeights< Order::One, PIT > &grid_wts)
Definition: grid_weights.hpp:103
KOKKOS_INLINE_FUNCTION void set_to_midplane()
Definition: grid_weights.hpp:39
Definition: grid_weights.hpp:11
SimdGridVec p
Definition: grid_weights.hpp:75
KOKKOS_INLINE_FUNCTION void add_hint(const SimdGridWeights< Order::One, PIT > &grid_wts, int i_simd)
Definition: grid_weights.hpp:108
KOKKOS_INLINE_FUNCTION bool is_valid(int i_simd) const
Definition: grid_weights.hpp:84
KOKKOS_INLINE_FUNCTION bool is_valid(int i_simd) const
Definition: grid_weights.hpp:56
PhiWtUsage
Definition: grid_weights.hpp:9
Definition: grid_weights.hpp:10
KOKKOS_INLINE_FUNCTION void mark_as_invalid()
Definition: grid_weights.hpp:98