NiHu  2.0
complexity_estimator.hpp
Go to the documentation of this file.
1 // This file is a part of NiHu, a C++ BEM template library.
2 //
3 // Copyright (C) 2012-2014 Peter Fiala <fiala@hit.bme.hu>
4 // Copyright (C) 2012-2014 Peter Rucz <rucz@hit.bme.hu>
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
24 #ifndef COMPLEXITY_ESTIMATOR_HPP_INCLUDED
25 #define COMPLEXITY_ESTIMATOR_HPP_INCLUDED
26 
27 #include "../tmp/integer.hpp"
28 #include "field.hpp"
29 
30 namespace NiHu
31 {
32 
38 template <class TestField, class TrialField, class KernelEstimator>
40 {
41 public:
43  typedef TestField test_field_t;
45  typedef TrialField trial_field_t;
46 
47  enum {
56  };
57 
59  static unsigned const total_field_complexity = tmp::max_<
62  >::type::value;
63 
69  static unsigned eval(
70  field_base<test_field_t> const &test_field,
71  field_base<trial_field_t> const &trial_field
72  )
73  {
74  return total_field_complexity + KernelEstimator::eval(test_field, trial_field);
75  }
76 };
77 
78 
84 template <class Estim1, class...Estims>
87  Estim1,
88  typename merge_kernel_complexity_estimators<Estims...>::type
89  >
90 {
91 };
92 
93 
99 template <class Estim1, class Estim2>
101 {
102  struct type
103  {
111  template <class test_field_t, class trial_field_t>
112  static unsigned eval(
113  field_base<test_field_t> const &test_field,
114  field_base<trial_field_t> const &trial_field
115  )
116  {
117  return std::max(
118  Estim1::eval(test_field, trial_field),
119  Estim2::eval(test_field, trial_field)
120  );
121  }
122  };
123 };
124 
125 }
126 
127 #endif
128 
tmp::integer
integer type representation
Definition: integer.hpp:54
NiHu::complexity_estimator::total_field_complexity
static const unsigned total_field_complexity
Definition: complexity_estimator.hpp:59
NiHu::complexity_estimator::eval
static unsigned eval(field_base< test_field_t > const &test_field, field_base< trial_field_t > const &trial_field)
compute total complexity
Definition: complexity_estimator.hpp:69
NiHu::complexity_estimator::trial_field_complexity
@ trial_field_complexity
the trial field complexity
Definition: complexity_estimator.hpp:53
NiHu::complexity_estimator::trial_field_t
TrialField trial_field_t
the trial field type
Definition: complexity_estimator.hpp:45
field.hpp
implementation of fields and field views
NiHu::complexity_estimator::test_field_t
TestField test_field_t
the test field type
Definition: complexity_estimator.hpp:43
NiHu::shape_set_traits::jacobian_order
Defines the polynomial order of the shape set's Jacobian.
Definition: shapeset.hpp:130
NiHu::field_base
CRTP base class of all fields.
Definition: field.hpp:111
NiHu::merge_kernel_complexity_estimators
merge at least two complexity estimators
Definition: complexity_estimator.hpp:85
NiHu::complexity_estimator::test_field_complexity
@ test_field_complexity
the test field complexity
Definition: complexity_estimator.hpp:49
NiHu::shape_set_traits::polynomial_order
Defines the polynomial order of the shape set.
Definition: shapeset.hpp:124
NiHu::merge_kernel_complexity_estimators< Estim1, Estim2 >::type::eval
static unsigned eval(field_base< test_field_t > const &test_field, field_base< trial_field_t > const &trial_field)
compute complexity of merged estimators
Definition: complexity_estimator.hpp:112
tmp::max_
Compute maximum of types.
Definition: relation.hpp:63
NiHu::complexity_estimator
class to estimate kernel complexity between two fields
Definition: complexity_estimator.hpp:39