Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
dirichlet_hho_v2.cc
Go to the documentation of this file.
1
25#include "rheolef.h"
26using namespace rheolef;
27using namespace std;
28#include "sinusprod_dirichlet.h"
29#include "diffusion_isotropic.h"
30int main(int argc, char**argv) {
31 environment rheolef (argc, argv);
32 geo omega (argv[1]);
33 string Pkd = (argc > 2) ? argv[2] : "P1d",
34 Pld = (argc > 3) ? argv[3] : Pkd;
35 space Xh (omega, Pld),
36 Mh (omega["sides"], Pkd);
37 Mh.block("boundary");
38 size_t k = Xh.degree(), l = Mh.degree(), d = omega.dimension();
39 Float beta = (argc > 4) ? atof(argv[4]) : 10*(k+1)*(k+d)/Float(d);
40 check_macro(l == k-1 || l == k || l == k+1,
41 "invalid (k,l) = ("<<k<<","<<l<<")");
42 space Xhs(omega, "P"+to_string(k+1)+"d"),
43 Zh (omega, "P0"),
44 Mht(omega, "trace_n(RT"+to_string(k)+"d)");
45 space Yh = Xh*Xhs*Xh*Mht*Xhs*Zh*Xh*Mht*Zh;
46 trial x(Yh), lambda(Mh);
47 test y(Yh), mu(Mh);
48 auto u = x[0], us = x[1], ut = x[2], deltat = x[3], vs = x[4];
49 auto w = y[0], ws = y[1], wt = y[2], phit = y[3], ys = y[4];
50 auto zeta1 = x[5], vt = x[6], gammat = x[7], zeta2 = x[8];
51 auto xi1 = y[5], yt = y[6], kappat = y[7], xi2 = y[8];
53 iopt.invert = true;
54 auto gamma = pow(h_local(),2);
55 auto a_expr = dot(grad_h(us),A(d)*grad_h(ws))
56 + dot(grad_h(us)-grad_h(u),A(d)*grad_h(ys))
57 + dot(grad_h(ws)-grad_h(w),A(d)*grad_h(vs))
58 + (us-u)*xi1 + (ws-w)*zeta1 - gamma*zeta1*xi1
59 + (us-ut)*yt + (ws-wt)*vt
60 + vs*xi2 + ys*zeta2 - gamma*zeta2*xi2
62 beta*pow(h_local(),-1.)*deltat*phit
63 + u*dot(A(d)*grad_h(ys),normal())
64 + w*dot(A(d)*grad_h(vs),normal())
65 + (u+us-ut-deltat)*kappat
66 + (w+ws-wt-phit )*gammat);
67 form a = integrate(omega, a_expr);
68 form inv_a = integrate(omega, a_expr, iopt);
69 form b = integrate(omega,on_local_sides(-mu*(
70 dot(A(d)*grad_h(vs),normal()) + gammat)));
71 field lh = integrate (omega, f(d)*w);
72 field lambda_h(Mh,0);
73 form s = -b*inv_a*trans(b);
74 s.set_symmetric_definite_positive();
75 field rhs = -b*(inv_a*lh);
76 problem p (s);
77 p.solve (rhs, lambda_h);
78 field xh = inv_a*(lh - b.trans_mult(lambda_h));
79 dout << catchmark("beta") << beta << endl
80 << catchmark("u") << xh[0]
81 << catchmark("us") << xh[1]
82 << catchmark("ut") << xh[2]
83 << catchmark("delta") << xh[3]
84 << catchmark("vs") << xh[4]
85 << catchmark("zeta1") << xh[5]
86 << catchmark("vt") << xh[6]
87 << catchmark("gammat") << xh[7]
88 << catchmark("zeta2") << xh[8]
89 << catchmark("lambda") << lambda_h;
90}
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
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.
int main()
Definition field2bb.cc:58
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
This file is part of Rheolef.
space_mult_list< T, M > pow(const space_basic< T, M > &X, size_t n)
Definition space_mult.h:120
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
details::field_expr_v2_nonlinear_terminal_function< details::normal_pseudo_function< Float > > normal()
normal: 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::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
details::field_expr_v2_nonlinear_terminal_function< details::h_local_pseudo_function< Float > > h_local()
h_local: see the expression page for the full documentation
rheolef::std enable_if ::type dot const Expr1 expr1, const Expr2 expr2 dot(const Expr1 &expr1, const Expr2 &expr2)
csr< T, sequential > trans(const csr< T, sequential > &a)
trans(a): see the form page for the full documentation
Definition csr.h:455
STL namespace.
rheolef - reference manual
The sinus product function – right-hand-side and boundary condition for the Poisson problem.
Definition cavity_dg.h:29
Definition sphere.icc:25
Definition leveque.h:25