Rheolef  7.1
an efficient C++ finite element environment
convect2.cc

Convection-diffusion equation by BDF2 scheme and the method of characteristics

// mkgeo_grid -e 1000 -a -2 -b 2 > line2.geo
// ./convect line2 1e-3 5 > line2.branch
// ./convect2 line2 1e-3 5 > line22.branch
// (./convect_error < line2.branch > line2-cmp.branch) 2>&1|g -v trace |g -v load |tee cv.gdat
// (./convect_error < line22.branch > line22-cmp.branch) 2>&1|g -v trace |g -v load |tee cv2.gdat
#include "rheolef.h"
using namespace rheolef;
using namespace std;
#include "rotating-hill.h"
int main (int argc, char **argv) {
environment rheolef (argc,argv);
geo omega (argv[1]);
string approx = (argc > 2) ? argv[2] : "P1";
Float nu = (argc > 3) ? atof(argv[3]) : 1e-2;
size_t n_max = (argc > 4) ? atoi(argv[4]) : 50;
size_t d = omega.dimension();
Float delta_t = 2*acos(-1.)/n_max;
space Vh (omega, approx, "vector");
field uh = interpolate (Vh, u(d));
space Xh (omega, approx);
Xh.block ("boundary");
field phi_h = interpolate (Xh, phi(d,nu,0));
field phi_h_prec = interpolate (Xh, phi(d,nu,0));
characteristic X1 ( -delta_t*uh);
characteristic X2 (-2*delta_t*uh);
iopt.set_order (Xh.degree());
trial varphi (Xh); test psi (Xh);
branch event ("t","phi");
dout << catchmark("nu") << nu << endl
<< event (0, phi_h);
for (size_t n = 1; n <= n_max; n++) {
Float t = n*delta_t;
Float alpha = Float(1.5) + delta_t*phi::sigma(d,nu,t);
Float beta = delta_t*nu;
form c = integrate (alpha*varphi*psi + beta*dot(grad(varphi),grad(psi)), iopt);
field lh = integrate (omega, (2*compose(phi_h, X1) - 0.5*compose(phi_h_prec, X2))*psi, iopt);
phi_h_prec = phi_h;
problem p (c);
p.solve (lh, phi_h);
dout << event (t, phi_h);
}
}
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
form
see the form page for the full documentation
bdf::alpha
Float alpha[pmax+1][pmax+1]
Definition: bdf.icc:28
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
rheolef::integrate_option::set_order
void set_order(size_t r)
Definition: integrate_option.h:254
field
see the field page for the full documentation
nu
Definition: nu.h:26
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
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
mkgeo_ball.c
c
Definition: mkgeo_ball.sh:153
rotating-hill.h
Convection-diffusion equation – the rotating hill benchmark.
rheolef::grad
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(const Expr &expr)
grad(uh): see the expression page for the full documentation
Definition: field_expr_terminal.h:911
rheolef.h
rheolef - reference manual
p
Definition: sphere.icc:25
rheolef::integrate_option
see the integrate_option page for the full documentation
Definition: integrate_option.h:125
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
main
int main(int argc, char **argv)
Definition: convect2.cc:34
psi
Definition: interpolate_RTk_polynom.icc:34
rheolef::integrate_option::gauss_lobatto
Definition: integrate_option.h:133
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
characteristic
see the characteristic page for the full documentation
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
Float
see the Float page for the full documentation
mkgeo_ball.d
d
Definition: mkgeo_ball.sh:154
branch
see the branch page for the full documentation
u
Float u(const point &x)
Definition: transmission_error.cc:26
rheolef::integrate_option::set_family
void set_family(family_type type)
Definition: integrate_option.h:260
phi::sigma
Float sigma
Definition: transport_dg_error.cc:27
mkgeo_ball.n
n
Definition: mkgeo_ball.sh:150
trial
see the test page for the full documentation
rheolef::Float
double Float
see the Float page for the full documentation
Definition: Float.h:143
rheolef::dout
odiststream dout(cout)
see the diststream page for the full documentation
Definition: diststream.h:430
rheolef::std
Definition: vec_expr_v2.h:391
geo
see the geo page for the full documentation
rk::beta
Float beta[][pmax+1]
Definition: runge_kutta_semiimplicit.icc:60