From 03b2fe60ff49748aaff8402824ea0457eef24d5c Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Wed, 8 Mar 2023 20:52:56 -0800 Subject: New user input for grid type (collocated, staggered, hybrid) (#3683) * Introduce `warpx.grid_type` parameter * Replace `or` with `||` * Update examples with new user input syntax * Fix `if` condition * Improve error message * Fix `if` condition * Fix bugs * Fix warning * Fix RZ * Debugging * Fix RZ * Fix bug * Clean up * More changes: - set default algo parameters with hybrid grid - all hybrid input parameters under warpx name * Set default field gathering algo for hybrid grids * Update documentation --- Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp') diff --git a/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp b/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp index b9afc63b4..8330b645e 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp @@ -141,7 +141,7 @@ SpectralKSpace::getKComponent( const DistributionMapping& dm, * corresponding correcting "shift" factor, along the dimension * specified by `i_dim`. * - * (By default, we assume the FFT is done from/to a nodal grid in real space + * (By default, we assume the FFT is done from/to a collocated grid in real space * It the FFT is performed from/to a cell-centered grid in real space, * a correcting "shift" factor must be applied in spectral space.) */ @@ -190,14 +190,13 @@ SpectralKSpace::getSpectralShiftFactor( const DistributionMapping& dm, * * \param n_order Order of accuracy of the stencil, in discretizing * a spatial derivative - * \param nodal Whether the stencil is to be applied to a nodal or - staggered set of fields + * \param grid_type type of grid (collocated or not) */ KVectorComponent SpectralKSpace::getModifiedKComponent( const DistributionMapping& dm, const int i_dim, const int n_order, - const bool nodal ) const + const short grid_type ) const { // Initialize an empty DeviceVector in each box KVectorComponent modified_k_comp(spectralspace_ba, dm); @@ -217,7 +216,7 @@ SpectralKSpace::getModifiedKComponent( const DistributionMapping& dm, } else { // Compute real-space stencil coefficients - Vector h_stencil_coef = WarpX::getFornbergStencilCoefficients(n_order, nodal); + Vector h_stencil_coef = WarpX::getFornbergStencilCoefficients(n_order, grid_type); Gpu::DeviceVector d_stencil_coef(h_stencil_coef.size()); Gpu::copyAsync(Gpu::hostToDevice, h_stencil_coef.begin(), h_stencil_coef.end(), d_stencil_coef.begin()); @@ -243,7 +242,7 @@ SpectralKSpace::getModifiedKComponent( const DistributionMapping& dm, { p_modified_k[i] = 0; for (int n=0; n