WarpX
Toggle main menu visibility
Loading...
Searching...
No Matches
Source
EmbeddedBoundary
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
21
amrex::Gpu::DeviceVector<Neighbours>
neigh_faces
;
22
amrex::Gpu::DeviceVector<amrex::Real>
area
;
23
// this vector stores the indices to access in the previous vectors
24
amrex::Gpu::DeviceVector<int>
inds
;
25
//number of entries of inds which correspond to this element
26
amrex::BaseFab<int>
size
;
27
// Each entry points to an element inside the inds vector
28
amrex::BaseFab<int*>
inds_pointer
;
29
30
int
vecs_size
;
31
32
36
AMREX_GPU_HOST_DEVICE
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
61
AMREX_GPU_HOST_DEVICE
62
static
amrex::Array1D<int, 0, 1>
uint8_to_inds
(
Neighbours
mask
){
63
amrex::Array1D<int, 0, 1>
res;
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
AMReX_BaseFab.H
AMREX_GPU_HOST_DEVICE
#define AMREX_GPU_HOST_DEVICE
AMReX_Gpu.H
mask
Array4< int const > mask
WarpXFaceInfoBox_fwd.H
amrex::BaseFab
amrex::Gpu::DeviceVector
PODVector< T, ArenaAllocator< T > > DeviceVector
FaceInfoBox
Definition
WarpXFaceInfoBox.H:18
FaceInfoBox::vecs_size
int vecs_size
Definition
WarpXFaceInfoBox.H:30
FaceInfoBox::addConnectedNeighbor
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
FaceInfoBox::size
amrex::BaseFab< int > size
Definition
WarpXFaceInfoBox.H:26
FaceInfoBox::inds_pointer
amrex::BaseFab< int * > inds_pointer
Definition
WarpXFaceInfoBox.H:28
FaceInfoBox::uint8_to_inds
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
FaceInfoBox::inds
amrex::Gpu::DeviceVector< int > inds
Definition
WarpXFaceInfoBox.H:24
FaceInfoBox::neigh_faces
amrex::Gpu::DeviceVector< Neighbours > neigh_faces
Definition
WarpXFaceInfoBox.H:21
FaceInfoBox::area
amrex::Gpu::DeviceVector< amrex::Real > area
Definition
WarpXFaceInfoBox.H:22
FaceInfoBox::Neighbours
Neighbours
Definition
WarpXFaceInfoBox.H:19
FaceInfoBox::w
@ w
Definition
WarpXFaceInfoBox.H:19
FaceInfoBox::s
@ s
Definition
WarpXFaceInfoBox.H:19
FaceInfoBox::ne
@ ne
Definition
WarpXFaceInfoBox.H:19
FaceInfoBox::n
@ n
Definition
WarpXFaceInfoBox.H:19
FaceInfoBox::se
@ se
Definition
WarpXFaceInfoBox.H:19
FaceInfoBox::sw
@ sw
Definition
WarpXFaceInfoBox.H:19
FaceInfoBox::nw
@ nw
Definition
WarpXFaceInfoBox.H:19
FaceInfoBox::e
@ e
Definition
WarpXFaceInfoBox.H:19
amrex::Array1D
Generated by
1.17.0