Rheolef  7.1
an efficient C++ finite element environment
convect2.cc
Go to the documentation of this file.
1 // mkgeo_grid -e 1000 -a -2 -b 2 > line2.geo
26 // ./convect line2 1e-3 5 > line2.branch
27 // ./convect2 line2 1e-3 5 > line22.branch
28 // (./convect_error < line2.branch > line2-cmp.branch) 2>&1|g -v trace |g -v load |tee cv.gdat
29 // (./convect_error < line22.branch > line22-cmp.branch) 2>&1|g -v trace |g -v load |tee cv2.gdat
30 #include "rheolef.h"
31 using namespace rheolef;
32 using namespace std;
33 #include "rotating-hill.h"
34 int main (int argc, char **argv) {
35  environment rheolef (argc,argv);
36  geo omega (argv[1]);
37  string approx = (argc > 2) ? argv[2] : "P1";
38  Float nu = (argc > 3) ? atof(argv[3]) : 1e-2;
39  size_t n_max = (argc > 4) ? atoi(argv[4]) : 50;
40  size_t d = omega.dimension();
41  Float delta_t = 2*acos(-1.)/n_max;
42  space Vh (omega, approx, "vector");
43  field uh = interpolate (Vh, u(d));
44  space Xh (omega, approx);
45  Xh.block ("boundary");
46  field phi_h = interpolate (Xh, phi(d,nu,0));
47  field phi_h_prec = interpolate (Xh, phi(d,nu,0));
48  characteristic X1 ( -delta_t*uh);
49  characteristic X2 (-2*delta_t*uh);
50  integrate_option iopt;
52  iopt.set_order (Xh.degree());
53  trial varphi (Xh); test psi (Xh);
54  branch event ("t","phi");
55  dout << catchmark("nu") << nu << endl
56  << event (0, phi_h);
57  for (size_t n = 1; n <= n_max; n++) {
58  Float t = n*delta_t;
59  Float alpha = Float(1.5) + delta_t*phi::sigma(d,nu,t);
60  Float beta = delta_t*nu;
61  form c = integrate (alpha*varphi*psi + beta*dot(grad(varphi),grad(psi)), iopt);
62  field lh = integrate (omega, (2*compose(phi_h, X1) - 0.5*compose(phi_h_prec, X2))*psi, iopt);
63  phi_h_prec = phi_h;
64  problem p (c);
65  p.solve (lh, phi_h);
66  dout << event (t, phi_h);
67  }
68 }
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 characteristic 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 catchmark page for the full documentation
Definition: catchmark.h:67
see the environment page for the full documentation
Definition: environment.h:104
see the integrate_option page for the full documentation
void set_family(family_type type)
double Float
see the Float page for the full documentation
Definition: Float.h:143
odiststream dout(cout)
see the diststream page for the full documentation
Definition: diststream.h:430
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(int argc, char **argv)
Definition: convect2.cc:34
Float alpha[pmax+1][pmax+1]
Definition: bdf.icc:28
This file is part of Rheolef.
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
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
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
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
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
Float beta[][pmax+1]
rheolef - reference manual
Convection-diffusion equation – the rotating hill benchmark.
Definition: nu.h:26
Definition: sphere.icc:25
Float sigma
Float u(const point &x)