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