WarpX
WarpX_FDTD.H
Go to the documentation of this file.
1 /* Copyright 2019 Axel Huebl, David Grote
2  *
3  * This file is part of WarpX.
4  *
5  * License: BSD-3-Clause-LBNL
6  */
7 #ifndef WARPX_FDTD_H_
8 #define WARPX_FDTD_H_
9 
10 #include <AMReX.H>
11 #include <AMReX_FArrayBox.H>
12 
14 void warpx_computedivb(int i, int j, int k, int dcomp,
15  amrex::Array4<amrex::Real> const& divB,
19  amrex::Real dxinv,
20  amrex::Real dyinv,
21  amrex::Real dzinv
22 #ifdef WARPX_DIM_RZ
23  , amrex::Real const rmin
24 #endif
25  )
26 {
27 
28  using namespace amrex;
29 
30 #if defined WARPX_DIM_3D
31  divB(i,j,k,dcomp) = (Bx(i+1,j ,k ) - Bx(i,j,k))*dxinv
32  + (By(i ,j+1,k ) - By(i,j,k))*dyinv
33  + (Bz(i ,j ,k+1) - Bz(i,j,k))*dzinv;
34 #elif defined WARPX_DIM_XZ
35  divB(i,j,0,dcomp) = (Bx(i+1,j ,0) - Bx(i,j,0))*dxinv
36  + (Bz(i ,j+1,0) - Bz(i,j,0))*dzinv;
37  amrex::ignore_unused(k, By, dyinv);
38 #elif defined WARPX_DIM_1D_Z
39  divB(i,0,0,dcomp) = (Bz(i+1,0 ,0) - Bz(i,0,0))*dzinv;
40  amrex::ignore_unused(j, Bx, dxinv);
41  amrex::ignore_unused(k, By, dyinv);
42 #elif defined WARPX_DIM_RZ
43  const amrex::Real ru = 1._rt + 0.5_rt/(rmin*dxinv + i + 0.5_rt);
44  const amrex::Real rd = 1._rt - 0.5_rt/(rmin*dxinv + i + 0.5_rt);
45  divB(i,j,0,dcomp) = (ru*Bx(i+1,j,0) - rd*Bx(i,j,0))*dxinv
46  + (Bz(i,j+1,0) - Bz(i,j,0))*dzinv;
47  amrex::ignore_unused(k, By, dyinv);
48 #endif
49 }
50 
51 #endif
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void warpx_computedivb(int i, int j, int k, int dcomp, amrex::Array4< amrex::Real > const &divB, amrex::Array4< amrex::Real const > const &Bx, amrex::Array4< amrex::Real const > const &By, amrex::Array4< amrex::Real const > const &Bz, amrex::Real dxinv, amrex::Real dyinv, amrex::Real dzinv, amrex::Real const rmin)
Definition: WarpX_FDTD.H:14
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
i
Definition: check_interp_points_and_weights.py:174