WarpX
Loading...
Searching...
No Matches
SphericalYeeAlgorithm.H
Go to the documentation of this file.
1/* Copyright 2020 Remi Lehe
2 *
3 * This file is part of WarpX.
4 *
5 * License: BSD-3-Clause-LBNL
6 */
7
8#ifndef WARPX_FINITE_DIFFERENCE_ALGORITHM_SPHERICAL_YEE_H_
9#define WARPX_FINITE_DIFFERENCE_ALGORITHM_SPHERICAL_YEE_H_
10
11#include "Utils/WarpXConst.H"
12
13#include <AMReX.H>
14#include <AMReX_Array4.H>
15#include <AMReX_Gpu.H>
16#include <AMReX_REAL.H>
17
18#include <array>
19#include <cmath>
20
21
27
29 std::array<amrex::Real,3>& cell_size,
30 amrex::Vector<amrex::Real>& stencil_coefs_r) {
31
32 using namespace amrex::literals;
33 // Store the inverse cell size along each direction in the coefficients
34 stencil_coefs_r.resize(1);
35 stencil_coefs_r[0] = 1._rt/cell_size[0]; // 1./dr
36 }
37
43 static amrex::Real ComputeMaxDt (amrex::Real const * const dx) {
44 using namespace amrex::literals;
45 // The numerical value of the max Dt below was determined empirically (for one case)
46 const amrex::Real delta_t = 0.78_rt * dx[0] / PhysConst::c;
47 return delta_t;
48 }
49
54 // The spherical solver requires one guard cell in each dimension
55 return amrex::IntVect{AMREX_D_DECL(1,1,1)};
56 }
57
63 static amrex::Real UpwardDrr_over_r (
65 amrex::Real const r, amrex::Real const dr,
66 amrex::Real const * const coefs_r, int const n_coefs_r,
67 int const i, int const j, int const k, int const comp ) {
68
69 using namespace amrex::literals;
70 amrex::ignore_unused(n_coefs_r);
71
72 amrex::Real const inv_dr = coefs_r[0];
73 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) );
74 }
75
81 static amrex::Real DownwardDrr2_over_r2 (
83 amrex::Real const r, amrex::Real const dr,
84 amrex::Real const * const coefs_r, int const n_coefs_r,
85 int const i, int const j, int const k, int const comp ) {
86
87 using namespace amrex::literals;
88 amrex::ignore_unused(n_coefs_r);
89
90 amrex::Real const inv_dr = coefs_r[0];
91 amrex::Real const rph = r + 0.5_rt*dr;
92 amrex::Real const rmh = r - 0.5_rt*dr;
93 return 1._rt/(r*r) * inv_dr*( rph*rph*F(i,j,k,comp) - rmh*rmh*F(i-1,j,k,comp) );
94 }
95
101 static amrex::Real DownwardDrr_over_r (
103 amrex::Real const r, amrex::Real const dr,
104 amrex::Real const * const coefs_r, int const n_coefs_r,
105 int const i, int const j, int const k, int const comp ) {
106
107 using namespace amrex::literals;
108 amrex::ignore_unused(n_coefs_r);
109
110 amrex::Real const inv_dr = coefs_r[0];
111 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) );
112 }
113
117 static amrex::Real UpwardDr (
119 amrex::Real const * const coefs_r, int const n_coefs_r,
120 int const i, int const j, int const k, int const comp ) {
121
122 amrex::ignore_unused(n_coefs_r);
123
124 amrex::Real const inv_dr = coefs_r[0];
125 return inv_dr*( F(i+1,j,k,comp) - F(i,j,k,comp) );
126 }
127
131 static amrex::Real DownwardDr (
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 ) {
135
136 amrex::ignore_unused(n_coefs_r);
137
138 amrex::Real const inv_dr = coefs_r[0];
139 return inv_dr*( F(i,j,k,comp) - F(i-1,j,k,comp) );
140 }
141
142};
143
144#endif // WARPX_FINITE_DIFFERENCE_ALGORITHM_SPHERICAL_YEE_H_
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
#define AMREX_D_DECL(a, b, c)
static constexpr auto c
vacuum speed of light [m/s]
Definition constant.H:44
__host__ __device__ void ignore_unused(const Ts &...)
IntVectND< 3 > IntVect
Definition SphericalYeeAlgorithm.H:26
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 SphericalYeeAlgorithm.H:117
static amrex::Real ComputeMaxDt(amrex::Real const *const dx)
Definition SphericalYeeAlgorithm.H:43
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 SphericalYeeAlgorithm.H:131
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 SphericalYeeAlgorithm.H:63
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 SphericalYeeAlgorithm.H:101
static amrex::IntVect GetMaxGuardCell()
Returns maximum number of guard cells required by the field-solve.
Definition SphericalYeeAlgorithm.H:53
static void InitializeStencilCoefficients(std::array< amrex::Real, 3 > &cell_size, amrex::Vector< amrex::Real > &stencil_coefs_r)
Definition SphericalYeeAlgorithm.H:28
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE amrex::Real DownwardDrr2_over_r2(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 SphericalYeeAlgorithm.H:81