# PhasicFlow: src/phasicFlow/repository/Time/timeControl.hpp Source File

timeControl.hpp
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.
-----------------------------------------------------------------------------*/
#ifndef __timeControl_hpp__
#define __timeControl_hpp__
#include "types.hpp"
#include "ranges.hpp"
#include "streams.hpp"
namespace pFlow
{
class dictionary;
class timeControl
{
protected:
// - integration time step
real dt_;
// - start time of simulation
real startTime_;
// - end time of simulation
real endTime_;
// - stopAt
real stopAt_;
// - current time of simulation
real currentTime_;
// - time interval for time folder output
real saveInterval_;
// - the last time folder that was saved
real lastSaved_;
// - current iteration number (for this execution)
int32 currentIter_;
// - time precision for output time folders
int32 timePrecision_;
bool managedExternaly_ = false;
word timeName_ = "wrongSettings"; // for managedExternamly
real writeTime_ = 0; // for managedExternamly
realStridedRange timersReportInterval_;
int32StridedRagne screenReportInterval_ ={0,100};
bool outputToFile_ = false;
void checkForOutputToFile();
bool screenReport()const;
public:
timeControl(const dictionary& dict);
timeControl(
dictionary& dict,
real startTime,
real endTime,
real saveInterval,
word startTimeName);
virtual ~timeControl()
{}
real dt()const
{
return dt_;
}
real setTime(real t)
{
real tmp = currentTime_;
currentTime_ = t;
lastSaved_ = t;
checkForOutputToFile();
return tmp;
}
void setStopAt(real sT)
{
if(managedExternaly_)
{
stopAt_ = sT;
}
}
real startTime()const
{
return startTime_;
}
word timeName()const;
real currentTime() const
{
return currentTime_;
}
word currentTimeWord(bool forSave = true)const
{
return real2FixedStripZeros( currentTime(), timePrecision());
/*if(forSave)
{
if(!managedExternaly_)
else
return timeName_;
}
else
{
return real2FixedStripZeros( currentTime(), timePrecision());
}*/
}
int32 currentIter()const
{
return currentIter_;
}
bool finalTime()const;
bool reachedStopAt()const;
bool outputToFile()const
{
return outputToFile_;
}
bool timersReportTime()const;
bool setOutputToFile(real writeTime, const word& timeName)
{
if(managedExternaly_)
{
timeName_ = timeName;
writeTime_ = writeTime;
}
return true;
}
bool operator ++(int);
void setSaveTimeFolder(
bool saveToFile,
const word& timeName = "wrongTimeFolder");
int32 timePrecision()const
{
return timePrecision_;
}
};
} // pFlow
#endif // __timeControl_hpp__
pFlow::timeControl::timersReportInterval_
realStridedRange timersReportInterval_
Definition: timeControl.hpp:77
pFlow::timeControl::startTime_
real startTime_
Definition: timeControl.hpp:48
pFlow::timeControl::timeName_
word timeName_
Definition: timeControl.hpp:73
pFlow::timeControl::managedExternaly_
bool managedExternaly_
Definition: timeControl.hpp:71
pFlow::timeControl::timersReportTime
bool timersReportTime() const
Definition: timeControl.cpp:157
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::real2FixedStripZeros
word real2FixedStripZeros(const real &v, int32 numPrecision=6)
Definition: bTypesFunctions.cpp:101
pFlow::timeControl::stopAt_
real stopAt_
Definition: timeControl.hpp:54
pFlow::timeControl::operator++
bool operator++(int)
Definition: timeControl.cpp:174
pFlow::timeControl::setTime
real setTime(real t)
Definition: timeControl.hpp:107
types.hpp
pFlow::timeControl::dt
real dt() const
Definition: timeControl.hpp:102
pFlow::timeControl::currentTime_
real currentTime_
Definition: timeControl.hpp:57
pFlow::timeControl::writeTime_
real writeTime_
Definition: timeControl.hpp:75
pFlow::timeControl::setOutputToFile
bool setOutputToFile(real writeTime, const word &timeName)
Definition: timeControl.hpp:168
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::stridedRange< real >
pFlow::timeControl::endTime_
real endTime_
Definition: timeControl.hpp:51
pFlow::timeControl::dt_
real dt_
Definition: timeControl.hpp:45
pFlow::timeControl::timePrecision_
int32 timePrecision_
Definition: timeControl.hpp:69
pFlow::timeControl::lastSaved_
real lastSaved_
Definition: timeControl.hpp:63
pFlow
Definition: demComponent.hpp:28
pFlow::timeControl::~timeControl
virtual ~timeControl()
Definition: timeControl.hpp:98
pFlow::timeControl::timeName
word timeName() const
Definition: timeControl.cpp:103
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::timeControl::screenReportInterval_
int32StridedRagne screenReportInterval_
Definition: timeControl.hpp:79
pFlow::timeControl
Definition: timeControl.hpp:37
pFlow::timeControl::screenReport
bool screenReport() const
Definition: timeControl.cpp:26
ranges.hpp
pFlow::timeControl::checkForOutputToFile
void checkForOutputToFile()
Definition: timeControl.cpp:125
pFlow::timeControl::outputToFile
bool outputToFile() const
Definition: timeControl.hpp:161
pFlow::timeControl::saveInterval_
real saveInterval_
Definition: timeControl.hpp:60
streams.hpp
pFlow::timeControl::currentTime
real currentTime() const
Definition: timeControl.hpp:131
pFlow::timeControl::finalTime
bool finalTime() const
Definition: timeControl.cpp:111
pFlow::timeControl::currentIter
int32 currentIter() const
Definition: timeControl.hpp:152
pFlow::timeControl::timeControl
timeControl(const dictionary &dict)
Definition: timeControl.cpp:32
pFlow::timeControl::outputToFile_
bool outputToFile_
Definition: timeControl.hpp:81
pFlow::timeControl::currentIter_
int32 currentIter_
Definition: timeControl.hpp:66
pFlow::timeControl::startTime
real startTime() const
Definition: timeControl.hpp:124
pFlow::timeControl::currentTimeWord
word currentTimeWord(bool forSave=true) const
Definition: timeControl.hpp:136
pFlow::timeControl::setSaveTimeFolder
void setSaveTimeFolder(bool saveToFile, const word &timeName="wrongTimeFolder")
Definition: timeControl.cpp:163
pFlow::timeControl::setStopAt
void setStopAt(real sT)
Definition: timeControl.hpp:116
pFlow::dictionary
Definition: dictionary.hpp:38
pFlow::timeControl::reachedStopAt
bool reachedStopAt() const
Definition: timeControl.cpp:118
pFlow::timeControl::timePrecision
int32 timePrecision() const
Definition: timeControl.hpp:184