p_laplacian_post.cc
Go to the documentation of this file.
#include "rheolef.h"
using namespace rheolef;
using namespace std;
#include "eta.h"
void usage(string name) {
derr << name << ": usage: "
<< name << " "
<< "[-|file[.field[.gz]]] "
<< "[-check] "
<< "[-residue] "
<< "[-criteria] "
<< endl;
exit (1);
}
field residue (Float p, const field& uh) {
const space& Xh = uh.get_space();
trial u (Xh); test v (Xh);
field lh = integrate (v);
form m = integrate (u*v);
form a = integrate (compose (eta(p), norm2(grad(uh)))*dot(grad(u),grad(v)));
field mrh = a*uh - lh;
mrh["boundary"] = 0;
field rh (Xh);
problem pm (m);
pm.solve(mrh, rh);
rh["boundary"] = 0;
return rh;
}
void check (Float p, const field& uh) {
field rh = residue(p, uh);
const space& Xh = rh.get_space();
trial u (Xh); test v (Xh);
form m = integrate (u*v);
Float res = sqrt(m(rh,rh));
derr << "check: residue = " << res << endl;
check_macro (res < 1e-3, "unexpected residue");
}
field criteria (Float p, const field& uh) {
const space& Xh = uh.get_space();
if (uh.get_approx() == "P1") return interpolate (Xh, abs(uh));
return interpolate (Xh, pow(norm(grad(uh)), p/2));
}
void
load (idiststream& in, Float& p, field& uh) {
in >> catchmark("p") >> p
>> catchmark("u") >> uh;
}
int main(int argc, char**argv) {
environment rheolef (argc,argv);
if (argc < 3) usage(argv[0]);
Float p;
field uh;
if (string (argv[1]) == "-") {
load (din, p, uh);
} else {
idiststream in;
in.open(argv[1], "field");
load (in, p, uh);
}
for (int i = 2; i < argc; i++) {
if (strcmp (argv[i], "-check") == 0) { check (p, uh); }
else if (strcmp (argv[i], "-residue") == 0) { dout << catchmark("ru") << residue (p, uh); }
else if (strcmp (argv[i], "-criteria") == 0) { dout << catchmark("c") << criteria (p, uh); }
else {
derr << argv[0] << ": unknown option \'" << argv[i] << "'" << endl;
usage(argv[0]);
}
}
}
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
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
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