GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/common/dumuxmessage.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 219 219 100.0%
Functions: 1 1 100.0%
Branches: 99 108 91.7%

Line Branch Exec Source
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 //
4 // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 /*!
8 * \file
9 * \ingroup Core
10 * \brief Provides the class creating the famous DuMu<sup>x</sup> start and end messages
11 */
12 #ifndef DUMUX_MESSAGE_HH
13 #define DUMUX_MESSAGE_HH
14
15 #include <iomanip>
16 #include <iostream>
17 #include <ctime>
18
19 #include <dumux/io/format.hh>
20
21 namespace Dumux {
22
23 /*!
24 * \ingroup Core
25 * \brief DuMu<sup>x</sup> start and end message.
26 */
27 class DumuxMessage
28 {
29 //! The current number of messages. Please adjust if you add one.
30 static const int nMessages_ = 34;
31
32 public:
33
34 /*!
35 * \brief Selects random messages to write out at the start and end of a simulation run.
36 * \param firstCall Indicates if it's the first call and we have to dice (simulation is starting).
37 */
38 868 static void print(bool firstCall = false)
39 {
40 // initialize in case someone forgets to set first call
41 868 static int dice = 8;
42
43
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 404 times.
868 if(firstCall)
44 {
45 // roll the dice to decide which start message will be displayed
46 464 std::srand(std::time(0));
47 464 dice = std::rand() % (nMessages_ + 1);
48 }
49
50 868 std::cout << std::endl;
51
52
35/36
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 18 times.
✓ Branch 6 taken 31 times.
✓ Branch 7 taken 43 times.
✓ Branch 8 taken 46 times.
✓ Branch 9 taken 30 times.
✓ Branch 10 taken 35 times.
✓ Branch 11 taken 24 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 25 times.
✓ Branch 14 taken 29 times.
✓ Branch 15 taken 45 times.
✓ Branch 16 taken 17 times.
✓ Branch 17 taken 17 times.
✓ Branch 18 taken 8 times.
✓ Branch 19 taken 12 times.
✓ Branch 20 taken 12 times.
✓ Branch 21 taken 20 times.
✓ Branch 22 taken 37 times.
✓ Branch 23 taken 19 times.
✓ Branch 24 taken 36 times.
✓ Branch 25 taken 32 times.
✓ Branch 26 taken 16 times.
✓ Branch 27 taken 27 times.
✓ Branch 28 taken 20 times.
✓ Branch 29 taken 37 times.
✓ Branch 30 taken 20 times.
✓ Branch 31 taken 33 times.
✓ Branch 32 taken 13 times.
✓ Branch 33 taken 28 times.
✓ Branch 34 taken 19 times.
✗ Branch 35 not taken.
868 switch (dice)
53 {
54 29 case 0:
55
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 13 times.
29 if(firstCall)
56 16 std::cout << "Welcome aboard DuMuX airlines. Please fasten your seatbelts! "
57 48 << "Emergency exits are near the time integration." << std::endl;
58 else
59 26 std::cout << "We hope that you enjoyed simulating with us " << std::endl
60 26 << "and that you will choose us next time, too." << std::endl;
61 break;
62 23 case 1:
63
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9 times.
23 if(firstCall)
64 28 std::cout << "Let's get the cow off the ice." << std::endl;
65 else
66 18 std::cout << "DuMuX got the cow off the ice." << std::endl;
67 break;
68 21 case 2:
69
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 10 times.
21 if(firstCall)
70 11 std::cout << "Science, my lad, is made up of mistakes, but they are "
71 << "mistakes which it is useful to make, because they lead little "
72 44 << "by little to the truth." << std::endl
73 22 << " - Jules Verne, A journey to the center of the earth" << std::endl;
74 else
75 10 std::cout << "[We see that] science is eminently perfectible, and that each theory has "
76 30 << "constantly to give way to a fresh one." << std::endl
77 20 << " - Jules Verne, Journey to the Center of the Earth" << std::endl;
78
79 break;
80 16 case 3:
81
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 if(firstCall)
82 8 std::cout << "Wherever he saw a hole he always wanted to know the depth of it. "
83 24 << "To him this was important." << std::endl
84 16 << " - Jules Verne, A journey to the center of the earth" << std::endl;
85 else
86 16 std::cout << "We may brave human laws, but we cannot resist natural ones." << std::endl
87 16 << " - Jules Verne, 20,000 Leagues Under the Sea" << std::endl;
88 break;
89 14 case 4:
90
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 5 times.
14 if(firstCall)
91 18 std::cout << "Silence - to delight Bernd." << std::endl;
92 else
93 5 std::cout << std::endl << std::endl;
94 break;
95 18 case 5:
96 36 std::cout << "Don't panic... !" << std::endl;
97 break;
98 31 case 6:
99
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 15 times.
31 if(firstCall)
100 32 std::cout << "You idiot! You signed the order to destroy Earth!" << std::endl
101 32 << " - Douglas Adams, HGttG" << std::endl;
102 else
103 30 std::cout << "Marvin: I've been talking to the main computer." << std::endl
104 30 << "Arthur: And?" << std::endl
105 30 << "Marvin: It hates me." << std::endl
106 30 << " - Douglas Adams, HGttG" << std::endl;
107 break;
108 43 case 7:
109
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 20 times.
43 if(firstCall)
110 23 std::cout << "In the beginning the Universe was created. This has made a lot of "
111 69 << "people very angry and has been widely regarded as a bad move.!" << std::endl
112 46 << " - Douglas Adams, HGttG " << std::endl;
113 else
114 20 std::cout << "Forty-two. I checked it very thoroughly, and that quite definitely is the answer. I think "
115 60 << "the problem, to be quite honest with you, is that you\'ve never actually known what the question is." << std::endl
116 40 << " - Douglas Adams, HGttG " << std::endl;
117 break;
118 46 case 8:
119 92 std::cout << " ## @@@@ @ @ @ @" << std::endl;
120 92 std::cout << " ### # @ @ @@ @@ @ " << std::endl;
121 92 std::cout << " ## # @ @ @ @ @ @ @ @ @ @ @" << std::endl;
122 92 std::cout << " ## # @ @ @ @ @ @ @ @ " << std::endl;
123 92 std::cout << " # # @@@@ @@@ @ @ @@@ " << std::endl;
124 92 std::cout << " # # " << std::endl;
125 92 std::cout << " # # " << std::endl;
126 230 std::cout << " # ## %%% " << std::setw(8) << std::right << DUMUX_VERSION << std::endl;
127 92 std::cout << " # ### % % %% %% " << std::endl;
128 92 std::cout << "#### #%%% %% %%%%% %%%%%%%%%%%%%%%%%" << std::endl;
129 break;
130 30 case 9:
131 60 std::cout << "### # # # # " << std::endl;
132 60 std::cout << "# # # # ## ## # # # " << std::endl;
133 60 std::cout << "# # # # # # # # # # # " << std::endl;
134 60 std::cout << "### ## # # ## " << std::endl;
135 60 std::cout << " " << std::endl;
136 60 std::cout << "Dune for Multi-{ Phase, " << std::endl;
137 60 std::cout << " Component, " << std::endl;
138 60 std::cout << " Scale, " << std::endl;
139 60 std::cout << " Physics, " << std::endl;
140 60 std::cout << " ...} flow and transport in porous media" << std::endl;
141 break;
142 35 case 10:
143
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 17 times.
35 if(firstCall)
144 36 std::cout << "Elliot Carver: Mr. Jones, are we ready to release our new software?" << std::endl
145 36 << "Jones: Yes, sir. As requested, it's full of bugs, which means people will be forced to upgrade for years." << std::endl
146 36 << " - James Bond, Tomorrow Never Dies" << std::endl;
147 else
148 {
149 34 std::cout << "Elliot Carver: Outstanding." << std::endl
150 34 << " - James Bond, Tomorrow Never Dies" << std::endl;
151 }
152 break;
153 24 case 11:
154
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(firstCall)
155 24 std::cout << "Chuck Norris has successfully compiled DuMuX." << std::endl;
156 else
157 24 std::cout << "Chuck Norris has compiled DuMuX even two times in a row!" << std::endl;
158 break;
159 16 case 12:
160
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 if (firstCall)
161 {
162 16 std::cout << " ┌──────────────────┐" << std::endl;
163
4/12
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 8 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
24 std::cout << Fmt::format(" │{:^20}│", Fmt::format("DuMuX {} \u2661", DUMUX_VERSION)) << std::endl;
164 16 std::cout << " └──────────────────┘" << std::endl;
165 }
166 else
167 16 std::cout << "\n" << std::endl;
168 break;
169 25 case 13:
170
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 12 times.
25 if(firstCall)
171 {
172 26 std::cout << "Everything starts somewhere, though many physicists disagree." << std::endl
173 26 << " - Terry Pratchett " << std::endl;
174 }
175 else
176 {
177 24 std::cout << "Opera happens because a large number of things amazingly fail to go wrong." << std::endl
178 24 << " - Terry Pratchett " << std::endl;
179 }
180 break;
181 29 case 14:
182 58 std::cout << "To infinity and beyond." << std::endl
183 58 << " - Buzz Lightyear, Toy Story" << std::endl;
184 break;
185 45 case 15:
186
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 22 times.
45 if(firstCall)
187 {
188 46 std::cout << "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off." << std::endl
189 46 << " - Bjarne Stroustrup " << std::endl;
190 }
191 else
192 {
193 44 std::cout << "There's an old story about the person who wished his computer were as easy to use as his telephone." << std::endl
194 44 << "That wish has come true, since I no longer know how to use my telephone." << std::endl
195 44 << " - Bjarne Stroustrup " << std::endl;
196 }
197 break;
198 17 case 16:
199
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(firstCall)
200 {
201 18 std::cout << "Now, all we need is a little Energon and a lot of luck!" << std::endl
202 18 << " - Optimus Prime, The Transformers: The Movie " << std::endl;
203 }
204 else
205 {
206 16 std::cout << "Sometimes even the wisest of men and machines can be in error." << std::endl
207 16 << " - Optimus Prime, The Transformers: The Movie " << std::endl;
208 }
209 break;
210 17 case 17:
211
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(firstCall)
212 {
213 18 std::cout << "Let's go. In and out, 20 minutes adventure." << std::endl
214 18 << " - Rick Sanchez, Rick & Morty " << std::endl;
215 }
216 else
217 {
218 16 std::cout << "Losers look stuff up while the rest of us are carpin' all them diems." << std::endl
219 16 << " - Summer Smith, Rick & Morty" << std::endl;
220 }
221 break;
222 8 case 18:
223
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(firstCall)
224 {
225 12 std::cout << "It's the job that's never started as takes longest to finish." << std::endl
226 12 << " - Sam Gamgee, LotR " << std::endl;
227 }
228 else
229 {
230 4 std::cout << "He that breaks a thing to find out what it is, has left the path of wisdom." << std::endl
231 4 << " - Gandalf, LotR " << std::endl;
232 }
233 break;
234 12 case 19:
235
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if(firstCall)
236 {
237 12 std::cout << "The Ring has awoken, it's heard its master's call." << std::endl
238 12 << " - Gandalf, LotR " << std::endl;
239 }
240 else
241 {
242 12 std::cout << "It's a dangerous business, Frodo, going out your door. " << std::endl
243 12 << "You step onto the road, and if you don't keep your feet, there's no knowing where you might be swept off to." << std::endl
244 12 << " - Frodo Baggins, LotR " << std::endl;
245 }
246 break;
247 12 case 20:
248
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if(firstCall)
249 {
250 12 std::cout << "Who knows? Have patience. Go where you must go, and hope!" << std::endl
251 12 << " - Gandalf, LotR " << std::endl;
252 }
253 else
254 {
255 12 std::cout << "Don't adventures ever have an end? I suppose not. Someone else always has to carry on the story." << std::endl
256 12 << " - Bilbo Baggins, LotR " << std::endl;
257 }
258 break;
259 20 case 21:
260
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 10 times.
20 if(firstCall)
261 {
262 20 std::cout << "As long as I'm better than everyone else I suppose it doesn't matter." << std::endl
263 20 << " - Jamie Lannister, GoT" << std::endl;
264 }
265 else
266 {
267 20 std::cout << "My watch has ended." << std::endl
268 20 << " - Jon Snow, GoT" << std::endl;
269 }
270 break;
271 37 case 22:
272
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 18 times.
37 if(firstCall)
273 {
274 38 std::cout << "You'll find I'm full of surprises." << std::endl
275 38 << " - Luke Skywalker, Star Wars: The Empire Strikes Back " << std::endl;
276 }
277 else
278 {
279 36 std::cout << "I find your lack of faith disturbing." << std::endl
280 36 << " - Darth Vader, Star Wars: A New Hope " << std::endl;
281 }
282 break;
283 19 case 23:
284
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 9 times.
19 if(firstCall)
285 {
286 20 std::cout << "Here goes nothing." << std::endl
287 20 << " - Lando Calrissian, Star Wars: Return of the Jedi" << std::endl;
288 }
289 else
290 {
291 18 std::cout << "Chewie, we're home." << std::endl
292 18 << " - Han Solo, Star Wars: The Force Awakens" << std::endl;
293 }
294 break;
295 36 case 24:
296
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 17 times.
36 if(firstCall)
297 {
298 38 std::cout << "The Force is strong with this one." << std::endl
299 38 << " - Darth Vader, Star Wars: A New Hope " << std::endl;
300 }
301 else
302 {
303 34 std::cout << "In my experience, there's no such thing as luck." << std::endl
304 34 << " - Obi-Wan Kenobi, Star Wars: A New Hope " << std::endl;
305 }
306 break;
307 32 case 25:
308
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
32 if(firstCall)
309 {
310 36 std::cout << "The city's central computer told you? R2D2, you know better than to trust a strange computer!" << std::endl
311 36 << " - C3PO, Star Wars: The Empire Strikes Back " << std::endl;
312 }
313 else
314 {
315 28 std::cout << "He's quite clever, you know...for a human being." << std::endl
316 28 << " - C3PO, Star Wars: The Empire Strikes Back " << std::endl;
317 }
318 break;
319 16 case 26:
320
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 if(firstCall)
321 {
322 16 std::cout << "I know some things. I can, you know, do math and stuff." << std::endl
323 16 << " - Harry Potter " << std::endl;
324 }
325 else
326 {
327 16 std::cout << "Harry then did something that was both very brave and very stupid." << std::endl
328 16 << " - Harry Potter and the Sorcerer's Stone " << std::endl;
329 }
330 break;
331 27 case 27:
332
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 11 times.
27 if(firstCall)
333 {
334 32 std::cout << "I'll be in my bedroom, making no noise and pretending I'm not there." << std::endl
335 32 << " - Harry Potter " << std::endl;
336 }
337 else
338 {
339 22 std::cout << "Honestly, if you were any slower, you'd be going backward." << std::endl
340 22 << " - Draco Malfoy " << std::endl;
341 }
342 break;
343 20 case 28:
344 40 std::cout << "I can do this all day." << std::endl
345 40 << " - Captain America " << std::endl;
346 break;
347 37 case 29:
348
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 18 times.
37 if(firstCall)
349 {
350 38 std::cout << "Your scientists were so preoccupied with whether or not they could, they didn't stop to think if they should." << std::endl
351 38 << " - Ian Malcolm, Jurassic Park " << std::endl;
352 }
353 else
354 {
355 36 std::cout << "Boy, do I hate being right all the time." << std::endl
356 36 << " - Ian Malcolm, Jurassic Park " << std::endl;
357 }
358 break;
359 20 case 30:
360
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 9 times.
20 if(firstCall)
361 {
362 11 std::cout << "It's a UNIX System! I know this! "
363 33 << " - Lex Murphy, Jurassic Park " << std::endl;
364 }
365 else
366 {
367 18 std::cout << "When you gotta go, you gotta go." << std::endl
368 18 << " - Ian Malcolm, Jurassic Park " << std::endl;
369 }
370 break;
371 33 case 31:
372
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(firstCall)
373 {
374 17 std::cout << "Whatever happens, that's the plan. "
375 51 << " - Kayla Watts, Jurassic World Dominion " << std::endl;
376 }
377 else
378 {
379 32 std::cout << "Can we start over?" << std::endl
380 32 << " - Claire Dearing, Jurassic World Dominion " << std::endl;
381 }
382 break;
383 13 case 32:
384
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6 times.
13 if(firstCall)
385 {
386 7 std::cout << "The code is more what you'd call 'guidelines' than actual rules. "
387 21 << " - Hector Barbossa, Pirates of the Caribbean " << std::endl;
388 }
389 else
390 {
391 12 std::cout << "Did everyone see that? Because I will not be doing it again." << std::endl
392 12 << " - Jack Sparrow, Pirates of the Caribbean " << std::endl;
393 }
394 break;
395 28 case 33:
396
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 13 times.
28 if(firstCall)
397 {
398 15 std::cout << "If you were waiting for the opportune moment, that was it. "
399 45 << " - Jack Sparrow, Pirates of the Caribbean " << std::endl;
400 }
401 else
402 {
403 26 std::cout << "I love those moments. I like to wave at them as they pass by." << std::endl
404 26 << " - Jack Sparrow, Pirates of the Caribbean " << std::endl;
405 }
406 break;
407 19 case 34:
408 38 std::cout << "And that was without even a single drop of rum." << std::endl
409 38 << " - Jack Sparrow, Pirates of the Caribbean " << std::endl;
410 break;
411
412 // Note: If you add a case, you have to increase the number of messages (nMessages_ variable).
413
414 default: // silence to delight Bernd
415 return;
416 }
417 868 std::cout << std::endl;
418 }
419 };
420
421 } // end namespace Dumux
422
423 #endif
424