diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp | 10 | ||||
-rw-r--r-- | Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.H | 38 |
2 files changed, 36 insertions, 12 deletions
diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp index 46ac2c0b8..5b024b425 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmRZ.cpp @@ -400,7 +400,7 @@ void PsatdAlgorithmRZ::InitializeSpectralCoefficients (SpectralFieldDataRZ const if (time_averaging && J_linear) { - constexpr amrex::Real c2 = PhysConst::c; + constexpr amrex::Real c2 = PhysConst::c * PhysConst::c; const amrex::Real dt3 = dt * dt * dt; const amrex::Real om = c * k_norm; const amrex::Real om2 = om * om; @@ -408,14 +408,14 @@ void PsatdAlgorithmRZ::InitializeSpectralCoefficients (SpectralFieldDataRZ const if (om != 0.0_rt) { - X5(i,j,k) = c2 / ep0 * (S_ck(i,j,k) / om2 - (1._rt - C(i,j,k)) / (om4 * dt) + X5(i,j,k,mode) = c2 / ep0 * (S_ck(i,j,k,mode) / om2 - (1._rt - C(i,j,k,mode)) / (om4 * dt) - 0.5_rt * dt / om2); - X6(i,j,k) = c2 / ep0 * ((1._rt - C(i,j,k)) / (om4 * dt) - 0.5_rt * dt / om2); + X6(i,j,k,mode) = c2 / ep0 * ((1._rt - C(i,j,k,mode)) / (om4 * dt) - 0.5_rt * dt / om2); } else { - X5(i,j,k) = - c2 * dt3 / (8._rt * ep0); - X6(i,j,k) = - c2 * dt3 / (24._rt * ep0); + X5(i,j,k,mode) = - c2 * dt3 / (8._rt * ep0); + X6(i,j,k,mode) = - c2 * dt3 / (24._rt * ep0); } } }); diff --git a/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.H b/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.H index 58950d8af..e4d522c9f 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.H +++ b/Source/FieldSolver/SpectralSolver/SpectralFieldDataRZ.H @@ -73,9 +73,17 @@ class SpectralFieldDataRZ */ void CopySpectralDataComp (const int src_comp, const int dest_comp) { - // The last two arguments represent the number of components and - // the number of ghost cells to perform this operation - Copy(fields, fields, src_comp, dest_comp, n_rz_azimuthal_modes, 0); + // In spectral space fields of each mode are grouped together, so that the index + // of a field for a specific mode is given by field_index + mode*n_fields. + // That’s why, looping over all azimuthal modes, we need to take into account corresponding + // shift, given by imode * m_n_fields. + for (int imode=0 ; imode < n_rz_azimuthal_modes ; imode++) + { + const int shift_comp = imode * m_n_fields; + // The last two arguments represent the number of components and + // the number of ghost cells to perform this operation + Copy(fields, fields, src_comp + shift_comp, dest_comp + shift_comp, 1, 0); + } } /** @@ -85,8 +93,16 @@ class SpectralFieldDataRZ */ void ZeroOutDataComp(const int icomp) { - // The last argument represents the number of components to perform this operation - fields.setVal(0., icomp, n_rz_azimuthal_modes); + // In spectral space fields of each mode are grouped together, so that the index + // of a field for a specific mode is given by field_index + mode*n_fields. + // That’s why, looping over all azimuthal modes, we need to take into account corresponding + // shift, given by imode * m_n_fields. + for (int imode=0 ; imode < n_rz_azimuthal_modes ; imode++) + { + const int shift_comp = imode * m_n_fields; + // The last argument represents the number of components to perform this operation + fields.setVal(0., icomp + shift_comp, 1); + } } /** @@ -97,8 +113,16 @@ class SpectralFieldDataRZ */ void ScaleDataComp(const int icomp, const amrex::Real scale_factor) { - // The last argument represents the number of components to perform this operation - fields.mult(scale_factor, icomp, n_rz_azimuthal_modes); + // In spectral space fields of each mode are grouped together, so that the index + // of a field for a specific mode is given by field_index + mode*n_fields. + // That’s why, looping over all azimuthal modes, we need to take into account corresponding + // shift, given by imode * m_n_fields. + for (int imode=0 ; imode < n_rz_azimuthal_modes ; imode++) + { + const int shift_comp = imode * m_n_fields; + // The last argument represents the number of components to perform this operation + fields.mult(scale_factor, icomp + shift_comp, 1); + } } void InitFilter (amrex::IntVect const & filter_npass_each_dir, bool const compensation, |