NiHu  2.0
match_types.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 
21 #ifndef MATCH_TYPES_HPP_INCLUDED
22 #define MATCH_TYPES_HPP_INCLUDED
23 
24 #include <type_traits>
25 #include "formalism.hpp"
26 #include "../tmp/algorithm.hpp"
27 
28 namespace NiHu
29 {
30 
32 namespace match
33 {
35  typedef std::integral_constant<int, -1> no_match_type;
36 
38  typedef std::integral_constant<int, 0> match_0d_type;
40  typedef std::integral_constant<int, 1> match_1d_type;
42  typedef std::integral_constant<int, 2> match_2d_type;
43 }
44 
49 template <class TestField, class TrialField, class Enable = void>
51 
53 template <class TestField, class TrialField>
54 struct match_type_vector<TestField, TrialField,
55  typename std::enable_if<
56  std::is_same<
57  typename get_formalism<TestField, TrialField>::type,
58  formalism::general
59  >::value
60  >::type
61 >
62 {
63 private:
64  enum { d = TestField::elem_t::domain_t::dimension }; // the element's intrinsic dimension
65  typedef typename TestField::elem_t test_elem_t;
66  typedef typename TrialField::elem_t trial_elem_t;
67 
73  template <class vector, unsigned dim>
74  struct push_if_needed : std::conditional<
75  (d > dim) ||
76  (d == dim && std::is_same<test_elem_t, trial_elem_t>::value),
77  typename tmp::push_back<vector, std::integral_constant<int, int(dim)> >::type,
78  vector
79  > {};
80 
81 public:
82  typedef typename push_if_needed<
83  typename push_if_needed<
84  typename push_if_needed<
85  tmp::vector<>, 0>::type, 1
86  >::type, 2
87  >::type type;
88 };
89 
91 template <class TestField, class TrialField>
92 struct match_type_vector<TestField, TrialField, typename std::enable_if<
93  is_collocational<TestField, TrialField>::value
94 >::type>
95 {
96 private:
97  enum { d = TestField::elem_t::domain_t::dimension };
98  typedef typename TestField::elem_t test_elem_t;
100  typedef typename TrialField::elem_t trial_elem_t;
101 
108  template <class vector, unsigned dim>
109  struct push_if_needed : std::conditional<
110  (d == dim && std::is_same<test_elem_t, trial_elem_t>::value) ||
111  (d > dim && (tmp::is_member<test_dof_vector, position_dof<dim> >::value || tmp::is_member<test_dof_vector, dof0 >::value))
112  ,
113  typename tmp::push_back<vector, std::integral_constant<int, int(dim)> >::type,
114  vector
115  > {};
116 
117 public:
118  typedef typename push_if_needed<
119  typename push_if_needed<
120  typename push_if_needed<
121  tmp::vector<>, 0>::type, 1
122  >::type, 2
123  >::type type;
124 };
125 
126 }
127 
128 #endif // MATCH_TYPES_HPP_INCLUDED
129 
NiHu::match_type_vector
matafunction assigning a match type vector to two fields
Definition: match_types.hpp:50
formalism.hpp
return weak form formalism from the test and trial field types
NiHu::shape_set_traits::position_dof_vector
defines the nodal degrees of freedoms of the shape functions
Definition: shapeset.hpp:164
tmp::vector<>
NiHu::match::match_0d_type
std::integral_constant< int, 0 > match_0d_type
two elements are adjacent with a 0d (vertex) match
Definition: match_types.hpp:38
NiHu::match::match_2d_type
std::integral_constant< int, 2 > match_2d_type
two elements are adjacent with a 2d (surface) match
Definition: match_types.hpp:42
NiHu::match::match_1d_type
std::integral_constant< int, 1 > match_1d_type
two elements are adjacent with a 1d (line) match
Definition: match_types.hpp:40
tmp::push_back
push an element to the back
Definition: sequence.hpp:99
NiHu::match::no_match_type
std::integral_constant< int, -1 > no_match_type
no singularity
Definition: match_types.hpp:35