Hermes2D  2.0
hdiv.h
1 // This file is part of Hermes2D.
2 //
3 // Hermes2D is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 2 of the License, or
6 // (at your option) any later version.
7 //
8 // Hermes2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Hermes2D. If not, see <http://www.gnu.org/licenses/>.
15 
16 #ifndef __H2D_INTEGRALS_HDIV_H
17 #define __H2D_INTEGRALS_HDIV_H
18 
19 namespace Hermes
20 {
21  namespace Hermes2D
22  {
23  template<typename T>
24  inline T int_g_h(Function<T>* fg, Function<T>* fh, RefMap* rg, RefMap* rh)
25  {
26  Quad2D* quad = rg->get_quad_2d();
27  int o = fg->get_fn_order() + fh->get_fn_order() + 2 + rg->get_inv_ref_order();
28  limit_order(o, rg->get_active_element()->get_mode());
29  fg->set_quad_order(o, H2D_FN_VAL);
30  fh->set_quad_order(o, H2D_FN_VAL);
31 
32  T *g0 = fg->get_fn_values(0), *g1 = fg->get_fn_values(1);
33  T *h0 = fh->get_fn_values(0), *h1 = fh->get_fn_values(1);
34 
35  T result = 0.0;
36 
37  double3* pt = quad->get_points(o, rg->get_active_element()->get_mode());
38  int np = quad->get_num_points(o, rg->get_active_element()->get_mode());
39  double2x2* mg, *mh;
40  mg = rg->get_inv_ref_map(o);
41  mh = rh->get_inv_ref_map(o);
42  double* jac = rg->get_jacobian(o);
43  for (int i = 0; i < np; i++, mg++, mh++)
44  result += pt[i][2] * jac[i] * (( (*mg)[1][1]*g0[i] - (*mg)[1][0]*g1[i]) * ( (*mh)[1][1]*h0[i] - (*mh)[1][0]*h1[i]) +
45  (-(*mg)[0][1]*g0[i] + (*mg)[0][0]*g1[i]) * (-(*mh)[0][1]*h0[i] + (*mh)[0][0]*h1[i]));
46 
47  return result;
48  }
49  }
50 }
51 #endif