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;
12  View<bool*,CLayout,DeviceType> is_inside;
13 
15 
16  GradParXTmp(const Grid<DeviceType>& grid, int nseg, double sml_bt_sign, rtype* bd_fort)
17  : sgn(-(sml_bt_sign<0.0 ? -1.0 : 1.0)), // Reverse sign since negative gradient is desired
18  lplane_to_neighbors(grid.ff_lplane_to_neighbors.template mirror<DeviceType>()),
19  rplane_to_neighbors(grid.ff_rplane_to_neighbors.template mirror<DeviceType>()),
20  is_inside(NoInit("is_inside"),grid.nnode)
21 
22  {
23  Boundary<DeviceType> bd(nseg, bd_fort);
24 
25  // get is_inside for every node
27  }
28 
29  // For testing - set is_insde=.true.
30  GradParXTmp(const Grid<DeviceType>& grid, double sml_bt_sign)
31  : sgn(-(sml_bt_sign<0.0 ? -1.0 : 1.0)), // Reverse sign since negative gradient is desired
32  lplane_to_neighbors(grid.ff_lplane_to_neighbors.template mirror<DeviceType>()),
33  rplane_to_neighbors(grid.ff_rplane_to_neighbors.template mirror<DeviceType>()),
34  is_inside(NoInit("is_inside"),grid.nnode)
35 
36  {
37  // Assume all nodes are inside
38  Kokkos::deep_copy(is_inside, true);
39  }
40 
41  void set_is_inside(const Boundary<DeviceType>& bd, const View<bool*,CLayout,DeviceType>& is_inside_local){
42  Kokkos::parallel_for("gradparx2", Kokkos::RangePolicy<ExSpace>(0,is_inside_local.extent(0)), KOKKOS_LAMBDA( const int i ){
43  is_inside_local(i) = bd.is_inside(i);
44  });
45  }
46 };
47 
48 void negative_gradparx2(const GradParXTmp& gptx, const View<double**,CLayout,DeviceType>& input, const View<double**,CLayout,DeviceType>& output, Order derivative_order);
49 
50 #endif
Definition: boundary.hpp:6
void negative_gradparx2(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:97
GradParXTmp()
Definition: gradparx2.hpp:14
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:16
GradParXTmp(const Grid< DeviceType > &grid, double sml_bt_sign)
Definition: gradparx2.hpp:30
View< bool *, CLayout, DeviceType > is_inside
Definition: gradparx2.hpp:12
KOKKOS_INLINE_FUNCTION bool is_inside(int i) const
Definition: boundary.hpp:34
Definition: boundary.hpp:12
Order
Definition: globals.hpp:77
Projection< DeviceType > lplane_to_neighbors
Definition: gradparx2.hpp:10
Kokkos::Device< ExSpace, MemSpace > DeviceType
Definition: space_settings.hpp:47
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::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:41
Projection< DeviceType > rplane_to_neighbors
Definition: gradparx2.hpp:11