timeFlowControl.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 #ifndef __timeFlowControl_hpp__
22 #define __timeFlowControl_hpp__
23 
24 #include "types.hpp"
25 #include "streams.hpp"
26 
27 namespace pFlow
28 {
29 
30 class dictionary;
31 
33 {
34 protected:
35 
37 
39 
41 
43 
44  size_t numInserted_ = 0;
45 
46  bool readTimeFlowControl(const dictionary& dict);
47 
48  bool writeTimeFlowControl(dictionary& dict) const;
49 
50  size_t numberToBeInserted(real currentTime)
51  {
52  if(currentTime<startTime_)return 0;
53  if(currentTime>endTime_) return 0;
54 
55  return static_cast<size_t>( (currentTime - startTime_ + interval_)*rate_ - numInserted_ );
56  }
57 
58  size_t addToNumInserted(size_t newInserted)
59  {
60  return numInserted_ += newInserted;
61  }
62 
63 public:
64 
65 
66  timeFlowControl(const dictionary& dict);
67 
68 
69  bool insertionTime( real currentTime, real dt)
70  {
71  if(currentTime < startTime_) return false;
72 
73  if(currentTime > endTime_) return false;
74  if( mod(abs(currentTime-startTime_),interval_)/dt < 1 ) return true;
75 
76  return false;
77  }
78 
79  size_t totalInserted()const
80  {
81  return numInserted_;
82  }
83 
84  bool read(const dictionary& dict)
85  {
86  return readTimeFlowControl(dict);
87  }
88 
89  bool write(dictionary& dict)const
90  {
91  return writeTimeFlowControl(dict);
92  }
93 
94 };
95 
96 }
97 
98 #endif //__timeFlowControl_hpp__
pFlow::timeFlowControl::timeFlowControl
timeFlowControl(const dictionary &dict)
Definition: timeFlowControl.cpp:52
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::timeFlowControl::endTime_
real endTime_
Definition: timeFlowControl.hpp:38
pFlow::timeFlowControl::rate_
real rate_
Definition: timeFlowControl.hpp:42
pFlow::timeFlowControl::read
bool read(const dictionary &dict)
Definition: timeFlowControl.hpp:84
types.hpp
pFlow::timeFlowControl::numberToBeInserted
size_t numberToBeInserted(real currentTime)
Definition: timeFlowControl.hpp:50
pFlow::timeFlowControl::numInserted_
size_t numInserted_
Definition: timeFlowControl.hpp:44
pFlow::timeFlowControl
Definition: timeFlowControl.hpp:32
pFlow
Definition: demComponent.hpp:28
pFlow::timeFlowControl::startTime_
real startTime_
Definition: timeFlowControl.hpp:36
pFlow::timeFlowControl::totalInserted
size_t totalInserted() const
Definition: timeFlowControl.hpp:79
pFlow::timeFlowControl::writeTimeFlowControl
bool writeTimeFlowControl(dictionary &dict) const
Definition: timeFlowControl.cpp:38
pFlow::abs
INLINE_FUNCTION_HD real abs(real x)
Definition: math.hpp:43
pFlow::timeFlowControl::write
bool write(dictionary &dict) const
Definition: timeFlowControl.hpp:89
pFlow::mod
INLINE_FUNCTION_HD real mod(real x, real y)
Definition: math.hpp:72
streams.hpp
pFlow::timeFlowControl::addToNumInserted
size_t addToNumInserted(size_t newInserted)
Definition: timeFlowControl.hpp:58
pFlow::timeFlowControl::readTimeFlowControl
bool readTimeFlowControl(const dictionary &dict)
Definition: timeFlowControl.cpp:25
pFlow::timeFlowControl::insertionTime
bool insertionTime(real currentTime, real dt)
Definition: timeFlowControl.hpp:69
pFlow::timeFlowControl::interval_
real interval_
Definition: timeFlowControl.hpp:40
pFlow::dictionary
Definition: dictionary.hpp:38