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 "WarpXFaceInfoBox_fwd.H"
12 
13 #include <AMReX_Gpu.H>
14 #include <AMReX_BaseFab.H>
15 
16 #include <bitset>
17 
18 struct FaceInfoBox {
19  enum Neighbours : uint8_t {n, s, e, w, nw, ne, sw, se};
20 
23  // this vector stores the indices to access in the previous vectors
25  //number of entries of inds which correspond to this element
27  // Each entry points to an element inside the inds vector
29 
30  int vecs_size;
31 
32 
37  static void addConnectedNeighbor(int i, int j, int ind, Neighbours* neigh_face_ptr){
38 
39  if(i == -1 && j == -1){
40  *(neigh_face_ptr + ind) = nw;
41  }else if(i == -1 && j == 0){
42  *(neigh_face_ptr + ind) = w;
43  }else if(i == -1 && j == 1){
44  *(neigh_face_ptr + ind) = sw;
45  }else if(i == 0 && j == -1){
46  *(neigh_face_ptr + ind) = n;
47  }else if(i == 0 && j == 1){
48  *(neigh_face_ptr + ind) = s;
49  }else if(i == 1 && j == -1){
50  *(neigh_face_ptr + ind) = ne;
51  }else if(i == 1 && j == 0){
52  *(neigh_face_ptr + ind) = e;
53  }else if(i == 1 && j == 1){
54  *(neigh_face_ptr + ind) = se;
55  }
56  }
57 
64 
65  if(mask == Neighbours::nw){
66  res(0) = -1;
67  res(1) = -1;
68  }else if(mask == Neighbours::w){
69  res(0) = -1;
70  res(1) = 0;
71  }else if(mask == Neighbours::sw){
72  res(0) = -1;
73  res(1) = 1;
74  }else if(mask == Neighbours::n){
75  res(0) = 0;
76  res(1) = -1;
77  }else if(mask == Neighbours::s){
78  res(0) = 0;
79  res(1) = 1;
80  }else if(mask == Neighbours::ne){
81  res(0) = 1;
82  res(1) = -1;
83  }else if(mask == Neighbours::e){
84  res(0) = 1;
85  res(1) = 0;
86  }else if(mask == Neighbours::se){
87  res(0) = 1;
88  res(1) = 1;
89  }
90 
91  return res;
92  }
93 };
94 
95 #endif //WARPX_SOURCE_EMBEDDEDBOUNDARY_WARPXFACEINFOBOX_H
#define AMREX_GPU_HOST_DEVICE
Array4< int const > mask
i
Definition: check_interp_points_and_weights.py:174
tuple w
Definition: yt3d_mpi.py:46
Definition: WarpXFaceInfoBox.H:18
int vecs_size
Definition: WarpXFaceInfoBox.H:30
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:37
amrex::BaseFab< int > size
Definition: WarpXFaceInfoBox.H:26
amrex::BaseFab< int * > inds_pointer
Definition: WarpXFaceInfoBox.H:28
amrex::Gpu::DeviceVector< int > inds
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:62
amrex::Gpu::DeviceVector< Neighbours > neigh_faces
Definition: WarpXFaceInfoBox.H:21
amrex::Gpu::DeviceVector< amrex::Real > area
Definition: WarpXFaceInfoBox.H:22
Neighbours
Definition: WarpXFaceInfoBox.H:19
@ w
Definition: WarpXFaceInfoBox.H:19
@ s
Definition: WarpXFaceInfoBox.H:19
@ ne
Definition: WarpXFaceInfoBox.H:19
@ n
Definition: WarpXFaceInfoBox.H:19
@ se
Definition: WarpXFaceInfoBox.H:19
@ sw
Definition: WarpXFaceInfoBox.H:19
@ nw
Definition: WarpXFaceInfoBox.H:19
@ e
Definition: WarpXFaceInfoBox.H:19