Rheolef  7.2
an efficient C++ finite element environment
reconstruction_hho_check.cc

residue check

#include "rheolef.h"
using namespace rheolef;
using namespace std;
#include "sinusprod.h"
int main(int argc, char**argv) {
Float tol = (argc > 1) ? atof(argv[1]) : 1e-15;
environment rheolef (argc, argv);
field us_h, zeta_h;
din >> catchmark("us") >> us_h
>> catchmark("zeta") >> zeta_h;
const space& Xhs = us_h.get_space();
const space& Zh = zeta_h.get_space();
const geo& omega = Xhs.get_geo();
check_macro (Xhs.degree() > 0, "invalid Xhs degree");
size_t k = Xhs.degree() - 1, d = omega.dimension();
string Pkd = "P"+to_string(k)+"d",
Pld = (argc > 2) ? argv[2] : Pkd;
space Xh (omega, Pld),
Mh (omega["sides"], Pkd);
trial u(Xh), lambda(Mh), us(Xhs), zeta (Zh);
test v(Xh), mu (Mh), vs(Xhs), xi (Zh);
integrate_option iopt;
iopt.invert = true;
form as = integrate (dot(grad_h(us),A(d)*grad_h(vs)));
form bs = integrate (us*xi);
form inv_m = integrate (u*v, iopt);
field llh = integrate(u_exact(d)*v);
field pi_Xh_u = inv_m*llh;
field pi_Mh_lambda(Mh);
problem pms (ms);
pms.solve (rhs, pi_Mh_lambda);
field lh = integrate (dot(grad_h(pi_Xh_u),A(d)*grad_h(vs))
+ on_local_sides((pi_Mh_lambda-pi_Xh_u)
*dot(normal(),A(d)*grad_h(vs))));
field kh = integrate (pi_Xh_u*xi);
field rus = as*us_h - lh;
field rz = bs*us_h - kh;
Float err_us = rus.max_abs();
Float err_z = rz.max_abs();
derr << "err_us = " << err_us << endl;
derr << "err_z = " << err_z << endl;
derr << "|zeta_h| = " << zeta_h.max_abs() << endl;
return (max(max(err_us,err_z), zeta_h.max_abs()) < tol) ? 0 : 1;
}
field lh(Float epsilon, Float t, const test &v)
see the Float 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
idiststream din(cin)
see the diststream page for the full documentation
Definition: diststream.h:464
odiststream derr(cerr)
see the diststream page for the full documentation
Definition: diststream.h:473
see the space page for the full documentation
see the test page for the full documentation
see the test page for the full documentation
Tensor diffusion – isotropic case.
point u(const point &x)
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_expr_v2_variational_arg< Expr >::value,details::field_expr_quadrature_on_sides< Expr > >::type on_local_sides(const Expr &expr)
on_local_sides(expr): 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:211
std::enable_if< details::has_field_rdof_interface< Expr >::value,details::field_expr_v2_nonlinear_terminal_field< typename Expr::scalar_type,typename Expr::memory_type,details::differentiate_option::gradient >>::type grad_h(const Expr &expr)
grad_h(uh): see the expression page for the full documentation
details::field_expr_v2_nonlinear_terminal_function< details::normal_pseudo_function< Float > > normal()
normal: see the expression page for the full documentation
int main(int argc, char **argv)
rheolef - reference manual
The sinus product function.
Definition: leveque.h:25
g u_exact
Definition: taylor_exact.h:26