Scippy

UG

Ubiquity Generator framework

paraDef.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and software framework */
4 /* UG --- Ubquity Generator Framework */
5 /* */
6 /* Copyright Written by Yuji Shinano <shinano@zib.de>, */
7 /* Copyright (C) 2021 by Zuse Institute Berlin, */
8 /* licensed under LGPL version 3 or later. */
9 /* Commercial licenses are available through <licenses@zib.de> */
10 /* */
11 /* This code is free software; you can redistribute it and/or */
12 /* modify it under the terms of the GNU Lesser General Public License */
13 /* as published by the Free Software Foundation; either version 3 */
14 /* of the License, or (at your option) any later version. */
15 /* */
16 /* This program is distributed in the hope that it will be useful, */
17 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
18 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
19 /* GNU Lesser General Public License for more details. */
20 /* */
21 /* You should have received a copy of the GNU Lesser General Public License */
22 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 /* */
24 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
25 
26 /**@file paraDef.h
27  * @brief Defines for UG Framework
28  * @author Yuji Shinano
29  *
30  *
31  *
32  */
33 
34 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35 
36 
37 #ifndef __PARA_DEF_H__
38 #define __PARA_DEF_H__
39 #include <stdexcept>
40 #include <iostream>
41 #include <sstream>
42 #include <string>
43 #include <cfloat>
44 
45 namespace UG
46 {
47 
48 #define UG_VERSION 100 /**< UG version number (multiplied by 100 to get integer number) */
49 #define DEFAULT_NUM_EPSILON 1e-9 /**< default upper bound for floating points to be considered zero */
50 #define MINEPSILON 1e-20 /**< minimum value for any numerical epsilon */
51 
52 #define THROW_LOGICAL_ERROR1( msg1 ) \
53  { \
54  std::ostringstream s; \
55  s << "[LOGICAL ERROR:" << __FILE__ << "] func = " \
56  << __func__ << ", line = " << __LINE__ << " - " \
57  << ( msg1 ); \
58  throw std::logic_error( s.str() ); \
59  }
60 
61 #define ABORT_LOGICAL_ERROR1( msg1 ) \
62  { \
63  std::cerr << "[LOGICAL ERROR:" << __FILE__ << "] func = " \
64  << __func__ << ", line = " << __LINE__ << " - " \
65  << ( msg1 ); \
66  abort(); \
67  }
68 
69 #define THROW_LOGICAL_ERROR2( msg1, msg2 ) \
70  { \
71  std::ostringstream s_; \
72  s_ << "[LOGICAL ERROR:" << __FILE__ << "] func = " \
73  << __func__ << ", line = " << __LINE__ << " - " \
74  << ( msg1 ) << ( msg2 ); \
75  throw std::logic_error( s_.str() ); \
76  }
77 
78 #define ABORT_LOGICAL_ERROR2( msg1, msg2 ) \
79  { \
80  std::cerr << "[LOGICAL ERROR:" << __FILE__ << "] func = " \
81  << __func__ << ", line = " << __LINE__ << " - " \
82  << ( msg1 ) << ( msg2 ); \
83  abort(); \
84  }
85 
86 #define THROW_LOGICAL_ERROR3( msg1, msg2, msg3 ) \
87  { \
88  std::ostringstream s_; \
89  s_ << "[LOGICAL ERROR:" << __FILE__ << "] func = " \
90  << __func__ << ", line = " << __LINE__ << " - " \
91  << ( msg1 ) << ( msg2 ) << ( msg3 ); \
92  throw std::logic_error( s_.str() ); \
93  }
94 
95 #define ABORT_LOGICAL_ERROR3( msg1, msg2, msg3 ) \
96  { \
97  std::cerr << "[LOGICAL ERROR:" << __FILE__ << "] func = " \
98  << __func__ << ", line = " << __LINE__ << " - " \
99  << ( msg1 ) << ( msg2 ) << ( msg3 ); \
100  abort(); \
101  }
102 
103 #define THROW_LOGICAL_ERROR4( msg1, msg2, msg3, msg4 ) \
104  { \
105  std::ostringstream s_; \
106  s_ << "[LOGICAL ERROR:" << __FILE__ << "] func = " \
107  << __func__ << ", line = " << __LINE__ << " - " \
108  << ( msg1 ) << ( msg2 ) << ( msg3 ) << ( msg4 ); \
109  throw std::logic_error( s_.str() ); \
110  }
111 
112 #define THROW_LOGICAL_ERROR5( msg1, msg2, msg3, msg4, msg5) \
113  { \
114  std::ostringstream s_; \
115  s_ << "[LOGICAL ERROR:" << __FILE__ << "] func = " \
116  << __func__ << ", line = " << __LINE__ << " - " \
117  << ( msg1 ) << ( msg2 ) << ( msg3 ) << ( msg4 ) << ( msg5 ); \
118  throw std::logic_error( s_.str() ); \
119  }
120 
121 #define THROW_LOGICAL_ERROR6( msg1, msg2, msg3, msg4, msg5, msg6) \
122  { \
123  std::ostringstream s_; \
124  s_ << "[LOGICAL ERROR:" << __FILE__ << "] func = " \
125  << __func__ << ", line = " << __LINE__ << " - " \
126  << ( msg1 ) << ( msg2 ) << ( msg3 ) << ( msg4 ) << ( msg5 ) << ( msg6 ); \
127  throw std::logic_error( s_.str() ); \
128  }
129 
130 #define THROW_LOGICAL_ERROR7( msg1, msg2, msg3, msg4, msg5, msg6, msg7) \
131  { \
132  std::ostringstream s_; \
133  s_ << "[LOGICAL ERROR:" << __FILE__ << "] func = " \
134  << __func__ << ", line = " << __LINE__ << " - " \
135  << ( msg1 ) << ( msg2 ) << ( msg3 ) << ( msg4 ) << ( msg5 ) << ( msg6 ) << ( msg7 ); \
136  throw std::logic_error( s_.str() ); \
137  }
138 
139 #define THROW_LOGICAL_ERROR8( msg1, msg2, msg3, msg4, msg5, msg6, msg7, msg8) \
140  { \
141  std::ostringstream s_; \
142  s_ << "[LOGICAL ERROR:" << __FILE__ << "] func = " \
143  << __func__ << ", line = " << __LINE__ << " - " \
144  << ( msg1 ) << ( msg2 ) << ( msg3 ) << ( msg4 ) << ( msg5 ) << ( msg6 ) << ( msg7 ) << ( msg8 ); \
145  throw std::logic_error( s_.str() ); \
146  }
147 
148 #define THROW_LOGICAL_ERROR9( msg1, msg2, msg3, msg4, msg5, msg6, msg7, msg8, msg9) \
149  { \
150  std::ostringstream s_; \
151  s_ << "[LOGICAL ERROR:" << __FILE__ << "] func = " \
152  << __func__ << ", line = " << __LINE__ << " - " \
153  << ( msg1 ) << ( msg2 ) << ( msg3 ) << ( msg4 ) << ( msg5 ) << ( msg6 ) << ( msg7 ) << ( msg8 ) << ( msg9 ); \
154  throw std::logic_error( s_.str() ); \
155  }
156 
157 #ifdef _COMM_MPI_WORLD
158 #define DELETE_TRANSFER_OBJECT_IN_THREADED_SOLVER( object ) \
159 
160 #else
161 #define DELETE_TRANSFER_OBJECT_IN_THREADED_SOLVER( object ) \
162  if( object ) delete object
163 #endif
164 
165 #define REALABS(x) (fabs(x))
166 #define EPSEQ(x,y,eps) (REALABS((x)-(y)) <= (eps))
167 #define EPSLT(x,y,eps) ((x)-(y) < -(eps))
168 #define EPSLE(x,y,eps) ((x)-(y) <= (eps))
169 #define EPSGT(x,y,eps) ((x)-(y) > (eps))
170 #define EPSGE(x,y,eps) ((x)-(y) >= -(eps))
171 #define EPSZ(x,eps) (REALABS(x) <= (eps))
172 #define EPSP(x,eps) ((x) > (eps))
173 #define EPSN(x,eps) ((x) < -(eps))
174 #define EPSFLOOR(x,eps) (floor((x)+(eps)))
175 #define EPSCEIL(x,eps) (ceil((x)-(eps)))
176 #define EPSFRAC(x,eps) ((x)-EPSFLOOR(x,eps))
177 #define EPSISINT(x,eps) (EPSFRAC(x,eps) <= (eps))
178 
179 static const int MaxStrLen = 1024;
180 static const int LpMaxNamelen = 1024;
181 
182 static const int CompTerminatedNormally = 0;
183 static const int CompTerminatedByAnotherTask = 1;
184 static const int CompTerminatedByInterruptRequest = 2;
185 static const int CompTerminatedInRacingStage = 3;
186 static const int CompInterruptedInRacingStage = 4;
187 static const int CompInterruptedInMerging = 5;
188 static const int CompTerminatedByTimeLimit = 6;
189 static const int CompTerminatedByMemoryLimit = 7;
190 
191 }
192 
193 #endif // __PARA_DEF_H__
static const int LpMaxNamelen
Definition: paraDef.h:180
static const int CompTerminatedByInterruptRequest
Definition: paraDef.h:184
static const int CompTerminatedByTimeLimit
Definition: paraDef.h:188
static const int CompTerminatedByMemoryLimit
Definition: paraDef.h:189
static const int CompInterruptedInMerging
Definition: paraDef.h:187
static const int CompTerminatedByAnotherTask
Definition: paraDef.h:183
static const int CompInterruptedInRacingStage
Definition: paraDef.h:186
static const int CompTerminatedNormally
Definition: paraDef.h:182
static const int MaxStrLen
Definition: paraDef.h:179
static const int CompTerminatedInRacingStage
Definition: paraDef.h:185