Rheolef  7.1
an efficient C++ finite element environment
burgers_dg.cc
Go to the documentation of this file.
1 #include "rheolef.h"
26 using namespace rheolef;
27 using namespace std;
28 #include "harten.h"
29 #include "burgers.icc"
30 #include "burgers_flux_godunov.icc"
31 #include "runge_kutta_ssp.icc"
32 int main(int argc, char**argv) {
33  environment rheolef (argc, argv);
34  geo omega (argv[1]);
35  space Xh (omega, argv[2]);
36  Float cfl = 1;
37  limiter_option lopt;
38  size_t nmax = (argc > 3) ? atoi(argv[3]) : numeric_limits<size_t>::max();
39  Float tf = (argc > 4) ? atof(argv[4]) : 2.5;
40  size_t p = (argc > 5) ? atoi(argv[5]) : ssp::pmax;
41  lopt.M = (argc > 6) ? atoi(argv[6]) : u_init().M();
42  if (nmax == numeric_limits<size_t>::max()) {
43  nmax = (size_t)floor(1+tf/(cfl*omega.hmin()));
44  }
45  Float delta_t = tf/nmax;
46  integrate_option iopt;
47  iopt.invert = true;
48  trial u (Xh); test v (Xh);
49  form inv_m = integrate (u*v, iopt);
50  vector<field> uh(p+1, field(Xh,0));
51  uh[0] = interpolate (Xh, u_init());
52  branch even("t","u");
53  dout << catchmark("delta_t") << delta_t << endl
54  << even(0,uh[0]);
55  for (size_t n = 1; n <= nmax; ++n) {
56  for (size_t i = 1; i <= p; ++i) {
57  uh[i] = 0;
58  for (size_t j = 0; j < i; ++j) {
59  field lh =
60  - integrate (dot(compose(f,uh[j]),grad_h(v)))
61  + integrate ("internal_sides",
62  compose (phi, normal(), inner(uh[j]), outer(uh[j]))*jump(v))
63  + integrate ("boundary",
64  compose (phi, normal(), uh[j], g(n*delta_t))*v);
65  uh[i] += ssp::alpha[p][i][j]*uh[j] - delta_t*ssp::beta[p][i][j]*(inv_m*lh);
66  }
67  uh[i] = limiter(uh[i], g(n*delta_t)(point(-1)), lopt);
68  }
69  uh[0] = uh[p];
70  dout << even(n*delta_t,uh[0]);
71  }
72 }
g
u_exact g
Definition: burgers_diffusion_exact.h:33
mkgeo_ball.n
int n
Definition: mkgeo_ball.sh:150
runge_kutta_ssp.icc
The strong stability preserving Runge-Kutta scheme – coefficients.
ssp::pmax
constexpr size_t pmax
Definition: runge_kutta_ssp.icc:26
burgers_flux_godunov.icc
The Burgers equation – the Godonov flux.
ssp::alpha
Float alpha[][pmax+1][pmax+1]
Definition: runge_kutta_ssp.icc:28
form
see the form page for the full documentation
rheolef::catchmark
see the catchmark page for the full documentation
Definition: catchmark.h:67
rheolef::dot
rheolef::std enable_if ::type dot const Expr1 expr1, const Expr2 expr2 dot(const Expr1 &expr1, const Expr2 &expr2)
dot(x,y): see the expression page for the full documentation
Definition: vec_expr_v2.h:415
field
see the field page for the full documentation
rheolef::normal
details::field_expr_v2_nonlinear_terminal_function< details::normal_pseudo_function< Float > > normal()
normal: see the expression page for the full documentation
Definition: field_expr_terminal.h:439
rheolef::field
field_basic< Float > field
see the field page for the full documentation
Definition: field.h:419
phi
Definition: phi.h:25
rheolef::integrate
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
u_init
u_exact u_init
Definition: burgers_diffusion_exact.h:32
rheolef::limiter_option
see the limiter page for the full documentation
Definition: limiter.h:72
space
see the space page for the full documentation
harten.h
The Burgers problem: the Harten exact solution.
rheolef.h
rheolef - reference manual
main
int main(int argc, char **argv)
Definition: burgers_dg.cc:32
p
Definition: sphere.icc:25
rheolef::integrate_option
see the integrate_option page for the full documentation
Definition: integrate_option.h:125
ssp::beta
Float beta[][pmax+1][pmax+1]
Definition: runge_kutta_ssp.icc:40
rheolef::interpolate
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::environment
see the environment page for the full documentation
Definition: environment.h:115
lh
field lh(Float epsilon, Float t, const test &v)
Definition: burgers_diffusion_operators.icc:25
u_exact::M
Float M() const
Definition: burgers_diffusion_exact.h:29
rheolef::limiter
field_basic< T, M > limiter(const field_basic< T, M > &uh, const T &bar_g_S, const limiter_option &opt)
see the limiter page for the full documentation
Definition: limiter.cc:65
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::integrate_option::invert
bool invert
Definition: integrate_option.h:168
test
see the test page for the full documentation
u
Definition: leveque.h:25
Float
see the Float page for the full documentation
rheolef::point
point_basic< Float > point
Definition: point.h:164
rheolef::limiter_option::M
Float M
Definition: limiter.h:75
branch
see the branch page for the full documentation
u
Float u(const point &x)
Definition: transmission_error.cc:26
burgers.icc
The Burgers equation – the f function.
rheolef::compose
details::field_expr_v2_nonlinear_node_nary< typename details::function_traits< Function >::functor_type,typename details::field_expr_v2_nonlinear_terminal_wrapper_traits< Exprs >::type... > ::type compose(const Function &f, const Exprs &... exprs)
see the compose page for the full documentation
Definition: compose.h:246
rheolef::grad_h
std::enable_if< details::is_field_convertible< Expr >::value,details::field_expr_v2_nonlinear_terminal_field< typename Expr::scalar_type,typename Expr::memory_type,details::differentiate_option::gradient >>::type grad_h(const Expr &expr)
grad_h(uh): see the expression page for the full documentation
Definition: field_expr_terminal.h:949
trial
see the test page for the full documentation
rheolef::dout
odiststream dout(cout)
see the diststream page for the full documentation
Definition: diststream.h:430
f
Definition: cavity_dg.h:29
rheolef::std
Definition: vec_expr_v2.h:402
geo
see the geo page for the full documentation