From 64afe18b0ce353228c34e6f747a54bde29cda4f6 Mon Sep 17 00:00:00 2001 From: danielbelkin Date: Wed, 15 Jul 2020 21:13:54 -0700 Subject: Add support for infinite-order PSATD (#1169) * Set k_modified = k for inf order * Add support for nox = inf in input file * Added infinite-order to documentation * Add back in accidentally-removed line * End-of-line whitespaces? * End-of-line whitespaces. * Remove vspace Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> * Remove vspace Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> * Add whitespace Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> * Remove unnecessary line Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> * Whitespace Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> * Remove whitespace * Clarify error message Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> * ...whitespace Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> --- .../FieldSolver/SpectralSolver/SpectralKSpace.cpp | 114 ++++++++++++--------- 1 file changed, 65 insertions(+), 49 deletions(-) (limited to 'Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp') diff --git a/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp b/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp index 8de6de185..480e915a9 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp @@ -178,48 +178,64 @@ SpectralKSpace::getModifiedKComponent( const DistributionMapping& dm, // Initialize an empty ManagedVector in each box KVectorComponent modified_k_comp(spectralspace_ba, dm); - // Compute real-space stencil coefficients - Vector stencil_coef = getFonbergStencilCoefficients(n_order, nodal); + if (n_order == -1) { // Infinite-order case + for ( MFIter mfi(spectralspace_ba, dm); mfi.isValid(); ++mfi ){ + const ManagedVector& k = k_vec[i_dim][mfi]; + ManagedVector& modified_k = modified_k_comp[mfi]; - // Loop over boxes and allocate the corresponding ManagedVector - // for each box owned by the local MPI proc - for ( MFIter mfi(spectralspace_ba, dm); mfi.isValid(); ++mfi ){ - Real delta_x = dx[i_dim]; - const ManagedVector& k = k_vec[i_dim][mfi]; - ManagedVector& modified_k = modified_k_comp[mfi]; + // Allocate modified_k to the same size as k + modified_k.resize( k.size() ); - // Allocate modified_k to the same size as k - modified_k.resize( k.size() ); + // Fill the modified k vector + for (int i=0; i stencil_coef = getFonbergStencilCoefficients(n_order, nodal); + + // Loop over boxes and allocate the corresponding ManagedVector + // for each box owned by the local MPI proc + for ( MFIter mfi(spectralspace_ba, dm); mfi.isValid(); ++mfi ){ + Real delta_x = dx[i_dim]; + const ManagedVector& k = k_vec[i_dim][mfi]; + ManagedVector& modified_k = modified_k_comp[mfi]; + + // Allocate modified_k to the same size as k + modified_k.resize( k.size() ); + + // Fill the modified k vector + for (int i=0; i getFonbergStencilCoefficients( const int n_order, const bool nodal ) { AMREX_ALWAYS_ASSERT_WITH_MESSAGE( n_order%2 == 0, - "n_order should be even."); + "n_order should be even."); const int m = n_order/2; Vector coefs; coefs.resize( m+1 ); @@ -249,21 +265,21 @@ getFonbergStencilCoefficients( const int n_order, const bool nodal ) // Coefficients for nodal (a.k.a. centered) finite-difference if (nodal == true) { - coefs[0] = -2.; // First coefficient - for (int n=1; n