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