NiHu  2.0
p2x_integral.hpp
Go to the documentation of this file.
1 
7 #ifndef NIHU_P2X_INTEGRAL_HPP_INCLUDED
8 #define NIHU_P2X_INTEGRAL_HPP_INCLUDED
9 
11 #include "core/field.hpp"
12 #include "fmm_operator.hpp"
14 #include "core/jacobian_computer.hpp"
15 #include "util/matrix_traits.hpp"
16 #include "util/type2tag.hpp"
17 
18 #include <type_traits>
19 
20 namespace NiHu
21 {
22 namespace fmm
23 {
24 
29 template <class Operator, class TrialField>
31 
32 
33 template <class Operator, class TrialField>
34 struct integral_operator_expression_traits<p2x_integral<Operator, TrialField> >
35 {
36  typedef typename std::decay<Operator>::type operator_t;
37  typedef typename operator_t::test_input_t test_input_t;
38  typedef TrialField trial_input_t;
39  typedef Eigen::Matrix<
40  typename scalar<typename operator_t::result_t>::type,
42  num_cols<typename operator_t::result_t>::value * TrialField::nset_t::num_nodes
43  > result_t;
44 };
45 
46 
47 template <class Operator, class TrialField>
48 class p2x_integral
49  : public integral_operator_expression<p2x_integral<Operator, TrialField> >
50  , public fmm_operator<typename std::decay<Operator>::type::fmm_tag>
51 {
52 public:
53  typedef typename std::decay<Operator>::type operator_t;
54  typedef TrialField trial_field_t;
55 
56  typedef typename trial_field_t::elem_t elem_t;
57  typedef typename trial_field_t::nset_t nset_t;
58 
59  typedef typename operator_t::test_input_t test_input_t;
60  typedef trial_field_t trial_input_t;
61 
62  typedef typename elem_t::domain_t domain_t;
63  typedef typename domain_t::xi_t xi_t;
64  typedef NiHu::gaussian_quadrature<domain_t> quadrature_t;
65 
66  typedef typename operator_t::result_t op_result_t;
67  static int const op_num_cols = num_cols<op_result_t>::value;
68  static int const op_num_rows = num_rows<op_result_t>::value;
69  static size_t const result_cols = op_num_cols * nset_t::num_nodes;
70  typedef Eigen::Matrix<
71  typename scalar<typename operator_t::result_t>::type,
72  op_num_rows, result_cols
73  > result_t;
74 
75  p2x_integral(Operator &&op, size_t order)
76  : m_op(std::forward<Operator>(op))
77  , m_quadrature(unsigned(order))
78  {
79  }
80 
81  size_t rows(test_input_t const &to) const
82  {
83  return m_op.rows(to);
84  }
85 
86  size_t cols(trial_input_t const &) const
87  {
88  return result_cols;
89  }
90 
91  result_t operator()(test_input_t const &to, trial_field_t const &field) const
92  {
93  result_t mat = result_t::Zero(rows(to), cols(field));
94  elem_t const &elem = field.get_elem();
95  for (auto const &q : m_quadrature)
96  {
97  xi_t const &xi = q.get_xi();
98  auto N = nset_t::template eval_shape<0>(xi);
99 
100  double w = q.get_w();
101  typename operator_t::trial_input_t tri(elem, xi);
102  double jac = jacobian_computer<elem_t>::eval(elem, xi);
103  auto K = m_op(to, tri);
104  for (Eigen::Index i = 0; i < nset_t::num_nodes; ++i)
105  mat.block(0, i*op_num_cols, K.rows(), op_num_cols) +=
106  K
107  * (N(i, 0) * Eigen::Matrix<double, op_num_cols, op_num_cols>::Identity())
108  *(w * jac);
109  }
110  return mat;
111  }
112 
113 private:
114  Operator m_op;
115  quadrature_t m_quadrature;
116 };
117 
118 template <class Operator, class TrialFieldTag>
119 p2x_integral<Operator, typename tag2type<TrialFieldTag>::type>
120 create_p2x_integral(Operator &&op, size_t order, TrialFieldTag)
121 {
122  typedef typename tag2type<TrialFieldTag>::type TrialField;
123  return p2x_integral<Operator, TrialField>(std::forward<Operator>(op), order);
124 }
125 
126 } // end of namespace fmm
127 } // namespace NiHu
128 
129 #endif /* NIHU_P2X_INTEGRAL_HPP_INCLUDED */
type2tag.hpp
Assign a tag to a type.
gaussian_quadrature.hpp
implementation of Gaussian quadratures
NiHu::num_cols
metafunction returning the number of compile time columns
Definition: matrix_traits.hpp:41
matrix_traits.hpp
compile time properties of matrices
integral_operator_expression.hpp
Arithmetics of integral operators.
NiHu::gaussian_quadrature< domain_t >
field.hpp
implementation of fields and field views
NiHu::fmm::integral_operator_expression_traits
the traits structure of an integral operator
Definition: integral_operator_expression.hpp:33
NiHu::volume_element::domain_t
typename base_t::domain_t domain_t
the domain type
Definition: element.hpp:637
NiHu::fmm::integral_operator_expression
the base class of every integral operator
Definition: integral_operator_expression.hpp:28
NiHu::bessel::K
make_complex< T >::type K(T const &z)
K_nu(z) modified Bessel function.
NiHu::num_rows
metafunction returning the number of compile time rows
Definition: matrix_traits.hpp:16
fmm_operator.hpp
FMM operator types and tags.
NiHu::fmm::fmm_operator
Operator defining its tag type.
Definition: fmm_operator.hpp:85
NiHu::fmm::p2x_integral
integrate a p2x-operator over a trial field
Definition: p2x_integral.hpp:30
NiHu::volume_element
class describing a volume element that has no normal vector
Definition: element.hpp:455