Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
leveque_dg.cc

The Leveque benchmark by discontinuous Galerkin method.

The Leveque benchmark by discontinuous Galerkin method

#include "rheolef.h"
using namespace rheolef;
using namespace std;
#include "leveque.h"
#include "bdf.icc"
int main(int argc, char**argv) {
environment rheolef (argc, argv);
geo omega (argv[1]);
space Xh (omega, argv[2]);
size_t n_max = (argc > 3) ? atoi(argv[3]) : 1000;
size_t strip = (argc > 4) ? string(argv[4]) == "true" : false;
size_t p = (argc > 5) ? atoi(argv[5]) : min(Xh.degree()+1,bdf::pmax);
size_t d = omega.dimension();
Float tf = u::period(), delta_t = tf/n_max;
trial phi (Xh); test xi (Xh);
branch event ("t","phi");
vector<field> phi_h (p+1);
phi_h[0] = phi_h[1] = lazy_interpolate (Xh, phi0(d));
dout << event (0, phi_h[0]);
for (size_t n = 1; n <= n_max; n++) {
Float t = n*delta_t;
if (n % 10 == 0) derr << "[" << n << "]";
size_t pn = min(n,p);
form an = integrate ((bdf::alpha[pn][0]/delta_t*phi + dot(u(d,t),grad_h(phi)))*xi)
+ integrate ("internal_sides",
- dot(u(d,t),normal())*jump(phi)*average(xi)
+ 0.5*abs(dot(u(d,t),normal()))*jump(phi)*jump(xi));
field rhs(Xh, 0);
for (size_t i = 1; i <= pn; i++)
rhs += (bdf::alpha[pn][i]/delta_t)*phi_h[i];
field lh = integrate(rhs*xi);
problem pb (an);
pb.solve (lh, phi_h[0]);
check_macro (phi_h[0].max_abs() < 100, "BDF failed -- HINT: decrease delta_t");
if (!strip || n == n_max) dout << event (t, phi_h[0]);
for (size_t i = min(p,pn+1); i >= 1; i--)
phi_h[i] = phi_h[i-1];
}
derr << endl;
}
BDF(p) backward differentiation formula – coefficients.
field lh(Float epsilon, Float t, const test &v)
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
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()
Definition field2bb.cc:58
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
The Leveque benchmark – function definition.
Float alpha[pmax+1][pmax+1]
Definition bdf.icc:28
constexpr size_t pmax
Definition bdf.icc:26
This file is part of Rheolef.
STL namespace.
rheolef - reference manual
Definition sphere.icc:25
Definition leveque.h:37
Definition phi.h:25
Definition leveque.h:25
static Float period()
Definition leveque.h:32