cosinusprod_post_dg.cc
Go to the documentation of this file.
#include "rheolef.h"
using namespace rheolef;
using namespace std;
#include "cosinusprod.h"
#include "cosinusprod_grad.h"
int main(int argc, char**argv) {
environment rheolef(argc, argv);
field uh; din >> uh;
space Xh = uh.get_space();
geo omega = Xh.get_geo();
size_t k = Xh.degree();
size_t d = omega.dimension();
space Vh (omega, "P"+itos(k));
Vh.block("boundary");
space Wh (omega["boundary"], "P"+itos(k));
test u (Vh); trial v (Vh);
integrate_option fopt;
fopt.lump = true;
fopt.set_family(integrate_option::gauss_lobatto);
fopt.set_order(k);
form m = integrate (u*v, fopt);
field lh = integrate (uh*v, fopt);
field uh_star (Vh, 0);
uh_star ["boundary"] = interpolate(Wh, u_exact(d));
problem pm (m);
pm.solve (lh, uh_star);
integrate_option iopt;
iopt.set_family(integrate_option::gauss);
iopt.set_order(2*k+1);
space Xh1 (omega, "P"+itos(k+1)+"d");
field eh = interpolate (Xh1, uh-u_exact(d));
field eh_star = interpolate (Xh1, uh_star-u_exact(d));
field eta_h = eh_star - eh;
Float err_linf = eh.max_abs();
Float err_star_linf = eh_star.max_abs();
Float eta_linf = eta_h.max_abs();
Float err_l2 = sqrt(integrate (omega, sqr(uh-u_exact(d)), iopt));
Float err_star_l2 = sqrt(integrate (omega, sqr(uh_star-u_exact(d)), iopt));
Float eta_l2 = sqrt(integrate (omega, sqr(eta_h), iopt));
Float err_h1 = sqrt(integrate (omega, norm2(grad_h(uh)-grad_u(d)), iopt));
Float err_star_h1 = sqrt(integrate (omega, norm2(grad(uh_star)-grad_u(d)), iopt));
Float eta_h1 = sqrt(integrate (omega, norm2(grad_h(eta_h)), iopt));
// gradient as P0
space G0h (omega, "P0", "vector");
field grad_eh = interpolate (G0h, grad_h(eh));
field grad_eta_h = interpolate (G0h, grad_h(eta_h));
// proj gradient as P1
space G1h (omega, "P1", "vector");
G1h.block("boundary");
test uu (G1h); trial vv (G1h);
form m1v = integrate(dot(uu,vv), fopt);
field l1h = integrate (dot(grad_eh,vv));
field grad_eh_p1 (G1h, 0);
problem pm1v (m1v);
pm1v.solve(l1h, grad_eh_p1);
field l2h = integrate (dot(grad_eta_h,vv));
field grad_eta_h_p1 (G1h, 0);
pm1v.solve(l2h, grad_eta_h_p1);
// calcul de s_eta_h = sqrt(int_K eta_h^2 dx) : P0
space X0h (omega, "P0");
test v0 (X0h);
field s_eta_h2 = integrate (sqr(eta_h)*v0);
field s_eta_h = interpolate (X0h, sqrt(s_eta_h2));
field s_eh2 = integrate (sqr(uh-u_exact(d))*v0);
field s_eh = interpolate (X0h, sqrt(s_eh2));
derr << "err_l2 = " << err_l2 << endl
<< "eta_l2 = " << eta_l2 << endl
<< "err_star_l2 = " << err_star_l2 << endl
<< "err_linf = " << err_linf << endl
<< "eta_linf = " << eta_linf << endl
<< "err_star_linf = " << err_star_linf << endl
<< "err_h1 = " << err_h1 << endl
<< "eta_h1 = " << eta_h1 << endl
<< "err_star_h1 = " << err_star_h1 << endl;
dout << catchmark ("grad_eta_h") << grad_eta_h_p1
<< catchmark ("grad_eh") << grad_eh_p1
<< catchmark ("eta_h") << eta_h
<< catchmark ("eh") << eh
<< catchmark ("uh") << uh
<< catchmark ("uh_star") << uh_star
<< catchmark ("s_eta_h") << s_eta_h
<< catchmark ("s_eh") << s_eh
;
}
Xh1
space_basic< T, M > Xh1
Definition: field_expr.h:220
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
rheolef::integrate_option::set_order
void set_order(size_t r)
Definition: integrate_option.h:254
field
see the field page for the full documentation
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::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
cosinusprod.h
The cosinus product function.
rheolef::integrate_option::lump
bool lump
Definition: integrate_option.h:168
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
rheolef::integrate_option
see the integrate_option page for the full documentation
Definition: integrate_option.h:125
rheolef::integrate_option::gauss
@ gauss
Definition: integrate_option.h:132
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
eh
field_basic< T, M > eh
Definition: form_field_expr.h:58
rheolef::din
idiststream din
see the diststream page for the full documentation
Definition: diststream.h:427
rheolef::integrate_option::gauss_lobatto
@ gauss_lobatto
Definition: integrate_option.h:133
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
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
u_exact
g u_exact
Definition: taylor_exact.h:26
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
mkgeo_ball.d
d
Definition: mkgeo_ball.sh:154
u
Float u(const point &x)
Definition: transmission_error.cc:26
grad_u
tensor grad_u
Definition: transport_tensor_exact.icc:26
cosinusprod_grad.h
The cosinus product function – its gradient.
rheolef::integrate_option::set_family
void set_family(family_type type)
Definition: integrate_option.h:260
main
int main(int argc, char **argv)
Definition: cosinusprod_post_dg.cc:30
rheolef::grad_h
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_h(const Expr &expr)
grad_h(uh): see the expression page for the full documentation
Definition: field_expr_terminal.h:949
trial
see the test page for the full documentation
rheolef::dout
odiststream dout(cout)
see the diststream page for the full documentation
Definition: diststream.h:430
rheolef::itos
std::string itos(std::string::size_type i)
itos: see the rheostream page for the full documentation
rheolef::std
Definition: vec_expr_v2.h:391
geo
see the geo page for the full documentation