Skip to content

Commit e150cad

Browse files
committed
allow for different pre and post-smoothers
1 parent 719ad00 commit e150cad

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

src/solvers/mg_solver.hpp

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ struct MGParams {
4242
int max_iters = 1000;
4343
Real residual_tolerance = 1.e-12;
4444
bool do_FAS = true;
45-
std::string smoother = "SRJ2";
45+
std::string presmoother = "SRJ2";
46+
std::string postsmoother = "SRJ2";
4647
bool two_by_two_diagonal = false;
4748
int max_coarsenings = std::numeric_limits<int>::max();
4849
std::string prolongation = "OldLinear";
@@ -53,7 +54,9 @@ struct MGParams {
5354
residual_tolerance =
5455
pin->GetOrAddReal(input_block, "residual_tolerance", residual_tolerance);
5556
do_FAS = pin->GetOrAddBoolean(input_block, "do_FAS", do_FAS);
56-
smoother = pin->GetOrAddString(input_block, "smoother", smoother);
57+
std::string smoother = pin->GetOrAddString(input_block, "smoother", "SRJ2");
58+
presmoother = pin->GetOrAddString(input_block, "presmoother", smoother);
59+
postsmoother = pin->GetOrAddString(input_block, "postsmoother", smoother);
5760
prolongation = pin->GetOrAddString(input_block, "prolongation", prolongation);
5861
two_by_two_diagonal =
5962
pin->GetOrAddBoolean(input_block, "two_by_two_diagonal", two_by_two_diagonal);
@@ -118,23 +121,24 @@ class MGSolver : public SolverBase, MGSolverCounter {
118121
} else {
119122
BCFunc = ApplyBoundaryConditionsOnCoarseOrFineMD;
120123
}
124+
125+
auto get_stages = [](const std::string &sm) {
126+
if (sm == "none") {
127+
return 0;
128+
} else if (sm == "SRJ1") {
129+
return 1;
130+
} else if (sm == "SRJ2") {
131+
return 2;
132+
} else if (sm == "SRJ3") {
133+
return 3;
134+
} else {
135+
PARTHENON_FAIL("Unknown smoother type.");
136+
}
137+
return 0;
138+
};
121139

122-
auto smoother = params_.smoother;
123-
if (smoother == "none") {
124-
pre_stages = 0;
125-
post_stages = 0;
126-
} else if (smoother == "SRJ1") {
127-
pre_stages = 1;
128-
post_stages = 1;
129-
} else if (smoother == "SRJ2") {
130-
pre_stages = 2;
131-
post_stages = 2;
132-
} else if (smoother == "SRJ3") {
133-
pre_stages = 3;
134-
post_stages = 3;
135-
} else {
136-
PARTHENON_FAIL("Unknown smoother type.");
137-
}
140+
pre_stages = get_stages(params_.presmoother);
141+
post_stages = get_stages(params_.postsmoother);
138142
}
139143

140144
void SetConstantProlongation(bool const_pro) { constant_prolongation = const_pro; }
@@ -315,7 +319,7 @@ class MGSolver : public SolverBase, MGSolverCounter {
315319
}
316320

317321
std::string GetTimeLabel(const std::string &name, const std::shared_ptr<BlockListPartition> &partition) {
318-
return GetTimeLabel(name, partition->grid.logical_level());
322+
return GetTimeLabel(name, partition->grid.multigrid_level());
319323
}
320324

321325
TaskID AddJacobiIteration(TaskList &tl, TaskID depends_on, Real omega,
@@ -370,7 +374,7 @@ class MGSolver : public SolverBase, MGSolverCounter {
370374
if (stages == 0) {
371375
return depends_on;
372376
} else if (stages == 1) {
373-
return AddJacobiIteration(tl, depends_on, 1.0, partition, pmesh, in_is_zero);
377+
return AddJacobiIteration(tl, depends_on, 0.666, partition, pmesh, in_is_zero);
374378
} else if (stages == 2) {
375379
// Damping factors from Yang & Mittal (2017)
376380
const std::array<std::array<Real, 2>, 3> omega{{{0.8723, 0.5395}, {1.3895, 0.5617}, {1.7319, 0.5695}}};

0 commit comments

Comments
 (0)