multiRotatingAxis.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 __multiRotatingAxis_hpp__
22 #define __multiRotatingAxis_hpp__
23 
24 
25 #include "rotatingAxis.hpp"
26 #include "KokkosTypes.hpp"
27 
28 
29 namespace pFlow
30 {
31 
32 class dictionary;
33 class multiRotatingAxisMotion;
34 
35 
37 :
38  public rotatingAxis
39 {
40 protected:
41 
42  // this is either host/device pointer
44 
46 
47 public:
48 
51 
54 
56  multiRotatingAxis(multiRotatingAxisMotion* axisMotion, const dictionary& dict);
57 
58  /*FUNCTION_HD
59  multiRotatingAxis(const realx3& p1, const realx3& p2, real omega = 0.0);*/
60 
62  multiRotatingAxis(const multiRotatingAxis&) = default;
63 
66 
69  {
70  realx3 parentVel(0);
71  auto parIndex = parentAxisIndex();
72 
73  while(parIndex != -1)
74  {
75  auto& ax = axisList_[parIndex];
76  parentVel += ax.linTangentialVelocityPoint(p);
77  parIndex = ax.parentAxisIndex();
78  }
79 
80  return parentVel + rotatingAxis::linTangentialVelocityPoint(p);
81  }
82 
83 
84 
86  realx3 transferPoint(const realx3& p, real dt)const
87  {
88  auto newP = p;
89 
90  // rotation around this axis
91  if(isRotating())
92  {
93  newP = pFlow::rotate(p, *this, dt);
94  }
95 
96  auto parIndex = parentAxisIndex_;
97  while(parIndex != -1)
98  {
99  auto& ax = axisList_[parIndex];
100  newP = pFlow::rotate(newP, ax, dt);
101  parIndex = ax.parentAxisIndex();
102  }
103 
104  return newP;
105  }
106 
108  bool hasParrent()const
109  {
110  return parentAxisIndex_ > -1;
111  }
112 
115  {
116  return parentAxisIndex_;
117  }
118 
119  // this pointer is device pointer
122  {
123  axisList_ = axisList;
124  }
125  // it is assumed that the axis with deepest level
126  // (with more parrents) is moved first and then
127  // the axis with lower levels
128  void move(real dt)
129  {
130 
131  if( !hasParrent() ) return;
132 
133  auto lp1 = point1();
134  auto lp2 = point2();
135 
136  lp1 = axisList_[parentAxisIndex()].transferPoint(lp1, dt);
137  lp2 = axisList_[parentAxisIndex()].transferPoint(lp2, dt);
138 
139  set(lp1, lp2);
140  }
141 
142 
143 
144  // - IO operation
145  FUNCTION_H
146  bool read(multiRotatingAxisMotion* axisMotion, const dictionary& dict);
147 
148  FUNCTION_H
149  bool write(const multiRotatingAxisMotion* axisMotion, dictionary& dict) const;
150 
151  /*FUNCTION_H
152  bool read(iIstream& is);
153 
154  FUNCTION_H
155  bool write(iOstream& os)const;*/
156 
157 };
158 
159 /*inline iOstream& operator <<(iOstream& os, const multiRotatingAxis& ax)
160 {
161  if(!ax.write(os))
162  {
163  fatalExit;
164  }
165  return os;
166 }
167 
168 inline iIstream& operator >>(iIstream& is, multiRotatingAxis& ax)
169 {
170  if( !ax.read(is) )
171  {
172  fatalExit;
173  }
174  return is;
175 }*/
176 
177 }
178 
179 
180 #endif
pFlow::multiRotatingAxis::write
FUNCTION_H bool write(const multiRotatingAxisMotion *axisMotion, dictionary &dict) const
Definition: multiRotatingAxis.cpp:80
pFlow::multiRotatingAxis::read
FUNCTION_H bool read(multiRotatingAxisMotion *axisMotion, const dictionary &dict)
Definition: multiRotatingAxis.cpp:56
pFlow::real
float real
Definition: builtinTypes.hpp:46
KokkosTypes.hpp
rotatingAxis.hpp
pFlow::line::set
INLINE_FUNCTION_HD void set(const realx3 &lp1, const realx3 &lp2)
Definition: line.hpp:78
pFlow::rotatingAxis::isRotating
INLINE_FUNCTION_HD bool isRotating() const
Definition: rotatingAxis.hpp:74
pFlow
Definition: demComponent.hpp:28
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
pFlow::multiRotatingAxis
Definition: multiRotatingAxis.hpp:36
pFlow::multiRotatingAxis::setAxisList
INLINE_FUNCTION_H void setAxisList(multiRotatingAxis *axisList)
Definition: multiRotatingAxis.hpp:121
pFlow::multiRotatingAxis::pointTangentialVel
INLINE_FUNCTION_HD realx3 pointTangentialVel(const realx3 &p) const
Definition: multiRotatingAxis.hpp:68
pFlow::multiRotatingAxis::multiRotatingAxis
INLINE_FUNCTION_HD multiRotatingAxis()
Definition: multiRotatingAxis.hpp:50
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::rotatingAxis
Definition: rotatingAxis.hpp:35
pFlow::line::point2
INLINE_FUNCTION_HD realx3 point2() const
Definition: line.hpp:90
pFlow::multiRotatingAxis::hasParrent
INLINE_FUNCTION_HD bool hasParrent() const
Definition: multiRotatingAxis.hpp:108
pFlow::multiRotatingAxis::move
void move(real dt)
Definition: multiRotatingAxis.hpp:128
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:53
pFlow::multiRotatingAxis::parentAxisIndex_
int32 parentAxisIndex_
Definition: multiRotatingAxis.hpp:45
FUNCTION_HD
#define FUNCTION_HD
Definition: pFlowMacros.hpp:57
pFlow::multiRotatingAxis::operator=
FUNCTION_HD multiRotatingAxis & operator=(const multiRotatingAxis &)=default
rotate
INLINE_FUNCTION_HD realx3 rotate(const realx3 &p, const line &ln, real theta)
pFlow::multiRotatingAxis::axisList_
multiRotatingAxis * axisList_
Definition: multiRotatingAxis.hpp:43
pFlow::multiRotatingAxisMotion
Definition: multiRotatingAxisMotion.hpp:37
pFlow::line::point1
INLINE_FUNCTION_HD realx3 point1() const
Definition: line.hpp:86
pFlow::multiRotatingAxis::transferPoint
INLINE_FUNCTION_HD realx3 transferPoint(const realx3 &p, real dt) const
Definition: multiRotatingAxis.hpp:86
pFlow::rotatingAxis::linTangentialVelocityPoint
INLINE_FUNCTION_HD realx3 linTangentialVelocityPoint(const realx3 &p) const
Definition: rotatingAxisI.hpp:22
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
pFlow::triple< real >
pFlow::multiRotatingAxis::parentAxisIndex
INLINE_FUNCTION_HD int32 parentAxisIndex() const
Definition: multiRotatingAxis.hpp:114
pFlow::dictionary
Definition: dictionary.hpp:38