v0.8.20
Common.hpp
Go to the documentation of this file.
1 /** \file Common.hpp
2  * \brief Basic structures and data
3  *
4  * MoFEM is free software: you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the
6  * Free Software Foundation, either version 3 of the License, or (at your
7  * option) any later version.
8  *
9  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12  * License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>
16  */
17 
18 #ifndef __COMMON_HPP__
19 #define __COMMON_HPP__
20 
21 namespace MoFEM {
22 
23 /**
24  * @brief No entity handle is indicated by zero handle, i.e. root meshset
25  *
26  */
28 
29 /**
30  * This small utility that cascades two key extractors will be
31  * used throughout the boost example
32  * <a
33  * href=http://www.boost.org/doc/libs/1_53_0/libs/multi_index/example/complex_structs.cpp>
34  * http://www.boost.org/doc/libs/1_53_0/libs/multi_index/example/complex_structs.cpp
35  * </a>
36  */
37 template <class KeyExtractor1, class KeyExtractor2> struct KeyFromKey {
38 public:
39  typedef typename KeyExtractor1::result_type result_type;
40 
41  KeyFromKey(const KeyExtractor1 &key1_ = KeyExtractor1(),
42  const KeyExtractor2 &key2_ = KeyExtractor2())
43  : key1(key1_), key2(key2_) {}
44 
45  template <typename Arg> result_type operator()(Arg &arg) const {
46  return key1(key2(arg));
47  }
48 
49 private:
50  KeyExtractor1 key1;
51  KeyExtractor2 key2;
52 };
53 
54 template <typename id_type> struct LtBit {
55  inline bool operator()(const id_type &valueA, const id_type &valueB) const {
56  return valueA.to_ulong() < valueB.to_ulong();
57  }
58 };
59 
60 template <typename id_type> struct EqBit {
61  inline bool operator()(const id_type &valueA, const id_type &valueB) const {
62  return valueA.to_ulong() == valueB.to_ulong();
63  }
64 };
65 
66 template <typename id_type> struct HashBit {
67  inline unsigned int operator()(const id_type &value) const {
68  return value.to_ulong();
69  }
70 };
71 
72 template <class X> inline std::string toString(X x) {
73  std::ostringstream buffer;
74  buffer << x;
75  return buffer.str();
76 }
77 
78 } // namespace MoFEM
79 
80 #include <Exceptions.hpp>
81 #include <Types.hpp>
82 
83 #endif //__COMMON_HPP__
84 
85 /**
86  * \defgroup mofem MoFEM
87  */
Exceptions and error handlers.
const EntityHandle no_handle
No entity handle is indicated by zero handle, i.e. root meshset.
Definition: Common.hpp:27
KeyFromKey(const KeyExtractor1 &key1_=KeyExtractor1(), const KeyExtractor2 &key2_=KeyExtractor2())
Definition: Common.hpp:41
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
KeyExtractor1 key1
Definition: Common.hpp:50
bool operator()(const id_type &valueA, const id_type &valueB) const
Definition: Common.hpp:61
KeyExtractor2 key2
Definition: Common.hpp:51
unsigned int operator()(const id_type &value) const
Definition: Common.hpp:67
std::string toString(X x)
Definition: Common.hpp:72
Types.
bool operator()(const id_type &valueA, const id_type &valueB) const
Definition: Common.hpp:55
result_type operator()(Arg &arg) const
Definition: Common.hpp:45
KeyExtractor1::result_type result_type
Definition: Common.hpp:39