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 
29 
30 namespace pFlow
31 {
32 
33 
34 class dictionary;
35 
36 
38 {
39 protected:
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  timeControl(const dictionary& dict);
94 
96  dictionary& dict,
98  real endTime,
99  real saveInterval,
100  word startTimeName);
101 
102  virtual ~timeControl()
103  {}
104 
105 
106  real dt()const
107  {
108  return dt_;
109  }
110 
112  {
113  real tmp = currentTime_;
114  currentTime_ = t;
115  lastSaved_ = t;
117  return tmp;
118  }
119 
120  void setStopAt(real sT)
121  {
123  {
124  stopAt_ = sT;
125  }
126  }
127 
129  {
130  return startTime_;
131  }
132 
133  word timeName()const;
134 
135  real currentTime() const
136  {
137  return currentTime_;
138  }
139 
140  word currentTimeWord(bool forSave = true)const
141  {
143  /*if(forSave)
144  {
145  if(!managedExternaly_)
146 
147  else
148  return timeName_;
149  }
150  else
151  {
152  return real2FixedStripZeros( currentTime(), timePrecision());
153  }*/
154  }
155 
157  {
158  return currentIter_;
159  }
160 
161  bool finalTime()const;
162 
163  bool reachedStopAt()const;
164 
165  bool outputToFile()const
166  {
167  return outputToFile_;
168  }
169 
170  bool timersReportTime()const;
171 
172  bool sortTime()const;
173 
174  bool setOutputToFile(real writeTime, const word& timeName)
175  {
177  {
179  writeTime_ = writeTime;
180  }
181  return true;
182  }
183 
184  bool operator ++(int);
185 
186  void setSaveTimeFolder(
187  bool saveToFile,
188  const word& timeName = "wrongTimeFolder");
189 
191  {
192  return timePrecision_;
193  }
194 
195 
196 
197 
198 };
199 
200 
201 } // pFlow
202 
203 #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:174
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:196
pFlow::timeControl::sortTime
bool sortTime() const
Definition: timeControl.cpp:180
pFlow::timeControl::setTime
real setTime(real t)
Definition: timeControl.hpp:111
types.hpp
pFlow::timeControl::dt
real dt() const
Definition: timeControl.hpp:106
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:174
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:102
pFlow::timeControl::timeName
word timeName() const
Definition: timeControl.cpp:120
pFlow::timeControl::performSorting_
Logical performSorting_
Definition: timeControl.hpp:79
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::timeControl::sortingInterval_
realStridedRange sortingInterval_
Definition: timeControl.hpp:81
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:142
pFlow::timeControl::outputToFile
bool outputToFile() const
Definition: timeControl.hpp:165
pFlow::timeControl::saveInterval_
real saveInterval_
Definition: timeControl.hpp:60
streams.hpp
pFlow::timeControl::currentTime
real currentTime() const
Definition: timeControl.hpp:135
pFlow::timeControl::finalTime
bool finalTime() const
Definition: timeControl.cpp:128
pFlow::timeControl::currentIter
int32 currentIter() const
Definition: timeControl.hpp:156
pFlow::Logical
Definition: Logical.hpp:35
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:128
pFlow::timeControl::currentTimeWord
word currentTimeWord(bool forSave=true) const
Definition: timeControl.hpp:140
pFlow::timeControl::setSaveTimeFolder
void setSaveTimeFolder(bool saveToFile, const word &timeName="wrongTimeFolder")
Definition: timeControl.cpp:185
pFlow::timeControl::setStopAt
void setStopAt(real sT)
Definition: timeControl.hpp:120
pFlow::dictionary
Definition: dictionary.hpp:38
pFlow::timeControl::reachedStopAt
bool reachedStopAt() const
Definition: timeControl.cpp:135
pFlow::timeControl::timePrecision
int32 timePrecision() const
Definition: timeControl.hpp:190