Skip to content

Commit a3553f7

Browse files
committed
encap: Compute relative residuals as well.
Signed-off-by: Matthew Emmett <[email protected]>
1 parent d7fe9ac commit a3553f7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

include/pfasst/encap/encap_sweeper.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,21 +242,21 @@ namespace pfasst
242242
{
243243
if (this->abs_residual_tol > 0.0 || this->rel_residual_tol > 0.0) {
244244
if (this->residuals.size() == 0) {
245-
for (auto x: this->get_nodes()) {
246-
UNUSED(x);
245+
for (size_t m = 0; m < this->get_nodes().size(); m++) {
247246
this->residuals.push_back(this->get_factory()->create(pfasst::encap::solution));
248247
}
249248
}
250249
this->residual(this->get_controller()->get_time_step(), this->residuals);
251-
vector<time> rnorms;
252-
for (auto r: this->residuals) {
253-
rnorms.push_back(r->norm0());
250+
vector<time> anorms, rnorms;
251+
for (size_t m = 0; m < this->get_nodes().size(); m++) {
252+
anorms.push_back(this->residuals[m]->norm0());
253+
rnorms.push_back(anorms.back() / this->get_state(m)->norm0());
254254
}
255+
auto amax = *std::max_element(anorms.begin(), anorms.end());
255256
auto rmax = *std::max_element(rnorms.begin(), rnorms.end());
256-
if (rmax < this->abs_residual_tol) {
257+
if (amax < this->abs_residual_tol || rmax < this->rel_residual_tol) {
257258
return true;
258259
}
259-
// XXX: check rel norms too
260260
}
261261
return false;
262262
}

0 commit comments

Comments
 (0)