Loading...
Searching...
No Matches
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 lazy_interpolate (Xh, abs(uh));
return lazy_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]);
}
}
}
usage
void usage()
Definition csr.cc:261
lh
field lh(Float epsilon, Float t, const test &v)
Definition burgers_diffusion_operators.icc:25
Float
see the Float page for the full documentation
field
see the field page for the full documentation
form
see the form page for the full documentation
problem
see the problem page for the full documentation
rheolef::catchmark
see the catchmark page for the full documentation
Definition catchmark.h:67
rheolef::environment
see the environment page for the full documentation
Definition environment.h:121
rheolef::idiststream
idiststream: see the diststream page for the full documentation
Definition diststream.h:336
rheolef::idiststream::open
void open(std::string filename, std::string suffix="", const communicator &comm=communicator())
This routine opens a physical input file.
Definition diststream.cc:85
space
see the space page for the full documentation
test
see the test page for the full documentation
trial
see the test page for the full documentation
eta.h
The p-Laplacian problem – the eta function.
main
int main()
Definition field2bb.cc:58
check_macro
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
rheolef::grad
std::enable_if< details::has_field_rdof_interface< Expr >::value, details::field_expr_v2_nonlinear_terminal_field< typenameExpr::scalar_type, typenameExpr::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:930
rheolef::lazy_interpolate
field_basic< T, M > lazy_interpolate(const space_basic< T, M > &X2h, const field_basic< T, M > &u1h)
see the interpolate page for the full documentation
Definition field.h:871
rheolef::norm2
T norm2(const vec< T, M > &x)
norm2(x): see the expression page for the full documentation
Definition vec.h:379
rheolef::pow
space_mult_list< T, M > pow(const space_basic< T, M > &X, size_t n)
Definition space_mult.h:120
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:211
rheolef::dot
rheolef::std enable_if ::type dot const Expr1 expr1, const Expr2 expr2 dot(const Expr1 &expr1, const Expr2 &expr2)
Definition vec_expr_v2.h:415
rheolef::norm
T norm(const vec< T, M > &x)
norm(x): see the expression page for the full documentation
Definition vec.h:387
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:247
std
STL namespace.
residue
field residue(Float p, const field &uh)
Definition p_laplacian_post.cc:35
criteria
field criteria(Float p, const field &uh)
Definition p_laplacian_post.cc:58
check
void check(Float p, const field &uh)
Definition p_laplacian_post.cc:49
load
void load(idiststream &in, Float &p, field &uh)
Definition p_laplacian_post.cc:64
rheolef.h
rheolef - reference manual
eta
Definition eta.h:25
p
Definition sphere.icc:25
u
Definition leveque.h:25