Rheolef  7.2
an efficient C++ finite element environment
dirichlet_hho_v2.cc
Go to the documentation of this file.
1 #include "rheolef.h"
26 using namespace rheolef;
27 using namespace std;
28 #include "sinusprod_dirichlet.h"
29 #include "diffusion_isotropic.h"
30 int 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];
52  integrate_option iopt;
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
Definition: environment.h:121
see the integrate_option page for the full documentation
double Float
see the Float page for the full documentation
Definition: Float.h:143
odiststream dout(cout)
see the diststream page for the full documentation
Definition: diststream.h:467
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)
int main(int argc, char **argv)
This file is part of Rheolef.
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
csr< T, sequential > trans(const csr< T, sequential > &a)
trans(a): see the form page for the full documentation
Definition: csr.h:455
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
space_mult_list< T, M > pow(const space_basic< T, M > &X, size_t n)
Definition: space_mult.h:120
details::field_expr_v2_nonlinear_terminal_function< details::normal_pseudo_function< Float > > normal()
normal: see the expression page for the full documentation
Float gamma[][pmax+1]
Float beta[][pmax+1]
rheolef - reference manual
The sinus product function – right-hand-side and boundary condition for the Poisson problem.
Definition: sphere.icc:25
Definition: leveque.h:25