www.cemf.ir
multiRotatingAxisMotion.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 __multiRotatingAxisMotion_hpp__
22 #define __multiRotatingAxisMotion_hpp__
23 
24 
25 #include "types.hpp"
26 #include "typeInfo.hpp"
27 #include "VectorDual.hpp"
28 #include "List.hpp"
29 #include "multiRotatingAxis.hpp"
30 
31 
32 namespace pFlow
33 {
34 
35 // forward
36 class dictionary;
37 
66 {
67 public:
68 
72  class Model
73  {
74  protected:
75 
78 
79  public:
80 
83  axis_(axis),
84  numAxis_(numAxis)
85  {}
86 
88  Model(const Model&) = default;
89 
90 
92  Model& operator=(const Model&) = default;
93 
94 
96  realx3 pointVelocity(int32 n, const realx3& p)const
97  {
98  return axis_[n].pointTangentialVel(p);
99  }
100 
102  realx3 operator()(int32 n, const realx3& p)const
103  {
104  return pointVelocity(n,p);
105  }
106 
108  realx3 transferPoint(int32 n, const realx3 p, real dt)const
109  {
110  return axis_[n].transferPoint(p, dt);
111  }
112 
114  {
115  return numAxis_;
116  }
117  };
118 
119 protected:
120 
122 
125 
128 
131 
133  label numAxis_= 0;
134 
136  bool readDictionary(const dictionary& dict);
137 
139  bool writeDictionary(dictionary& dict)const;
140 
141 public:
142 
144  TypeInfoNV("multiRotatingAxisMotion");
145 
146  // - Constructor
147 
149  FUNCTION_H
151 
153  FUNCTION_H
154  multiRotatingAxisMotion(const dictionary& dict);
155 
157  FUNCTION_H
159 
162 
164  FUNCTION_H
166 
169 
171  FUNCTION_H
172  ~multiRotatingAxisMotion() = default;
173 
174  // - Methods
175 
178  {
179  for(int32 i= 0; i<numAxis_; i++ )
180  {
181  axis_[i].setTime(t);
182  axis_[i].setAxisList(getAxisListPtrDevice());
183  }
185  axis_.syncViews();
186 
187  return Model(axis_.deviceVector(), numAxis_);
188  }
189 
193  {
194  return axis_.hostVectorAll().data();
195  }
196 
200  {
201  return axis_.deviceVectorAll().data();
202  }
203 
206  int32 nameToIndex(const word& name)const
207  {
208  if( auto i = axisName_.findi(name); i == -1)
209  {
211  "axis name " << name << " does not exist. \n";
212  fatalExit;
213  return i;
214  }
215  else
216  {
217  return i;
218  }
219 
220  }
221 
224  word indexToName(label i)const
225  {
226  if(i < numAxis_ )
227  return axisName_[i];
228  else
229  {
231  "out of range access to the list of axes " << i <<endl<<
232  " size of axes_ is "<<numAxis_<<endl;
233  fatalExit;
234  return "";
235  }
236  }
237 
240  bool isMoving()const
241  {
242  return true;
243  }
244 
246  FUNCTION_H
247  bool move(real t, real dt);
248 
249  // - IO operation
250 
252  FUNCTION_H
253  bool read(iIstream& is);
254 
256  FUNCTION_H
257  bool write(iOstream& os)const;
258 
259 
260 };
261 
262 } // pFlow
263 
264 #endif //__multiRotatingAxisMotion_hpp__
pFlow::multiRotatingAxisMotion::Model::pointVelocity
INLINE_FUNCTION_HD realx3 pointVelocity(int32 n, const realx3 &p) const
Definition: multiRotatingAxisMotion.hpp:96
pFlow::multiRotatingAxisMotion::axis_
axisVector_HD axis_
Vector of multiRotaingAxis axes.
Definition: multiRotatingAxisMotion.hpp:124
pFlow::List< word >
pFlow::multiRotatingAxisMotion::readDictionary
bool readDictionary(const dictionary &dict)
Read from a dictionary.
Definition: multiRotatingAxisMotion.cpp:27
pFlow::VectorDual::syncViews
INLINE_FUNCTION_H void syncViews()
Definition: VectorDual.hpp:909
pFlow::multiRotatingAxisMotion::getAxisListPtrDevice
INLINE_FUNCTION_H multiRotatingAxis * getAxisListPtrDevice()
Pointer to axis list on device.
Definition: multiRotatingAxisMotion.hpp:199
multiRotatingAxis.hpp
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
types.hpp
pFlow::multiRotatingAxisMotion::indexToName
INLINE_FUNCTION_H word indexToName(label i) const
Index of motion component to component name.
Definition: multiRotatingAxisMotion.hpp:224
List.hpp
pFlow::VectorDual::data
INLINE_FUNCTION_H pointer data()
Definition: VectorDual.hpp:787
pFlow::multiRotatingAxisMotion::Model::operator=
INLINE_FUNCTION_HD Model & operator=(const Model &)=default
pFlow::multiRotatingAxisMotion::Model::numComponents
INLINE_FUNCTION_HD int32 numComponents() const
Definition: multiRotatingAxisMotion.hpp:113
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::multiRotatingAxisMotion::write
FUNCTION_H bool write(iOstream &os) const
Write to output stream os.
Definition: multiRotatingAxisMotion.cpp:219
pFlow::multiRotatingAxisMotion::numAxis_
label numAxis_
Number of axes.
Definition: multiRotatingAxisMotion.hpp:133
pFlow::multiRotatingAxisMotion::nameToIndex
INLINE_FUNCTION_H int32 nameToIndex(const word &name) const
Name of motion component to index.
Definition: multiRotatingAxisMotion.hpp:206
pFlow::multiRotatingAxisMotion::~multiRotatingAxisMotion
FUNCTION_H ~multiRotatingAxisMotion()=default
Destructor.
pFlow::multiRotatingAxisMotion::Model::axis_
deviceViewType1D< multiRotatingAxis > axis_
Definition: multiRotatingAxisMotion.hpp:76
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::multiRotatingAxisMotion::sortedIndex_
VectorDual< int32 > sortedIndex_
Sorted index based on number of parrents each axis ha.
Definition: multiRotatingAxisMotion.hpp:127
pFlow::VectorDual::modifyOnHost
INLINE_FUNCTION_H void modifyOnHost()
Definition: VectorDual.hpp:830
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
1D array (vector) with default device (memory space and execution space)
Definition: KokkosTypes.hpp:121
VectorDual.hpp
pFlow
Definition: demGeometry.hpp:27
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:62
pFlow::List::findi
int32 findi(const T &val) const
Definition: ListI.hpp:125
pFlow::multiRotatingAxis
Defines an axis of rotation that rotates around itself and rotates around another axis.
Definition: multiRotatingAxis.hpp:75
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::VectorDual< multiRotatingAxis >
pFlow::multiRotatingAxisMotion::isMoving
INLINE_FUNCTION_HD bool isMoving() const
Is moving.
Definition: multiRotatingAxisMotion.hpp:240
pFlow::multiRotatingAxisMotion::writeDictionary
bool writeDictionary(dictionary &dict) const
Write to a dictionary.
Definition: multiRotatingAxisMotion.cpp:139
pFlow::multiRotatingAxisMotion::getModel
Model getModel(real t)
Retrun motion model at time t.
Definition: multiRotatingAxisMotion.hpp:177
pFlow::multiRotatingAxisMotion::move
FUNCTION_H bool move(real t, real dt)
Move points.
Definition: multiRotatingAxisMotion.cpp:178
pFlow::multiRotatingAxisMotion::Model
Motion model class to be passed to computational units/kernels for transfing points and returning vel...
Definition: multiRotatingAxisMotion.hpp:72
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:57
pFlow::multiRotatingAxisMotion::TypeInfoNV
TypeInfoNV("multiRotatingAxisMotion")
Type info.
pFlow::multiRotatingAxisMotion::Model::Model
INLINE_FUNCTION_HD Model(deviceViewType1D< multiRotatingAxis > axis, int32 numAxis)
Definition: multiRotatingAxisMotion.hpp:82
pFlow::multiRotatingAxisMotion::getAxisListPtrHost
INLINE_FUNCTION_H multiRotatingAxis * getAxisListPtrHost()
Pointer to axis list on host side.
Definition: multiRotatingAxisMotion.hpp:192
pFlow::multiRotatingAxisMotion::read
FUNCTION_H bool read(iIstream &is)
Read from input stream is.
Definition: multiRotatingAxisMotion.cpp:198
pFlow::multiRotatingAxisMotion::axisName_
wordList axisName_
List of axes names.
Definition: multiRotatingAxisMotion.hpp:130
n
uint32 n
Definition: NBSLoop.hpp:24
pFlow::multiRotatingAxisMotion::multiRotatingAxisMotion
FUNCTION_H multiRotatingAxisMotion()
Empty constructor.
Definition: multiRotatingAxisMotion.cpp:163
pFlow::multiRotatingAxisMotion
Rotating axis motion model for walls.
Definition: multiRotatingAxisMotion.hpp:65
pFlow::multiRotatingAxisMotion::operator=
FUNCTION_H multiRotatingAxisMotion & operator=(const multiRotatingAxisMotion &)=default
Copy assignment.
typeInfo.hpp
pFlow::multiRotatingAxisMotion::Model::numAxis_
int32 numAxis_
Definition: multiRotatingAxisMotion.hpp:77
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple< real >
pFlow::multiRotatingAxisMotion::Model::transferPoint
INLINE_FUNCTION_HD realx3 transferPoint(int32 n, const realx3 p, real dt) const
Definition: multiRotatingAxisMotion.hpp:108
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::multiRotatingAxisMotion::Model::operator()
INLINE_FUNCTION_HD realx3 operator()(int32 n, const realx3 &p) const
Definition: multiRotatingAxisMotion.hpp:102
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