NiHu  2.0
element_match.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 
25 #ifndef ELEMENT_MATCH_HPP_INCLUDED
26 #define ELEMENT_MATCH_HPP_INCLUDED
27 
28 #include "element.hpp"
29 #include "match_types.hpp"
30 #include "field.hpp"
31 #include "formalism.hpp"
32 #include <type_traits>
33 #include <iostream>
34 
35 namespace NiHu
36 {
37 
40 {
41 public:
47  int match_dimension,
48  element_overlapping const &overlap = element_overlapping())
49  : m_match_dimension(match_dimension)
50  , m_overlap(overlap)
51  {
52  }
53 
55  int get_match_dimension() const { return m_match_dimension; }
56 
58  element_overlapping const &get_overlap() const { return m_overlap; }
59 
60  std::ostream &print_debug(std::ostream &os = std::cout) const
61  {
62  os << "Element_match info:" << std::endl
63  << "Match_dimension: " << m_match_dimension << std::endl;
64  if (m_match_dimension != 2)
65  m_overlap.print_debug(os);
66 
67  return os;
68  }
69 
70 private:
72  int m_match_dimension;
74  element_overlapping const m_overlap;
75 };
76 
77 
85 template <class test_field_t, class trial_field_t>
87  field_base<test_field_t> const &test_field,
88  field_base<trial_field_t> const &trial_field)
89 {
90  // face match is only possible if the element types are the same
91  // (not dealing with 3d volume elements)
92  bool const face_match_possible = std::is_same<
93  typename test_field_t::elem_t,
94  typename trial_field_t::elem_t
95  >::value;
96 
97  // actual face match: if the elem id's are the same (same element)
98  if (face_match_possible) // compile time if
99  if (test_field.get_elem().get_id() == trial_field.get_elem().get_id())
100  return element_match(test_field_t::elem_t::domain_t::dimension);
101 
103 
104  // lower dimensional checks are needed for
105  // - galerkin formulations in general
106  // - collocational formulations if the test field contains nodes on the boundary
108  || tmp::is_member<test_dof_vector, dof1 >::value && (test_field_t::elem_t::domain_t::dimension > 1)
110  {
111  element_overlapping overlap(test_field.get_elem().get_overlapping(trial_field.get_elem()));
112 
113  // edge match
114  if (overlap.get_num() > 1)
115  return element_match(1, overlap);
116 
117  // vertex match
118  if (overlap.get_num() == 1)
119  return element_match(0, overlap);
120  }
121 
122  // no match
123  return element_match(-1);
124 }
125 
126 }
127 
128 #endif // ELEMENT_MATCH_HPP_INCLUDED
129 
NiHu::element_match_eval
element_match element_match_eval(field_base< test_field_t > const &test_field, field_base< trial_field_t > const &trial_field)
function to determine the overlapping state of two elements
Definition: element_match.hpp:86
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
NiHu::element_match::element_match
element_match(int match_dimension, element_overlapping const &overlap=element_overlapping())
constructor
Definition: element_match.hpp:46
match_types.hpp
NiHu::element_match::get_match_dimension
int get_match_dimension() const
return singularity type
Definition: element_match.hpp:55
NiHu::formalism::general
general case when the test field is not Dirac
Definition: formalism.hpp:37
NiHu::element_match::get_overlap
const element_overlapping & get_overlap() const
return overlapping state
Definition: element_match.hpp:58
field.hpp
implementation of fields and field views
NiHu::element_overlapping
class describing the overlapping state of two elements
Definition: element.hpp:39
NiHu::get_formalism
return formalism from Test and Trial field types
Definition: formalism.hpp:47
NiHu::element_match
class describing the adjacency (match) state of two elements
Definition: element_match.hpp:39
NiHu::field_base::get_elem
const elem_t & get_elem() const
return underlying element
Definition: field.hpp:149
NiHu::field_base
CRTP base class of all fields.
Definition: field.hpp:111
tmp::is_member
return true if the element is member of a sequence
Definition: algorithm.hpp:311
NiHu::element_overlapping::get_num
unsigned get_num(void) const
return number of coincident nodes
Definition: element.hpp:43
element.hpp
Declaration of element classes.