From a0870a3063e9e655e281cc31e2d1b6580294696e Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Thu, 4 Mar 2021 13:00:13 -0800 Subject: Implement averaged algo on staggered grids & merge spectral classes (#1544) * Refactor and clean up some spectral classes * Abort when current correction or Vay deposition are not implemented * Implement general equations for averaged Galilean * Allocate averaged MultiFabs also when aux_is_nodal=1 and do_nodal=0 * Allocate +ngextra guard cells also for averaged MultiFabs * Make alias MultiFabs for averaged aux data * With averaging, interpolate from avg_fp (not fp) to aux * Fix some limits of the coefficients * Fix bug causing NaNs in spectral coefficients * Add 2D CI test with same analysis as nodal test * Add 3D CI test with same analysis as nodal test * Add limit that was not covered (knorm=0 && knorm_c!=0 && nu=0) * Allocate T2_coef only if Galilean algorithm is used * Allocate X4_coef only if Galilean algorithm is used * Remove extra ghost cell from 'avg_fp' MultiFabs --- Source/WarpX.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'Source/WarpX.cpp') diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 5d2c1e9e9..05d0c0f21 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -820,6 +820,23 @@ WarpX::ReadParameters () } } + if (current_deposition_algo == CurrentDepositionAlgo::Vay) { + if (m_v_galilean[0] != 0. || m_v_galilean[1] != 0. || m_v_galilean[2] != 0.) { + amrex::Abort("Vay current deposition not implemented for Galilean algorithms"); + } + } + + if (current_correction) { + if (m_v_galilean[0] != 0. || m_v_galilean[1] != 0. || m_v_galilean[2] != 0.) { + if (fft_do_time_averaging) { + amrex::Abort("Current correction not implemented for averaged Galilean algorithm"); + } + } + } + +# ifdef WARPX_DIM_RZ + update_with_rho = true; // Must be true for RZ PSATD +# else if (m_v_galilean[0] == 0. && m_v_galilean[1] == 0. && m_v_galilean[2] == 0. && m_v_comoving[0] == 0. && m_v_comoving[1] == 0. && m_v_comoving[2] == 0.) { update_with_rho = false; // standard PSATD @@ -827,6 +844,7 @@ WarpX::ReadParameters () else { update_with_rho = true; // Galilean PSATD or comoving PSATD } +# endif // Overwrite update_with_rho with value set in input file pp.query("update_with_rho", update_with_rho); @@ -1174,7 +1192,6 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm current_fp[lev][1] = std::make_unique(amrex::convert(ba,jy_nodal_flag),dm,ncomps,ngJ,tag("current_fp[y]")); current_fp[lev][2] = std::make_unique(amrex::convert(ba,jz_nodal_flag),dm,ncomps,ngJ,tag("current_fp[z]")); - Bfield_avg_fp[lev][0] = std::make_unique(amrex::convert(ba,Bx_nodal_flag),dm,ncomps,ngE,tag("Bfield_avg_fp[x]")); Bfield_avg_fp[lev][1] = std::make_unique(amrex::convert(ba,By_nodal_flag),dm,ncomps,ngE,tag("Bfield_avg_fp[y]")); Bfield_avg_fp[lev][2] = std::make_unique(amrex::convert(ba,Bz_nodal_flag),dm,ncomps,ngE,tag("Bfield_avg_fp[z]")); @@ -1274,6 +1291,7 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm { // Create aux multifabs on Nodal Box Array BoxArray const nba = amrex::convert(ba,IntVect::TheNodeVector()); + Bfield_aux[lev][0] = std::make_unique(nba,dm,ncomps,ngE,tag("Bfield_aux[x]")); Bfield_aux[lev][1] = std::make_unique(nba,dm,ncomps,ngE,tag("Bfield_aux[y]")); Bfield_aux[lev][2] = std::make_unique(nba,dm,ncomps,ngE,tag("Bfield_aux[z]")); @@ -1281,6 +1299,14 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm Efield_aux[lev][0] = std::make_unique(nba,dm,ncomps,ngE,tag("Efield_aux[x]")); Efield_aux[lev][1] = std::make_unique(nba,dm,ncomps,ngE,tag("Efield_aux[y]")); Efield_aux[lev][2] = std::make_unique(nba,dm,ncomps,ngE,tag("Efield_aux[z]")); + + Efield_avg_aux[lev][0] = std::make_unique(*Efield_aux[lev][0], amrex::make_alias, 0, ncomps); + Efield_avg_aux[lev][1] = std::make_unique(*Efield_aux[lev][1], amrex::make_alias, 0, ncomps); + Efield_avg_aux[lev][2] = std::make_unique(*Efield_aux[lev][2], amrex::make_alias, 0, ncomps); + + Bfield_avg_aux[lev][0] = std::make_unique(*Bfield_aux[lev][0], amrex::make_alias, 0, ncomps); + Bfield_avg_aux[lev][1] = std::make_unique(*Bfield_aux[lev][1], amrex::make_alias, 0, ncomps); + Bfield_avg_aux[lev][2] = std::make_unique(*Bfield_aux[lev][2], amrex::make_alias, 0, ncomps); } else if (lev == 0) { @@ -1302,7 +1328,6 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm Efield_aux[lev][1] = std::make_unique(amrex::convert(ba,Ey_nodal_flag),dm,ncomps,ngE,tag("Efield_aux[y]")); Efield_aux[lev][2] = std::make_unique(amrex::convert(ba,Ez_nodal_flag),dm,ncomps,ngE,tag("Efield_aux[z]")); - Bfield_avg_aux[lev][0] = std::make_unique(amrex::convert(ba,Bx_nodal_flag),dm,ncomps,ngE,tag("Bfield_avg_aux[x]")); Bfield_avg_aux[lev][1] = std::make_unique(amrex::convert(ba,By_nodal_flag),dm,ncomps,ngE,tag("Bfield_avg_aux[y]")); Bfield_avg_aux[lev][2] = std::make_unique(amrex::convert(ba,Bz_nodal_flag),dm,ncomps,ngE,tag("Bfield_avg_aux[z]")); @@ -1310,7 +1335,6 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm Efield_avg_aux[lev][0] = std::make_unique(amrex::convert(ba,Ex_nodal_flag),dm,ncomps,ngE,tag("Efield_avg_aux[x]")); Efield_avg_aux[lev][1] = std::make_unique(amrex::convert(ba,Ey_nodal_flag),dm,ncomps,ngE,tag("Efield_avg_aux[y]")); Efield_avg_aux[lev][2] = std::make_unique(amrex::convert(ba,Ez_nodal_flag),dm,ncomps,ngE,tag("Efield_avg_aux[z]")); - } // -- cgit v1.2.3