# PhasicFlow: src/phasicFlow/Timer/Timer.cpp Source File

Timer.cpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#include "Timer.hpp"
#include "Timers.hpp"
#include "streams.hpp"
pFlow::Timer::Timer(const word name, Timers* parrent)
:
name_(name),
parrent_(parrent)
{
if(parrent_)
parrent_->addToList(this);
}
pFlow::Timer::~Timer()
{
if(parrent_)
{
parrent_->removeFromList(this);
}
}
pFlow::int32 pFlow::Timer::level()const
{
if(parrent_)
return parrent_->level()+1;
else
return 0;
}
bool pFlow::Timer::write(iOstream& os, bool subTree)const
{
if(!timerActive() && !master())return true;
int32 lvl = level();
for(int32 l=1; l<lvl; l++)
{
os<<"┃ ";
}
if(lvl>0)
{
if(master())
os<<"┣━━ ";
else
if(lvl==1)
os<<"┃└─ ";
else
os<<" └─ ";
}
else
; //os<<"⊿ ";
if(lvl==0)
os<<greenColor<<boldChar;
else if(master())
os<<yellowColor;
os<<name_;
auto tt = accTimersTotal();
if(abs(tt)>smallValue)
{
os<<" execution time (s): total ("<<
tt<<")";
if(!master())
{
os<<", av. ("<<
averageTime()<<").";
}
}
os<<defaultColor;
os<<'\n';
return true;
}
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