-
-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathUtilities.C
84 lines (81 loc) · 2.43 KB
/
Utilities.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "Utilities.H"
using namespace Foam;
void adapterInfo(const std::string message, const std::string level)
{
if (level.compare("info") == 0)
{
// Prepend the message with a string
Info << INFO_STR_ADAPTER
<< message.c_str()
<< nl;
}
else if (level.compare("warning") == 0)
{
// Produce a warning message with cyan header
WarningInFunction
<< "\033[36m" // cyan color
<< "Warning in the preCICE adapter: "
<< "\033[0m" // restore color
<< nl
<< message.c_str()
<< nl
<< nl;
}
else if (level.compare("error") == 0)
{
// Produce an error message with red header
// and exit the functionObject.
// It will also exit the simulation, unless it
// is called inside the functionObject's read().
FatalErrorInFunction
<< "\033[31m" // red color
<< "Error in the preCICE adapter: "
<< "\033[0m" // restore color
<< nl
<< message.c_str()
<< nl
<< exit(FatalError);
}
else if (level.compare("error-deferred") == 0)
{
// Produce an warning message with red header.
// OpenFOAM degrades errors inside read()
// to warnings, stops the function object, but does
// not exit. We throw a warning which is described
// as an error, so that OpenFOAM does not exit,
// but the user still sees that this is the actual
// problem. We catch these errors and exit later.
WarningInFunction
<< "\033[31m" // red color
<< "Error (deferred - will exit later) in the preCICE adapter: "
<< "\033[0m" // restore color
<< nl
<< message.c_str()
<< nl
<< nl;
}
else if (level.compare("debug") == 0)
{
Pout << INFO_STR_ADAPTER
<< "[DEBUG] "
<< message.c_str()
<< nl;
}
else if (level.compare("dev") == 0)
{
Info << "\033[35m" // cyan color
<< INFO_STR_ADAPTER
<< "[under development] "
<< "\033[0m " // restore color
<< message.c_str()
<< nl;
}
else
{
Info << INFO_STR_ADAPTER
<< "[unknown info level] "
<< message.c_str()
<< nl;
}
return;
}