v0.5.86
definitions.h
Go to the documentation of this file.
1 /** \file definitions.h
2  * \brief useful compiler directives and definitions
3  */
4 
5 /* MoFEM is free software: you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License as published by the
7  * Free Software Foundation, either version 3 of the License, or (at your
8  * option) any later version.
9  *
10  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13  * License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>
17 */
18 
19 #ifndef __DEFINITONS_H__
20 #define __DEFINITONS_H__
21 
22 //taken from http://stackoverflow.com/questions/295120/c-mark-as-deprecated
23 #ifdef __GNUC__
24  #define DEPRECATED __attribute__((deprecated))
25 #elif defined(_MSC_VER)
26  #define DEPRECATED __declspec(deprecated)
27 #else
28  #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
29  #define DEPRECATED
30 #endif
31 
32 
33 /** \brief Interfaces IDs
34  *
35  * To manage different complexities related to field, finite elements mesh
36  * refinements, etc. a appropriate interfaces related to each complexities are
37  * created. Interfaces by itself could vary by functionality or the same function
38  * can me managed with two interfaces with waring level of abstraction.
39  *
40  */
41 enum Interfaces {
43  //Field Interface
44  CORE_INTERFACE = 1<<0|1<<1,
46  SIMPLE_INTERFACE = 1<<0|1<<3,
47  MESH_REFINE = 1<<1|1<<2,
48  PRISM_INTEFACE = 1<<1|1<<3,
49  SERIES_RECORDER = 1<<1|1<<4,
50  ISMANAGER_INTERFACE = 1<<1|1<<5,
51  VECMANAGER_INTERFACE = 1<<1|1<<6,
52  FIELDBLAS_INTERFACE = 1<<1|1<<7,
54  //Independent Interfaces
55  TETGEN_INTERFACE = 1<<3|1<<4, ///< used to generate mesh using TetGen
56  MED_INTERFACE = 1<<3|1<<5, ///< interface to med data format
57  NODEMERGER_INTERFACE = 1<<3|1<<6, ///< used to merge nodes
58  BITLEVELCOUPLER_INTERFACE = 1<<3|1<<7, ///< used to couple bit levels by finding parent children relation
59  PRISMSFROMSURFACE_INTERFACE = 1<<3|1<<8, ///< create prisms from surface elements
60  MESHSETSMANAGER_INTERFACE = 1<<3|1<<9, ///< Interface to manage meshsets with materials and boundary conditions
61  COORDSSYSTEMMANAGER_INTERFACE = 1<<3|1<<10, ///< Interface to manage coordinate systems
62  CUTMESH_INTERFACE = 1<<3|1<<11 ///< Cutting mesh
63 };
64 
66  //Loop Methods
67  KSP_METHOD = 1<<0,
68  SNES_METHOD = 1<<1,
69  TS_METHOD = 1<<2,
70  BASIC_METHOD = 1<<0|1<<1|1<<2,
71  FE_METHOD = 1<<0|1<<1|1<<2|1<<3,
72  ENT_METHOD = 1<<0|1<<1|1<<2|1<<4
73 };
74 
75 /**
76  * \brief interfaces for PETSc DM interfaces
77  */
81 };
82 
83 /**
84  * \brief Interfaces uses to manage base functions
85  */
93  TET_BASE_FUNCTION_INTERFACE = 1<<1|1<<3|1<<3,
94  TRI_BASE_FUNCTION_INTERFACE = 1<<1|1<<3|1<<4,
95  EDGE_BASE_FUNCTION_INTERFACE = 1<<1|1<<3|1<<5,
98 };
99 
100 /** \brief Error handling
101  *
102  * This is complementary to PETSC error codes. The numerical values for
103  * these are defined in include/petscerror.h. The names are defined in err.c
104  *
105  * MoAB error messages are defined in naob/Types.hpp
106  *
107  */
120 };
121 
122 /// \brief approximation base
124  NOBASE = 0,
125  AINSWORTH_LEGENDRE_BASE = 1, ///< Ainsworth Cole (Legendre) approx. base \cite NME:NME847
126  AINSWORTH_LOBBATO_BASE, ///< Like AINSWORTH_LEGENDRE_BASE but with Lobatto base instead Legendre \cite beriot2015efficient
127  AINSWORTH_BERNSTEIN_BEZIER_BASE, ///< Not yet implemented, in implementation we will follow \cite ainsworth2011bernstein
128  DEMKOWICZ_JACOBI_BASE, ///< Construction of base is by Demkowicz \cite fuentes2015orientation
129  USER_BASE, ///< user implemented approximation base
131 };
132 
133 const static char * const ApproximationBaseNames[] = {
134  "NOBASE",
135  "AINSWORTH_LEGENDRE_BASE",
136  "AINSWORTH_LOBBATO_BASE",
137  "AINSWORTH_BERNSTEIN_BEZIER_BASE",
138  "DEMKOWICZ_JACOBI_BASE",
139  "USER_BASE",
140  "LASTBASE"
141 };
142 
143 #ifdef __cplusplus
144 const static FieldApproximationBase ApproximationBaseArray[] = {
145  NOBASE,
150  USER_BASE,
151  LASTBASE
152 };
153 #endif // __cplusplus
154 
155 /// \brief approximation spaces
157  NOSPACE = 0,
158  NOFIELD = 1, ///< scalar or vector of scalars describe (no true field)
159  H1, ///< continuous field
160  HDIV, ///< field with continuous normal traction
161  HCURL, ///< field with continuous tangents
162  L2, ///< field with C-1 continuity
163  LASTSPACE ///< FieldSpace in [ 0, LASTSPACE )
164 };
165 
166 const static char * const FieldSpaceNames[] = {
167  "NOSPACE",
168  "NOFIELD",
169  "H1",
170  "HDIV",
171  "HCURL",
172  "L2",
173  "LASTSPACE"
174 };
175 
176 /// \brief Those types control how functions respond on arguments, f.e. error handling
178  MF_ZERO = 0,
179  MF_EXCL = 1<<0,
180  MF_EXIST = 1<<1
181 };
182 
183 /// \brief RowColData
186 };
187 
188 /**
189  * Controls adjency multi_index container (e.g. BYROW is adjacenciecy by field on on rows), see
190  * \ref MoFEM::FieldEntityEntFiniteElementAdjacencyMap
191  *
192  */
193 enum ByWhat {
194  BYROW = 1<<0,
195  BYCOL = 1<<1,
196  BYDATA = 1<<2,
197  BYROWDATA = 1<<0|1<<2,
198  BYCOLDATA = 1<<1|1<<2,
199  BYROWCOL = 1<<0|1<<1,
200  BYALL = 1<<0|1<<1|1<<2
201 };
202 
203 /**
204  * \bief Types of sets and boundary conditions
205  *
206  */
207 enum CubitBC {
209  NODESET = 1<<0,
210  SIDESET = 1<<1,
211  BLOCKSET = 1<<2,
212  MATERIALSET = 1<<3,
214  FORCESET = 1<<5,
215  PRESSURESET = 1<<6,
216  VELOCITYSET = 1<<7,
219  HEATFLUXSET = 1<<10,
220  INTERFACESET = 1<<11,
221  UNKNOWNNAME = 1<<12,
222  MAT_ELASTICSET = 1<<13, ///< block name is "MAT_ELASTIC"
223  MAT_INTERFSET = 1<<14,
224  MAT_THERMALSET = 1<<15, ///< block name is "MAT_THERMAL"
225  BODYFORCESSET = 1<<16, ///< block name is "BODY_FORCES"
226  MAT_MOISTURESET = 1<<17, ///< block name is "MAT_MOISTURE"
227  DIRICHLET_BC = 1<<18,
228  NEUMANN_BC = 1<<19,
229  LASTSET_BC = 1<<20
230 };
231 
232 // OFF_DEPRECATED static const unsigned int UNKNOWNCUBITNAME = UNKNOWNNAME;
233 // OFF_DEPRECATED static const unsigned int LASTCUBITSET = LASTSET_BC;
234 
235 /**
236  * \brief Names of types of sets and boundary conditions
237  */
238 const static char * const CubitBCNames[] = {
239  "UNKNOWNSET",
240  "NODESET",
241  "SIDESET",
242  "BLOCKSET",
243  "MATERIALSET",
244  "DISPLACEMENTSET",
245  "FORCESET",
246  "PRESSURESET",
247  "VELOCITYSET",
248  "ACCELERATIONSET",
249  "TEMPERATURESET",
250  "HEATFLUXSET",
251  "INTERFACESET",
252  "UNKNOWNNAME",
253  "MAT_ELASTICSET",
254  "MAT_INTERFSET",
255  "MAT_THERMALSET",
256  "BODYFORCESSET",
257  "MAT_MOISTURESET",
258  "DIRICHLET_BC",
259  "NEUMANN_BC",
260  "LASTSET_BC"
261 };
262 
263 /**
264  * \brief Format of rows in gradients of H1 base functions
265  */
268 };
269 
270 /**
271  * \brief Format in rows of Hdiv base functions
272  */
275 };
276 
277 /**
278  * \brief Format in rows of Hdiv gradients of base functions
279  */
282 };
283 
284 /**
285  * \brief Format in rows of Hcurl base functions
286  */
289 };
290 
291 /**
292  * \brief Format in rows of Hcurl gradients of base functions
293  */
296 };
297 
298 #define BITREFEDGES_SIZE 6 ///< number of edges on tetrahedral
299 #define BITREFLEVEL_SIZE 128 ///< max number of refinements
300 #define BITFIELDID_SIZE 32 ///< max number of fields
301 #define BITFEID_SIZE 32 ///< max number of finite elements
302 #define BITPROBLEMID_SIZE 32 ///< max number of problems
303 #define BITINTERFACEUID_SIZE 32
304 
305 #define MYPCOMM_INDEX 0 ///< default communicator number PCOMM
306 
307 //This Is form MOAB
308 #define MB_TYPE_WIDTH 4
309 #define MB_ID_WIDTH (8*sizeof(EntityHandle)-MB_TYPE_WIDTH)
310 #define MB_TYPE_MASK ((EntityHandle)0xF << MB_ID_WIDTH)
311 // 2^MB_TYPE_WIDTH-1 ------^
312 
313 #define MB_START_ID ((EntityID)1) ///< All entity id's currently start at 1
314 #define MB_END_ID ((EntityID)MB_ID_MASK) ///< Last id is the complement of the MASK
315 #define MB_ID_MASK (~MB_TYPE_MASK)
316 
317 #define MAX_DOFS_ON_ENTITY 512 ///< Maximal number of DOFs on entity
318 #define DOF_UID_MASK_ON_ENTITY (MAX_DOFS_ON_ENTITY-1) ///< Mask for DOF number on entity form UId
319 
320 #define NOT_USED(x) ( (void)(x) )
321 
322 /** \brief set barrier start
323  * Run code in sequence, starting from process 0, and ends on last process.
324  *
325  * It can be only used for testing. Do not use that function as a part of these
326  * code.
327  *
328  */
329 #define BARRIER_RANK_START(PCMB) \
330  { for(unsigned int i = 0; \
331  i<PCMB->proc_config().proc_rank(); i++) MPI_Barrier(PCMB->proc_config().proc_comm()); };
332 
333 /** \brief set barrier start
334  * Run code in sequence, starting from process 0, and ends on last process.
335  *
336  * It can be only used for testing. Do not use that function as a part of these
337  * code.
338  *
339  */
340 #define BARRIER_RANK_END(PCMB) \
341  { for(unsigned int i = PCMB->proc_config().proc_rank(); \
342  i<PCMB->proc_config().proc_size(); i++) MPI_Barrier(PCMB->proc_config().proc_comm()); };
343 
344 #ifdef __cplusplus
345 extern "C" {
346 #endif
347 
348 /**
349  * \brief Is used to indicate that macro is deprecated
350  * Do nothing just triggers error at the compilation
351  */
353 
354 #ifdef __cplusplus
355 }
356 #endif
357 
358 /**
359  * \brief check error code of MoAB function
360  * @param a MoABErrorCode
361  */
362 #define CHKERRQ_MOAB(a) do { \
363  ErrorCode val = (a); \
364  if (MB_SUCCESS != val) { \
365  std::ostringstream ss; \
366  ss << "Error code " << val << " at " << __FILE__ << ":" << __LINE__ << std::endl; \
367  std::string str(ss.str()); \
368  SETERRQ(PETSC_COMM_SELF,MOFEM_MOAB_ERROR,str.c_str()); \
369  } \
370 } while (false)
371 
372 /**
373  * \bried Check error code of MoAB function and throw MoFEM exception
374  * @param a MoABErrorCode
375  */
376 #define MOAB_THROW(a) do { \
377  ErrorCode val = (a); \
378  if (MB_SUCCESS != val) { \
379  std::ostringstream ss; \
380  ss << "Error code " << val << " at " << __FILE__ << ":" << __LINE__ << std::endl; \
381  throw MoFEMException(MOFEM_MOAB_ERROR,ss.str().c_str() ); \
382  } \
383 } while (false)
384 
385 /**
386  * \brief Throw MoFEM exception
387  * @param a message
388  */
389 #define THROW_MESSAGE(a) { \
390  std::ostringstream ss; \
391  ss << a << " " << " at " << __FILE__ << ":" << __LINE__ << std::endl; \
392  throw MoFEMException(MOFEM_MOFEMEXCEPTION_THROW,ss.str().c_str() ); \
393 }
394 
395 /**
396  * \brief Convert number to string
397  * @param x number
398  */
399 #define SSTR(x) toString(x)
400 
401 #endif //__DEFINITONS_H__
field with continuous normal traction
Definition: definitions.h:160
user implemented approximation base
Definition: definitions.h:129
block name is "MAT_MOISTURE"
Definition: definitions.h:226
create prisms from surface elements
Definition: definitions.h:59
scalar or vector of scalars describe (no true field)
Definition: definitions.h:158
HCurlFormatting
Format in rows of Hcurl base functions.
Definition: definitions.h:287
RowColData
RowColData.
Definition: definitions.h:184
used to merge nodes
Definition: definitions.h:57
DMInterfaces
interfaces for PETSc DM interfaces
Definition: definitions.h:78
FieldSpace in [ 0, LASTSPACE )
Definition: definitions.h:163
interface to med data format
Definition: definitions.h:56
static const char *const ApproximationBaseNames[]
Definition: definitions.h:133
Interfaces
Interfaces IDs.
Definition: definitions.h:41
Interface to manage coordinate systems.
Definition: definitions.h:61
used to generate mesh using TetGen
Definition: definitions.h:55
Not yet implemented, in implementation we will follow .
Definition: definitions.h:127
Cutting mesh.
Definition: definitions.h:62
FieldApproximationBase
approximation base
Definition: definitions.h:123
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:125
block name is "MAT_THERMAL"
Definition: definitions.h:224
ByWhat
Definition: definitions.h:193
block name is "BODY_FORCES"
Definition: definitions.h:225
static const char *const FieldSpaceNames[]
Definition: definitions.h:166
Interface to manage meshsets with materials and boundary conditions.
Definition: definitions.h:60
field with continuous tangents
Definition: definitions.h:161
BaseIntefaces
Interfaces uses to manage base functions.
Definition: definitions.h:86
CubitBC
Definition: definitions.h:207
FieldSpace
approximation spaces
Definition: definitions.h:156
DEPRECATED void macro_is_depracted_using_deprecated_function()
Is used to indicate that macro is deprecated Do nothing just triggers error at the compilation...
Definition: Core.cpp:69
block name is "MAT_ELASTIC"
Definition: definitions.h:222
used to couple bit levels by finding parent children relation
Definition: definitions.h:58
#define DEPRECATED
Definition: definitions.h:29
Like AINSWORTH_LEGENDRE_BASE but with Lobatto base instead Legendre .
Definition: definitions.h:126
LoopInterfaces
Definition: definitions.h:65
HCurlDiffFormatting
Format in rows of Hcurl gradients of base functions.
Definition: definitions.h:294
H1DiffFormating
Format of rows in gradients of H1 base functions.
Definition: definitions.h:266
HDivDiffFormatting
Format in rows of Hdiv gradients of base functions.
Definition: definitions.h:280
continuous field
Definition: definitions.h:159
MoFEMErrorCodes
Error handling.
Definition: definitions.h:108
static const char *const CubitBCNames[]
Names of types of sets and boundary conditions.
Definition: definitions.h:238
Construction of base is by Demkowicz .
Definition: definitions.h:128
MoFEMTypes
Those types control how functions respond on arguments, f.e. error handling.
Definition: definitions.h:177
field with C-1 continuity
Definition: definitions.h:162
HDivFormatting
Format in rows of Hdiv base functions.
Definition: definitions.h:273