vibrating.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 __vibrating_hpp__
22 #define __vibrating_hpp__
23 
24 
25 #include "timeInterval.hpp"
26 
27 #include "streams.hpp"
28 
29 namespace pFlow
30 {
31 
32 class dictionary;
33 class vibrating;
34 
35 
36 class vibrating
37 :
38  public timeInterval
39 {
40 
41 protected:
42 
43  // rotation speed
45 
47 
49 
50  realx3 velocity_{0,0,0};
51 
53 
56  {
57  if(inTimeRange())
58  {
60  }else
61  {
62  velocity_ = {0,0,0};
63  }
64  }
65 
66 public:
67 
70 
72  vibrating(const dictionary& dict);
73 
74 
76  vibrating(const vibrating&) = default;
77 
78  vibrating& operator=(const vibrating&) = default;
79 
81  void setTime(real t)
82  {
83  if( !equal(t, time()) ) velocity0_ = velocity_;
86  }
87 
90  {
91  return velocity_;
92  }
93 
96  {
97  if(!inTimeRange()) return p;
98  return p + static_cast<real>(0.5)*dt*(velocity0_+velocity_);
99  }
100 
101  // - IO operation
102  FUNCTION_H
103  bool read(const dictionary& dict);
104 
105  FUNCTION_H
106  bool write(dictionary& dict) const;
107 
108  FUNCTION_H
109  bool read(iIstream& is);
110 
111  FUNCTION_H
112  bool write(iOstream& os)const;
113 
114 };
115 
116 inline iOstream& operator <<(iOstream& os, const vibrating& obj)
117 {
118  if(!obj.write(os))
119  {
120  fatalExit;
121  }
122  return os;
123 }
124 
126 {
127  if( !obj.read(is) )
128  {
129  fatalExit;
130  }
131  return is;
132 }
133 
134 }
135 
136 
137 #endif
timeInterval.hpp
pFlow::real
float real
Definition: builtinTypes.hpp:46
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::vibrating::angularFreq_
realx3 angularFreq_
Definition: vibrating.hpp:44
pFlow::vibrating
Definition: vibrating.hpp:36
pFlow::vibrating::velocity0_
realx3 velocity0_
Definition: vibrating.hpp:52
pFlow::timeInterval::startTime
INLINE_FUNCTION_HD auto startTime() const
Definition: timeInterval.hpp:45
pFlow::sin
INLINE_FUNCTION_HD real sin(real x)
Definition: math.hpp:168
pFlow::vibrating::transferPoint
INLINE_FUNCTION_HD realx3 transferPoint(const realx3 &p, real dt)
Definition: vibrating.hpp:95
pFlow::vibrating::calculateVelocity
INLINE_FUNCTION_HD void calculateVelocity()
Definition: vibrating.hpp:55
pFlow::vibrating::operator=
vibrating & operator=(const vibrating &)=default
pFlow
Definition: demComponent.hpp:28
pFlow::vibrating::velocity_
realx3 velocity_
Definition: vibrating.hpp:50
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::timeInterval::time
INLINE_FUNCTION_HD auto time() const
Definition: timeInterval.hpp:57
pFlow::vibrating::phaseAngle_
realx3 phaseAngle_
Definition: vibrating.hpp:46
pFlow::vibrating::linTangentialVelocityPoint
INLINE_FUNCTION_HD realx3 linTangentialVelocityPoint(const realx3 &p) const
Definition: vibrating.hpp:89
pFlow::vibrating::read
FUNCTION_H bool read(const dictionary &dict)
Definition: vibrating.cpp:40
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::timeInterval::inTimeRange
INLINE_FUNCTION_HD bool inTimeRange() const
Definition: timeInterval.hpp:76
pFlow::timeInterval
Definition: timeInterval.hpp:16
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
FUNCTION_HD
#define FUNCTION_HD
Definition: pFlowMacros.hpp:57
streams.hpp
pFlow::vibrating::write
FUNCTION_H bool write(dictionary &dict) const
Definition: vibrating.cpp:55
pFlow::vibrating::setTime
INLINE_FUNCTION_HD void setTime(real t)
Definition: vibrating.hpp:81
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
pFlow::triple< real >
pFlow::timeInterval::setTime
INLINE_FUNCTION_HD void setTime(real t)
Definition: timeInterval.hpp:63
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::equal
INLINE_FUNCTION_HD bool equal(const real &s1, const real &s2)
Definition: bTypesFunctions.hpp:188
pFlow::dictionary
Definition: dictionary.hpp:38
pFlow::vibrating::vibrating
FUNCTION_HD vibrating()
Definition: vibrating.hpp:69
pFlow::vibrating::amplitude_
realx3 amplitude_
Definition: vibrating.hpp:48