www.cemf.ir
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 // forward
33 class dictionary;
34 
35 
65 class vibrating
66 :
67  public timeInterval
68 {
69 
70 private:
71 
72  // rotation speed
74 
76 
78 
79  realx3 velocity_{0,0,0};
80 
82 
85  {
86  if(inTimeRange())
87  {
89  }else
90  {
91  velocity_ = {0,0,0};
92  }
93  }
94 
95 public:
96 
97  TypeInfoNV("vibrating");
98 
100  vibrating()=default;
101 
102  FUNCTION_H
103  explicit vibrating(const dictionary& dict);
104 
105 
107  vibrating(const vibrating&) = default;
108 
109  vibrating& operator=(const vibrating&) = default;
110 
112  void setTime(real t)
113  {
114  if( !equal(t, time()) ) velocity0_ = velocity_;
117  }
118 
121  {
122  return velocity_;
123  }
124 
126  realx3 transferPoint(const realx3& p, real dt)const
127  {
128  if(!inTimeRange()) return p;
129  return p + static_cast<real>(0.5*dt)*(velocity0_+velocity_);
130  }
131 
132  // - IO operation
133  FUNCTION_H
134  bool read(const dictionary& dict);
135 
136  FUNCTION_H
137  bool write(dictionary& dict) const;
138 
139  FUNCTION_H
140  bool read(iIstream& is);
141 
142  FUNCTION_H
143  bool write(iOstream& os)const;
144 
145 };
146 
147 inline iOstream& operator <<(iOstream& os, const vibrating& obj)
148 {
149  if(!obj.write(os))
150  {
151  fatalExit;
152  }
153  return os;
154 }
155 
157 {
158  if( !obj.read(is) )
159  {
160  fatalExit;
161  }
162  return is;
163 }
164 
165 }
166 
167 
168 #endif
timeInterval.hpp
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::vibrating::angularFreq_
realx3 angularFreq_
Definition: vibrating.hpp:73
pFlow::vibrating
Vibrating model for a wall.
Definition: vibrating.hpp:65
pFlow::vibrating::velocity0_
realx3 velocity0_
Definition: vibrating.hpp:81
pFlow::timeInterval::startTime
INLINE_FUNCTION_HD auto startTime() const
Definition: timeInterval.hpp:45
pFlow::equal
INLINE_FUNCTION_HD bool equal(const box &b1, const box &b2, real tol=smallValue)
Definition: box.hpp:135
pFlow::vibrating::transferPoint
INLINE_FUNCTION_HD realx3 transferPoint(const realx3 &p, real dt) const
Definition: vibrating.hpp:126
pFlow::vibrating::calculateVelocity
INLINE_FUNCTION_HD void calculateVelocity()
Definition: vibrating.hpp:84
pFlow::vibrating::operator=
vibrating & operator=(const vibrating &)=default
pFlow
Definition: demGeometry.hpp:27
pFlow::vibrating::velocity_
realx3 velocity_
Definition: vibrating.hpp:79
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:62
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::timeInterval::time
INLINE_FUNCTION_HD auto time() const
Definition: timeInterval.hpp:57
pFlow::vibrating::phaseAngle_
realx3 phaseAngle_
Definition: vibrating.hpp:75
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:61
streams.hpp
pFlow::vibrating::linVelocityPoint
INLINE_FUNCTION_HD realx3 linVelocityPoint(const realx3 &) const
Definition: vibrating.hpp:120
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:112
pFlow::sin
Vector< T, Allocator > sin(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:92
pFlow::vibrating::TypeInfoNV
TypeInfoNV("vibrating")
pFlow::vibrating::vibrating
FUNCTION_HD vibrating()=default
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple< real >
pFlow::timeInterval::setTime
INLINE_FUNCTION_HD void setTime(real t)
Definition: timeInterval.hpp:63
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
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::vibrating::amplitude_
realx3 amplitude_
Definition: vibrating.hpp:77