Rheolef  7.1
an efficient C++ finite element environment
convect_error.cc
Go to the documentation of this file.
1 #include "rheolef.h"
26 using namespace rheolef;
27 using namespace std;
28 #include "rotating-hill.h"
29 int main (int argc, char **argv) {
30  environment rheolef (argc,argv);
31  Float tol = (argc > 1) ? atof(argv[1]) : 1e-10;
32  Float nu;
33  din >> catchmark("nu") >> nu;
34  branch get ("t","phi");
35  branch put ("t","phi_h","pi_h_phi");
36  derr << "# t\terror_l2\terror_linf" << endl;
37  field phi_h;
38  Float err_l2_l2 = 0;
39  Float err_linf_linf = 0;
40  for (Float t = 0, t_prec = 0; din >> get (t, phi_h); t_prec = t) {
41  const space& Xh = phi_h.get_space();
42  size_t d = Xh.get_geo().dimension();
43  field pi_h_phi = interpolate (Xh, phi(d,nu,t));
44  trial phi (Xh); test psi (Xh);
45  form m = integrate (phi*psi);
46  field eh = phi_h - pi_h_phi;
47  Float err_l2 = sqrt(m(eh,eh));
48  Float err_linf = eh.max_abs();
49  err_l2_l2 += sqr(err_l2)*(t - t_prec);
50  err_linf_linf = max(err_linf_linf, err_linf);
51  dout << put (t, phi_h, pi_h_phi);
52  derr << t << "\t" << err_l2 << "\t" << err_linf << endl;
53  }
54  derr << "# error_l2_l2 = " << sqrt(err_l2_l2) << endl;
55  derr << "# error_linf_linf = " << err_linf_linf << endl;
56  return (err_linf_linf <= tol) ? 0 : 1;
57 }
Float phi(const point &nu, Float a, Float b)
see the Float page for the full documentation
see the branch page for the full documentation
see the field page for the full documentation
see the form page for the full documentation
see the catchmark page for the full documentation
Definition: catchmark.h:67
see the environment page for the full documentation
Definition: environment.h:104
T max_abs() const
Definition: field.h:731
idiststream din
see the diststream page for the full documentation
Definition: diststream.h:427
odiststream dout(cout)
see the diststream page for the full documentation
Definition: diststream.h:430
odiststream derr(cerr)
see the diststream page for the full documentation
Definition: diststream.h:436
see the space page for the full documentation
see the test page for the full documentation
see the test page for the full documentation
int main(int argc, char **argv)
field_basic< T, M > eh
This file is part of Rheolef.
void put(std::ostream &out, std::string name, const tiny_matrix< T > &a)
Definition: tiny_lu.h:155
std::enable_if< details::is_field_expr_v2_nonlinear_arg< Expr >::value &&! is_undeterminated< Result >::value, Result >::type integrate(const geo_basic< T, M > &omega, const Expr &expr, const integrate_option &iopt, Result dummy=Result())
see the integrate page for the full documentation
Definition: integrate.h:202
field_basic< T, M > interpolate(const space_basic< T, M > &V2h, const field_basic< T, M > &u1h)
see the interpolate page for the full documentation
Definition: interpolate.cc:233
rheolef - reference manual
Convection-diffusion equation – the rotating hill benchmark.
Definition: nu.h:26
Definition: phi.h:25