Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
cosinusprod_post_dg.cc
Go to the documentation of this file.
1
25#include "rheolef.h"
26using namespace rheolef;
27using namespace std;
28#include "cosinusprod.h"
29#include "cosinusprod_grad.h"
30int main(int argc, char**argv) {
31 environment rheolef(argc, argv);
32 field uh; din >> uh;
33 space Xh = uh.get_space();
34 geo omega = Xh.get_geo();
35 size_t k = Xh.degree();
36 size_t d = omega.dimension();
37 space Vh (omega, "P"+to_string(k));
38 Vh.block("boundary");
39 space Wh (omega["boundary"], "P"+to_string(k));
40 test u (Vh); trial v (Vh);
42 fopt.lump = true;
44 fopt.set_order(k);
45 form m = integrate (u*v, fopt);
46 field lh = integrate (uh*v, fopt);
47 field uh_star (Vh, 0);
48 uh_star ["boundary"] = lazy_interpolate(Wh, u_exact(d));
49 problem pm (m);
50 pm.solve (lh, uh_star);
53 iopt.set_order(2*k+1);
54 space Xh1 (omega, "P"+to_string(k+1)+"d");
56 field eh_star = lazy_interpolate (Xh1, uh_star-u_exact(d));
57 field eta_h = eh_star - eh;
58 Float err_linf = eh.max_abs();
59 Float err_star_linf = eh_star.max_abs();
60 Float eta_linf = eta_h.max_abs();
61 Float err_l2 = sqrt(integrate (omega, sqr(uh-u_exact(d)), iopt));
62 Float err_star_l2 = sqrt(integrate (omega, sqr(uh_star-u_exact(d)), iopt));
63 Float eta_l2 = sqrt(integrate (omega, sqr(eta_h), iopt));
64 Float err_h1 = sqrt(integrate (omega, norm2(grad_h(uh)-grad_u(d)), iopt));
65 Float err_star_h1 = sqrt(integrate (omega, norm2(grad(uh_star)-grad_u(d)), iopt));
66 Float eta_h1 = sqrt(integrate (omega, norm2(grad_h(eta_h)), iopt));
67 // gradient as P0
68 space G0h (omega, "P0", "vector");
69 field grad_eh = lazy_interpolate (G0h, grad_h(eh));
70 field grad_eta_h = lazy_interpolate (G0h, grad_h(eta_h));
71 // proj gradient as P1
72 space G1h (omega, "P1", "vector");
73 G1h.block("boundary");
74 test uu (G1h); trial vv (G1h);
75 form m1v = integrate(dot(uu,vv), fopt);
76 field l1h = integrate (dot(grad_eh,vv));
77 field grad_eh_p1 (G1h, 0);
78 problem pm1v (m1v);
79 pm1v.solve(l1h, grad_eh_p1);
80 field l2h = integrate (dot(grad_eta_h,vv));
81 field grad_eta_h_p1 (G1h, 0);
82 pm1v.solve(l2h, grad_eta_h_p1);
83 // calcul de s_eta_h = sqrt(int_K eta_h^2 dx) : P0
84 space X0h (omega, "P0");
85 test v0 (X0h);
86 field s_eta_h2 = integrate (sqr(eta_h)*v0);
87 field s_eta_h = lazy_interpolate (X0h, sqrt(s_eta_h2));
88 field s_eh2 = integrate (sqr(uh-u_exact(d))*v0);
89 field s_eh = lazy_interpolate (X0h, sqrt(s_eh2));
90 derr << "err_l2 = " << err_l2 << endl
91 << "eta_l2 = " << eta_l2 << endl
92 << "err_star_l2 = " << err_star_l2 << endl
93 << "err_linf = " << err_linf << endl
94 << "eta_linf = " << eta_linf << endl
95 << "err_star_linf = " << err_star_linf << endl
96 << "err_h1 = " << err_h1 << endl
97 << "eta_h1 = " << eta_h1 << endl
98 << "err_star_h1 = " << err_star_h1 << endl;
99 dout << catchmark ("grad_eta_h") << grad_eta_h_p1
100 << catchmark ("grad_eh") << grad_eh_p1
101 << catchmark ("eta_h") << eta_h
102 << catchmark ("eh") << eh
103 << catchmark ("uh") << uh
104 << catchmark ("uh_star") << uh_star
105 << catchmark ("s_eta_h") << s_eta_h
106 << catchmark ("s_eh") << s_eh
107 ;
108}
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
see the catchmark page for the full documentation
Definition catchmark.h:67
see the environment page for the full documentation
see the integrate_option page for the full documentation
void set_family(family_type type)
see the space page for the full documentation
see the test page for the full documentation
see the test page for the full documentation
The cosinus product function.
The cosinus product function – its gradient.
int main()
Definition field2bb.cc:58
space_basic< T, M > Xh1
Definition field_expr.h:232
This file is part of Rheolef.
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
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
T norm2(const vec< T, M > &x)
norm2(x): see the expression page for the full documentation
Definition vec.h:379
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_h(const Expr &expr)
grad_h(uh): 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
rheolef::std enable_if ::type dot const Expr1 expr1, const Expr2 expr2 dot(const Expr1 &expr1, const Expr2 &expr2)
STL namespace.
rheolef - reference manual
Definition leveque.h:25