1 #ifndef FIELD_FOLLOWING_COORDINATES_HPP
2 #define FIELD_FOLLOWING_COORDINATES_HPP
12 Kokkos::View<int**,Kokkos::LayoutRight,DeviceType>
tr;
13 Kokkos::View<double***,Kokkos::LayoutRight,DeviceType>
p;
16 Kokkos::View<double**,Kokkos::LayoutRight,DeviceType>
result;
23 :
tr(Kokkos::ViewAllocateWithoutInitializing(
"tr"),2,grid.nnode),
24 p(Kokkos::ViewAllocateWithoutInitializing(
"p"),2,grid.nnode,3),
25 result(Kokkos::ViewAllocateWithoutInitializing(
"result"),2,grid.nnode)
37 void cnvt_grid_ff2real(
const Grid<DeviceType>& grid,
const Kokkos::View<double**,Kokkos::LayoutRight,DeviceType>& input,
const Kokkos::View<double**,Kokkos::LayoutRight,DeviceType>& output){
39 if(input.extent(0) != 2 || input.extent(1) != grid.
nnode ||
40 output.extent(0)!= 2 || output.extent(1)!= grid.
nnode )
exit_XGC(
"\nError in cnvt_grid_ff2real: Unexpected View sizes. \n");
43 Kokkos::deep_copy(output, 0.0);
46 Kokkos::View<double**,Kokkos::LayoutRight,DeviceType> vol(
"vol",input.layout());
49 Kokkos::View<double**,Kokkos::LayoutRight,DeviceType> node_vol_ff(Kokkos::ViewAllocateWithoutInitializing(
"node_vol_ff"),input.layout());
57 for (
int dir=0;dir<2;dir++){
58 for (
int j=0;j<3;j++){
60 int nd=grid.
nodes(ff.
tr(dir,i)-1).vertex[j] - 1;
61 double wt=ff.
p(dir,i,j)*node_vol_ff(dir,nd);
64 Kokkos::atomic_add(&(output(dir,nd)), wt*input(dir,i));
65 Kokkos::atomic_add(&(vol(dir,nd)), wt);
72 for (
int dir=0;dir<2;dir++){
73 if(vol(dir, i) == 0.0){
76 output(dir, i) /= vol(dir, i);
82 Kokkos::parallel_for(
"cnvt_grid_ff2real_fillempty", Kokkos::RangePolicy<ExSpace>(0,grid.
nnode), KOKKOS_LAMBDA(
const int i ){
83 for (
int dir=0; dir<2; dir++){
87 for (
int j=0;j<3;j++){
88 int nd=grid.
nodes(ff.
tr(cdir,i)-1).vertex[j] - 1;
89 double wt=ff.
p(cdir,i,j);
92 output(dir,i) += wt*input(dir,nd);
105 void cnvt_grid_real2ff(
const Grid<DeviceType>& grid,
const Kokkos::View<double**,Kokkos::LayoutRight,DeviceType>& input,
const Kokkos::View<double**,Kokkos::LayoutRight,DeviceType>& output){
107 if(input.extent(0) != 2 || input.extent(1) != grid.
nnode ||
108 output.extent(0)!= 2 || output.extent(1)!= grid.
nnode )
exit_XGC(
"\nError in cnvt_grid_real2ff: Unexpected View sizes. \n");
111 Kokkos::deep_copy(output, 0.0);
118 for (
int dir=0;dir<2;dir++){
119 for (
int j=0;j<3;j++){
120 int nd=grid.
nodes(ff.
tr(dir,i)-1).vertex[j] - 1;
122 double wt=ff.
p(dir,i,j);
125 output(dir,i) += wt*input(dir,nd);
141 Kokkos::deep_copy(input,
result);
void array_deep_copy(T *array, const Kokkos::View< T *, Kokkos::LayoutRight, Device > &view)
Definition: array_deep_copy.hpp:11
Definition: field_following_coordinates.hpp:10
Kokkos::View< double **, Kokkos::LayoutRight, DeviceType > result
Definition: field_following_coordinates.hpp:16
double * get_grid_node_vol_ff_loc()
int * get_psn_ff_hdp_tr_loc()
FieldFollowingCoordinates()
Definition: field_following_coordinates.hpp:20
Kokkos::View< int **, Kokkos::LayoutRight, DeviceType > tr
Definition: field_following_coordinates.hpp:12
FieldFollowingCoordinates(const Grid< DeviceType > &grid)
Definition: field_following_coordinates.hpp:22
void cnvt_grid_real2ff(const Grid< DeviceType > &grid, const Kokkos::View< double **, Kokkos::LayoutRight, DeviceType > &input, const Kokkos::View< double **, Kokkos::LayoutRight, DeviceType > &output)
Definition: field_following_coordinates.hpp:105
Kokkos::View< double ***, Kokkos::LayoutRight, DeviceType > p
Definition: field_following_coordinates.hpp:13
void cnvt_grid_ff2real(const Grid< DeviceType > &grid, const Kokkos::View< double **, Kokkos::LayoutRight, DeviceType > &input, const Kokkos::View< double **, Kokkos::LayoutRight, DeviceType > &output)
Definition: field_following_coordinates.hpp:37
void exit_XGC(std::string msg)
Definition: globals.hpp:36
void cnvt_grid_real2ff(const Grid< DeviceType > &grid, const Kokkos::View< double **, Kokkos::LayoutRight, DeviceType > &input)
Definition: field_following_coordinates.hpp:137
double * get_psn_ff_hdp_p_loc()
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
int nnode
Number of grid nodes.
Definition: grid.hpp:83
Kokkos::View< Vertex *, Kokkos::LayoutRight, Device > nodes
Definition: grid.hpp:92