|
6 | 6 | int main(int argc, char* argv[]) |
7 | 7 | { |
8 | 8 | Kokkos::ScopeGuard kokkos_scope(argc, argv); |
| 9 | + |
9 | 10 | // Initialize LIKWID markers if enabled |
10 | 11 | LIKWID_INIT(); |
11 | 12 |
|
12 | 13 | // Parse command-line arguments to extract problem configuration |
13 | 14 | ConfigParser parser; |
14 | 15 | parser.parse(argc, argv); |
15 | 16 |
|
16 | | - // Create GMGPolar solver |
17 | | - std::unique_ptr<IGMGPolar> solver(parser.solver()); |
18 | | - |
19 | | - // --- General solver output and visualization settings --- // |
20 | | - solver->verbose(parser.verbose()); // Enable/disable verbose output |
21 | | - solver->paraview(parser.paraview()); // Enable/disable ParaView output |
22 | | - |
23 | | - // --- Parallelization and threading settings --- // |
24 | | - solver->maxOpenMPThreads(parser.maxOpenMPThreads()); // Maximum OpenMP threads to use |
25 | | - omp_set_num_threads(parser.maxOpenMPThreads()); // Global OpenMP thread limit |
26 | | - |
27 | | - // --- Numerical method setup --- // |
28 | | - solver->DirBC_Interior(parser.DirBC_Interior()); // Interior boundary conditions: Dirichlet, Across-the-origin, |
29 | | - solver->stencilDistributionMethod(parser.stencilDistributionMethod()); // Stencil distribution strategy: Take, Give |
30 | | - solver->cacheDensityProfileCoefficients( |
31 | | - parser.cacheDensityProfileCoefficients()); // Cache density profile coefficients: alpha, beta |
32 | | - solver->cacheDomainGeometry(parser.cacheDomainGeometry()); // Cache domain geometry data: arr, att, art, detDF |
33 | | - |
34 | | - // --- Multigrid settings --- // |
35 | | - solver->extrapolation(parser.extrapolation()); // Enable/disable extrapolation |
36 | | - solver->maxLevels(parser.maxLevels()); // Max multigrid levels (-1 = use deepest possible) |
37 | | - solver->preSmoothingSteps(parser.preSmoothingSteps()); // Smoothing before coarse-grid correction |
38 | | - solver->postSmoothingSteps(parser.postSmoothingSteps()); // Smoothing after coarse-grid correction |
39 | | - solver->multigridCycle(parser.multigridCycle()); // Multigrid cycle type |
40 | | - solver->FMG(parser.FMG()); // Full Multigrid mode on/off |
41 | | - solver->FMG_iterations(parser.FMG_iterations()); // FMG iteration count |
42 | | - solver->FMG_cycle(parser.FMG_cycle()); // FMG cycle type |
43 | | - |
44 | | - // --- Preconditioned Conjugate Gradient settings --- // |
45 | | - solver->PCG(parser.PCG()); // Preconditioned Conjugate Gradient mode on/off |
46 | | - solver->PCG_FMG(parser.PCG_FMG()); // Use FMG as preconditioner for PCG |
47 | | - solver->PCG_FMG_iterations(parser.PCG_FMG_iterations()); // FMG iterations for PCG preconditioner |
48 | | - solver->PCG_FMG_cycle(parser.PCG_FMG_cycle()); // FMG cycle type for PCG preconditioner |
49 | | - solver->PCG_MG_iterations(parser.PCG_MG_iterations()); // Multigrid iterations for PCG preconditioner |
50 | | - solver->PCG_MG_cycle(parser.PCG_MG_cycle()); // Multigrid cycle type for PCG preconditioner |
51 | | - |
52 | | - // --- Iterative solver controls --- // |
53 | | - solver->maxIterations(parser.maxIterations()); // Max number of iterations |
54 | | - solver->residualNormType(parser.residualNormType()); // Residual norm type (L2, weighted-L2, L∞) |
55 | | - solver->absoluteTolerance(parser.absoluteTolerance()); // Absolute residual tolerance |
56 | | - solver->relativeTolerance(parser.relativeTolerance()); // Relative residual tolerance |
57 | | - |
58 | | - // --- Finalize solver setup --- // |
59 | | - solver->setup(); // (allocates internal data, prepares operators, etc.) |
60 | | - |
61 | | - // --- Provide optional exact solution --- // |
62 | | - solver->setSolution(&parser.exactSolution()); |
63 | | - // --- Solve Phase --- // |
64 | 17 | std::visit( |
65 | | - [&](auto const& boundary_condition) { |
66 | | - solver->solve(boundary_condition, parser.sourceTerm()); |
| 18 | + [&parser](auto const& domain_geometry, auto const& density_profile_coeffs, auto const& boundary_condition) { |
| 19 | + // Get the types of the domain geometry and the density profile coefficients |
| 20 | + using DG = std::decay_t<decltype(domain_geometry)>; |
| 21 | + using DC = std::decay_t<decltype(density_profile_coeffs)>; |
| 22 | + |
| 23 | + // Create GMGPolar solver for the selected geometry and coefficient types |
| 24 | + GMGPolar<DG, DC> solver(parser.grid(), domain_geometry, density_profile_coeffs); |
| 25 | + |
| 26 | + // --- General solver output and visualization settings --- // |
| 27 | + solver.verbose(parser.verbose()); // Enable/disable verbose output |
| 28 | + solver.paraview(parser.paraview()); // Enable/disable ParaView output |
| 29 | + |
| 30 | + // --- Parallelization and threading settings --- // |
| 31 | + solver.maxOpenMPThreads(parser.maxOpenMPThreads()); // Maximum OpenMP threads to use |
| 32 | + omp_set_num_threads(parser.maxOpenMPThreads()); // Global OpenMP thread limit |
| 33 | + |
| 34 | + // --- Numerical method setup --- // |
| 35 | + solver.DirBC_Interior( |
| 36 | + parser.DirBC_Interior()); // Interior boundary conditions: Dirichlet, Across-the-origin |
| 37 | + solver.stencilDistributionMethod( |
| 38 | + parser.stencilDistributionMethod()); // Stencil distribution strategy: Take, Give |
| 39 | + solver.cacheDensityProfileCoefficients( |
| 40 | + parser.cacheDensityProfileCoefficients()); // Cache density profile coefficients: alpha, beta |
| 41 | + solver.cacheDomainGeometry( |
| 42 | + parser.cacheDomainGeometry()); // Cache domain geometry data: arr, att, art, detDF |
| 43 | + |
| 44 | + // --- Multigrid settings --- // |
| 45 | + solver.extrapolation(parser.extrapolation()); // Enable/disable extrapolation |
| 46 | + solver.maxLevels(parser.maxLevels()); // Max multigrid levels (-1 = use deepest possible) |
| 47 | + solver.preSmoothingSteps(parser.preSmoothingSteps()); // Smoothing before coarse-grid correction |
| 48 | + solver.postSmoothingSteps(parser.postSmoothingSteps()); // Smoothing after coarse-grid correction |
| 49 | + solver.multigridCycle(parser.multigridCycle()); // Multigrid cycle type |
| 50 | + solver.FMG(parser.FMG()); // Full Multigrid mode on/off |
| 51 | + solver.FMG_iterations(parser.FMG_iterations()); // FMG iteration count |
| 52 | + solver.FMG_cycle(parser.FMG_cycle()); // FMG cycle type |
| 53 | + |
| 54 | + // --- Preconditioned Conjugate Gradient settings --- // |
| 55 | + solver.PCG(parser.PCG()); // Preconditioned Conjugate Gradient mode on/off |
| 56 | + solver.PCG_FMG(parser.PCG_FMG()); // Use FMG as preconditioner for PCG |
| 57 | + solver.PCG_FMG_iterations(parser.PCG_FMG_iterations()); // FMG iterations for PCG preconditioner |
| 58 | + solver.PCG_FMG_cycle(parser.PCG_FMG_cycle()); // FMG cycle type for PCG preconditioner |
| 59 | + solver.PCG_MG_iterations(parser.PCG_MG_iterations()); // Multigrid iterations for PCG preconditioner |
| 60 | + solver.PCG_MG_cycle(parser.PCG_MG_cycle()); // Multigrid cycle type for PCG preconditioner |
| 61 | + |
| 62 | + // --- Iterative solver controls --- // |
| 63 | + solver.maxIterations(parser.maxIterations()); // Max number of iterations |
| 64 | + solver.residualNormType(parser.residualNormType()); // Residual norm type (L2, weighted-L2, L∞) |
| 65 | + solver.absoluteTolerance(parser.absoluteTolerance()); // Absolute residual tolerance |
| 66 | + solver.relativeTolerance(parser.relativeTolerance()); // Relative residual tolerance |
| 67 | + |
| 68 | + // --- Finalize solver setup --- // |
| 69 | + solver.setup(); // (allocates internal data, prepares operators, etc.) |
| 70 | + |
| 71 | + // --- Provide optional exact solution --- // |
| 72 | + solver.setSolution(&parser.exactSolution()); |
| 73 | + |
| 74 | + // --- Solve Phase --- // |
| 75 | + solver.solve(boundary_condition, parser.sourceTerm()); |
| 76 | + |
| 77 | + // --- Retrieve solution and associated grid --- // |
| 78 | + Vector<double> solution = solver.solution(); |
| 79 | + const PolarGrid& grid = solver.grid(); |
| 80 | + |
| 81 | + // Print timing statistics for each solver phase |
| 82 | + solver.printTimings(); |
67 | 83 | }, |
68 | | - parser.boundaryConditions()); |
69 | | - |
70 | | - // --- Retrieve solution and associated grid --- // |
71 | | - Vector<double> solution = solver->solution(); |
72 | | - const PolarGrid& grid = solver->grid(); |
| 84 | + parser.domainGeometry(), parser.densityProfileCoefficients(), parser.boundaryConditions()); |
73 | 85 |
|
74 | 86 | // Finalize LIKWID performance markers |
75 | 87 | LIKWID_CLOSE(); |
76 | 88 |
|
77 | | - // Print timing statistics for each solver phase |
78 | | - solver->printTimings(); |
79 | | - |
80 | 89 | return 0; |
81 | 90 | } |
0 commit comments