From 65fc740e9ea6ad8e20bca20fae08b67e31db3285 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni Date: Fri, 7 Feb 2025 14:01:50 -0800 Subject: [PATCH] Remove old `multi_J` variables from WarpX class --- ...inputs_test_3d_langmuir_multi_psatd_multiJ | 5 +- Source/Evolve/WarpXEvolve.cpp | 8 +- Source/Initialization/WarpXInitData.cpp | 8 +- Source/WarpX.H | 8 +- Source/WarpX.cpp | 76 +++++++++---------- 5 files changed, 47 insertions(+), 58 deletions(-) diff --git a/Examples/Tests/langmuir/inputs_test_3d_langmuir_multi_psatd_multiJ b/Examples/Tests/langmuir/inputs_test_3d_langmuir_multi_psatd_multiJ index 764ed21a19b..fd3e373b0e1 100644 --- a/Examples/Tests/langmuir/inputs_test_3d_langmuir_multi_psatd_multiJ +++ b/Examples/Tests/langmuir/inputs_test_3d_langmuir_multi_psatd_multiJ @@ -5,10 +5,7 @@ FILE = inputs_base_3d algo.current_deposition = direct algo.maxwell_solver = psatd warpx.cfl = 0.5773502691896258 -#warpx.do_multi_J = 1 -#warpx.do_multi_J_n_depositions = 2 -#psatd.J_in_time = linear +psatd.JRhom = "LL2" psatd.solution_type = first-order psatd.update_with_rho = 1 warpx.abort_on_warning_threshold = medium -psatd.JRhom = "LL2" diff --git a/Source/Evolve/WarpXEvolve.cpp b/Source/Evolve/WarpXEvolve.cpp index b40503ac1c7..d00d899584d 100644 --- a/Source/Evolve/WarpXEvolve.cpp +++ b/Source/Evolve/WarpXEvolve.cpp @@ -199,9 +199,9 @@ WarpX::Evolve (int numsteps) PushParticlesandDeposit(cur_time, skip_deposition); } // Electromagnetic case: multi-J algorithm - else if (do_multi_J) + else if (m_JRhom) { - OneStep_multiJ(cur_time); + OneStep_JRhom(cur_time); } // Electromagnetic case: no subcycling or no mesh refinement else if ( !m_do_subcycling || (finest_level == 0)) @@ -660,7 +660,7 @@ void WarpX::SyncCurrentAndRho () } void -WarpX::OneStep_multiJ (const amrex::Real cur_time) +WarpX::OneStep_JRhom (const amrex::Real cur_time) { #ifdef WARPX_USE_FFT @@ -726,7 +726,7 @@ WarpX::OneStep_multiJ (const amrex::Real cur_time) } // Number of depositions for multi-J scheme - const int n_deposit = WarpX::do_multi_J_n_depositions; + const int n_deposit = WarpX::m_JRhom_subintervals; // Time sub-step for each multi-J deposition const amrex::Real sub_dt = dt[0] / static_cast(n_deposit); // Whether to perform multi-J depositions on a time interval that spans diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index cf452df56a2..d897cecf362 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -389,10 +389,10 @@ WarpX::PrintMainPICparameters () if (WarpX::do_divb_cleaning) { amrex::Print() << " | - div(B) cleaning is ON \n"; } - if (do_multi_J){ - amrex::Print() << " | - multi-J deposition is ON \n"; - amrex::Print() << " | - do_multi_J_n_depositions = " - << WarpX::do_multi_J_n_depositions << "\n"; + if (m_JRhom){ + amrex::Print() << " | - JRhom algorithm is ON \n"; + amrex::Print() << " | - m_JRhom_subintervals = " + << WarpX::m_JRhom_subintervals << "\n"; if (J_in_time == JInTime::Linear){ amrex::Print() << " | - J_in_time = linear \n"; } diff --git a/Source/WarpX.H b/Source/WarpX.H index dd4a92d459c..b1d896f4254 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -368,9 +368,6 @@ public: //! Specifies the type of grid used for the above sorting, i.e. cell-centered, nodal, or mixed static amrex::IntVect sort_idx_type; - static bool do_multi_J; - static int do_multi_J_n_depositions; - //! With mesh refinement, particles located inside a refinement patch, but within //! #n_field_gather_buffer cells of the edge of the patch, will gather the fields //! from the lower refinement level instead of the refinement patch itself @@ -1214,7 +1211,7 @@ private: /** * \brief Perform one PIC iteration, with the multiple J deposition per time step */ - void OneStep_multiJ (amrex::Real cur_time); + void OneStep_JRhom (amrex::Real cur_time); void RestrictCurrentFromFineToCoarsePatch ( const ablastr::fields::MultiLevelVectorField& J_fp, @@ -1789,7 +1786,8 @@ private: std::unique_ptr m_implicit_solver; // JRhom algorithm - std::string m_JRhom; + bool m_JRhom = false; + int m_JRhom_subintervals; }; #endif diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index a05a2f55032..6447b07681e 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -173,9 +173,6 @@ amrex::IntVect WarpX::sort_idx_type(AMREX_D_DECL(0,0,0)); bool WarpX::do_dynamic_scheduling = true; -bool WarpX::do_multi_J = false; -int WarpX::do_multi_J_n_depositions; - IntVect WarpX::filter_npass_each_dir(1); int WarpX::n_field_gather_buffer = -1; @@ -642,12 +639,6 @@ WarpX::ReadParameters () pp_warpx.query("verbose", verbose); utils::parser::queryWithParser(pp_warpx, "regrid_int", regrid_int); pp_warpx.query("do_subcycling", m_do_subcycling); - pp_warpx.query("do_multi_J", do_multi_J); - if (do_multi_J) - { - utils::parser::getWithParser( - pp_warpx, "do_multi_J_n_depositions", do_multi_J_n_depositions); - } pp_warpx.query("use_hybrid_QED", use_hybrid_QED); pp_warpx.query("safe_guard_cells", m_safe_guard_cells); std::vector override_sync_intervals_string_vec = {"1"}; @@ -1196,12 +1187,6 @@ WarpX::ReadParameters () "Vay deposition is implemented only for PSATD"); } - if (WarpX::current_deposition_algo == CurrentDepositionAlgo::Vay) { - WARPX_ALWAYS_ASSERT_WITH_MESSAGE( - do_multi_J == false, - "Vay deposition not implemented with multi-J algorithm"); - } - if (current_deposition_algo == CurrentDepositionAlgo::Villasenor) { WARPX_ALWAYS_ASSERT_WITH_MESSAGE( evolve_scheme == EvolveScheme::SemiImplicitEM || @@ -1498,26 +1483,19 @@ WarpX::ReadParameters () pp_psatd.query_enum_sloppy("J_in_time", J_in_time, "-_"); pp_psatd.query_enum_sloppy("rho_in_time", rho_in_time, "-_"); - if (m_psatd_solution_type != PSATDSolutionType::FirstOrder || !do_multi_J) - { - WARPX_ALWAYS_ASSERT_WITH_MESSAGE( - rho_in_time == RhoInTime::Linear, - "psatd.rho_in_time=constant not yet implemented, " - "except for psatd.solution_type=first-order and warpx.do_multi_J=1"); - } - - pp_psatd.query("JRhom", m_JRhom); - if (!m_JRhom.empty()) { - amrex::AllPrint() << "psatd.JRhom = " << m_JRhom << std::endl; - do_multi_J = true; + std::string JRhom_input; + pp_psatd.query("JRhom", JRhom_input); + if (!JRhom_input.empty()) { WARPX_ALWAYS_ASSERT_WITH_MESSAGE( - m_JRhom.length() >= 3, + JRhom_input.length() >= 3, "psatd.JRhom input string is too short to parse" ); - if (m_JRhom[0] == 'C') { + m_JRhom = true; + // parse time dependency of J from first character + if (JRhom_input[0] == 'C') { J_in_time = JInTime::Constant; } - else if (m_JRhom[0] == 'L') { + else if (JRhom_input[0] == 'L') { J_in_time = JInTime::Linear; } else { @@ -1525,10 +1503,11 @@ WarpX::ReadParameters () "Time dependency of J set by psatd.JRhom not implemented" ); } - if (m_JRhom[1] == 'C') { + // parse time dependency of rho from second character + if (JRhom_input[1] == 'C') { rho_in_time = RhoInTime::Constant; } - else if (m_JRhom[1] == 'L') { + else if (JRhom_input[1] == 'L') { rho_in_time = RhoInTime::Linear; } else { @@ -1536,13 +1515,28 @@ WarpX::ReadParameters () "Time dependency of rho set by psatd.JRhom not implemented" ); } - for (char m : m_JRhom.substr(2)) { + // parse number of subintervals from last digit + for (char m : JRhom_input.substr(2)) { WARPX_ALWAYS_ASSERT_WITH_MESSAGE( std::isdigit(m), "psatd.JRhom input string does not include integer 'm'" ); } - do_multi_J_n_depositions = std::stoi(m_JRhom.substr(2)); + m_JRhom_subintervals = std::stoi(JRhom_input.substr(2)); + } + + if (current_deposition_algo == CurrentDepositionAlgo::Vay) { + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( + m_JRhom == false, + "Vay deposition not implemented with JRhom algorithm"); + } + + if (m_psatd_solution_type != PSATDSolutionType::FirstOrder || m_JRhom == false) + { + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( + rho_in_time == RhoInTime::Linear, + "psatd.rho_in_time=constant not yet implemented, " + "except for psatd.solution_type=first-order with JRhom algorithm"); } // Current correction activated by default, unless a charge-conserving @@ -1557,8 +1551,8 @@ WarpX::ReadParameters () } // TODO Remove this default when current correction will - // be implemented for the multi-J algorithm as well. - if (do_multi_J) { current_correction = false; } + // be implemented for the JRhom algorithm as well. + if (m_JRhom) { current_correction = false; } pp_psatd.query("current_correction", current_correction); @@ -1697,7 +1691,7 @@ WarpX::ReadParameters () "psatd.update_with_rho must be equal to 1 for comoving PSATD" ); - if (do_multi_J) + if (m_JRhom) { WARPX_ALWAYS_ASSERT_WITH_MESSAGE( v_galilean_is_zero, @@ -2117,7 +2111,7 @@ WarpX::AllocLevelData (int lev, const BoxArray& ba, const DistributionMapping& d WarpX::m_v_galilean, WarpX::m_v_comoving, m_safe_guard_cells, - WarpX::do_multi_J, + WarpX::m_JRhom, WarpX::fft_do_time_averaging, ::isAnyBoundaryPML(field_boundary_lo, field_boundary_hi), WarpX::do_pml_in_domain, @@ -2468,7 +2462,7 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm if (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::PSATD) { if (do_dive_cleaning || update_with_rho || current_correction) { // For the multi-J algorithm we can allocate only one rho component (no distinction between old and new) - rho_ncomps = (WarpX::do_multi_J) ? ncomps : 2*ncomps; + rho_ncomps = (WarpX::m_JRhom) ? ncomps : 2*ncomps; } } if (rho_ncomps > 0) @@ -2858,7 +2852,7 @@ void WarpX::AllocLevelSpectralSolverRZ (amrex::Vector(WarpX::do_multi_J_n_depositions); } + if (WarpX::m_JRhom) { solver_dt /= static_cast(WarpX::m_JRhom_subintervals); } if (evolve_scheme == EvolveScheme::StrangImplicitSpectralEM) { // The step is Strang split into two half steps solver_dt /= 2.; @@ -2915,7 +2909,7 @@ void WarpX::AllocLevelSpectralSolver (amrex::Vector(WarpX::do_multi_J_n_depositions); } + if (WarpX::m_JRhom) { solver_dt /= static_cast(WarpX::m_JRhom_subintervals); } if (evolve_scheme == EvolveScheme::StrangImplicitSpectralEM) { // The step is Strang split into two half steps solver_dt /= 2.;