Rheolef  7.1
an efficient C++ finite element environment
p_laplacian_post.cc
Go to the documentation of this file.
1 #include "rheolef.h"
22 using namespace rheolef;
23 using namespace std;
24 #include "eta.h"
25 void usage(string name) {
26  derr << name << ": usage: "
27  << name << " "
28  << "[-|file[.field[.gz]]] "
29  << "[-check] "
30  << "[-residue] "
31  << "[-criteria] "
32  << endl;
33  exit (1);
34 }
35 field residue (Float p, const field& uh) {
36  const space& Xh = uh.get_space();
37  trial u (Xh); test v (Xh);
38  field lh = integrate (v);
39  form m = integrate (u*v);
40  form a = integrate (compose (eta(p), norm2(grad(uh)))*dot(grad(u),grad(v)));
41  field mrh = a*uh - lh;
42  mrh["boundary"] = 0;
43  field rh (Xh);
44  problem pm (m);
45  pm.solve(mrh, rh);
46  rh["boundary"] = 0;
47  return rh;
48 }
49 void check (Float p, const field& uh) {
50  field rh = residue(p, uh);
51  const space& Xh = rh.get_space();
52  trial u (Xh); test v (Xh);
53  form m = integrate (u*v);
54  Float res = sqrt(m(rh,rh));
55  derr << "check: residue = " << res << endl;
56  check_macro (res < 1e-3, "unexpected residue");
57 }
58 field criteria (Float p, const field& uh) {
59  const space& Xh = uh.get_space();
60  if (uh.get_approx() == "P1") return interpolate (Xh, abs(uh));
61  return interpolate (Xh, pow(norm(grad(uh)), p/2));
62 }
63 void
64 load (idiststream& in, Float& p, field& uh) {
65  in >> catchmark("p") >> p
66  >> catchmark("u") >> uh;
67 }
68 int main(int argc, char**argv) {
69  environment rheolef (argc,argv);
70  if (argc < 3) usage(argv[0]);
71  Float p;
72  field uh;
73  if (string (argv[1]) == "-") {
74  load (din, p, uh);
75  } else {
76  idiststream in;
77  in.open(argv[1], "field");
78  load (in, p, uh);
79  }
80  for (int i = 2; i < argc; i++) {
81  if (strcmp (argv[i], "-check") == 0) { check (p, uh); }
82  else if (strcmp (argv[i], "-residue") == 0) { dout << catchmark("ru") << residue (p, uh); }
83  else if (strcmp (argv[i], "-criteria") == 0) { dout << catchmark("c") << criteria (p, uh); }
84  else {
85  derr << argv[0] << ": unknown option \'" << argv[i] << "'" << endl;
86  usage(argv[0]);
87  }
88  }
89 }
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
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
field
see the field page for the full documentation
residue
field residue(Float p, const field &uh)
Definition: p_laplacian_post.cc:35
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
eta
Definition: eta.h:25
space
see the space page for the full documentation
rheolef::pow
space_mult_list< T, M > pow(const space_basic< T, M > &X, size_t n)
Definition: space_mult.h:120
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::norm
T norm(const vec< T, M > &x)
norm(x): see the expression page for the full documentation
Definition: vec.h:387
eta.h
The p-Laplacian problem – the eta function.
rheolef.h
rheolef - reference manual
rheolef::norm2
T norm2(const vec< T, M > &x)
norm2(x): see the expression page for the full documentation
Definition: vec.h:379
p
Definition: sphere.icc:25
a
Definition: diffusion_isotropic.h:25
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
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
lh
field lh(Float epsilon, Float t, const test &v)
Definition: burgers_diffusion_operators.icc:25
main
int main(int argc, char **argv)
Definition: p_laplacian_post.cc:68
mkgeo_sector.m
m
Definition: mkgeo_sector.sh:118
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
usage
void usage(string name)
Definition: p_laplacian_post.cc:25
u
Float u(const point &x)
Definition: transmission_error.cc:26
load
void load(idiststream &in, Float &p, field &uh)
Definition: p_laplacian_post.cc:64
check
void check(Float p, const field &uh)
Definition: p_laplacian_post.cc:49
trial
see the test page for the full documentation
criteria
field criteria(Float p, const field &uh)
Definition: p_laplacian_post.cc:58
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
mkgeo_contraction.name
name
Definition: mkgeo_contraction.sh:133