8#ifndef WARPX_FINITE_DIFFERENCE_ALGORITHM_CYLINDRICAL_YEE_H_
9#define WARPX_FINITE_DIFFERENCE_ALGORITHM_CYLINDRICAL_YEE_H_
29 std::array<amrex::Real,3>& cell_size,
33 using namespace amrex;
35 stencil_coefs_r.resize(1);
36 stencil_coefs_r[0] = 1._rt/cell_size[0];
37 stencil_coefs_z.resize(1);
38 stencil_coefs_z[0] = 1._rt/cell_size[2];
47 int const n_rz_azimuthal_modes ) {
48 using namespace amrex::literals;
53 std::array< amrex::Real, 6 >
const multimode_coeffs = {{ 0.2105_rt, 1.0_rt, 3.5234_rt, 8.5104_rt, 15.5059_rt, 24.5037_rt }};
54 const amrex::Real multimode_alpha = (n_rz_azimuthal_modes < 7)?
55 multimode_coeffs[n_rz_azimuthal_modes-1]:
56 (n_rz_azimuthal_modes - 1._rt)*(n_rz_azimuthal_modes - 1._rt) - 0.4_rt;
57 const amrex::Real delta_t = 1._rt / ( std::sqrt(
58 (1._rt + multimode_alpha) / (dx[0]*dx[0])
59 + 1._rt / (dx[1]*dx[1])
61#elif defined(WARPX_DIM_RCYLINDER)
64 const amrex::Real delta_t = 0.8_rt * dx[0] /
PhysConst::c;
84 amrex::Real
const r, amrex::Real
const dr,
85 amrex::Real
const *
const coefs_r,
int const n_coefs_r,
86 int const i,
int const j,
int const k,
int const comp ) {
88 using namespace amrex;
91 Real
const inv_dr = coefs_r[0];
92 return 1._rt/r * inv_dr*( (r+0.5_rt*dr)*F(i+1,j,k,comp) - (r-0.5_rt*dr)*F(i,j,k,comp) );
102 amrex::Real
const r, amrex::Real
const dr,
103 amrex::Real
const *
const coefs_r,
int const n_coefs_r,
104 int const i,
int const j,
int const k,
int const comp ) {
106 using namespace amrex;
109 Real
const inv_dr = coefs_r[0];
110 return 1._rt/r * inv_dr*( (r+0.5_rt*dr)*F(i,j,k,comp) - (r-0.5_rt*dr)*F(i-1,j,k,comp) );
118 amrex::Real
const *
const coefs_r,
int const n_coefs_r,
119 int const i,
int const j,
int const k,
int const comp ) {
121 using namespace amrex;
124 Real
const inv_dr = coefs_r[0];
125 return inv_dr*( F(i+1,j,k,comp) - F(i,j,k,comp) );
133 amrex::Real
const *
const coefs_r,
int const n_coefs_r,
134 int const i,
int const j,
int const k,
int const comp ) {
136 using namespace amrex;
139 Real
const inv_dr = coefs_r[0];
140 return inv_dr*( F(i,j,k,comp) - F(i-1,j,k,comp) );
146 template<
typename T_Field>
150 amrex::Real
const r, amrex::Real
const dr,
151 amrex::Real
const *
const coefs_r,
int const ,
152 int const i,
int const j,
int const k,
int const comp ) {
154 using namespace amrex;
156 Real
const inv_dr2 = coefs_r[0]*coefs_r[0];
157 return 1._rt/r * inv_dr2*( (r+0.5_rt*dr)*(F(i+1,j,k,comp) - F(i,j,k,comp))
158 - (r-0.5_rt*dr)*(F(i,j,k,comp) - F(i-1,j,k,comp)) );
166 amrex::Real
const *
const coefs_z,
int const n_coefs_z,
167 int const i,
int const j,
int const k,
int const comp ) {
172 amrex::Real
const inv_dz = coefs_z[0];
173 return inv_dz*( F(i,j+1,k,comp) - F(i,j,k,comp) );
174#elif defined(WARPX_DIM_RCYLINDER)
175 using namespace amrex::literals;
186 amrex::Real
const *
const coefs_z,
int const n_coefs_z,
187 int const i,
int const j,
int const k,
int const comp ) {
192 amrex::Real
const inv_dz = coefs_z[0];
193 return inv_dz*( F(i,j,k,comp) - F(i,j-1,k,comp) );
194#elif defined(WARPX_DIM_RCYLINDER)
195 using namespace amrex::literals;
203 template<
typename T_Field>
207 amrex::Real
const *
const coefs_z,
int const ,
208 int const i,
int const j,
int const k,
int const ncomp=0 ) {
210 using namespace amrex;
213 Real
const inv_dz2 = coefs_z[0]*coefs_z[0];
214 return inv_dz2*( F(i,j-1,k,ncomp) - 2._rt*F(i,j,k,ncomp) + F(i,j+1,k,ncomp) );
215#elif defined(WARPX_DIM_RCYLINDER)
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
#define AMREX_D_DECL(a, b, c)
constexpr auto c
vacuum speed of light [m/s]
Definition constant.H:149
__host__ __device__ void ignore_unused(const Ts &...)
Definition CylindricalYeeAlgorithm.H:26
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real Dzz(T_Field const &F, amrex::Real const *const coefs_z, int const, int const i, int const j, int const k, int const ncomp=0)
Definition CylindricalYeeAlgorithm.H:205
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real DownwardDr(amrex::Array4< amrex::Real const > const &F, amrex::Real const *const coefs_r, int const n_coefs_r, int const i, int const j, int const k, int const comp)
Definition CylindricalYeeAlgorithm.H:131
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real DownwardDrr_over_r(amrex::Array4< amrex::Real const > const &F, amrex::Real const r, amrex::Real const dr, amrex::Real const *const coefs_r, int const n_coefs_r, int const i, int const j, int const k, int const comp)
Definition CylindricalYeeAlgorithm.H:100
static amrex::IntVect GetMaxGuardCell()
Returns maximum number of guard cells required by the field-solve.
Definition CylindricalYeeAlgorithm.H:72
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real UpwardDrr_over_r(amrex::Array4< amrex::Real const > const &F, amrex::Real const r, amrex::Real const dr, amrex::Real const *const coefs_r, int const n_coefs_r, int const i, int const j, int const k, int const comp)
Definition CylindricalYeeAlgorithm.H:82
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real Dr_rDr_over_r(T_Field const &F, amrex::Real const r, amrex::Real const dr, amrex::Real const *const coefs_r, int const, int const i, int const j, int const k, int const comp)
Definition CylindricalYeeAlgorithm.H:148
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real DownwardDz(amrex::Array4< amrex::Real const > const &F, amrex::Real const *const coefs_z, int const n_coefs_z, int const i, int const j, int const k, int const comp)
Definition CylindricalYeeAlgorithm.H:184
static amrex::Real ComputeMaxDt(amrex::Real const *const dx, int const n_rz_azimuthal_modes)
Definition CylindricalYeeAlgorithm.H:46
static void InitializeStencilCoefficients(std::array< amrex::Real, 3 > &cell_size, amrex::Vector< amrex::Real > &stencil_coefs_r, amrex::Vector< amrex::Real > &stencil_coefs_z)
Definition CylindricalYeeAlgorithm.H:28
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real UpwardDz(amrex::Array4< amrex::Real const > const &F, amrex::Real const *const coefs_z, int const n_coefs_z, int const i, int const j, int const k, int const comp)
Definition CylindricalYeeAlgorithm.H:164
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real UpwardDr(amrex::Array4< amrex::Real const > const &F, amrex::Real const *const coefs_r, int const n_coefs_r, int const i, int const j, int const k, int const comp)
Definition CylindricalYeeAlgorithm.H:116