XGC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gradparx2.hpp
Go to the documentation of this file.
1 #ifndef GRADPARX2_HPP
2 #define GRADPARX2_HPP
3 
4 #include "globals.hpp"
5 #include "grid.hpp"
6 #include "boundary.hpp"
7 
8 struct GradParXTmp{
9  double sgn;
10  View<int**,CLayout,DeviceType> tr;
11  View<double***,CLayout,DeviceType> p;
12  View<double**,CLayout,DeviceType> dx;
13  View<bool*,CLayout,DeviceType> is_inside;
14 
16 
17  GradParXTmp(const Grid<DeviceType>& grid, int nseg, double sml_bt_sign, rtype* bd_fort)
18  : sgn(-(sml_bt_sign<0.0 ? -1.0 : 1.0)), // Reverse sign since negative gradient is desired
19  tr(NoInit("tr"),2,grid.nnode),
20  p(NoInit("p"),2,grid.nnode,3),
21  dx(NoInit("dx"),2,grid.nnode),
22  is_inside(NoInit("is_inside"),grid.nnode)
23 
24  {
25  Kokkos::deep_copy(tr,grid.one_plane_ff.tr);
26  Kokkos::deep_copy(p,grid.one_plane_ff.p);
27  Kokkos::deep_copy(dx,grid.one_plane_ff.dx);
28 
29  Boundary<DeviceType> bd(nseg, bd_fort);
30 
31  // get is_inside for every node
33  }
34 
35  // For testing - set is_insde=.true.
36  GradParXTmp(const Grid<DeviceType>& grid, double sml_bt_sign)
37  : sgn(-(sml_bt_sign<0.0 ? -1.0 : 1.0)), // Reverse sign since negative gradient is desired
38  tr(NoInit("tr"),2,grid.nnode),
39  p(NoInit("p"),2,grid.nnode,3),
40  dx(NoInit("dx"),2,grid.nnode),
41  is_inside(NoInit("is_inside"),grid.nnode)
42 
43  {
44  Kokkos::deep_copy(tr,grid.one_plane_ff.tr);
45  Kokkos::deep_copy(p,grid.one_plane_ff.p);
46  Kokkos::deep_copy(dx,grid.one_plane_ff.dx);
47 
48  // Assume all nodes are inside
49  Kokkos::deep_copy(is_inside, true);
50  }
51 
52  void set_is_inside(const Boundary<DeviceType>& bd, const View<bool*,CLayout,DeviceType>& is_inside_local){
53  Kokkos::parallel_for("gradparx2", Kokkos::RangePolicy<ExSpace>(0,is_inside_local.extent(0)), KOKKOS_LAMBDA( const int i ){
54  is_inside_local(i) = bd.is_inside(i);
55  });
56  }
57 };
58 
59 void negative_gradparx2(const Grid<DeviceType>& grid, const GradParXTmp& gptx, const View<double**,CLayout,DeviceType>& input, const View<double**,CLayout,DeviceType>& output, Order derivative_order);
60 
61 #endif
Projection< HostType > one_plane_ff
Definition: grid.hpp:319
View< int **, CLayout, DeviceType > tr
Definition: gradparx2.hpp:10
Definition: boundary.hpp:6
View< double **, CLayout, DeviceType > dx
Definition: gradparx2.hpp:12
GradParXTmp()
Definition: gradparx2.hpp:15
double sgn
Definition: gradparx2.hpp:9
Definition: gradparx2.hpp:8
GradParXTmp(const Grid< DeviceType > &grid, int nseg, double sml_bt_sign, rtype *bd_fort)
Definition: gradparx2.hpp:17
GradParXTmp(const Grid< DeviceType > &grid, double sml_bt_sign)
Definition: gradparx2.hpp:36
View< bool *, CLayout, DeviceType > is_inside
Definition: gradparx2.hpp:13
KOKKOS_INLINE_FUNCTION bool is_inside(int i) const
Definition: boundary.hpp:34
View< double ***, CLayout, Device > p
Definition: grid.hpp:55
Definition: boundary.hpp:12
Order
Definition: globals.hpp:77
void negative_gradparx2(const Grid< DeviceType > &grid, const GradParXTmp &gpxt, const Kokkos::View< double **, Kokkos::LayoutRight, DeviceType > &input, const Kokkos::View< double **, Kokkos::LayoutRight, DeviceType > &output, Order derivative_order)
Definition: gradparx2.cpp:24
View< double ***, CLayout, DeviceType > p
Definition: gradparx2.hpp:11
View< int **, CLayout, Device > tr
Definition: grid.hpp:54
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
View< double **, CLayout, Device > dx
Definition: grid.hpp:56
Kokkos::ViewAllocateWithoutInitializing NoInit
Definition: space_settings.hpp:68
void set_is_inside(const Boundary< DeviceType > &bd, const View< bool *, CLayout, DeviceType > &is_inside_local)
Definition: gradparx2.hpp:52