LifeV
LifeV.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief LifeV main header file
30 
31 
32  @author Luca Formaggia
33  @author Jean-Fred Gerbeau.
34  @author Christophe Prud'homme
35 
36  @contributor Simone Deparis <simone.deparis@epfl.ch>
37  @maintainer Simone Deparis <simone.deparis@epfl.ch>
38 
39  @date 01-01-2004, 01-12-2010
40 
41  Defines typedefs and macros common to ALL lifeV.h software
42  it must be includes in all translation units.
43 */
44 
45 
46 /*
47  * The macros PACKAGE, PACKAGE_NAME, etc, get defined for each package and need to
48  * be undef'd here to avoid warnings when this file is included from another package.
49  */
50 
51 #ifdef PACKAGE
52 #undef PACKAGE
53 #endif
54 
55 #ifdef PACKAGE_NAME
56 #undef PACKAGE_NAME
57 #endif
58 
59 #ifdef PACKAGE_BUGREPORT
60 #undef PACKAGE_BUGREPORT
61 #endif
62 
63 #ifdef PACKAGE_STRING
64 #undef PACKAGE_STRING
65 #endif
66 
67 #ifdef PACKAGE_TARNAME
68 #undef PACKAGE_TARNAME
69 #endif
70 
71 #ifdef PACKAGE_VERSION
72 #undef PACKAGE_VERSION
73 #endif
74 
75 #ifdef VERSION
76 #undef VERSION
77 #endif
78 
79 #include <lifev/core/Core_config.h>
80 //#include <lifev/structure/Structure_config.h>
81 #include <LifeV_config.h>
82 
83 #ifndef __cplusplus
84 #error You must use C++ for LifeV
85 #endif
86 
87 #ifndef _LIFEV_HH_
88 #define _LIFEV_HH_
89 
90 #include <stdint.h>
91 
92 #include <cstdlib>
93 #include <iostream>
94 #include <cmath>
95 #include <numeric>
96 #include <iosfwd>
97 #include <string>
98 #include <limits>
99 #include <set>
100 #include <list>
101 #include <map>
102 #include <vector>
103 
104 
105 #include <boost/shared_ptr.hpp>
106 #include <boost/numeric/ublas/vector.hpp>
107 #include <boost/function.hpp>
108 
109 
110 // deprecated attribute for LifeV functions
111 // the macro is needed to avoid problems with compilers other than gcc
112 // other compiler specific implementation of the deprecated attribute can be
113 // added with #elif defined macros
114 #ifdef __GNUC__
115 #define LIFEV_DEPRECATED( func ) func __attribute__ ((deprecated))
116 #else
117 #define LIFEV_DEPRECATED( func ) func
118 #endif
119 
120 // macro to avoid warning in opt mode for variables that are only needed for
121 // dbg mode
122 // note: these problems arise when there is no clear separation between a
123 // function that does some work and return some state, so it should be
124 // avoided as much as possible.
125 #define LIFEV_UNUSED(x) ((void)x)
126 
127 #include <lifev/core/util/LifeAssert.hpp>
128 
129 namespace LifeV
130 {
131 
132 /*!
133  @page types_page LifeV Types
134  @section types Types
135  @subsection real Real Numbers
136 
137  LifeV defines a number of types that are used in the library.
138 
139  -# \c Real 64 bits real number type
140 
141  @section ints Integers
142 
143  LifeV defines a number of integer type that have controlled bit
144  size. These types are constructed automatically by LifeV in order to have
145  platform independant integer types.
146 
147  Here is the list of signed integers:
148 
149  -# \c int1_type a 1 bit signed integer
150  -# \c int8_type a 8 bit signed integer
151  -# \c int16_type a 16 bit signed integer
152  -# \c int32_type a 32 bit signed integer
153  -# \c int64_type a 64 bit signed integer
154 
155  Here is the list of unsigned integers:
156 
157  -# \c uint1_type a 1 bit unsigned integer
158  -# \c uint8_type a 8 bit unsigned integer
159  -# \c uint16_type a 16 bit unsigned integer
160  -# \c uint32_type a 32 bit unsigned integer
161  -# \c uint64_type a 64 bit unsigned integer
162 
163  LifeV defines a number of useful aliases for integers
164  -# \c Int an alias to int32_type
165  -# \c UInt an alias to uint32_type used for adressing
166  -# \c ID an alias to id_type used to identify local numbering or components
167  -# \c size_type an alias to size_t used as indices for arrays, vectors or matrices
168  -# \c flag_Type an alias to uint32_type used for boolean flags
169 
170 */
171 
172 // Create type that are machine independent
173 
174 //! Generic real data
175 typedef double Real;
176 
177 typedef int8_t int8_type;
178 typedef int16_t int16_type;
179 typedef int32_t int32_type;
180 typedef int64_t int64_type;
181 
182 typedef uint8_t uint8_type;
183 typedef uint16_t uint16_type;
184 typedef uint32_t uint32_type;
185 typedef uint64_t uint64_type;
186 
187 //! Generic integer data
188 typedef int32_type Int;
189 
190 //! generic unsigned integer (used mainly for addressing)
192 
193 //! IDs
194 typedef uint32_type ID;
195 
196 //! bit-flag with up to 32 different flags
198 
199 //! Epetra int type (can be int or long long, accordingly to release notes)
200 typedef int EpetraInt_Type; // 32-bit (long long for 64-bit indices)
201 
202 //! flag related free functions and functors
203 namespace Flag
204 {
205 /** @name FlagFunctions
206  * They implement basic operations on boolean flags
207  */
208 //@{
209 //! It returns true if all bit-flags common set in refFlag are also set in inputFlag
210 inline bool testAllSet ( flag_Type const& inputFlag, flag_Type const& refFlag )
211 {
212  return ( inputFlag & refFlag ) == refFlag;
213 }
214 
215 //! returns true if at least one flag set in refFlag is set in inputFlag
216 inline bool testOneSet ( flag_Type const& inputFlag, flag_Type const& refFlag )
217 {
218  return inputFlag & refFlag;
219 }
220 
221 //! returns false if at least one flag set in refFlag is set in inputFlag
222 inline bool testOneNotSet ( flag_Type const& inputFlag, flag_Type const& refFlag )
223 {
224  return ! (inputFlag & refFlag);
225 }
226 
227 //! turns on the refFlag active bits in inputFlag
228 inline flag_Type turnOn ( flag_Type const& inputFlag, flag_Type const& refFlag )
229 {
230  return inputFlag | refFlag;
231 }
232 
233 //! turns off the refFlag active bits in inputFlag
234 inline flag_Type turnOff ( flag_Type const& inputFlag, flag_Type const& refFlag )
235 {
236  return inputFlag & ~refFlag;
237 }
238 
239 //! switches the refFlag active bits in inputFlag
240 inline flag_Type change ( flag_Type const& inputFlag, flag_Type const& refFlag )
241 {
242  return inputFlag ^ refFlag;
243 }
244 
245 //! replaces the given flag with the reference one. This method is introduced with the same
246 //! signature of the other methods in order to be used as a policy
247 inline flag_Type replaceFlag ( flag_Type const& /*inputFlag*/, flag_Type const& refFlag )
248 {
249  return refFlag;
250 }
251 
252 //! showMe method to print out flag status
253 //! the flag is converted to its binary form ( right -> left corresponds to first -> last flag )
254 void showMe ( flag_Type const& flag, std::ostream& out = std::cout );
255 //@}
256 
257 //end namespace Flag
258 }
259 // For now only 3 dimensional problems.
260 extern const UInt nDimensions;
261 
262 // used to denote an ID not set. We use max of Int (instead of UInt) since
263 // MPI does not have the UInt type.
264 const ID NotAnId = std::numeric_limits<Int>::max();
265 #define NDIM 3
266 
267 //! clearVector
268 /*!
269  * This is a general purpose utility that clears up a std::vector<T>
270  * making sure that it does not uses up memory after the call
271  * Useful when memory is an issue, since clear() does not free memory
272  * */
273 template<typename T>
274 void clearVector (T& stdVector)
275 {
276  stdVector.clear();
277  T().swap (stdVector);
278 }
279 //! resizeVector
280 /*!
281  * This is a general purpose utility that resizes up a std::vector<T>
282  * making sure that it does not uses up more memory after the call
283  * Useful when memory is an issue, since resize() does not free memory
284  */
285 template<typename T>
286 void resizeVector (T& stdVector, UInt const& newsize)
287 {
288  stdVector.resize (newsize);
289  if (stdVector.capacity() > stdVector.size() )
290  {
291  T (stdVector).swap (stdVector);
292  }
293 }
294 
295 } // end namespace LifeV
296 
297 #endif
uint32_type flag_Type
bit-flag with up to 32 different flags
Definition: LifeV.hpp:197
flag_Type turnOn(flag_Type const &inputFlag, flag_Type const &refFlag)
turns on the refFlag active bits in inputFlag
Definition: LifeV.hpp:228
int8_t int8_type
Definition: LifeV.hpp:177
flag_Type turnOff(flag_Type const &inputFlag, flag_Type const &refFlag)
turns off the refFlag active bits in inputFlag
Definition: LifeV.hpp:234
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
int16_t int16_type
Definition: LifeV.hpp:178
uint16_t uint16_type
Definition: LifeV.hpp:183
void updateInverseJacobian(const UInt &iQuadPt)
void resizeVector(T &stdVector, UInt const &newsize)
resizeVector
Definition: LifeV.hpp:286
bool testOneSet(flag_Type const &inputFlag, flag_Type const &refFlag)
returns true if at least one flag set in refFlag is set in inputFlag
Definition: LifeV.hpp:216
flag_Type change(flag_Type const &inputFlag, flag_Type const &refFlag)
switches the refFlag active bits in inputFlag
Definition: LifeV.hpp:240
uint32_type ID
IDs.
Definition: LifeV.hpp:194
void showMe(flag_Type const &flag, std::ostream &out=std::cout)
showMe method to print out flag status the flag is converted to its binary form ( right -> left corre...
Definition: LifeV.cpp:40
uint8_t uint8_type
Definition: LifeV.hpp:182
void clearVector(T &stdVector)
clearVector
Definition: LifeV.hpp:274
double Real
Generic real data.
Definition: LifeV.hpp:175
int32_t int32_type
Definition: LifeV.hpp:179
flag related free functions and functors
Definition: LifeV.hpp:203
bool testAllSet(flag_Type const &inputFlag, flag_Type const &refFlag)
It returns true if all bit-flags common set in refFlag are also set in inputFlag. ...
Definition: LifeV.hpp:210
const UInt nDimensions(NDIM)
const ID NotAnId
Definition: LifeV.hpp:264
bool testOneNotSet(flag_Type const &inputFlag, flag_Type const &refFlag)
returns false if at least one flag set in refFlag is set in inputFlag
Definition: LifeV.hpp:222
uint32_t uint32_type
Definition: LifeV.hpp:184
uint64_t uint64_type
Definition: LifeV.hpp:185
int EpetraInt_Type
Epetra int type (can be int or long long, accordingly to release notes)
Definition: LifeV.hpp:200
int64_t int64_type
Definition: LifeV.hpp:180
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
flag_Type replaceFlag(flag_Type const &, flag_Type const &refFlag)
replaces the given flag with the reference one.
Definition: LifeV.hpp:247