template <class P>
field tau_h0 = tau_h, uh0 = uh, ph0 = ph;
derr << "# n t rel_err residue lambda_min" << endl;
derr << "0 0 0 " << r << endl;
for (
size_t n = 1;
n <= max_iter; ++
n) {
step (tau_h0, uh0, ph0, tau_h, uh, ph);
Float rel_err_prec = rel_err, r_prec = r;
rel_err =
field(tau_h-tau_h0).max_abs() +
field(uh-uh0).max_abs();
derr <<
n <<
" " <<
n*delta_t <<
" " << rel_err <<
" " << r << endl;
if (rel_err < tol) return true;
if (rel_err_prec != 0 && ((rel_err > 10*rel_err_prec && r > 10*r_prec) ||
(rel_err > 1e5 && r > 1e5) )) return false;
tau_h0 = tau_h; uh0 = uh; ph0 = ph;
}
return (rel_err < sqrt(tol));
}
template <class P>
if (restart == "") {
uh = P::velocity_field (Xh);
s0.set_metric(mp);
} else {
idiststream in (restart, "field");
in >> catchmark("tau") >> tau_h
>> catchmark("u") >> uh
>> catchmark("p") >> ph;
}
}
template <class P>
field tau_h1 = tau_h0, uh1 = uh0, ph1 = ph0;
sub_step1 (tau_h0, uh0, ph0, tau_h1, uh1, ph1);
field tau_h2 = tau_h1, uh2 = uh1;
sub_step2 (uh0, tau_h1, uh1, tau_h2, uh2);
sub_step1 (tau_h2, uh2, ph1, tau_h, uh, ph);
}
template <class P>
update_transport_stress (uh);
ru.set_b() = 0;
return rt.u().max_abs() + ru.u().max_abs() + rp.u().max_abs();
}