aboutsummaryrefslogtreecommitdiff
path: root/Source/WarpX.cpp
diff options
context:
space:
mode:
authorGravatar Edoardo Zoni <59625522+EZoni@users.noreply.github.com> 2021-02-02 17:25:24 -0800
committerGravatar GitHub <noreply@github.com> 2021-02-02 17:25:24 -0800
commite4e5ba3bca7379b51b9976c1da48d68ee9498264 (patch)
treee3dd561e46fc7875d9ea8dcc82559861a3ff874b /Source/WarpX.cpp
parentce748223f465225ac3871bafd9a6368c6a86c48d (diff)
downloadWarpX-e4e5ba3bca7379b51b9976c1da48d68ee9498264.tar.gz
WarpX-e4e5ba3bca7379b51b9976c1da48d68ee9498264.tar.zst
WarpX-e4e5ba3bca7379b51b9976c1da48d68ee9498264.zip
Refactor finite-order interpolation functions for momentum-conserving field gathering (#1653)
* Unify high-order Fornberg interpolation functions * Add Doxygen documentation for new function * Unify also FDTD linear interpolation functions * Improve new implementation * Compute stencil coefficients only at initialization * Small clean-up and optimization
Diffstat (limited to '')
-rw-r--r--Source/WarpX.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp
index 7fdd6a3f1..ff42c4758 100644
--- a/Source/WarpX.cpp
+++ b/Source/WarpX.cpp
@@ -11,6 +11,9 @@
*/
#include "WarpX.H"
#include "FieldSolver/WarpX_FDTD.H"
+#ifdef WARPX_USE_PSATD
+#include "FieldSolver/SpectralSolver/SpectralKSpace.H"
+#endif
#include "Python/WarpXWrappers.h"
#include "Utils/WarpXConst.H"
#include "Utils/WarpXUtil.H"
@@ -693,6 +696,32 @@ WarpX::ReadParameters ()
field_gathering_nox == 2 && field_gathering_noy == 2 && field_gathering_noz == 2,
"High-order interpolation (order > 2) is not implemented with mesh refinement");
}
+
+ // Host vectors for Fornberg stencil coefficients used for finite-order centering
+ host_centering_stencil_coeffs_x = getFornbergStencilCoefficients(field_gathering_nox, false);
+ host_centering_stencil_coeffs_y = getFornbergStencilCoefficients(field_gathering_noy, false);
+ host_centering_stencil_coeffs_z = getFornbergStencilCoefficients(field_gathering_noz, false);
+
+ // Device vectors for Fornberg stencil coefficients used for finite-order centering
+ device_centering_stencil_coeffs_x.resize(host_centering_stencil_coeffs_x.size());
+ amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice,
+ host_centering_stencil_coeffs_x.begin(),
+ host_centering_stencil_coeffs_x.end(),
+ device_centering_stencil_coeffs_x.begin());
+
+ device_centering_stencil_coeffs_y.resize(host_centering_stencil_coeffs_y.size());
+ amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice,
+ host_centering_stencil_coeffs_y.begin(),
+ host_centering_stencil_coeffs_y.end(),
+ device_centering_stencil_coeffs_y.begin());
+
+ device_centering_stencil_coeffs_z.resize(host_centering_stencil_coeffs_z.size());
+ amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice,
+ host_centering_stencil_coeffs_z.begin(),
+ host_centering_stencil_coeffs_z.end(),
+ device_centering_stencil_coeffs_z.begin());
+
+ amrex::Gpu::synchronize();
}
#endif