geometry.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 #include "geometry.hpp"
22 #include "vocabs.hpp"
23 
24 
26 {
27 
28  int8Vector propId(0, surface().capacity(),RESERVE());
29  propId.clear();
30 
31  uint32 pId;
32  ForAll(matI, materialName_)
33  {
34 
35  if( !wallProperty_.nameToIndex( materialName_[matI], pId ) )
36  {
38  "material name for the geometry is invalid: "<< materialName_[matI]<<endl;
39  return false;
40  }
41 
42  int32 surfSize = surface().surfNumTriangles(matI);
43 
44  for(int32 i=0; i<surfSize; i++)
45  {
46  propId.push_back(pId);
47  }
48  }
49 
50  propertyId_.assign(propId);
51 
52  return true;
53 
54 }
55 
57 (
58  systemControl& control,
59  const property& prop
60 )
61 :
62  demGeometry(control),
63  wallProperty_(prop),
64  geometryRepository_(control.geometry()),
65  triSurface_(
67  objectFile(
68  "triSurface",
69  "",
72  )
73  )
74  ),
75  motionComponentName_(
76  control.geometry().emplaceObject<wordField>(
77  objectFile(
78  "motionComponentName",
79  "",
82  ),
83  "motionNamesList"
84  )
85  ),
86  materialName_(
87  control.geometry().emplaceObject<wordField>(
88  objectFile(
89  "materialName",
90  "",
93  ),
94  "materialNamesList"
95  )
96  ),
97  propertyId_(
99  objectFile(
100  "propertyId",
101  "",
104  surface(),
105  0 ) ),
106  contactForceWall_(
108  objectFile(
109  "contactForceWall",
110  "",
113  surface(),
114  zero3) ),
115  stressWall_(
117  objectFile(
118  "stressWall",
119  "",
122  surface(),
123  zero3) )
124 {
125 
126  if(!findPropertyId())
127  {
128  fatalExit;
129  }
130 }
131 
133 (
134  systemControl& control,
135  const property& prop,
137  const wordVector& motionCompName,
138  const wordVector& matName
139 )
140 :
141  demGeometry(control),
142  wallProperty_(prop),
143  geometryRepository_(control.geometry()),
144  triSurface_(
146  objectFile(
147  "triSurface",
148  "",
151  ),
152  triSurface
153  )
154  ),
155  motionComponentName_(
156  control.geometry().emplaceObject<wordField>(
157  objectFile(
158  "motionComponentName",
159  "",
162  ),
163  "motionNamesList",
164  motionCompName
165  )
166  ),
167  materialName_(
168  control.geometry().emplaceObject<wordField>(
169  objectFile(
170  "materialName",
171  "",
174  ),
175  "materialNamesList",
176  matName
177  )
178  ),
179  propertyId_(
181  objectFile(
182  "propertyId",
183  "",
186  surface(),
187  0 ) ),
188  contactForceWall_(
190  objectFile(
191  "contactForceWall",
192  "",
195  surface(),
196  zero3) ),
197  stressWall_(
199  objectFile(
200  "stressWall",
201  "",
204  surface(),
205  zero3) )
206 {
207  if(!findPropertyId())
208  {
209  fatalExit;
210  }
211 }
212 
214 (
215  systemControl& control,
216  const property& prop,
217  const dictionary& dict,
219  const wordVector& motionCompName,
220  const wordVector& matName
221 )
222 :
223  geometry(control, prop, triSurface, motionCompName, matName)
224 {}
225 
226 
229 (
230  systemControl& control,
231  const property& prop
232 )
233 {
234  //motionModelFile__
235  auto motionDictPtr = IOobject::make<dictionary>
236  (
237  objectFile
238  (
240  control.geometry().path(),
243  ),
245  true
246  );
247 
248  word model = motionDictPtr().getObject<dictionary>().getVal<word>("motionModel");
249 
250  auto geomModel = angleBracketsNames("geometry", model);
251 
252  REPORT(1)<< "Selecting geometry model . . ."<<endREPORT;
253  if( systemControlvCtorSelector_.search(geomModel) )
254  {
255  auto objPtr = systemControlvCtorSelector_[geomModel] (control, prop);
256  REPORT(2)<<"Model "<< greenText(geomModel)<<" is created.\n"<<endREPORT;
257  return objPtr;
258  }
259  else
260  {
261  printKeys
262  (
263  fatalError << "Ctor Selector "<< yellowText(geomModel) << " dose not exist. \n"
264  <<"Avaiable ones are: \n\n"
265  ,
266  systemControlvCtorSelector_
267  );
268  fatalExit;
269  }
270 
271  return nullptr;
272 }
273 
275 {
276  this->zeroForce();
277  return true;
278 }
279 
280 
282 {
283 
284  auto Force = contactForceWall_.deviceVectorAll();
285  auto area = triSurface_.area().deviceVectorAll();
286  auto stress = stressWall_.deviceVectorAll();
287  auto numTri =triSurface_.size();
288 
289 
290  Kokkos::parallel_for(
291  "geometry::calculateStress",
292  numTri,
293  LAMBDA_HD(int32 i){
294  stress[i] = Force[i]/area[i];
295  });
296  Kokkos::fence();
297  return true;
298 
299 }
300 
303  systemControl& control,
304  const property& prop,
305  const dictionary& dict,
307  const wordVector& motionCompName,
308  const wordVector& propName)
309 {
310 
311  word model = dict.getVal<word>("motionModel");
312 
313  auto geomModel = angleBracketsNames("geometry", model);
314 
315  REPORT(1)<< "Selecting geometry model . . ."<<endREPORT;
316 
317  if( dictionaryvCtorSelector_.search(geomModel) )
318  {
319  auto objPtr = dictionaryvCtorSelector_[geomModel]
320  (
321  control,
322  prop,
323  dict,
324  triSurface,
325  motionCompName,
326  propName
327  );
328  REPORT(2)<<"Model "<< greenText(geomModel)<<" is created.\n"<<endREPORT;
329  return objPtr;
330  }
331  else
332  {
333  printKeys
334  (
335  fatalError << "Ctor Selector "<< yellowText(geomModel) << " dose not exist. \n"
336  <<"Avaiable ones are: \n\n"
337  ,
338  dictionaryvCtorSelector_
339  );
340  fatalExit;
341  }
342  return nullptr;
343 }
pFlow::geometry::materialName_
wordField & materialName_
Material name of each wall surface
Definition: geometry.hpp:64
pFlow::motionModelFile__
const char * motionModelFile__
Definition: vocabs.hpp:45
pFlow::geometry::surface
auto & surface()
Surface.
Definition: geometry.hpp:188
endREPORT
#define endREPORT
Definition: streams.hpp:41
pFlow::geometry::findPropertyId
bool findPropertyId()
Find property id of each triangle based on the supplied material name and the surface wall that the t...
Definition: geometry.cpp:25
fatalExit
#define fatalExit
Definition: error.hpp:57
REPORT
#define REPORT(n)
Definition: streams.hpp:40
pFlow::geometry::create
static uniquePtr< geometry > create(systemControl &control, const property &prop)
Definition: geometry.cpp:229
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:59
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::systemControl
Definition: systemControl.hpp:41
pFlow::printKeys
iOstream & printKeys(iOstream &os, const wordHashMap< T > &m)
pFlow::zero3
const realx3 zero3(0.0)
Definition: types.hpp:97
pFlow::objectFile::WRITE_ALWAYS
@ WRITE_ALWAYS
Definition: objectFile.hpp:46
pFlow::repository::emplaceObject
T & emplaceObject(const objectFile &objf, Args &&... args)
Definition: repositoryTemplates.cpp:38
pFlow::geometry::wallProperty_
const property & wallProperty_
Const reference to physical property of materials.
Definition: geometry.hpp:52
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:320
pFlow::Field< Vector, word, vecAllocator< word > >
greenText
#define greenText(text)
Definition: streams.hpp:32
pFlow::multiTriSurface
Definition: multiTriSurface.hpp:33
pFlow::objectFile::WRITE_NEVER
@ WRITE_NEVER
Definition: objectFile.hpp:47
pFlow::geometry::afterIteration
bool afterIteration() override
Operations after each iteration.
Definition: geometry.cpp:281
RESERVE
Definition: Vector.hpp:38
pFlow::triSurfaceField
Definition: triSurfaceField.hpp:34
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::angleBracketsNames
word angleBracketsNames(const word &w1, const word &w2)
Definition: bTypesFunctions.cpp:131
pFlow::objectFile::READ_ALWAYS
@ READ_ALWAYS
Definition: objectFile.hpp:39
ForAll
#define ForAll(i, container)
Definition: pFlowMacros.hpp:71
geometry.hpp
pFlow::geometry::beforeIteration
bool beforeIteration() override
Operations before each iteration.
Definition: geometry.cpp:274
pFlow::property::nameToIndex
bool nameToIndex(const word &name, uint32 &idx) const
Get the name of material in index idx Return true, if the name found, otherwise false.
Definition: property.hpp:179
pFlow::objectFile
Definition: objectFile.hpp:33
fatalError
#define fatalError
Definition: error.hpp:36
pFlow::repository::path
virtual fileSystem path() const
Definition: repository.cpp:61
pFlow::dictionary::getVal
T getVal(const word &keyword) const
Definition: dictionary.hpp:309
pFlow::property
property holds the pure properties of materials.
Definition: property.hpp:40
pFlow::Vector::clear
auto clear()
Definition: Vector.hpp:248
pFlow::objectFile::READ_NEVER
@ READ_NEVER
Definition: objectFile.hpp:40
pFlow::systemControl::geometry
const repository & geometry() const
Definition: systemControl.hpp:133
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
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::demGeometry
base for geometry that manages control
Definition: demGeometry.hpp:33
pFlow::objectFile::READ_IF_PRESENT
@ READ_IF_PRESENT
Definition: objectFile.hpp:41
pFlow::triSurface
Definition: triSurface.hpp:38
pFlow::geometry::propertyId_
int8TriSurfaceField_D & propertyId_
Property id of each triangle in the set of wall surfaces.
Definition: geometry.hpp:67
vocabs.hpp
pFlow::geometryRepository_
const char * geometryRepository_
Definition: vocabs.hpp:34
yellowText
#define yellowText(text)
Definition: streams.hpp:30
pFlow::Vector
Definition: Vector.hpp:46
pFlow::dictionary
Definition: dictionary.hpp:38
pFlow::geometry::geometry
geometry(systemControl &control, const property &prop)
Construct from controlSystem and property, for reading from file.
Definition: geometry.cpp:57