From b27deb6036cd2ccc928ce7b54e7885f916fb6cba Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Fri, 6 Mar 2026 16:45:02 +0100 Subject: [PATCH 1/4] Remove includes that are specific to tests or templates --- include/GMGPolar/igmgpolar.h | 3 --- tests/GMGPolar/convergence_order.cpp | 1 + tests/GMGPolar/solve_tests.cpp | 1 + 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/GMGPolar/igmgpolar.h b/include/GMGPolar/igmgpolar.h index 9e0d4bce..acdbf434 100644 --- a/include/GMGPolar/igmgpolar.h +++ b/include/GMGPolar/igmgpolar.h @@ -12,8 +12,6 @@ class Level; class LevelCache; #include "../InputFunctions/boundaryConditions.h" -#include "../InputFunctions/densityProfileCoefficients.h" -#include "../InputFunctions/domainGeometry.h" #include "../InputFunctions/exactSolution.h" #include "../InputFunctions/sourceTerm.h" #include "../Interpolation/interpolation.h" @@ -22,7 +20,6 @@ class LevelCache; #include "../LinearAlgebra/Vector/vector_operations.h" #include "../PolarGrid/polargrid.h" #include "../Definitions/global_definitions.h" -#include "test_cases.h" class IGMGPolar { diff --git a/tests/GMGPolar/convergence_order.cpp b/tests/GMGPolar/convergence_order.cpp index a75bbbb5..7aa4199b 100644 --- a/tests/GMGPolar/convergence_order.cpp +++ b/tests/GMGPolar/convergence_order.cpp @@ -5,6 +5,7 @@ #include #include +#include "../../include/ConfigParser/test_selection.h" #include "../../include/GMGPolar/gmgpolar.h" template diff --git a/tests/GMGPolar/solve_tests.cpp b/tests/GMGPolar/solve_tests.cpp index f7be2f40..5ab89a77 100644 --- a/tests/GMGPolar/solve_tests.cpp +++ b/tests/GMGPolar/solve_tests.cpp @@ -5,6 +5,7 @@ #include // Including the necessary header from the project +#include "../../include/ConfigParser/test_selection.h" #include "../../include/GMGPolar/gmgpolar.h" template From b8cd5e2ef79a5cdbcabc73aaf3f4e893a7de7f13 Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Mon, 9 Mar 2026 14:28:27 +0100 Subject: [PATCH 2/4] Use std::visit to resolve templates --- src/main.cpp | 109 +++++++++++++++++++++++++++------------------------ 1 file changed, 58 insertions(+), 51 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 36b3fbaa..b50c7141 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,6 @@ int main(int argc, char* argv[]) { - Kokkos::ScopeGuard kokkos_scope(argc, argv); // Initialize LIKWID markers if enabled LIKWID_INIT(); @@ -13,61 +12,69 @@ int main(int argc, char* argv[]) ConfigParser parser; parser.parse(argc, argv); - // Create GMGPolar solver - std::unique_ptr solver(parser.solver()); - - // --- General solver output and visualization settings --- // - solver->verbose(parser.verbose()); // Enable/disable verbose output - solver->paraview(parser.paraview()); // Enable/disable ParaView output - - // --- Parallelization and threading settings --- // - solver->maxOpenMPThreads(parser.maxOpenMPThreads()); // Maximum OpenMP threads to use - omp_set_num_threads(parser.maxOpenMPThreads()); // Global OpenMP thread limit - - // --- Numerical method setup --- // - solver->DirBC_Interior(parser.DirBC_Interior()); // Interior boundary conditions: Dirichlet, Across-the-origin, - solver->stencilDistributionMethod(parser.stencilDistributionMethod()); // Stencil distribution strategy: Take, Give - solver->cacheDensityProfileCoefficients( - parser.cacheDensityProfileCoefficients()); // Cache density profile coefficients: alpha, beta - solver->cacheDomainGeometry(parser.cacheDomainGeometry()); // Cache domain geometry data: arr, att, art, detDF - - // --- Multigrid settings --- // - solver->extrapolation(parser.extrapolation()); // Enable/disable extrapolation - solver->maxLevels(parser.maxLevels()); // Max multigrid levels (-1 = use deepest possible) - solver->preSmoothingSteps(parser.preSmoothingSteps()); // Smoothing before coarse-grid correction - solver->postSmoothingSteps(parser.postSmoothingSteps()); // Smoothing after coarse-grid correction - solver->multigridCycle(parser.multigridCycle()); // Multigrid cycle type - solver->FMG(parser.FMG()); // Full Multigrid mode on/off - solver->FMG_iterations(parser.FMG_iterations()); // FMG iteration count - solver->FMG_cycle(parser.FMG_cycle()); // FMG cycle type - - // --- Iterative solver controls --- // - solver->maxIterations(parser.maxIterations()); // Max number of iterations - solver->residualNormType(parser.residualNormType()); // Residual norm type (L2, weighted-L2, L∞) - solver->absoluteTolerance(parser.absoluteTolerance()); // Absolute residual tolerance - solver->relativeTolerance(parser.relativeTolerance()); // Relative residual tolerance - - // --- Finalize solver setup --- // - solver->setup(); // (allocates internal data, prepares operators, etc.) - - // --- Provide optional exact solution --- // - solver->setSolution(&parser.exactSolution()); - // --- Solve Phase --- // std::visit( - [&](auto const& boundary_condition) { - solver->solve(boundary_condition, parser.sourceTerm()); - }, - parser.boundaryConditions()); + [&parser](auto const& domain_geometry, auto const& density_profile_coeffs, auto const& boundary_condition) { + // Get the types of the domain geometry and the density profile coefficients + using DG = std::decay_t; + using DC = std::decay_t; + + // Create GMGPolar solver for the selected geometry and coefficient types + GMGPolar solver(parser.grid(), domain_geometry, density_profile_coeffs); + + // --- General solver output and visualization settings --- // + solver.verbose(parser.verbose()); // Enable/disable verbose output + solver.paraview(parser.paraview()); // Enable/disable ParaView output + + // --- Parallelization and threading settings --- // + solver.maxOpenMPThreads(parser.maxOpenMPThreads()); // Maximum OpenMP threads to use + omp_set_num_threads(parser.maxOpenMPThreads()); // Global OpenMP thread limit + + // --- Numerical method setup --- // + solver.DirBC_Interior( + parser.DirBC_Interior()); // Interior boundary conditions: Dirichlet, Across-the-origin + solver.stencilDistributionMethod( + parser.stencilDistributionMethod()); // Stencil distribution strategy: Take, Give + solver.cacheDensityProfileCoefficients( + parser.cacheDensityProfileCoefficients()); // Cache density profile coefficients: alpha, beta + solver.cacheDomainGeometry( + parser.cacheDomainGeometry()); // Cache domain geometry data: arr, att, art, detDF + + // --- Multigrid settings --- // + solver.extrapolation(parser.extrapolation()); // Enable/disable extrapolation + solver.maxLevels(parser.maxLevels()); // Max multigrid levels (-1 = use deepest possible) + solver.preSmoothingSteps(parser.preSmoothingSteps()); // Smoothing before coarse-grid correction + solver.postSmoothingSteps(parser.postSmoothingSteps()); // Smoothing after coarse-grid correction + solver.multigridCycle(parser.multigridCycle()); // Multigrid cycle type + solver.FMG(parser.FMG()); // Full Multigrid mode on/off + solver.FMG_iterations(parser.FMG_iterations()); // FMG iteration count + solver.FMG_cycle(parser.FMG_cycle()); // FMG cycle type + + // --- Iterative solver controls --- // + solver.maxIterations(parser.maxIterations()); // Max number of iterations + solver.residualNormType(parser.residualNormType()); // Residual norm type (L2, weighted-L2, L∞) + solver.absoluteTolerance(parser.absoluteTolerance()); // Absolute residual tolerance + solver.relativeTolerance(parser.relativeTolerance()); // Relative residual tolerance - // --- Retrieve solution and associated grid --- // - Vector solution = solver->solution(); - const PolarGrid& grid = solver->grid(); + // --- Finalize solver setup --- // + solver.setup(); // (allocates internal data, prepares operators, etc.) + + // --- Provide optional exact solution --- // + solver.setSolution(&parser.exactSolution()); + + // --- Solve Phase --- // + solver.solve(boundary_condition, parser.sourceTerm()); + + // --- Retrieve solution and associated grid --- // + Vector solution = solver.solution(); + const PolarGrid& grid = solver.grid(); + + // Print timing statistics for each solver phase + solver.printTimings(); + }, + parser.domainGeometry(), parser.densityProfileCoefficients(), parser.boundaryConditions()); // Finalize LIKWID performance markers LIKWID_CLOSE(); - // Print timing statistics for each solver phase - solver->printTimings(); - return 0; } From e6b32318a3bc7efe4e35c77af15e7d5c780997d2 Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Mon, 9 Mar 2026 17:55:00 +0100 Subject: [PATCH 3/4] Add include --- tests/GMGPolar/pcg_tests.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/GMGPolar/pcg_tests.cpp b/tests/GMGPolar/pcg_tests.cpp index e1e799fb..a68045bd 100644 --- a/tests/GMGPolar/pcg_tests.cpp +++ b/tests/GMGPolar/pcg_tests.cpp @@ -6,6 +6,7 @@ // Including the necessary header from the project #include "../../include/GMGPolar/gmgpolar.h" +#include "../../include/ConfigParser/test_selection.h" template class PCGTestCase; From 9df2877d4b621da5f7839b6560397c9023a28377 Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Tue, 10 Mar 2026 10:31:34 +0100 Subject: [PATCH 4/4] Put back ScopeGuard --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 1423ebfc..452a1aeb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,8 @@ int main(int argc, char* argv[]) { + Kokkos::ScopeGuard kokkos_scope(argc, argv); + // Initialize LIKWID markers if enabled LIKWID_INIT();