Rheolef  7.1
an efficient C++ finite element environment
stokes_cavity_check.cc
Go to the documentation of this file.
1 #include "rheolef.h"
22 using namespace rheolef;
23 using namespace std;
24 #include "cavity.h"
25 int main(int argc, char**argv) {
26  environment rheolef (argc, argv);
27  Float tol = (argc > 1) ? atof(argv[1]) : 1e-10;
28  field uh;
29 warning_macro("get field...");
30  din >> catchmark("u") >> uh;
31 warning_macro("get field done");
32  const space& Xh = uh.get_space();
33  const geo& omega = Xh.get_geo();
34  space Qh (omega, "P1");
35  field ph (Qh);
36  din >> catchmark("p") >> ph;
37  trial u (Xh), p (Qh); test v (Xh), q (Qh);
38  form a = integrate (2*ddot(D(u),D(v)));
39  form b = -integrate (div(u)*q);
40  form mp = integrate (p*q);
41  field m_ru = a*uh + b.trans_mult(ph);
42  field m_rp = b*uh;
43 warning_macro("field_indirect...");
44  m_ru["top"] = 0; m_ru["bottom"] = 0;
45 warning_macro("field_indirect done");
46  if (Xh.get_geo().dimension() == 3) {
47  m_ru[1]["left"] = 0; m_ru[1]["right"] = 0;
48  m_ru["front"] = 0; m_ru["back"] = 0;
49  } else {
50  m_ru["left"] = 0; m_ru["right"] = 0;
51  }
52  field rp (Qh);
53  problem pmp (mp);
54  pmp.solve (m_rp, rp);
55  Float res_u = m_ru.u().max_abs();
56  Float res_p = sqrt(mp(rp,rp));
57  Float res = max(res_u, res_p);
58  Float p_constant = mp(ph, field(Qh,1.));
59  derr << "check: residue(uh) = " << res_u << endl
60  << "check: residue(ph) = " << res_p << endl
61  << "check: residue = " << res << endl
62  << "m(p,1) = " << p_constant << endl;
63  return (res <= tol) ? 0 : 1;
64 }
rheolef::div
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::divergence >>::type div(const Expr &expr)
div(uh): see the expression page for the full documentation
Definition: field_expr_terminal.h:1031
form
see the form page for the full documentation
warning_macro
#define warning_macro(message)
Definition: dis_macros.h:53
rheolef::catchmark
see the catchmark page for the full documentation
Definition: catchmark.h:67
mkgeo_ball.b
int b
Definition: mkgeo_ball.sh:152
main
int main(int argc, char **argv)
Definition: stokes_cavity_check.cc:25
field
see the field page for the full documentation
rheolef::field
field_basic< Float > field
see the field page for the full documentation
Definition: field.h:419
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
space
see the space page for the full documentation
rheolef.h
rheolef - reference manual
p
Definition: sphere.icc:25
rheolef::ddot
T ddot(const tensor_basic< T > &a, const tensor_basic< T > &b)
ddot(x,y): see the expression page for the full documentation
Definition: tensor.cc:278
a
Definition: diffusion_isotropic.h:25
rheolef::din
idiststream din
see the diststream page for the full documentation
Definition: diststream.h:427
rheolef::environment
see the environment page for the full documentation
Definition: environment.h:115
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
u
Definition: leveque.h:25
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
cavity.h
The driven cavity benchmark: 2D boundary conditions.
rheolef::D
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 D(const Expr &expr)
D(uh): see the expression page for the full documentation.
Definition: field_expr_terminal.h:969
u
Float u(const point &x)
Definition: transmission_error.cc:26
trial
see the test page for the full documentation
rheolef::std
Definition: vec_expr_v2.h:402
geo
see the geo page for the full documentation