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 
81  bool outputToFile_ = false;
82 
83  void checkForOutputToFile();
84 
85  bool screenReport()const;
86 
87 public:
88 
89  timeControl(const dictionary& dict);
90 
92  dictionary& dict,
94  real endTime,
95  real saveInterval,
96  word startTimeName);
97 
98  virtual ~timeControl()
99  {}
100 
101 
102  real dt()const
103  {
104  return dt_;
105  }
106 
108  {
109  real tmp = currentTime_;
110  currentTime_ = t;
111  lastSaved_ = t;
113  return tmp;
114  }
115 
116  void setStopAt(real sT)
117  {
119  {
120  stopAt_ = sT;
121  }
122  }
123 
125  {
126  return startTime_;
127  }
128 
129  word timeName()const;
130 
131  real currentTime() const
132  {
133  return currentTime_;
134  }
135 
136  word currentTimeWord(bool forSave = true)const
137  {
139  /*if(forSave)
140  {
141  if(!managedExternaly_)
142 
143  else
144  return timeName_;
145  }
146  else
147  {
148  return real2FixedStripZeros( currentTime(), timePrecision());
149  }*/
150  }
151 
153  {
154  return currentIter_;
155  }
156 
157  bool finalTime()const;
158 
159  bool reachedStopAt()const;
160 
161  bool outputToFile()const
162  {
163  return outputToFile_;
164  }
165 
166  bool timersReportTime()const;
167 
168  bool setOutputToFile(real writeTime, const word& timeName)
169  {
171  {
173  writeTime_ = writeTime;
174  }
175  return true;
176  }
177 
178  bool operator ++(int);
179 
180  void setSaveTimeFolder(
181  bool saveToFile,
182  const word& timeName = "wrongTimeFolder");
183 
185  {
186  return timePrecision_;
187  }
188 
189 
190 
191 
192 };
193 
194 
195 } // pFlow
196 
197 #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