diff options
author | 2020-02-25 16:53:03 -0800 | |
---|---|---|
committer | 2020-02-25 16:53:03 -0800 | |
commit | 2a56e2b7eae582abc1b7e2eecd83af7a72610f9b (patch) | |
tree | 121821e7adc920dc3ef9d65b30847782df484e74 /Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CylindricalYeeAlgorithm.H | |
parent | 1bee3f7d669c16c69197182b828180cd0f562583 (diff) | |
download | WarpX-2a56e2b7eae582abc1b7e2eecd83af7a72610f9b.tar.gz WarpX-2a56e2b7eae582abc1b7e2eecd83af7a72610f9b.tar.zst WarpX-2a56e2b7eae582abc1b7e2eecd83af7a72610f9b.zip |
FDTD: Real Literals and Formatting (#736)
Clean up `amrex::Real` literals (aka "numbers"). This avoids
calculating a line in double precision and casting it down to
`Real` on assignment.
Also fixes some formatting issues.
(Commit credited to Remi.)
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Co-authored-by: Remi Lehe <remi.lehe@normalesup.org>
Diffstat (limited to '')
-rw-r--r-- | Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CylindricalYeeAlgorithm.H | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CylindricalYeeAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CylindricalYeeAlgorithm.H index ab32c8bcb..cdc693a78 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CylindricalYeeAlgorithm.H +++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CylindricalYeeAlgorithm.H @@ -12,6 +12,8 @@ #include <AMReX_Array4.H> #include <AMReX_Gpu.H> +#include <array> + /** * This struct contains only static functions to initialize the stencil coefficients * and to compute finite-difference derivatives for the Cartesian Yee algorithm. @@ -23,11 +25,12 @@ struct CylindricalYeeAlgorithm { amrex::Gpu::ManagedVector<amrex::Real>& stencil_coefs_r, amrex::Gpu::ManagedVector<amrex::Real>& stencil_coefs_z ) { + using namespace amrex; // Store the inverse cell size along each direction in the coefficients stencil_coefs_r.resize(1); - stencil_coefs_r[0] = 1./cell_size[0]; // 1./dr + stencil_coefs_r[0] = 1._rt/cell_size[0]; // 1./dr stencil_coefs_z.resize(1); - stencil_coefs_z[0] = 1./cell_size[2]; // 1./dz + stencil_coefs_z[0] = 1._rt/cell_size[2]; // 1./dz } /** Applies the differential operator `1/r * d(rF)/dr`, @@ -41,8 +44,9 @@ struct CylindricalYeeAlgorithm { amrex::Real const * const coefs_r, int const n_coefs_r, int const i, int const j, int const k, int const comp ) { - amrex::Real const inv_dr = coefs_r[0]; - return 1./r * inv_dr*( (r+0.5*dr)*F(i+1,j,k,comp) - (r-0.5*dr)*F(i,j,k,comp) ); + using namespace amrex; + Real const inv_dr = coefs_r[0]; + 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) ); }; /** Applies the differential operator `1/r * d(rF)/dr`, @@ -56,36 +60,39 @@ struct CylindricalYeeAlgorithm { amrex::Real const * const coefs_r, int const n_coefs_r, int const i, int const j, int const k, int const comp ) { - amrex::Real const inv_dr = coefs_r[0]; - return 1./r * inv_dr*( (r+0.5*dr)*F(i,j,k,comp) - (r-0.5*dr)*F(i-1,j,k,comp) ); + using namespace amrex; + Real const inv_dr = coefs_r[0]; + 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) ); }; /** - /* Perform derivative along r on a cell-centered grid, from a nodal field `F`*/ + * Perform derivative along r on a cell-centered grid, from a nodal field `F` */ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static amrex::Real UpwardDr ( amrex::Array4<amrex::Real> 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 ) { - amrex::Real const inv_dr = coefs_r[0]; + using namespace amrex; + Real const inv_dr = coefs_r[0]; return inv_dr*( F(i+1,j,k,comp) - F(i,j,k,comp) ); }; /** - /* Perform derivative along r on a nodal grid, from a cell-centered field `F`*/ + * Perform derivative along r on a nodal grid, from a cell-centered field `F` */ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static amrex::Real DownwardDr ( amrex::Array4<amrex::Real> 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 ) { - amrex::Real const inv_dr = coefs_r[0]; + using namespace amrex; + Real const inv_dr = coefs_r[0]; return inv_dr*( F(i,j,k,comp) - F(i-1,j,k,comp) ); }; /** - /* Perform derivative along z on a cell-centered grid, from a nodal field `F`*/ + * Perform derivative along z on a cell-centered grid, from a nodal field `F` */ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static amrex::Real UpwardDz ( amrex::Array4<amrex::Real> const& F, @@ -97,7 +104,7 @@ struct CylindricalYeeAlgorithm { }; /** - /* Perform derivative along z on a nodal grid, from a cell-centered field `F`*/ + * Perform derivative along z on a nodal grid, from a cell-centered field `F` */ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static amrex::Real DownwardDz ( amrex::Array4<amrex::Real> const& F, |