www.cemf.ir
MotionModel.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 __MotionModel_hpp__
22 #define __MotionModel_hpp__
23 
24 
25 
26 #include "VectorSingles.hpp"
27 #include "Vector.hpp"
28 #include "List.hpp"
29 #include "dictionary.hpp"
30 
31 
32 namespace pFlow
33 {
34 
38 template<typename Model, typename Component>
40 {
41 public:
42 
43  using ModelType = Model;
44 
45  using ModelComponent = Component;
46 
48 
53  {
54  private:
55 
57 
59 
60  public:
61 
64  (
66  uint32 numComp
67  ):
68  components_(Comps),
69  numComponents_(numComp)
70  {}
71 
73  ModelInterface(const ModelInterface&) = default;
74 
76  ModelInterface& operator=(const ModelInterface&) = default;
77 
79  ModelInterface(ModelInterface&&) noexcept = default;
80 
82  ModelInterface& operator=(ModelInterface&&) noexcept= default;
83 
85  ~ModelInterface()=default;
86 
89  {
90  return components_[n].linVelocityPoint(p);
91  }
92 
94  realx3 operator()(uint32 n, const realx3& p)const
95  {
96  return pointVelocity(n,p);
97  }
98 
100  realx3 transferPoint(uint32 n, const realx3 p, real dt)const
101  {
102  return components_[n].transferPoint(p, dt);
103  }
104 
106  uint32 size()const
107  {
108  return numComponents_;
109  }
110  };
111 
112 private:
113 
114  // friends
115  friend ModelType;
116 
119 
122 
125 
126 protected:
127 
129  inline
130  auto& getModel()
131  {
132  return static_cast<ModelType&>(*this);
133  }
134 
136  inline
137  const auto& getModel()const
138  {
139  return static_cast<const ModelType&>(*this);
140  }
141 
143  inline
144  auto impl_noneComponent()const
145  {
146  return ModelType::noneComponent();
147  }
148 
150  bool impl_nameToIndex(const word& name, uint32& idx)const;
151 
153  bool impl_indexToName(uint32 i, word& name)const;
154 
156  inline
158  {
159  return componentNames_;
160  }
161 
163  auto impl_getModelInterface(uint32 iter, real t, real dt)const
164  {
165  getModel().impl_setTime(iter, t, dt);
166 
167  return ModelInterface(
170  }
171 
173  bool impl_readDictionary(const dictionary& dict);
174 
176  bool impl_writeDictionary(dictionary& dict)const;
177 
178 public:
179 
180  // - Constructors
181 
183  MotionModel();
184 
186  MotionModel(const MotionModel&) = default;
187 
189  MotionModel(MotionModel&&) = default;
190 
192  MotionModel& operator=(const MotionModel&) = default;
193 
195  MotionModel& operator=(MotionModel&&) = default;
196 
198  ~MotionModel() = default;
199 
200  // - Methods
201 
203  bool nameToIndex(const word& name, uint32& idx)const
204  {
205  return getModel().impl_nameToIndex(name, idx);
206  }
207 
209  bool indexToName(uint32 idx, word& name)const
210  {
211  return getModel().impl_indexToName(idx, name);
212  }
213 
216  const wordList& componentNames()const
217  {
218  return getModel().impl_componentNames();
219  }
220 
222  bool isMoving()const
223  {
224  return getModel().impl_isMoving();
225  }
226 
228  bool move(uint32 iter, real t, real dt)
229  {
230  return getModel().impl_move(iter, t, dt);
231  }
232 
234  auto getModelInterface(uint32 iter, real t, real dt)const
235  {
236  return getModel().impl_getModelInterface(iter, t, dt);
237  }
238 
239 };
240 
241 } // pFlow
242 
243 #include "MotionModel.cpp"
244 
245 
246 #endif //__MotionModel_hpp__
pFlow::MotionModel::indexToName
bool indexToName(uint32 idx, word &name) const
Component index to motion component name.
Definition: MotionModel.hpp:209
pFlow::MotionModel::move
bool move(uint32 iter, real t, real dt)
Move the component itself.
Definition: MotionModel.hpp:228
pFlow::MotionModel::ModelInterface::operator=
INLINE_FUNCTION_HD ModelInterface & operator=(const ModelInterface &)=default
pFlow::MotionModel::operator=
MotionModel & operator=(const MotionModel &)=default
Copy assignment.
pFlow::MotionModel::componentNames_
wordList componentNames_
Names of compoenents.
Definition: MotionModel.hpp:124
pFlow::List< word >
pFlow::MotionModel::ModelInterface::ModelInterface
INLINE_FUNCTION_HD ModelInterface(deviceViewType1D< ModelComponent > Comps, uint32 numComp)
Definition: MotionModel.hpp:64
pFlow::MotionModel::getModelInterface
auto getModelInterface(uint32 iter, real t, real dt) const
Obtain an object to model interface.
Definition: MotionModel.hpp:234
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::MotionModel::ModelInterface::numComponents_
uint32 numComponents_
Definition: MotionModel.hpp:58
pFlow::rotatingAxisMotion
Rotating axis motion model for walls.
Definition: rotatingAxisMotion.hpp:59
pFlow::MotionModel::~MotionModel
~MotionModel()=default
Destructor.
pFlow::MotionModel::ModelInterface
Motion model class to be passed to computational units/kernels for transfing points and returning vel...
Definition: MotionModel.hpp:52
pFlow::MotionModel::ModelInterface::size
INLINE_FUNCTION_HD uint32 size() const
Definition: MotionModel.hpp:106
List.hpp
pFlow::MotionModel::impl_writeDictionary
bool impl_writeDictionary(dictionary &dict) const
Write to dictionary.
Definition: MotionModel.cpp:113
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::MotionModel::ModelInterface::operator()
INLINE_FUNCTION_HD realx3 operator()(uint32 n, const realx3 &p) const
Definition: MotionModel.hpp:94
pFlow::MotionModel::impl_noneComponent
auto impl_noneComponent() const
Return a none object for the motion model.
Definition: MotionModel.hpp:144
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::MotionModel::ModelInterface::pointVelocity
INLINE_FUNCTION_HD realx3 pointVelocity(uint32 n, const realx3 &p) const
Definition: MotionModel.hpp:88
pFlow::MotionModel::motionComponents_
ComponentVector_D motionComponents_
Vector to store motion components.
Definition: MotionModel.hpp:121
pFlow::MotionModel::ModelType
friend ModelType
Definition: MotionModel.hpp:115
pFlow::MotionModel::nameToIndex
bool nameToIndex(const word &name, uint32 &idx) const
name of the compoenent to index of the component
Definition: MotionModel.hpp:203
pFlow::MotionModel::impl_getModelInterface
auto impl_getModelInterface(uint32 iter, real t, real dt) const
Return model interface.
Definition: MotionModel.hpp:163
pFlow::MotionModel::impl_readDictionary
bool impl_readDictionary(const dictionary &dict)
Read from dictionary.
Definition: MotionModel.cpp:56
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
1D array (vector) with default device (memory space and execution space)
Definition: KokkosTypes.hpp:121
pFlow::MotionModel::MotionModel
MotionModel()
Empty.
Definition: MotionModel.cpp:144
MotionModel.cpp
pFlow
Definition: demGeometry.hpp:27
pFlow::MotionModel::ModelInterface::components_
deviceViewType1D< ModelComponent > components_
Definition: MotionModel.hpp:56
VectorSingles.hpp
pFlow::MotionModel::ModelInterface::transferPoint
INLINE_FUNCTION_HD realx3 transferPoint(uint32 n, const realx3 p, real dt) const
Definition: MotionModel.hpp:100
pFlow::rotatingAxis
An axis which rotates around itself at specified speed.
Definition: rotatingAxis.hpp:61
pFlow::MotionModel::componentNames
const wordList & componentNames() const
Return a const reference to the list of compoenent names.
Definition: MotionModel.hpp:216
pFlow::MotionModel::impl_indexToName
bool impl_indexToName(uint32 i, word &name) const
Component index to motion component name.
Definition: MotionModel.cpp:40
dictionary.hpp
pFlow::MotionModel::getModel
auto & getModel()
obtain a reference to the actual motion model
Definition: MotionModel.hpp:130
pFlow::VectorSingle< ModelComponent >
pFlow::VectorSingle::deviceViewAll
INLINE_FUNCTION_H auto & deviceViewAll()
Device view range [0,capcity)
Definition: VectorSingle.cpp:249
n
uint32 n
Definition: NBSLoop.hpp:24
pFlow::MotionModel::numComponents_
uint32 numComponents_
Number of axes components.
Definition: MotionModel.hpp:118
pFlow::MotionModel
Motion model abstract class (CRTP) for all the motion models.
Definition: MotionModel.hpp:39
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple< real >
pFlow::MotionModel::impl_nameToIndex
bool impl_nameToIndex(const word &name, uint32 &idx) const
Name of the compoenent to index of the component.
Definition: MotionModel.cpp:24
pFlow::MotionModel::getModel
const auto & getModel() const
Obtain a const reference to the actual motion model.
Definition: MotionModel.hpp:137
pFlow::MotionModel::isMoving
bool isMoving() const
Is the wall assocciated to this motion component moving?
Definition: MotionModel.hpp:222
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
Vector.hpp
pFlow::MotionModel::impl_componentNames
const wordList & impl_componentNames() const
const reference to the list of component names
Definition: MotionModel.hpp:157