Rheolef  7.2
an efficient C++ finite element environment
zalesak_circle_dg_error.cc
Go to the documentation of this file.
1
25#include "rheolef.h"
26using namespace rheolef;
27using namespace std;
28#include "zalesak_circle.h"
29Float heaviside (const Float& x) { return (x <= 0) ? 0 : 1; }
30int main(int argc, char**argv) {
31 environment rheolef (argc, argv);
32 size_t subdivide = (argc > 1) ? atoi(argv[1]) : 1;
33 Float tol = (argc > 2) ? atof(argv[2]) : 1e-12;
34 Float meas_gamma = phi_exact(0).perimeter();
35 branch event ("t","phi");
37 iopt.set_family ("equispaced");
38 iopt.set_order (subdivide);
39 dout << setprecision(numeric_limits<Float>::digits10)
40 << "# meas_gamma = " << meas_gamma << endl
41 << "# equispaced("<<subdivide<<")" << endl
42 << "# t err_l1 v=(m-m0)/m0 m" << endl;
43 bool first = true;
44 Float t = 0, err_linf_l1 = 0, m0 = 0, v_max = 0;
45 field phi_h;
46 geo omega;
47 while (din >> event (t, phi_h)) {
48 omega = phi_h.get_geo();
49 Float err_l1 = integrate (omega, abs(compose(heaviside,phi_h)
50 - compose(heaviside,phi_exact(t))), iopt);
51 Float m = integrate (omega, 1. - compose(heaviside,phi_h), iopt);
52 if (first) {
53 m0 = m;
54 first = false;
55 }
56 Float v = (m-m0)/m0;
57 dout << t << " " << err_l1/meas_gamma
58 << " " << v << " " << m << endl;
59 err_linf_l1 = max (err_linf_l1, err_l1/meas_gamma);
60 v_max = max (v_max, abs(v));
61 }
62 dout << "# omega.size = " << omega.size() << endl
63 << "# omega.hmin = " << omega.hmin() << endl
64 << "# err_linf_l1 = " << err_linf_l1 << endl
65 << "# v_max = " << v_max << endl;
66 return (err_linf_l1 < tol && v_max < tol) ? 0 : 1;
67}
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 geo page for the full documentation
see the environment page for the full documentation
Definition: environment.h:121
see the integrate_option page for the full documentation
void set_family(family_type type)
class rheolef::details::field_expr_v2_nonlinear_node_unary compose
This file is part of Rheolef.
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:211
STL namespace.
rheolef - reference manual
Float perimeter() const
Definition: zalesak.h:82
The Zalesak full disk benchmark – the exact solution.
int main(int argc, char **argv)
Float heaviside(const Float &x)