aboutsummaryrefslogtreecommitdiff
path: root/Source/FieldSolver/SpectralSolver
diff options
context:
space:
mode:
Diffstat (limited to 'Source/FieldSolver/SpectralSolver')
-rw-r--r--Source/FieldSolver/SpectralSolver/SpectralAlgorithms/AvgGalileanAlgorithm.cpp14
-rw-r--r--Source/FieldSolver/SpectralSolver/SpectralAlgorithms/GalileanAlgorithm.cpp17
-rw-r--r--Source/FieldSolver/SpectralSolver/SpectralAlgorithms/GalileanPsatdAlgorithmRZ.cpp9
-rw-r--r--Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp17
-rw-r--r--Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp8
-rw-r--r--Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.cpp1
-rw-r--r--Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithmRZ.cpp7
-rw-r--r--Source/FieldSolver/SpectralSolver/SpectralHankelTransform/BesselRoots.H1
-rw-r--r--Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp2
9 files changed, 27 insertions, 49 deletions
diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/AvgGalileanAlgorithm.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/AvgGalileanAlgorithm.cpp
index de02c0970..ea381235e 100644
--- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/AvgGalileanAlgorithm.cpp
+++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/AvgGalileanAlgorithm.cpp
@@ -249,10 +249,8 @@ AvgGalileanAlgorithm::pushSpectralFields(SpectralFieldData& f) const{
Array4<const Complex> Theta2_arr = Theta2_coef[mfi].array();
Array4<const Complex> Psi1_arr = Psi1_coef[mfi].array();
Array4<const Complex> Psi2_arr = Psi2_coef[mfi].array();
- Array4<const Complex> Psi3_arr = Psi3_coef[mfi].array();
Array4<const Complex> A1_arr = A1_coef[mfi].array();
- Array4<const Complex> A2_arr = A2_coef[mfi].array();
Array4<const Complex> Rhonew_arr = Rhonew_coef[mfi].array();
Array4<const Complex> Rhoold_arr = Rhoold_coef[mfi].array();
Array4<const Complex> Jcoef_arr =Jcoef_coef[mfi].array();
@@ -284,12 +282,6 @@ AvgGalileanAlgorithm::pushSpectralFields(SpectralFieldData& f) const{
const Complex rho_old = fields(i,j,k,Idx::rho_old);
const Complex rho_new = fields(i,j,k,Idx::rho_new);
- const Complex Ex_avg = fields(i,j,k,Idx::Ex_avg);
- const Complex Ey_avg= fields(i,j,k,Idx::Ey_avg);
- const Complex Ez_avg = fields(i,j,k,Idx::Ez_avg);
- const Complex Bx_avg = fields(i,j,k,Idx::Bx_avg);
- const Complex By_avg = fields(i,j,k,Idx::By_avg);
- const Complex Bz_avg = fields(i,j,k,Idx::Bz_avg);
// k vector values, and coefficients
const Real kx = modified_kx_arr[i];
@@ -315,14 +307,11 @@ AvgGalileanAlgorithm::pushSpectralFields(SpectralFieldData& f) const{
const Complex Psi1 = Psi1_arr(i,j,k);
const Complex Psi2 = Psi2_arr(i,j,k);
- const Complex Psi3 = Psi3_arr(i,j,k);
const Complex A1 = A1_arr(i,j,k);
- const Complex A2 = A2_arr(i,j,k);
const Complex CRhoold= Rhoold_arr(i,j,k);
const Complex CRhonew= Rhonew_arr(i,j,k);
const Complex Jcoef = Jcoef_arr(i,j,k);
-
//Update E (see the original Galilean article)
fields(i,j,k,Idx::Ex) = T2*C*Ex_old
+ T2*S_ck*c2*I*(ky*Bz_old - kz*By_old)
@@ -333,6 +322,7 @@ AvgGalileanAlgorithm::pushSpectralFields(SpectralFieldData& f) const{
fields(i,j,k,Idx::Ez) = T2*C*Ez_old
+ T2*S_ck*c2*I*(kx*By_old - ky*Bx_old)
+ X4*Jz - I*(X2*rho_new - T2*X3*rho_old)*kz;
+
// Update B (see the original Galilean article)
// Note: here X1 is T2*x1/(ep0*c*c*k_norm*k_norm), where
// x1 has the same definition as in the original paper
@@ -346,7 +336,7 @@ AvgGalileanAlgorithm::pushSpectralFields(SpectralFieldData& f) const{
- T2*S_ck*I*(kx*Ey_old - ky*Ex_old)
+ X1*I*(kx*Jy - ky*Jx);
-//Update the averaged E,B fields in time on the interval [(n-1/2)dx, (n+1/2)dx]
+ //Update the averaged E,B fields in time on the interval [(n-1/2)dx, (n+1/2)dx]
fields(i,j,k,Idx::Ex_avg) = Psi1*Ex_old
- Psi2*c2*I*(ky*Bz_old - kz*By_old)
+ Jcoef*Jx + ( CRhonew * rho_new + CRhoold*rho_old )*kx;
diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/GalileanAlgorithm.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/GalileanAlgorithm.cpp
index e969fd6cf..0757d17cd 100644
--- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/GalileanAlgorithm.cpp
+++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/GalileanAlgorithm.cpp
@@ -17,10 +17,10 @@ GalileanAlgorithm::GalileanAlgorithm(const SpectralKSpace& spectral_kspace,
const Real dt,
const bool update_with_rho)
// Initialize members of base class
- : m_v_galilean(v_galilean),
+ : SpectralBaseAlgorithm(spectral_kspace, dm, norder_x, norder_y, norder_z, nodal),
+ m_v_galilean(v_galilean),
m_dt(dt),
- m_update_with_rho(update_with_rho),
- SpectralBaseAlgorithm(spectral_kspace, dm, norder_x, norder_y, norder_z, nodal)
+ m_update_with_rho(update_with_rho)
{
const BoxArray& ba = spectral_kspace.spectralspace_ba;
@@ -34,7 +34,7 @@ GalileanAlgorithm::GalileanAlgorithm(const SpectralKSpace& spectral_kspace,
Theta2_coef = SpectralComplexCoefficients(ba, dm, 1, 0);
InitializeSpectralCoefficients(spectral_kspace, dm, dt);
-};
+}
/* Advance the E and B field in spectral space (stored in `f`) over one time step */
void
@@ -152,7 +152,7 @@ GalileanAlgorithm::pushSpectralFields (SpectralFieldData& f) const
fields(i,j,k,Idx::Bz) = T2*C*Bz_old - T2*S_ck*I*(kx*Ey_old - ky*Ex_old) + X1*I*(kx*Jy - ky*Jx);
});
}
-};
+}
void GalileanAlgorithm::InitializeSpectralCoefficients (const SpectralKSpace& spectral_kspace,
const amrex::DistributionMapping& dm,
@@ -421,9 +421,6 @@ GalileanAlgorithm::CurrentCorrection (SpectralFieldData& field_data,
// Loop over indices within one box
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
{
- // Record old values of the fields to be updated
- using Idx = SpectralFieldIndex;
-
// Shortcuts for the values of J and rho
const Complex Jx = fields(i,j,k,Idx::Jx);
const Complex Jy = fields(i,j,k,Idx::Jy);
@@ -476,8 +473,8 @@ GalileanAlgorithm::CurrentCorrection (SpectralFieldData& field_data,
}
void
-GalileanAlgorithm::VayDeposition (SpectralFieldData& field_data,
- std::array<std::unique_ptr<amrex::MultiFab>,3>& current)
+GalileanAlgorithm::VayDeposition (SpectralFieldData& /*field_data*/,
+ std::array<std::unique_ptr<amrex::MultiFab>,3>& /*current*/)
{
amrex::Abort("Vay deposition not implemented for Galilean PSATD");
}
diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/GalileanPsatdAlgorithmRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/GalileanPsatdAlgorithmRZ.cpp
index ed54dd21f..dab4b7428 100644
--- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/GalileanPsatdAlgorithmRZ.cpp
+++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/GalileanPsatdAlgorithmRZ.cpp
@@ -117,7 +117,6 @@ GalileanPsatdAlgorithmRZ::pushSpectralFields (SpectralFieldDataRZ & f)
amrex::Real const kz = modified_kz_arr[j];
constexpr amrex::Real c2 = PhysConst::c*PhysConst::c;
- constexpr amrex::Real inv_ep0 = 1._rt/PhysConst::ep0;
Complex const I = Complex{0._rt,1._rt};
amrex::Real const C = C_arr(i,j,k,mode);
amrex::Real const S_ck = S_ck_arr(i,j,k,mode);
@@ -151,7 +150,7 @@ GalileanPsatdAlgorithmRZ::pushSpectralFields (SpectralFieldDataRZ & f)
+ X1*I*(kr*Jp + kr*Jm);
});
}
-};
+}
void GalileanPsatdAlgorithmRZ::InitializeSpectralCoefficients (SpectralFieldDataRZ const & f)
{
@@ -300,9 +299,7 @@ GalileanPsatdAlgorithmRZ::CurrentCorrection (SpectralFieldDataRZ& field_data,
ParallelFor(bx, modes,
[=] AMREX_GPU_DEVICE(int i, int j, int k, int mode) noexcept
{
-
// All of the fields of each mode are grouped together
- using Idx = SpectralFieldIndex;
auto const Jp_m = Idx::Jx + Idx::n_fields*mode;
auto const Jm_m = Idx::Jy + Idx::n_fields*mode;
auto const Jz_m = Idx::Jz + Idx::n_fields*mode;
@@ -348,8 +345,8 @@ GalileanPsatdAlgorithmRZ::CurrentCorrection (SpectralFieldDataRZ& field_data,
}
void
-GalileanPsatdAlgorithmRZ::VayDeposition (SpectralFieldDataRZ& field_data,
- std::array<std::unique_ptr<amrex::MultiFab>,3>& current)
+GalileanPsatdAlgorithmRZ::VayDeposition (SpectralFieldDataRZ& /*field_data*/,
+ std::array<std::unique_ptr<amrex::MultiFab>,3>& /*current*/)
{
amrex::Abort("Vay deposition not implemented in RZ geometry");
}
diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp
index 631004325..ce0f466aa 100644
--- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp
+++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp
@@ -24,9 +24,9 @@ PsatdAlgorithm::PsatdAlgorithm(const SpectralKSpace& spectral_kspace,
const int norder_z, const bool nodal, const Real dt,
const bool update_with_rho)
// Initialize members of base class
- : m_dt( dt ),
- m_update_with_rho( update_with_rho ),
- SpectralBaseAlgorithm( spectral_kspace, dm, norder_x, norder_y, norder_z, nodal )
+ : SpectralBaseAlgorithm(spectral_kspace, dm, norder_x, norder_y, norder_z, nodal),
+ m_dt(dt),
+ m_update_with_rho(update_with_rho)
{
const BoxArray& ba = spectral_kspace.spectralspace_ba;
@@ -144,7 +144,7 @@ PsatdAlgorithm::pushSpectralFields(SpectralFieldData& f) const{
fields(i,j,k,Idx::Bz) = C*Bz_old - S_ck*I*(kx*Ey_old-ky*Ex_old) + X1*I*(kx*Jy-ky*Jx);
} );
}
-};
+}
/**
* \brief Initialize coefficients for update equations
@@ -256,8 +256,6 @@ PsatdAlgorithm::CurrentCorrection (SpectralFieldData& field_data,
// Loop over indices within one box
ParallelFor( bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
{
- using Idx = SpectralFieldIndex;
-
// Shortcuts for the values of J and rho
const Complex Jx = fields(i,j,k,Idx::Jx);
const Complex Jy = fields(i,j,k,Idx::Jy);
@@ -330,11 +328,11 @@ PsatdAlgorithm::VayDeposition (SpectralFieldData& field_data,
// Loop over indices within one box
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
{
- using Idx = SpectralFieldIndex;
-
// Shortcuts for the values of D
const Complex Dx = fields(i,j,k,Idx::Jx);
+#if (AMREX_SPACEDIM==3)
const Complex Dy = fields(i,j,k,Idx::Jy);
+#endif
const Complex Dz = fields(i,j,k,Idx::Jz);
// Imaginary unit
@@ -346,8 +344,7 @@ PsatdAlgorithm::VayDeposition (SpectralFieldData& field_data,
const amrex::Real ky_mod = modified_ky_arr[j];
const amrex::Real kz_mod = modified_kz_arr[k];
#else
- constexpr amrex::Real ky_mod = 0._rt;
- const amrex::Real kz_mod = modified_kz_arr[j];
+ const amrex::Real kz_mod = modified_kz_arr[j];
#endif
// Compute Jx
diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp
index 496470912..7cd230581 100644
--- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp
+++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp
@@ -141,7 +141,7 @@ PsatdAlgorithmRZ::pushSpectralFields(SpectralFieldDataRZ & f)
+ X1*I*(kr*Jp + kr*Jm);
});
}
-};
+}
void PsatdAlgorithmRZ::InitializeSpectralCoefficients (SpectralFieldDataRZ const & f)
{
@@ -238,9 +238,7 @@ PsatdAlgorithmRZ::CurrentCorrection (SpectralFieldDataRZ& field_data,
ParallelFor(bx, modes,
[=] AMREX_GPU_DEVICE(int i, int j, int k, int mode) noexcept
{
-
// All of the fields of each mode are grouped together
- using Idx = SpectralFieldIndex;
auto const Jp_m = Idx::Jx + Idx::n_fields*mode;
auto const Jm_m = Idx::Jy + Idx::n_fields*mode;
auto const Jz_m = Idx::Jz + Idx::n_fields*mode;
@@ -282,8 +280,8 @@ PsatdAlgorithmRZ::CurrentCorrection (SpectralFieldDataRZ& field_data,
}
void
-PsatdAlgorithmRZ::VayDeposition (SpectralFieldDataRZ& field_data,
- std::array<std::unique_ptr<amrex::MultiFab>,3>& current)
+PsatdAlgorithmRZ::VayDeposition (SpectralFieldDataRZ& /*field_data*/,
+ std::array<std::unique_ptr<amrex::MultiFab>,3>& /*current*/)
{
amrex::Abort("Vay deposition not implemented in RZ geometry");
}
diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.cpp
index 3354384f0..46e9b50f7 100644
--- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.cpp
+++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithm.cpp
@@ -43,7 +43,6 @@ SpectralBaseAlgorithm::ComputeSpectralDivE (
ParallelFor(bx,
[=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
{
- using Idx = SpectralFieldIndex;
// Shortcuts for the components of E
const Complex Ex = fields(i,j,k,Idx::Ex);
const Complex Ey = fields(i,j,k,Idx::Ey);
diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithmRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithmRZ.cpp
index 679fc5fba..4609b7177 100644
--- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithmRZ.cpp
+++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/SpectralBaseAlgorithmRZ.cpp
@@ -36,8 +36,7 @@ SpectralBaseAlgorithmRZ::ComputeSpectralDivE (
Array4<Complex> fields = field_data.fields[mfi].array();
// Extract pointers for the k vectors
- auto const & kr = field_data.getKrArray(mfi);
- Real const * kr_arr = kr.dataPtr();
+ Real const * kr_arr = field_data.getKrArray(mfi).dataPtr();
Real const * modified_kz_arr = modified_kz_vec[mfi].dataPtr();
int const nr = bx.length(0);
@@ -46,7 +45,7 @@ SpectralBaseAlgorithmRZ::ComputeSpectralDivE (
// Loop over indices within one box
ParallelFor(bx, modes,
- [=] AMREX_GPU_DEVICE(int i, int j, int k, int mode) noexcept
+ [=] AMREX_GPU_DEVICE(int i, int j, int /*k*/, int mode) noexcept
{
int const ic1 = Idx::Ex + mode*n_fields;
int const ic2 = Idx::Ey + mode*n_fields;
@@ -71,4 +70,4 @@ SpectralBaseAlgorithmRZ::ComputeSpectralDivE (
// Backward Fourier transform
field_data.BackwardTransform( divE, Idx::divE, 0 );
-};
+}
diff --git a/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/BesselRoots.H b/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/BesselRoots.H
index 8f569ec4e..a44d192fb 100644
--- a/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/BesselRoots.H
+++ b/Source/FieldSolver/SpectralSolver/SpectralHankelTransform/BesselRoots.H
@@ -133,6 +133,7 @@ void SecantRootFinder(int n, int nitmx, amrex::Real tol, amrex::Real *zeroj, int
c[1] = 0.999_rt;
*ier = 0;
+ p = *zeroj;
for (int ntry=0 ; ntry <= 1 ; ntry++) {
p0 = c[ntry]*(*zeroj);
diff --git a/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp b/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp
index 7515f59c6..d907152dc 100644
--- a/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp
+++ b/Source/FieldSolver/SpectralSolver/SpectralKSpace.cpp
@@ -194,7 +194,7 @@ SpectralKSpace::getModifiedKComponent( const DistributionMapping& dm,
// Allocate modified_k to the same size as k
const int N = k.size();
- modified_k.resize( k.size() );
+ modified_k.resize(N);
// Fill the modified k vector
Gpu::copyAsync(Gpu::deviceToDevice, k.begin(), k.end(), modified_k.begin());