From 97aa294586b0268ba0ca3f9f46680d5d52b02736 Mon Sep 17 00:00:00 2001 From: Roelof Groenewald <40245517+roelof-groenewald@users.noreply.github.com> Date: Mon, 6 Jan 2025 16:03:58 -0800 Subject: [PATCH] Use same MLMG parameters in MS solver as in ES solver (#5517) Fixes #5508. ~~We might not want to set the solver precision with the same values as used for the ES solver but that can be debated in this PR.~~ Note this is a patch fix until we can refactor the MS solver to separate it from the `WarpX` class. --------- Signed-off-by: roelof-groenewald --- .../MagnetostaticSolver/MagnetostaticSolver.cpp | 16 ++++++++-------- Source/WarpX.H | 1 + Source/WarpX.cpp | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp b/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp index 96e92b80359..ce39265e720 100644 --- a/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp +++ b/Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.cpp @@ -128,22 +128,22 @@ WarpX::AddMagnetostaticFieldLabFrame() // const amrex::Real magnetostatic_absolute_tolerance = self_fields_absolute_tolerance*PhysConst::c; // temporary fix!!! - const amrex::Real magnetostatic_absolute_tolerance = 0.0; - amrex::Real self_fields_required_precision; + const amrex::Real absolute_tolerance = 0.0; + amrex::Real required_precision; if constexpr (std::is_same::value) { - self_fields_required_precision = 1e-5; + required_precision = 1e-5; } else { - self_fields_required_precision = 1e-11; + required_precision = 1e-11; } - const int self_fields_max_iters = 200; - const int self_fields_verbosity = 2; + const int verbosity = 2; computeVectorPotential( m_fields.get_mr_levels_alldirs(FieldType::current_fp, finest_level), m_fields.get_mr_levels_alldirs(FieldType::vector_potential_fp_nodal, finest_level), - self_fields_required_precision, magnetostatic_absolute_tolerance, self_fields_max_iters, - self_fields_verbosity); + required_precision, absolute_tolerance, magnetostatic_solver_max_iters, + verbosity + ); } /* Compute the vector potential `A` by solving the Poisson equation with `J` as diff --git a/Source/WarpX.H b/Source/WarpX.H index 73998d6faf2..56d4f879de8 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -902,6 +902,7 @@ public: // Magnetostatic Solver Interface MagnetostaticSolver::VectorPoissonBoundaryHandler m_vector_poisson_boundary_handler; + int magnetostatic_solver_max_iters = 200; void ComputeMagnetostaticField (); void AddMagnetostaticFieldLabFrame (); void computeVectorPotential (ablastr::fields::MultiLevelVectorField const& curr, diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 965235e1078..75aa964da3a 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -684,6 +684,7 @@ WarpX::ReadParameters () poisson_solver_id!=PoissonSolverAlgo::IntegratedGreenFunction, "To use the FFT Poisson solver, compile with WARPX_USE_FFT=ON."); #endif + utils::parser::queryWithParser(pp_warpx, "self_fields_max_iters", magnetostatic_solver_max_iters); WARPX_ALWAYS_ASSERT_WITH_MESSAGE( (