PhasicFlow
v0.1
www.cemf.ir
Timer.cpp
Go to the documentation of this file.
1
/*------------------------------- phasicFlow ---------------------------------
2
O C enter of
3
O O E ngineering and
4
O O M ultiscale modeling of
5
OOOOOOO F luid flow
6
------------------------------------------------------------------------------
7
Copyright (C): www.cemf.ir
8
email: hamid.r.norouzi AT gmail.com
9
------------------------------------------------------------------------------
10
Licence:
11
This file is part of phasicFlow code. It is a free software for simulating
12
granular and multiphase flows. You can redistribute it and/or modify it under
13
the terms of GNU General Public License v3 or any other later versions.
14
15
phasicFlow is distributed to help others in their research in the field of
16
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
19
-----------------------------------------------------------------------------*/
20
21
#include "
Timer.hpp
"
22
#include "
Timers.hpp
"
23
#include "
streams.hpp
"
24
25
pFlow::Timer::Timer
(
const
word
name,
Timers
* parrent)
26
:
27
name_(name),
28
parrent_(parrent)
29
{
30
if
(
parrent_
)
31
parrent_
->
addToList
(
this
);
32
}
33
34
35
pFlow::Timer::~Timer
()
36
{
37
if
(parrent_)
38
{
39
parrent_->removeFromList(
this
);
40
}
41
}
42
43
pFlow::int32
pFlow::Timer::level
()
const
44
{
45
if
(parrent_)
46
return
parrent_->level()+1;
47
else
48
return
0;
49
}
50
51
52
bool
pFlow::Timer::write
(
iOstream
& os,
bool
subTree)
const
53
{
54
55
if
(!timerActive() && !master())
return
true
;
56
57
58
int32
lvl = level();
59
for
(
int32
l=1; l<lvl; l++)
60
{
61
os<<
"┃ "
;
62
}
63
64
if
(lvl>0)
65
{
66
67
if
(master())
68
os<<
"┣━━ "
;
69
else
70
if
(lvl==1)
71
os<<
"┃└─ "
;
72
else
73
os<<
" └─ "
;
74
}
75
else
76
;
//os<<"⊿ ";
77
78
if
(lvl==0)
79
os<<
greenColor
<<
boldChar
;
80
else
if
(master())
81
os<<
yellowColor
;
82
83
84
os<<name_;
85
86
auto
tt = accTimersTotal();
87
if
(
abs
(tt)>
smallValue
)
88
{
89
os<<
" execution time (s): total ("
<<
90
tt<<
")"
;
91
92
if
(!master())
93
{
94
os<<
", av. ("
<<
95
averageTime()<<
")."
;
96
}
97
}
98
99
os<<
defaultColor
;
100
os<<
'\n'
;
101
102
return
true
;
103
}
pFlow::Timers::addToList
void addToList(Timer *timer)
Definition:
Timers.hpp:78
pFlow::smallValue
const real smallValue
Definition:
numericConstants.hpp:33
pFlow::Timer::write
virtual bool write(iOstream &os, bool subTree) const
Definition:
Timer.cpp:52
pFlow::word
std::string word
Definition:
builtinTypes.hpp:63
pFlow::Timers
Definition:
Timers.hpp:33
boldChar
const char * boldChar
Definition:
iOstream.hpp:41
pFlow::Timer::Timer
Timer()
Definition:
Timer.hpp:66
pFlow::Timer::parrent_
Timers * parrent_
Definition:
Timer.hpp:60
pFlow::Timer::~Timer
virtual ~Timer()
Definition:
Timer.cpp:35
pFlow::int32
int int32
Definition:
builtinTypes.hpp:53
defaultColor
const char * defaultColor
Definition:
iOstream.hpp:31
pFlow::abs
INLINE_FUNCTION_HD real abs(real x)
Definition:
math.hpp:43
pFlow::Timer::level
virtual int32 level() const
Definition:
Timer.cpp:43
streams.hpp
Timers.hpp
Timer.hpp
yellowColor
const char * yellowColor
Definition:
iOstream.hpp:35
else
else
Definition:
initialize_Control.hpp:43
pFlow::iOstream
Definition:
iOstream.hpp:53
greenColor
const char * greenColor
Definition:
iOstream.hpp:34
src
phasicFlow
Timer
Timer.cpp
Generated by
1.8.17