www.cemf.ir
timeControl.hpp
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 
22 #ifndef __timeControl_hpp__
23 #define __timeControl_hpp__
24 
25 #include "types.hpp"
26 #include "ranges.hpp"
27 #include "streams.hpp"
28 #include "timeInfo.hpp"
29 
30 namespace pFlow
31 {
32 
33 
34 class dictionary;
35 
36 
38 {
39 private:
40 
41 
43 
44  // - integration time step
46 
47  // - start time of simulation
49 
50  // - end time of simulation
52 
53  // - stopAt
55 
56  // - current time of simulation
58 
59  // - time interval for time folder output
61 
62  // - the last time folder that was saved
64 
65  // - current iteration number (for this execution)
67 
68  // - time precision for output time folders
70 
71  bool managedExternaly_ = false;
72 
73  word timeName_ = "wrongSettings"; // for managedExternamly
74 
75  real writeTime_ = 0; // for managedExternamly
76 
78 
80 
82 
84 
85  bool outputToFile_ = false;
86 
87  void checkForOutputToFile();
88 
89  bool screenReport()const;
90 
91 public:
92 
93  explicit timeControl(const dictionary& dict);
94 
96  dictionary& dict,
98  real endTime,
99  real saveInterval,
100  word startTimeName);
101 
102  virtual ~timeControl() = default;
103 
104  real dt()const
105  {
106  return dt_;
107  }
108 
109  real setTime(real t);
110 
111 
112  void setStopAt(real sT)
113  {
115  {
116  stopAt_ = sT;
117  }
118  }
119 
121  {
122  return startTime_;
123  }
124 
125  word timeName()const;
126 
127  real currentTime() const
128  {
129  return currentTime_;
130  }
131 
132  word currentTimeWord(bool forSave = true)const
133  {
135  /*if(forSave)
136  {
137  if(!managedExternaly_)
138 
139  else
140  return timeName_;
141  }
142  else
143  {
144  return real2FixedStripZeros( currentTime(), timePrecision());
145  }*/
146  }
147 
149  {
150  return currentIter_;
151  }
152 
153  bool finalTime()const;
154 
155  bool reachedStopAt()const;
156 
157  bool outputToFile()const
158  {
159  return outputToFile_;
160  }
161 
162  bool timersReportTime()const;
163 
164  bool sortTime()const;
165 
166  bool setOutputToFile(real writeTime, const word& timeName)
167  {
169  {
171  writeTime_ = writeTime;
172  }
173  return true;
174  }
175 
176  bool operator ++(int);
177 
178  void setSaveTimeFolder(
179  bool saveToFile,
180  const word& timeName = "wrongTimeFolder");
181 
183  {
184  return timePrecision_;
185  }
186 
187  inline
189  {
190  return {static_cast<uint32>(currentIter_), currentTime_, dt_};
191  }
192 
193 
194 };
195 
196 
197 } // pFlow
198 
199 #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:181
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::real2FixedStripZeros
word real2FixedStripZeros(const real &v, int32 numPrecision=6)
Convert to fixed point variable and remove zeros.
Definition: bTypesFunctions.cpp:149
timeInfo.hpp
pFlow::timeControl::stopAt_
real stopAt_
Definition: timeControl.hpp:54
pFlow::timeControl::operator++
bool operator++(int)
Definition: timeControl.cpp:203
pFlow::timeControl::sortTime
bool sortTime() const
Definition: timeControl.cpp:187
types.hpp
pFlow::timeControl::dt
real dt() const
Definition: timeControl.hpp:104
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:166
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
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::timeInfo
Definition: timeInfo.hpp:28
pFlow::timeControl::lastSaved_
real lastSaved_
Definition: timeControl.hpp:63
pFlow
Definition: demGeometry.hpp:27
pFlow::timeControl::timeName
word timeName() const
Definition: timeControl.cpp:129
pFlow::timeControl::~timeControl
virtual ~timeControl()=default
pFlow::timeControl::performSorting_
Logical performSorting_
Definition: timeControl.hpp:79
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::timeControl::sortingInterval_
realStridedRange sortingInterval_
Definition: timeControl.hpp:81
pFlow::timeControl::setTime
real setTime(real t)
Definition: timeControl.cpp:120
pFlow::timeControl::screenReportInterval_
int32StridedRagne screenReportInterval_
Definition: timeControl.hpp:83
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:151
pFlow::timeControl::outputToFile
bool outputToFile() const
Definition: timeControl.hpp:157
pFlow::timeControl::saveInterval_
real saveInterval_
Definition: timeControl.hpp:60
pFlow::timeControl::TimeInfo
timeInfo TimeInfo() const
Definition: timeControl.hpp:188
streams.hpp
pFlow::timeControl::currentTime
real currentTime() const
Definition: timeControl.hpp:127
pFlow::timeControl::finalTime
bool finalTime() const
Definition: timeControl.cpp:137
pFlow::timeControl::currentIter
int32 currentIter() const
Definition: timeControl.hpp:148
pFlow::Logical
Holds a bool value and converts strings to bool.
Definition: Logical.hpp:39
pFlow::timeControl::timeControl
timeControl(const dictionary &dict)
Definition: timeControl.cpp:32
pFlow::timeControl::outputToFile_
bool outputToFile_
Definition: timeControl.hpp:85
pFlow::timeControl::currentIter_
int32 currentIter_
Definition: timeControl.hpp:66
pFlow::timeControl::startTime
real startTime() const
Definition: timeControl.hpp:120
pFlow::timeControl::currentTimeWord
word currentTimeWord(bool forSave=true) const
Definition: timeControl.hpp:132
pFlow::timeControl::setSaveTimeFolder
void setSaveTimeFolder(bool saveToFile, const word &timeName="wrongTimeFolder")
Definition: timeControl.cpp:192
pFlow::timeControl::setStopAt
void setStopAt(real sT)
Definition: timeControl.hpp:112
pFlow::dictionary
Dictionary holds a set of data entries or sub-dictionaries that are enclosed in a curely braces or ar...
Definition: dictionary.hpp:67
pFlow::timeControl::reachedStopAt
bool reachedStopAt() const
Definition: timeControl.cpp:144
pFlow::timeControl::timePrecision
int32 timePrecision() const
Definition: timeControl.hpp:182