geometryMotion.cpp
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 template<typename MotionModel>
23 {
24  motionIndex_.clear();
25  triMotionIndex_.reserve( this->surface().capacity() );
26  triMotionIndex_.clear();
27 
28  ForAll( surfI, motionComponentName_)
29  {
30  auto mName = motionComponentName_[surfI];
31  auto mInd = motionModel_.nameToIndex(mName);
32  motionIndex_.push_back(mInd);
33  // fill motionIndex for triangles of the surface
34  int32 surfSize = this->surface().surfNumTriangles(surfI);
35  for(int32 i=0; i<surfSize; i++)
36  {
37  triMotionIndex_.push_back(mInd);
38  }
39  }
40  motionIndex_.syncViews();
41  triMotionIndex_.syncViews();
42 
43  pointMotionIndex_.reserve(triSurface_.numPoints());
44  pointMotionIndex_.clear();
45 
46  ForAll(surfI, motionIndex_)
47  {
48  auto nP = triSurface_.surfNumPoints(surfI);
49  for(int32 i=0; i<nP; i++)
50  {
51  pointMotionIndex_.push_back(motionIndex_[surfI]);
52  }
53  }
54  pointMotionIndex_.syncViews();
55 
56  return true;
57 }
58 
59 
60 template<typename MotionModel>
62 (
63  systemControl& control,
64  const property& prop
65 )
66 :
67  geometry(control, prop),
68  motionModel_(
69  this->owner().template emplaceObject<MotionModel>(
70  objectFile(
72  "",
73  objectFile::READ_ALWAYS,
74  objectFile::WRITE_ALWAYS
75  )
76  )
77  ),
78  moveGeomTimer_("move geometry", &this->timers())
79 {
80  findMotionIndex();
81 }
82 
83 template<typename MotionModel>
85 (
86  systemControl& control,
87  const property& prop,
89  const wordVector& motionCompName,
90  const wordVector& propName,
91  const MotionModel& motionModel
92 )
93 :
94  geometry(
95  control,
96  prop,
97  triSurface,
98  motionCompName,
99  propName
100  ),
101  motionModel_(
102  this->owner().template emplaceObject<MotionModel>(
103  objectFile(
105  "",
106  objectFile::READ_NEVER,
107  objectFile::WRITE_ALWAYS
108  ),
109  motionModel
110  )
111  ),
112  moveGeomTimer_("move geometry", &this->timers())
113 {
114  findMotionIndex();
115 }
116 
117 template<typename MotionModel>
119 (
120  systemControl& control,
121  const property& prop,
122  const dictionary& dict,
124  const wordVector& motionCompName,
125  const wordVector& propName
126 )
127 :
128  geometry(
129  control,
130  prop,
131  dict,
132  triSurface,
133  motionCompName,
134  propName
135  ),
136  motionModel_(
137  this->owner().template emplaceObject<MotionModel>(
138  objectFile(
140  "",
141  objectFile::READ_NEVER,
142  objectFile::WRITE_ALWAYS
143  ),
144  dict
145  )
146  ),
147  moveGeomTimer_("move geometry", &this->timers())
148 {
149  findMotionIndex();
150 }
151 
152 template<typename MotionModel>
154 {
155  geometry::beforeIteration();
156  return true;
157 }
158 
159 template<typename MotionModel>
161 {
162  if( motionModel_.isMoving() )
163  {
164  moveGeomTimer_.start();
165  moveGeometry();
166  moveGeomTimer_.end();
167  }
168  return true;
169 }
170 
171 template<typename MotionModel>
173 {
174  geometry::afterIteration();
175  return true;
176 }
177 
178 template<typename MotionModel>
180 {
181 
182  real dt = this->dt();
183  real t = this->currentTime();
184 
185  auto pointMIndex= pointMotionIndex_.deviceVector();
186  auto mModel = motionModel_.getModel(t);
187  realx3* points = triSurface_.pointsData_D();
188  auto numPoints = triSurface_.numPoints();
189 
190 
191  Kokkos::parallel_for(
192  "geometryMotion<MotionModel>::movePoints",
193  numPoints,
194  LAMBDA_HD(int32 i){
195  auto newPos = mModel.transferPoint(pointMIndex[i], points[i], dt);
196  points[i] = newPos;
197  });
198 
199  Kokkos::fence();
200 
201  // move the motion components
202  motionModel_.move(t,dt);
203 
204  // end of calculations
205  moveGeomTimer_.end();
206 
207  return true;
208 }
pFlow::motionModelFile__
const char * motionModelFile__
Definition: vocabs.hpp:45
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::systemControl
Definition: systemControl.hpp:41
pFlow::geometryMotion::MotionModel
MotionModelType MotionModel
Definition: geometryMotion.hpp:42
pFlow::geometryMotion::moveGeometry
bool moveGeometry()
Move geometry.
Definition: geometryMotion.cpp:179
pFlow::multiTriSurface
Definition: multiTriSurface.hpp:33
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
ForAll
#define ForAll(i, container)
Definition: pFlowMacros.hpp:71
pFlow::objectFile
Definition: objectFile.hpp:33
pFlow::geometryMotion::geometryMotion
geometryMotion(systemControl &control, const property &prop)
Definition: geometryMotion.cpp:62
pFlow::geometryMotion::iterate
bool iterate() override
Iterate geometry one time step
Definition: geometryMotion.cpp:160
pFlow::property
property holds the pure properties of materials.
Definition: property.hpp:40
pFlow::geometryMotion::findMotionIndex
bool findMotionIndex()
determine the motion index of each triangle
Definition: geometryMotion.cpp:22
pFlow::geometry
Base class for geometry for managing tri-surfaces, geometry motion, and surface physical properties.
Definition: geometry.hpp:43
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:54
pFlow::geometryMotion::afterIteration
bool afterIteration() override
Operations after each iteration.
Definition: geometryMotion.cpp:172
pFlow::geometryMotion::beforeIteration
bool beforeIteration() override
Operations before each iteration.
Definition: geometryMotion.cpp:153
pFlow::triSurface
Definition: triSurface.hpp:38
pFlow::triple< real >
pFlow::Vector< word >
pFlow::dictionary
Definition: dictionary.hpp:38