diff options
author | 2020-07-02 16:02:38 -0700 | |
---|---|---|
committer | 2020-07-02 16:02:38 -0700 | |
commit | 81dd5a670799b72d0e99f04cb5028566ad767b18 (patch) | |
tree | 22038fd47ca042cd76e86e7b9535121149431211 /Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp | |
parent | 8d3f260ab158ca1ca9834b3517b7ea1441cf1225 (diff) | |
download | WarpX-81dd5a670799b72d0e99f04cb5028566ad767b18.tar.gz WarpX-81dd5a670799b72d0e99f04cb5028566ad767b18.tar.zst WarpX-81dd5a670799b72d0e99f04cb5028566ad767b18.zip |
PSATD: current correction works only with global FFTs (#1131)
* Clean up implementation of current correction:
- abort when current correction runs with psatd.periodic_single_box_fft=0
- rename input parameter from psatd.do_current_correction to psatd.current_correction
- add nodal tests in 2D and 3D (using direct current deposition)
- change 2D test: use Esirkepov deposition, instead of direct, as in 3D test
- add/update relevant checksum benchmarks
* Small clean-up
Diffstat (limited to 'Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp')
-rw-r--r-- | Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp index 9684fde27..c75e8b8c7 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp @@ -23,8 +23,8 @@ PsatdAlgorithm::PsatdAlgorithm(const SpectralKSpace& spectral_kspace, const int norder_x, const int norder_y, const int norder_z, const bool nodal, const Real dt) // Initialize members of base class - : SpectralBaseAlgorithm( spectral_kspace, dm, - norder_x, norder_y, norder_z, nodal ) + : m_dt( dt ), + SpectralBaseAlgorithm( spectral_kspace, dm, norder_x, norder_y, norder_z, nodal ) { const BoxArray& ba = spectral_kspace.spectralspace_ba; @@ -37,8 +37,6 @@ PsatdAlgorithm::PsatdAlgorithm(const SpectralKSpace& spectral_kspace, // Initialize coefficients for update equations InitializeSpectralCoefficients(spectral_kspace, dm, dt); - - m_dt = dt; } /** @@ -214,6 +212,7 @@ PsatdAlgorithm::CurrentCorrection( SpectralFieldData& field_data, // Extract arrays for the fields to be updated Array4<Complex> fields = field_data.fields[mfi].array(); + // Extract pointers for the k vectors const Real* const modified_kx_arr = modified_kx_vec[mfi].dataPtr(); #if (AMREX_SPACEDIM==3) @@ -225,17 +224,18 @@ PsatdAlgorithm::CurrentCorrection( SpectralFieldData& field_data, const Real dt = m_dt; // Loop over indices within one box - ParallelFor(bx, - [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept + ParallelFor( bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { // Record old values of the fields to be updated using Idx = SpectralFieldIndex; + // Shortcuts for the values of J and rho const Complex Jx = fields(i,j,k,Idx::Jx); const Complex Jy = fields(i,j,k,Idx::Jy); const Complex Jz = fields(i,j,k,Idx::Jz); const Complex rho_old = fields(i,j,k,Idx::rho_old); const Complex rho_new = fields(i,j,k,Idx::rho_new); + // k vector values, and coefficients const Real kx = modified_kx_arr[i]; #if (AMREX_SPACEDIM==3) @@ -245,10 +245,10 @@ PsatdAlgorithm::CurrentCorrection( SpectralFieldData& field_data, constexpr Real ky = 0; const Real kz = modified_kz_arr[j]; #endif - constexpr Complex I = Complex{0,1}; - const Real k_norm = std::sqrt( kx*kx + ky*ky + kz*kz ); + constexpr Complex I = Complex{0,1}; + // div(J) in Fourier space const Complex k_dot_J = kx*Jx + ky*Jy + kz*Jz; @@ -259,7 +259,7 @@ PsatdAlgorithm::CurrentCorrection( SpectralFieldData& field_data, fields(i,j,k,Idx::Jy) = Jy - (k_dot_J-I*(rho_new-rho_old)/dt)*ky/(k_norm*k_norm); fields(i,j,k,Idx::Jz) = Jz - (k_dot_J-I*(rho_new-rho_old)/dt)*kz/(k_norm*k_norm); } - }); + } ); } // Backward Fourier transform of J |