diff options
Diffstat (limited to 'Source/FieldSolver')
20 files changed, 77 insertions, 187 deletions
diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.H index f9a155742..fde6bcb02 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.H @@ -101,17 +101,9 @@ class PsatdAlgorithm : public SpectralBaseAlgorithm * base class \c SpectralBaseAlgorithm and cannot be overridden by further * derived classes. * - * \param[in] lev The mesh-refinement level * \param[in,out] field_data All fields in Fourier space - * \param[in,out] current Array of unique pointers to \c MultiFab storing - * the three components of the current density - * \param[in] rho Unique pointer to \c MultiFab storing the charge density */ - virtual void CurrentCorrection ( - const int lev, - SpectralFieldData& field_data, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho) override final; + virtual void CurrentCorrection (SpectralFieldData& field_data) override final; /** * \brief Virtual function for Vay current deposition in Fourier space diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp index 0515aa598..52813cb13 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp @@ -732,27 +732,13 @@ void PsatdAlgorithm::InitializeSpectralCoefficientsAveraging ( } } -void -PsatdAlgorithm::CurrentCorrection ( - const int lev, - SpectralFieldData& field_data, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho) +void PsatdAlgorithm::CurrentCorrection (SpectralFieldData& field_data) { // Profiling BL_PROFILE("PsatdAlgorithm::CurrentCorrection"); const SpectralFieldIndex& Idx = m_spectral_index; - // Forward Fourier transform of J and rho - field_data.ForwardTransform(lev, *current[0], Idx.Jx, 0); - field_data.ForwardTransform(lev, *current[1], Idx.Jy, 0); - field_data.ForwardTransform(lev, *current[2], Idx.Jz, 0); - field_data.ForwardTransform(lev, *rho, Idx.rho_old, 0); - field_data.ForwardTransform(lev, *rho, Idx.rho_new, 1); - - const amrex::IntVect& fill_guards = m_fill_guards; - // Loop over boxes for (amrex::MFIter mfi(field_data.fields); mfi.isValid(); ++mfi){ @@ -843,11 +829,6 @@ PsatdAlgorithm::CurrentCorrection ( } }); } - - // Backward Fourier transform of J - field_data.BackwardTransform(lev, *current[0], Idx.Jx, 0, fill_guards); - field_data.BackwardTransform(lev, *current[1], Idx.Jy, 0, fill_guards); - field_data.BackwardTransform(lev, *current[2], Idx.Jz, 0, fill_guards); } void diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.H index a01719a9a..13d2f1d5d 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.H @@ -55,16 +55,9 @@ class PsatdAlgorithmComoving : public SpectralBaseAlgorithm * base class \c SpectralBaseAlgorithm and cannot be overridden by further * derived classes. * - * \param[in] lev The mesh-refinement level * \param[in,out] field_data All fields in Fourier space - * \param[in,out] current Array of unique pointers to \c MultiFab storing - * the three components of the current density - * \param[in] rho Unique pointer to \c MultiFab storing the charge density */ - virtual void CurrentCorrection (const int lev, - SpectralFieldData& field_data, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho) override final; + virtual void CurrentCorrection (SpectralFieldData& field_data) override final; /** * \brief Virtual function for Vay current deposition in Fourier space. diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.cpp index b14ded092..77d03b500 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmComoving.cpp @@ -410,26 +410,13 @@ void PsatdAlgorithmComoving::InitializeSpectralCoefficients (const SpectralKSpac } } -void -PsatdAlgorithmComoving::CurrentCorrection (const int lev, - SpectralFieldData& field_data, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho) +void PsatdAlgorithmComoving::CurrentCorrection (SpectralFieldData& field_data) { // Profiling BL_PROFILE("PsatdAlgorithmComoving::CurrentCorrection"); const SpectralFieldIndex& Idx = m_spectral_index; - // Forward Fourier transform of J and rho - field_data.ForwardTransform(lev, *current[0], Idx.Jx, 0); - field_data.ForwardTransform(lev, *current[1], Idx.Jy, 0); - field_data.ForwardTransform(lev, *current[2], Idx.Jz, 0); - field_data.ForwardTransform(lev, *rho, Idx.rho_old, 0); - field_data.ForwardTransform(lev, *rho, Idx.rho_new, 1); - - const amrex::IntVect& fill_guards = m_fill_guards; - // Loop over boxes for (amrex::MFIter mfi(field_data.fields); mfi.isValid(); ++mfi){ @@ -508,11 +495,6 @@ PsatdAlgorithmComoving::CurrentCorrection (const int lev, } }); } - - // Backward Fourier transform of J - field_data.BackwardTransform(lev, *current[0], Idx.Jx, 0, fill_guards); - field_data.BackwardTransform(lev, *current[1], Idx.Jy, 0, fill_guards); - field_data.BackwardTransform(lev, *current[2], Idx.Jz, 0, fill_guards); } void diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.H index cee84f99d..11a1ea33a 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.H @@ -35,16 +35,9 @@ class PsatdAlgorithmGalileanRZ : public SpectralBaseAlgorithmRZ * base class \c SpectralBaseAlgorithmRZ (qualifier \c override) and cannot be * overridden by further derived classes (qualifier \c final). * - * \param[in] lev mesh-refinement level * \param[in,out] field_data all fields in Fourier space - * \param[in,out] current two-dimensional array of unique pointers to MultiFab - * storing the three components of the current density - * \param[in] rho unique pointer to MultiFab storing the charge density */ - virtual void CurrentCorrection ( const int lev, - SpectralFieldDataRZ& field_data, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho ) override final; + virtual void CurrentCorrection (SpectralFieldDataRZ& field_data) override final; /** * \brief Virtual function for Vay current deposition in Fourier space diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.cpp index 2faf48c04..831d1e89f 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmGalileanRZ.cpp @@ -290,23 +290,13 @@ void PsatdAlgorithmGalileanRZ::InitializeSpectralCoefficients (SpectralFieldData } void -PsatdAlgorithmGalileanRZ::CurrentCorrection (const int lev, - SpectralFieldDataRZ& field_data, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho ) +PsatdAlgorithmGalileanRZ::CurrentCorrection (SpectralFieldDataRZ& field_data) { // Profiling WARPX_PROFILE( "PsatdAlgorithmGalileanRZ::CurrentCorrection" ); const SpectralFieldIndex& Idx = m_spectral_index; - // Forward Fourier transform of J and rho - field_data.ForwardTransform( lev, *current[0], Idx.Jx, - *current[1], Idx.Jy); - field_data.ForwardTransform( lev, *current[2], Idx.Jz, 0); - field_data.ForwardTransform( lev, *rho, Idx.rho_old, 0 ); - field_data.ForwardTransform( lev, *rho, Idx.rho_new, 1 ); - // Loop over boxes for (amrex::MFIter mfi(field_data.fields); mfi.isValid(); ++mfi){ @@ -367,13 +357,6 @@ PsatdAlgorithmGalileanRZ::CurrentCorrection (const int lev, } }); } - - // Backward Fourier transform of J - field_data.BackwardTransform( lev, - *current[0], Idx.Jx, - *current[1], Idx.Jy); - field_data.BackwardTransform( lev, *current[2], Idx.Jz, 0 ); - } void diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.H index e9636fc32..414394ba9 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.H @@ -100,17 +100,9 @@ class PsatdAlgorithmJLinearInTime : public SpectralBaseAlgorithm * base class \c SpectralBaseAlgorithm and cannot be overridden by further * derived classes. * - * \param[in] lev The mesh-refinement level * \param[in,out] field_data All fields in Fourier space - * \param[in,out] current Array of unique pointers to \c MultiFab storing - * the three components of the current density - * \param[in] rho Unique pointer to \c MultiFab storing the charge density */ - virtual void CurrentCorrection ( - const int lev, - SpectralFieldData& field_data, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho) override final; + virtual void CurrentCorrection (SpectralFieldData& field_data) override final; /** * \brief Virtual function for Vay current deposition in Fourier space diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.cpp index 5db997612..d06087484 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJLinearInTime.cpp @@ -423,17 +423,12 @@ void PsatdAlgorithmJLinearInTime::InitializeSpectralCoefficientsAveraging ( } } -void -PsatdAlgorithmJLinearInTime::CurrentCorrection ( - const int lev, - SpectralFieldData& field_data, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho) +void PsatdAlgorithmJLinearInTime::CurrentCorrection (SpectralFieldData& field_data) { // Profiling BL_PROFILE("PsatdAlgorithmJLinearInTime::CurrentCorrection"); - amrex::ignore_unused(lev, field_data, current, rho); + amrex::ignore_unused(field_data); amrex::Abort("Current correction not implemented for multi-J PSATD algorithm"); } diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.H index 39e99012f..243760857 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.H @@ -52,16 +52,9 @@ class PsatdAlgorithmPml : public SpectralBaseAlgorithm * base class \c SpectralBaseAlgorithm and cannot be overridden by further * derived classes. * - * \param[in] lev The mesh-refinement level * \param[in,out] field_data All fields in Fourier space - * \param[in,out] current Array of unique pointers to \c MultiFab storing - * the three components of the current density - * \param[in] rho Unique pointer to \c MultiFab storing the charge density */ - virtual void CurrentCorrection (const int lev, - SpectralFieldData& field_data, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho) override final; + virtual void CurrentCorrection (SpectralFieldData& field_data) override final; /** * \brief Virtual function for Vay current deposition in Fourier space diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.cpp index 0780b8c52..7b8deec30 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPml.cpp @@ -402,10 +402,7 @@ void PsatdAlgorithmPml::InitializeSpectralCoefficients ( } void -PsatdAlgorithmPml::CurrentCorrection (const int /*lev*/, - SpectralFieldData& /*field_data*/, - std::array<std::unique_ptr<amrex::MultiFab>,3>& /*current*/, - const std::unique_ptr<amrex::MultiFab>& /*rho*/) +PsatdAlgorithmPml::CurrentCorrection (SpectralFieldData& /*field_data*/) { amrex::Abort("Current correction not implemented for PML PSATD"); } diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.H index fac84b90a..a9892cb40 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.H @@ -35,14 +35,8 @@ class PsatdAlgorithmPmlRZ : public SpectralBaseAlgorithmRZ * derived classes. * * \param[in,out] field_data All fields in Fourier space - * \param[in,out] current Array of unique pointers to \c MultiFab storing - * the three components of the current density - * \param[in] rho Unique pointer to \c MultiFab storing the charge density */ - virtual void CurrentCorrection (const int lev, - SpectralFieldDataRZ& field_data, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho) override final; + virtual void CurrentCorrection (SpectralFieldDataRZ& field_data) override final; /** * \brief Virtual function for Vay current deposition in Fourier space diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.cpp index 16f4f1e37..522fe1881 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmPmlRZ.cpp @@ -160,10 +160,7 @@ void PsatdAlgorithmPmlRZ::InitializeSpectralCoefficients (SpectralFieldDataRZ co } void -PsatdAlgorithmPmlRZ::CurrentCorrection (const int /* lev */, - SpectralFieldDataRZ& /* field_data */, - std::array<std::unique_ptr<amrex::MultiFab>,3>& /* current */, - const std::unique_ptr<amrex::MultiFab>& /* rho */) +PsatdAlgorithmPmlRZ::CurrentCorrection (SpectralFieldDataRZ& /* field_data */) { amrex::Abort("Current correction not implemented in RZ geometry PML"); } diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.H index fba8f0881..9bbb695d2 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.H @@ -38,16 +38,9 @@ class PsatdAlgorithmRZ : public SpectralBaseAlgorithmRZ * base class \c SpectralBaseAlgorithmRZ and cannot be overridden by further * derived classes. * - * \param[in] lev The mesh-refinement level * \param[in,out] field_data All fields in Fourier space - * \param[in,out] current Array of unique pointers to \c MultiFab storing - * the three components of the current density - * \param[in] rho Unique pointer to \c MultiFab storing the charge density */ - virtual void CurrentCorrection (const int lev, - SpectralFieldDataRZ& field_data, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho) override final; + virtual void CurrentCorrection (SpectralFieldDataRZ& field_data) override final; /** * \brief Virtual function for Vay current deposition in Fourier space diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp index efc9337af..5bb409269 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp @@ -413,24 +413,13 @@ void PsatdAlgorithmRZ::InitializeSpectralCoefficients (SpectralFieldDataRZ const } void -PsatdAlgorithmRZ::CurrentCorrection (const int lev, - SpectralFieldDataRZ& field_data, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho) +PsatdAlgorithmRZ::CurrentCorrection (SpectralFieldDataRZ& field_data) { // Profiling WARPX_PROFILE( "PsatdAlgorithmRZ::CurrentCorrection" ); const SpectralFieldIndex& Idx = m_spectral_index; - // Forward Fourier transform of J and rho - field_data.ForwardTransform( lev, - *current[0], Idx.Jx, - *current[1], Idx.Jy); - field_data.ForwardTransform( lev, *current[2], Idx.Jz, 0); - field_data.ForwardTransform( lev, *rho, Idx.rho_old, 0 ); - field_data.ForwardTransform( lev, *rho, Idx.rho_new, 1 ); - // Loop over boxes for (amrex::MFIter mfi(field_data.fields); mfi.isValid(); ++mfi){ @@ -487,13 +476,6 @@ PsatdAlgorithmRZ::CurrentCorrection (const int lev, } }); } - - // Backward Fourier transform of J - field_data.BackwardTransform( lev, - *current[0], Idx.Jx, - *current[1], Idx.Jy); - field_data.BackwardTransform( lev, - *current[2], Idx.Jz, 0 ); } void diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.H index 1efaf8319..b4d63ec81 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.H @@ -48,16 +48,9 @@ class SpectralBaseAlgorithm * (<a href="https://doi.org/10.1016/j.jcp.2013.03.010"> Vay et al, 2013</a>). * This virtual function is pure and must be defined in derived classes. * - * \param[in] lev The mesh-refinement level * \param[in,out] field_data All fields in Fourier space - * \param[in,out] current Array of unique pointers to \c MultiFab storing - * the three components of the current density - * \param[in] rho Unique pointer to \c MultiFab storing the charge density */ - virtual void CurrentCorrection (const int lev, - SpectralFieldData& field_data, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho) = 0; + virtual void CurrentCorrection (SpectralFieldData& field_data) = 0; /** * \brief Virtual function for Vay current deposition in Fourier space diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithmRZ.H b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithmRZ.H index 61b877c3e..9e7719a49 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithmRZ.H +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithmRZ.H @@ -33,15 +33,9 @@ class SpectralBaseAlgorithmRZ * (<a href="https://doi.org/10.1016/j.jcp.2013.03.010"> Vay et al, 2013</a>). * This virtual function is pure and must be defined in derived classes. * - * \param[in] lev The mesh-refinement level * \param[in,out] field_data All fields in Fourier space - * \param[in,out] current Array of unique pointers to \c MultiFab storing - * the three components of the current density - * \param[in] rho Unique pointer to \c MultiFab storing the charge density */ - virtual void CurrentCorrection ( const int lev, SpectralFieldDataRZ& field_data, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho ) = 0; + virtual void CurrentCorrection (SpectralFieldDataRZ& field_data) = 0; /** * \brief Compute spectral divergence of E diff --git a/Source/FieldSolver/SpectralSolver/SpectralSolver.H b/Source/FieldSolver/SpectralSolver/SpectralSolver.H index 78fdc16f8..0953996fa 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralSolver.H +++ b/Source/FieldSolver/SpectralSolver/SpectralSolver.H @@ -123,16 +123,10 @@ class SpectralSolver * defined in the base class SpectralBaseAlgorithm and possibly overridden * by its derived classes (e.g. PsatdAlgorithm, PsatdAlgorithmComoving, etc.), from * objects of class SpectralSolver through the private unique pointer \c algorithm - * - * \param[in] lev The mesh refinement level - * \param[in,out] current three-dimensional array of unique pointers to MultiFab - * storing the three components of the current density - * \param[in] rho unique pointer to MultiFab storing the charge density */ - void CurrentCorrection ( const int lev, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho ) { - algorithm->CurrentCorrection( lev, field_data, current, rho ); + void CurrentCorrection () + { + algorithm->CurrentCorrection(field_data); } /** diff --git a/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.H b/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.H index 9f9b8dbef..4868bd443 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.H +++ b/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.H @@ -98,14 +98,8 @@ class SpectralSolverRZ * defined in the base class SpectralBaseAlgorithmRZ and possibly overridden * by its derived classes (e.g. PsatdAlgorithmRZ), from * objects of class SpectralSolverRZ through the private unique pointer \c algorithm - * - * \param[in] lev The mesh refinement level - * \param[in,out] current two-dimensional array of unique pointers to MultiFab - * storing the three components of the current density - * \param[in] rho unique pointer to MultiFab storing the charge density */ - void CurrentCorrection (const int lev, std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho); + void CurrentCorrection (); /** * \brief Public interface to call the virtual function \c VayDeposition, diff --git a/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp index a16175b0f..0d515100a 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralSolverRZ.cpp @@ -149,16 +149,11 @@ SpectralSolverRZ::ComputeSpectralDivE (const int lev, * defined in the base class SpectralBaseAlgorithmRZ and possibly overridden * by its derived classes (e.g. PsatdAlgorithmRZ), from * objects of class SpectralSolverRZ through the private unique pointer \c algorithm - * - * \param[in,out] current two-dimensional array of unique pointers to MultiFab - * storing the three components of the current density - * \param[in] rho unique pointer to MultiFab storing the charge density */ void -SpectralSolverRZ::CurrentCorrection (const int lev, - std::array<std::unique_ptr<amrex::MultiFab>,3>& current, - const std::unique_ptr<amrex::MultiFab>& rho) { - algorithm->CurrentCorrection(lev, field_data, current, rho); +SpectralSolverRZ::CurrentCorrection () +{ + algorithm->CurrentCorrection(field_data); } void diff --git a/Source/FieldSolver/WarpXPushFieldsEM.cpp b/Source/FieldSolver/WarpXPushFieldsEM.cpp index 8537e89ce..2487ffa0c 100644 --- a/Source/FieldSolver/WarpXPushFieldsEM.cpp +++ b/Source/FieldSolver/WarpXPushFieldsEM.cpp @@ -268,6 +268,38 @@ WarpX::PSATDForwardTransformJ () #endif } +void WarpX::PSATDBackwardTransformJ () +{ + SpectralFieldIndex Idx; + int idx_jx, idx_jy, idx_jz; + + for (int lev = 0; lev <= finest_level; ++lev) + { + Idx = spectral_solver_fp[lev]->m_spectral_index; + + idx_jx = static_cast<int>(Idx.Jx); + idx_jy = static_cast<int>(Idx.Jy); + idx_jz = static_cast<int>(Idx.Jz); + + auto& current = (WarpX::do_current_centering) ? current_fp_nodal : current_fp; + + BackwardTransformVect(lev, *spectral_solver_fp[lev], current[lev], idx_jx, idx_jy, idx_jz); + + if (spectral_solver_cp[lev]) + { + Idx = spectral_solver_cp[lev]->m_spectral_index; + + idx_jx = static_cast<int>(Idx.Jx); + idx_jy = static_cast<int>(Idx.Jy); + idx_jz = static_cast<int>(Idx.Jz); + + // Current centering is not implemented with mesh refinement, so we do not yet need to + // distinguish between current_cp and current_cp_nodal, as for the fine patch currents + BackwardTransformVect(lev, *spectral_solver_cp[lev], current_cp[lev], idx_jx, idx_jy, idx_jz); + } + } +} + void WarpX::PSATDForwardTransformRho (const int icomp, const int dcomp) { @@ -303,6 +335,19 @@ WarpX::PSATDForwardTransformRho (const int icomp, const int dcomp) #endif } +void WarpX::PSATDCurrentCorrection () +{ + for (int lev = 0; lev <= finest_level; ++lev) + { + spectral_solver_fp[lev]->CurrentCorrection(); + + if (spectral_solver_cp[lev]) + { + spectral_solver_cp[lev]->CurrentCorrection(); + } + } +} + void WarpX::PSATDPushSpectralFields () { @@ -423,6 +468,14 @@ WarpX::PushPSATD () PSATDForwardTransformRho(1,1); // rho new } + // Correct the current in Fourier space so that the continuity equation is satisfied, and + // transform back to real space so that the current correction is reflected in the diagnostics + if (WarpX::current_correction) + { + PSATDCurrentCorrection(); + PSATDBackwardTransformJ(); + } + #ifdef WARPX_DIM_RZ if (pml_rz[0]) pml_rz[0]->PushPSATD(0); #endif |