WarpX
WarpXFaceInfoBox.H
Go to the documentation of this file.
1 /* Copyright 2021 Lorenzo Giacomel
2  *
3  * This file is part of WarpX.
4  *
5  * License: BSD-3-Clause-LBNL
6  */
7 
8 #ifndef WARPX_SOURCE_EMBEDDEDBOUNDARY_WARPXFACEINFOBOX_H
9 #define WARPX_SOURCE_EMBEDDEDBOUNDARY_WARPXFACEINFOBOX_H
10 
11 #include <AMReX_Gpu.H>
12 #include <AMReX_BaseFab.H>
13 
14 #include <bitset>
15 
16 struct FaceInfoBox {
17  enum Neighbours : uint8_t {n, s, e, w, nw, ne, sw, se};
18 
19  amrex::Gpu::DeviceVector<Neighbours> neigh_faces;
20  amrex::Gpu::DeviceVector<amrex::Real> area;
21  // this vector stores the indices to access in the previous vectors
22  amrex::Gpu::DeviceVector<int> inds;
23  //number of entries of inds which correspond to this element
24  amrex::BaseFab<int> size;
25  // Each entry points to an element inside the inds vector
26  amrex::BaseFab<int*> inds_pointer;
27 
28  int vecs_size;
29 
30 
34  AMREX_GPU_HOST_DEVICE
35  static void addConnectedNeighbor(int i, int j, int ind, Neighbours* neigh_face_ptr){
36 
37  if(i == -1 && j == -1){
38  *(neigh_face_ptr + ind) = nw;
39  }else if(i == -1 && j == 0){
40  *(neigh_face_ptr + ind) = w;
41  }else if(i == -1 && j == 1){
42  *(neigh_face_ptr + ind) = sw;
43  }else if(i == 0 && j == -1){
44  *(neigh_face_ptr + ind) = n;
45  }else if(i == 0 && j == 1){
46  *(neigh_face_ptr + ind) = s;
47  }else if(i == 1 && j == -1){
48  *(neigh_face_ptr + ind) = ne;
49  }else if(i == 1 && j == 0){
50  *(neigh_face_ptr + ind) = e;
51  }else if(i == 1 && j == 1){
52  *(neigh_face_ptr + ind) = se;
53  }
54  }
55 
59  AMREX_GPU_HOST_DEVICE
60  static amrex::Array1D<int, 0, 1> uint8_to_inds(Neighbours mask){
61  amrex::Array1D<int, 0, 1> res;
62 
63  if(mask == Neighbours::nw){
64  res(0) = -1;
65  res(1) = -1;
66  }else if(mask == Neighbours::w){
67  res(0) = -1;
68  res(1) = 0;
69  }else if(mask == Neighbours::sw){
70  res(0) = -1;
71  res(1) = 1;
72  }else if(mask == Neighbours::n){
73  res(0) = 0;
74  res(1) = -1;
75  }else if(mask == Neighbours::s){
76  res(0) = 0;
77  res(1) = 1;
78  }else if(mask == Neighbours::ne){
79  res(0) = 1;
80  res(1) = -1;
81  }else if(mask == Neighbours::e){
82  res(0) = 1;
83  res(1) = 0;
84  }else if(mask == Neighbours::se){
85  res(0) = 1;
86  res(1) = 1;
87  }
88 
89  return res;
90  }
91 };
92 
93 #endif //WARPX_SOURCE_EMBEDDEDBOUNDARY_WARPXFACEINFOBOX_H
Definition: WarpXFaceInfoBox.H:17
tuple w
Definition: yt3d_mpi.py:43
amrex::BaseFab< int * > inds_pointer
Definition: WarpXFaceInfoBox.H:26
int vecs_size
Definition: WarpXFaceInfoBox.H:28
Definition: WarpXFaceInfoBox.H:17
amrex::BaseFab< int > size
Definition: WarpXFaceInfoBox.H:24
static AMREX_GPU_HOST_DEVICE amrex::Array1D< int, 0, 1 > uint8_to_inds(Neighbours mask)
writes into i_face and j_face the intruded neighbors indices;
Definition: WarpXFaceInfoBox.H:60
amrex::Gpu::DeviceVector< Neighbours > neigh_faces
Definition: WarpXFaceInfoBox.H:19
Neighbours
Definition: WarpXFaceInfoBox.H:17
amrex::Gpu::DeviceVector< int > inds
Definition: WarpXFaceInfoBox.H:22
Definition: WarpXFaceInfoBox.H:17
Definition: WarpXFaceInfoBox.H:16
int n
Definition: run_libensemble_on_warpx.py:68
i
Definition: check_interp_points_and_weights.py:171
Definition: WarpXFaceInfoBox.H:17
static AMREX_GPU_HOST_DEVICE void addConnectedNeighbor(int i, int j, int ind, Neighbours *neigh_face_ptr)
add the neighbor i, j to the list of intruded neighbors.
Definition: WarpXFaceInfoBox.H:35
s
Definition: plot_results.py:103
Definition: WarpXFaceInfoBox.H:17
amrex::Gpu::DeviceVector< amrex::Real > area
Definition: WarpXFaceInfoBox.H:20
Definition: WarpXFaceInfoBox.H:17
Definition: WarpXFaceInfoBox.H:17
Definition: WarpXFaceInfoBox.H:17