OpenCAEPoro
v0.5.0
A simulator for multicomponent porous media flow
include
UtilError.hpp
Go to the documentation of this file.
1
12
#ifndef __ERRORLOG_HXX__
/*-- allow multiple inclusions --*/
13
#define __ERRORLOG_HXX__
15
// Standard header files
16
#include <iomanip>
17
#include <iostream>
18
#include <sstream>
19
21
#define OCP_LOCATION \
22
"\n --> function: "
<< __PRETTY_FUNCTION__ \
23
<< "\n --> file: " << __FILE__ << "::" << __LINE__
24
26
// msg: user-defined error message
27
// We use do-while to allow the macro to be ended with ";"
28
#define OCP_MESSAGE(msg) \
29
do { \
30
std::ostringstream info; \
31
info << std::setprecision(16); \
32
info << msg << OCP_LOCATION << '\n'; \
33
std::cerr << info.str().c_str(); \
34
} while (false)
35
37
// msg: user-defined warning message
38
// We use do-while to allow the macro to be ended with ";"
39
#define OCP_WARNING(msg) \
40
do { \
41
OCP_MESSAGE("### WARNING: "
<< (msg)); \
42
} while (false)
43
45
// msg: user-defined abort message
46
// We use do-while to allow the macro to be ended with ";"
47
#define OCP_ABORT(msg) \
48
do { \
49
OCP_MESSAGE("### ABORT: "
<< (msg)); \
50
std::abort(); \
51
} while (false)
52
54
// cond: check condition
55
// msg: user-defined error message
56
// We use do-while to allow the macro to be ended with ";"
57
#ifndef DEBUG
58
#define OCP_ASSERT(cond, msg) \
59
do { \
60
} while (false)
61
#else
62
#define OCP_ASSERT(cond, msg) \
63
do { \
64
if (!(cond)) { \
65
OCP_MESSAGE("### ASSERT: "
<< (msg) << " (" << #cond << ")"); \
66
std::abort(); \
67
} \
68
} while (false)
69
#endif
70
72
#ifndef OCPFUNCNAME
73
#define OCP_FUNCNAME \
74
do { \
75
} while (false)
76
#else
77
#define OCP_FUNCNAME \
78
do { \
79
std::cout << __FUNCTION__ << std::endl; \
80
} while (false)
81
#endif
82
83
#endif
/* end if for __ERRORLOG_HXX__ */
84
85
/*----------------------------------------------------------------------------*/
86
/* Brief Change History of This File */
87
/*----------------------------------------------------------------------------*/
88
/* Author Date Actions */
89
/*----------------------------------------------------------------------------*/
90
/* Shizhe Li Oct/01/2021 Create file */
91
/* Chensong Zhang Oct/15/2021 Format file */
92
/* Chensong Zhang Nov/15/2021 Test DEBUG mode */
93
/*----------------------------------------------------------------------------*/
Generated on Tue Feb 7 2023 01:49:51 for OpenCAEPoro by
1.9.1