Skip to content

Commit d05f6af

Browse files
committed
More changes for RSPHERE
1 parent 7bae6f2 commit d05f6af

File tree

4 files changed

+167
-3
lines changed

4 files changed

+167
-3
lines changed

Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ void FiniteDifferenceSolver::EvolveBSpherical (
530530
Array4<Real> const& Br = Bfield[0]->array(mfi);
531531
Array4<Real> const& Bt = Bfield[1]->array(mfi);
532532
Array4<Real> const& Bp = Bfield[2]->array(mfi);
533-
Array4<Real> const& Er = Efield[0]->array(mfi);
534533
Array4<Real> const& Et = Efield[1]->array(mfi);
535534
Array4<Real> const& Ep = Efield[2]->array(mfi);
536535

Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,6 @@ void FiniteDifferenceSolver::EvolveESpherical (
504504
Array4<Real> const& Er = Efield[0]->array(mfi);
505505
Array4<Real> const& Et = Efield[1]->array(mfi);
506506
Array4<Real> const& Ep = Efield[2]->array(mfi);
507-
Array4<Real> const& Br = Bfield[0]->array(mfi);
508507
Array4<Real> const& Bt = Bfield[1]->array(mfi);
509508
Array4<Real> const& Bp = Bfield[2]->array(mfi);
510509
Array4<Real> const& jr = Jfield[0]->array(mfi);
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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+
22+
/**
23+
* This struct contains only static functions to initialize the stencil coefficients
24+
* and to compute finite-difference derivatives for the Spherical Yee algorithm.
25+
*/
26+
struct SphericalYeeAlgorithm {
27+
28+
static void InitializeStencilCoefficients (
29+
std::array<amrex::Real,3>& cell_size,
30+
amrex::Vector<amrex::Real>& stencil_coefs_r) {
31+
32+
using namespace amrex;
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+
38+
/** Compute the maximum, CFL-stable timestep
39+
*
40+
* Compute the maximum timestep, for which the scheme remains stable
41+
* under the Courant-Friedrichs-Levy limit.
42+
*/
43+
static amrex::Real ComputeMaxDt (amrex::Real const * const dx) {
44+
using namespace amrex::literals;
45+
const amrex::Real alpha = 0.22_rt; // Check this value!
46+
const amrex::Real delta_t = 1._rt / ( std::sqrt(
47+
(1._rt + alpha) / (dx[0]*dx[0])
48+
) * PhysConst::c );
49+
return delta_t;
50+
}
51+
52+
/**
53+
* \brief Returns maximum number of guard cells required by the field-solve
54+
*/
55+
static amrex::IntVect GetMaxGuardCell () {
56+
// The spherical solver requires one guard cell in each dimension
57+
return amrex::IntVect{AMREX_D_DECL(1,1,1)};
58+
}
59+
60+
/** Applies the differential operator `1/r * d(rF)/dr`,
61+
* where `F` is on a *nodal* grid in `r`
62+
* and the differential operator is evaluated on a *cell-centered* grid.
63+
* The input parameter `r` is given at the cell-centered position */
64+
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
65+
static amrex::Real UpwardDrr_over_r (
66+
amrex::Array4<amrex::Real const> const& F,
67+
amrex::Real const r, amrex::Real const dr,
68+
amrex::Real const * const coefs_r, int const n_coefs_r,
69+
int const i, int const j, int const k, int const comp ) {
70+
71+
using namespace amrex;
72+
ignore_unused(n_coefs_r);
73+
74+
Real const inv_dr = coefs_r[0];
75+
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) );
76+
}
77+
78+
/** Applies the differential operator, the gradient, `1/r**2 * d(r**2F)/dr`,
79+
* where `F` is on a *cell-centered* grid in `r`
80+
* and the differential operator is evaluated on a *nodal* grid.
81+
* The input parameter `r` is given at the cell-centered position */
82+
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
83+
static amrex::Real DownwardDrr2_over_r2 (
84+
amrex::Array4<amrex::Real const> const& F,
85+
amrex::Real const r, amrex::Real const dr,
86+
amrex::Real const * const coefs_r, int const n_coefs_r,
87+
int const i, int const j, int const k, int const comp ) {
88+
89+
using namespace amrex;
90+
ignore_unused(n_coefs_r);
91+
92+
Real const inv_dr = coefs_r[0];
93+
Real const rph = r + 0.5_rt*dr;
94+
Real const rmh = r - 0.5_rt*dr;
95+
return 1._rt/(r*r) * inv_dr*( rph*rph*F(i,j,k,comp) - rmh*rmh*F(i-1,j,k,comp) );
96+
}
97+
98+
/** Applies the differential operator `1/r * d(rF)/dr`,
99+
* where `F` is on a *cell-centered* grid in `r`
100+
* and the differential operator is evaluated on a *nodal* grid.
101+
* The input parameter `r` is given at the cell-centered position */
102+
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
103+
static amrex::Real DownwardDrr_over_r (
104+
amrex::Array4<amrex::Real const> const& F,
105+
amrex::Real const r, amrex::Real const dr,
106+
amrex::Real const * const coefs_r, int const n_coefs_r,
107+
int const i, int const j, int const k, int const comp ) {
108+
109+
using namespace amrex;
110+
ignore_unused(n_coefs_r);
111+
112+
Real const inv_dr = coefs_r[0];
113+
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) );
114+
}
115+
116+
/**
117+
* Perform derivative along r on a cell-centered grid, from a nodal field `F` */
118+
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
119+
static amrex::Real UpwardDr (
120+
amrex::Array4<amrex::Real const> const& F,
121+
amrex::Real const * const coefs_r, int const n_coefs_r,
122+
int const i, int const j, int const k, int const comp ) {
123+
124+
using namespace amrex;
125+
ignore_unused(n_coefs_r);
126+
127+
Real const inv_dr = coefs_r[0];
128+
return inv_dr*( F(i+1,j,k,comp) - F(i,j,k,comp) );
129+
}
130+
131+
/**
132+
* Perform derivative along r on a nodal grid, from a cell-centered field `F` */
133+
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
134+
static amrex::Real DownwardDr (
135+
amrex::Array4<amrex::Real const> const& F,
136+
amrex::Real const * const coefs_r, int const n_coefs_r,
137+
int const i, int const j, int const k, int const comp ) {
138+
139+
using namespace amrex;
140+
ignore_unused(n_coefs_r);
141+
142+
Real const inv_dr = coefs_r[0];
143+
return inv_dr*( F(i,j,k,comp) - F(i-1,j,k,comp) );
144+
}
145+
146+
/** Applies the differential operator `1/r * d(r * dF/dr)/dr`,
147+
* where `F` is on a *cell-centered* or a nodal grid in `r`
148+
* The input parameter `r` is given at the cell-centered position */
149+
template< typename T_Field>
150+
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
151+
static amrex::Real Dr_rDr_over_r (
152+
T_Field const& F,
153+
amrex::Real const r, amrex::Real const dr,
154+
amrex::Real const * const coefs_r, int const /*n_coefs_r*/,
155+
int const i, int const j, int const k, int const comp ) {
156+
157+
using namespace amrex;
158+
159+
Real const inv_dr2 = coefs_r[0]*coefs_r[0];
160+
return 1._rt/r * inv_dr2*( (r+0.5_rt*dr)*(F(i+1,j,k,comp) - F(i,j,k,comp))
161+
- (r-0.5_rt*dr)*(F(i,j,k,comp) - F(i-1,j,k,comp)) );
162+
}
163+
164+
};
165+
166+
#endif // WARPX_FINITE_DIFFERENCE_ALGORITHM_SPHERICAL_YEE_H_

Source/Utils/WarpXUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void ReadBoostedFrameParameters(Real& gamma_boost, Real& beta_boost,
146146

147147
void ReadMovingWindowParameters(
148148
int& do_moving_window, int& start_moving_window_step, int& end_moving_window_step,
149-
int& moving_window_dir, amrex::Real& moving_window_v)
149+
[[maybe_unused]] int& moving_window_dir, amrex::Real& moving_window_v)
150150
{
151151
const ParmParse pp_warpx("warpx");
152152
pp_warpx.query("do_moving_window", do_moving_window);

0 commit comments

Comments
 (0)