The Burgers problem: the Harten exact solution at t=0.
The Burgers problem: the Harten exact solution at t=0
Float wmin = 0, wmax = 1, w0 = 0.5;
Float x_star = (x0 < 0.5) ? x0+0.5 : x0-0.5;
if (w_star > wmax) {
w0 = 0.5;
} else {
if (g_star < w_star) {
w0 = (w_star + wmin)/2;
} else {
if (w_star2 > wmax) {
w0 = (w_star + wmax)/2;
} else {
w0 = (w_star + w_star2)/2;
}
}
}
}
Float wini_list[] = {w0, wmax, wmin};
size_t i = 0;
int status = 0;
const Float tol = 1e2*numeric_limits<Float>::epsilon();
for (
Float wini : wini_list) {
if (
verbose) derr <<
"[harten] wmin="<<wmin<<
", wmax="<<wmax<<
", wini="<<wini<<endl;
if (
verbose) derr <<
"[harten] i r dw w, for t0=" <<
t0 <<
", x0="<<x0<< endl;
w = wini;
i = 0;
status = 0;
do {
if (
verbose) derr <<
"[harten] " << i <<
" " << fabs(r)
<< " " << dw << " " << w << endl;
if (fabs(r) <= tol && fabs(dw) <= tol) { break; }
if (++i >=
max_iter) { status = 1;
break; }
if (w+dw > 0 && w+dw < wmax) {
w += dw;
} else if (w+dw <= 0) {
w = (w + wmin)/2;
check_macro (1+w != w,
"Newton iteration: machine precision problem.");
} else {
w = (w + wmax)/2;
}
} while (true);
if (status == 0) break;
if (
verbose) derr <<
"[harten] failed: restart with another starting point..." << endl;
}
check_macro (status == 0,
"t = " <<
t0 <<
", x = " << x0 <<
" : Newton iteration " << i
<< ": precision " << tol << " not reached: " << fabs(r));
return (x[0] >= 0) ? w : -w;
}
protected:
};
see the Float page for the full documentation
see the point page for the full documentation
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
static const size_t max_iter
Float operator()(const point &x) const
Float df_dw(Float w, Float t, Float x) const