Rheolef  7.1
an efficient C++ finite element environment
leveque_dg.cc
Go to the documentation of this file.
1 #include "rheolef.h"
26 using namespace rheolef;
27 using namespace std;
28 #include "leveque.h"
29 #include "bdf.icc"
30 int 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  size_t d = omega.dimension();
38  Float tf = u::period(), delta_t = tf/n_max;
39  trial phi (Xh); test xi (Xh);
40  branch event ("t","phi");
41  vector<field> phi_h (p+1);
42  phi_h[0] = phi_h[1] = interpolate (Xh, phi0(d));
43  dout << event (0, phi_h[0]);
44  for (size_t n = 1; n <= n_max; n++) {
45  Float t = n*delta_t;
46  if (n % 10 == 0) derr << "[" << n << "]";
47  size_t pn = min(n,p);
48  form an = integrate ((bdf::alpha[pn][0]/delta_t*phi + dot(u(d,t),grad_h(phi)))*xi)
49  + integrate ("internal_sides",
50  - dot(u(d,t),normal())*jump(phi)*average(xi)
51  + 0.5*abs(dot(u(d,t),normal()))*jump(phi)*jump(xi));
52  field rhs(Xh, 0);
53  for (size_t i = 1; i <= pn; i++)
54  rhs += (bdf::alpha[pn][i]/delta_t)*phi_h[i];
55  field lh = integrate(rhs*xi);
56  problem pb (an);
57  pb.solve (lh, phi_h[0]);
58  check_macro (phi_h[0].max_abs() < 100, "BDF failed -- HINT: decrease delta_t");
59  if (!strip || n == n_max) dout << event (t, phi_h[0]);
60  for (size_t i = min(p,pn+1); i >= 1; i--)
61  phi_h[i] = phi_h[i-1];
62  }
63  derr << endl;
64 }
mkgeo_ball.n
int n
Definition: mkgeo_ball.sh:150
form
see the form page for the full documentation
bdf::alpha
Float alpha[pmax+1][pmax+1]
Definition: bdf.icc:28
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
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
bdf.icc
BDF(p) backward differentiation formula – coefficients.
mkgeo_ball.d
int d
Definition: mkgeo_ball.sh:154
phi
Float phi(const point &nu, Float a, Float b)
Definition: burgers_flux_godunov.icc:25
space
see the space page for the full documentation
rheolef.h
rheolef - reference manual
p
Definition: sphere.icc:25
u::period
static Float period()
Definition: leveque.h:32
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
phi0
Definition: leveque.h:37
main
int main(int argc, char **argv)
Definition: leveque_dg.cc:30
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
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
test
see the test page for the full documentation
problem
see the problem page for the full documentation
rheolef::details::max_abs
T max_abs(const T &x)
Definition: keller_details.h:47
rheolef::derr
odiststream derr(cerr)
see the diststream page for the full documentation
Definition: diststream.h:436
Float
see the Float page for the full documentation
branch
see the branch page for the full documentation
u
Float u(const point &x)
Definition: transmission_error.cc:26
leveque.h
The Leveque benchmark – function definition.
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
rheolef::std
Definition: vec_expr_v2.h:402
bdf::pmax
constexpr size_t pmax
Definition: bdf.icc:26
geo
see the geo page for the full documentation