From 72d4c3e50ad497e9a30d5676fe1a657113c544a6 Mon Sep 17 00:00:00 2001 From: Sebastian Grimberg Date: Tue, 12 Dec 2023 18:52:49 -0800 Subject: [PATCH] Add option to disable mesh refinement levels from MG hierarchy --- docs/src/config/solver.md | 1 + palace/utils/configfile.cpp | 3 +++ palace/utils/configfile.hpp | 4 ++++ palace/utils/geodata.cpp | 2 +- scripts/schema/config/solver.json | 1 + 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/src/config/solver.md b/docs/src/config/solver.md index 3359a4bfc..fccc7bc87 100644 --- a/docs/src/config/solver.md +++ b/docs/src/config/solver.md @@ -459,6 +459,7 @@ vectors in Krylov subspace methods or other parts of the code. ### Advanced linear solver options - `"InitialGuess" [true]` + - `"MGUseMesh" [true]` - `"MGAuxiliarySmoother" [true]` - `"MGSmoothEigScaleMax" [1.0]` - `"MGSmoothEigScaleMin" [0.0]` diff --git a/palace/utils/configfile.cpp b/palace/utils/configfile.cpp index d9c740fec..ff887fe50 100644 --- a/palace/utils/configfile.cpp +++ b/palace/utils/configfile.cpp @@ -1683,6 +1683,7 @@ void LinearSolverData::SetUp(json &solver) // Options related to multigrid. mg_max_levels = linear->value("MGMaxLevels", mg_max_levels); mg_coarsen_type = linear->value("MGCoarsenType", mg_coarsen_type); + mg_use_mesh = linear->value("MGUseMesh", mg_use_mesh); mg_cycle_it = linear->value("MGCycleIts", mg_cycle_it); mg_smooth_aux = linear->value("MGAuxiliarySmoother", mg_smooth_aux); mg_smooth_it = linear->value("MGSmoothIts", mg_smooth_it); @@ -1722,6 +1723,7 @@ void LinearSolverData::SetUp(json &solver) linear->erase("MGMaxLevels"); linear->erase("MGCoarsenType"); + linear->erase("MGUseMesh"); linear->erase("MGCycleIts"); linear->erase("MGAuxiliarySmoother"); linear->erase("MGSmoothIts"); @@ -1760,6 +1762,7 @@ void LinearSolverData::SetUp(json &solver) // std::cout << "MGMaxLevels: " << mg_max_levels << '\n'; // std::cout << "MGCoarsenType: " << mg_coarsen_type << '\n'; + // std::cout << "MGUseMesh: " << mg_use_mesh << '\n'; // std::cout << "MGCycleIts: " << mg_cycle_it << '\n'; // std::cout << "MGAuxiliarySmoother: " << mg_smooth_aux << '\n'; // std::cout << "MGSmoothIts: " << mg_smooth_it << '\n'; diff --git a/palace/utils/configfile.hpp b/palace/utils/configfile.hpp index f3ab70301..bc7070173 100644 --- a/palace/utils/configfile.hpp +++ b/palace/utils/configfile.hpp @@ -763,6 +763,10 @@ struct LinearSolverData }; MultigridCoarsenType mg_coarsen_type = MultigridCoarsenType::LOGARITHMIC; + // Controls whether or not to include in the geometric multigrid hierarchy the mesh levels + // from uniform refinement. + bool mg_use_mesh = true; + // Number of iterations for preconditioners which support it. For multigrid, this is the // number of V-cycles per Krylov solver iteration. int mg_cycle_it = 1; diff --git a/palace/utils/geodata.cpp b/palace/utils/geodata.cpp index 261d79e1a..cea8f1d68 100644 --- a/palace/utils/geodata.cpp +++ b/palace/utils/geodata.cpp @@ -199,7 +199,7 @@ void RefineMesh(const IoData &iodata, std::vector max_region_ref_levels = sphere.ref_levels; } } - if (iodata.solver.linear.mg_max_levels > 1) + if (iodata.solver.linear.mg_use_mesh && iodata.solver.linear.mg_max_levels > 1) { mesh.reserve(1 + uniform_ref_levels + max_region_ref_levels); } diff --git a/scripts/schema/config/solver.json b/scripts/schema/config/solver.json index 918efd847..167462107 100644 --- a/scripts/schema/config/solver.json +++ b/scripts/schema/config/solver.json @@ -108,6 +108,7 @@ "InitialGuess": { "type": "boolean" }, "MGMaxLevels": { "type": "integer", "minimum": 1 }, "MGCoarsenType": { "type": "string" }, + "MGUseMesh": { "type": "boolean" }, "MGAuxiliarySmoother": { "type": "boolean" }, "MGCycleIts": { "type": "integer", "exclusiveMinimum": 0 }, "MGSmoothIts": { "type": "integer", "exclusiveMinimum": 0 },