Rheolef  7.2
an efficient C++ finite element environment
zalesak_dg.cc
Go to the documentation of this file.
1
25#include "rheolef.h"
26using namespace rheolef;
27using namespace std;
28#include "zalesak.h"
29#include "bdf.icc"
30int main(int argc, char**argv) {
31 environment rheolef (argc, argv);
32 geo omega (argv[1]);
33 space Xh (omega, argv[2]);
34 size_t n_max = (argc > 3) ? atoi(argv[3]) : 1000;
35 size_t strip = (argc > 4) ? string(argv[4]) == "true" : false;
36 size_t p = (argc > 5) ? atoi(argv[5]) : min(Xh.degree()+1,bdf::pmax);
37 Float tf = u::period(), delta_t = tf/n_max;
38 trial phi (Xh); test xi (Xh);
39 form m = integrate (phi*xi),
40 a0 = integrate (dot(u(),grad_h(phi))*xi)
41 + integrate ("boundary", max(0, -dot(u(),normal()))*phi*xi)
42 + integrate ("internal_sides",
43 - dot(u(),normal())*jump(phi)*average(xi)
44 + 0.5*abs(dot(u(),normal()))*jump(phi)*jump(xi));
45 problem pb;
46 branch event ("t","phi");
47 vector<field> phi_h (p+1);
48 phi_h[0] = phi_h[1] = lazy_interpolate (Xh, phi0());
49 dout << event (0, phi_h[0]);
50 for (size_t n = 1; n <= n_max; n++) {
51 Float t = n*delta_t;
52 if (n % 10 == 0) derr << "[" << n << "]";
53 size_t pn = min(n,p);
54 field rhs(Xh, 0);
55 for (size_t i = 1; i <= pn; i++)
56 rhs += (bdf::alpha[pn][i]/delta_t)*phi_h[i];
57 field lh = integrate(rhs*xi)
58 + integrate("boundary", max(0,-dot(u(),normal()))*phi_exact(t)*xi);
59 if (pn <= p) {
60 form an = a0 + (bdf::alpha[pn][0]/delta_t)*m;
61 pb = problem (an);
62 }
63 pb.solve (lh, phi_h[0]);
64 check_macro (phi_h[0].max_abs() < 100, "BDF failed -- HINT: decrease delta_t");
65 if (!strip || n == n_max) dout << event (t, phi_h[0]);
66 for (size_t i = min(p,pn+1); i >= 1; i--)
67 phi_h[i] = phi_h[i-1];
68 }
69 derr << endl;
70}
BDF(p) backward differentiation formula – coefficients.
field lh(Float epsilon, Float t, const test &v)
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 geo page for the full documentation
see the problem page for the full documentation
see the environment page for the full documentation
Definition: environment.h:121
see the space page for the full documentation
see the test page for the full documentation
see the test page for the full documentation
point u(const point &x)
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
Float alpha[pmax+1][pmax+1]
Definition: bdf.icc:28
constexpr size_t pmax
Definition: bdf.icc:26
rheolef::details::is_vec dot
T max_abs(const T &x)
This file is part of Rheolef.
field_basic< T, M > lazy_interpolate(const space_basic< T, M > &X2h, const field_basic< T, M > &u1h)
see the interpolate page for the full documentation
Definition: field.h:871
std::enable_if< details::has_field_rdof_interface< Expr >::value, details::field_expr_v2_nonlinear_terminal_field< typenameExpr::scalar_type, typenameExpr::memory_type, details::differentiate_option::gradient > >::type grad_h(const Expr &expr)
grad_h(uh): see the expression page for the full documentation
details::field_expr_v2_nonlinear_terminal_function< details::normal_pseudo_function< Float > > normal()
normal: see the expression page for the full documentation
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
Definition: sphere.icc:25
Definition: leveque.h:37
Definition: phi.h:25
static Float period()
Definition: leveque.h:32
The Zalesak slotted disk benchmark – the exact solution.
int main(int argc, char **argv)
Definition: zalesak_dg.cc:30