From e4e5ba3bca7379b51b9976c1da48d68ee9498264 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Tue, 2 Feb 2021 17:25:24 -0800 Subject: 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 --- Source/WarpX.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'Source/WarpX.cpp') 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 -- cgit v1.2.3