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 
276  systemControl& control,
277  const property& prop,
278  const dictionary& dict,
280  const wordVector& motionCompName,
281  const wordVector& propName)
282 {
283 
284  word model = dict.getVal<word>("motionModel");
285 
286  auto geomModel = angleBracketsNames("geometry", model);
287 
288  REPORT(1)<< "Selecting geometry model . . ."<<endREPORT;
289 
290  if( dictionaryvCtorSelector_.search(geomModel) )
291  {
292  auto objPtr = dictionaryvCtorSelector_[geomModel]
293  (
294  control,
295  prop,
296  dict,
297  triSurface,
298  motionCompName,
299  propName
300  );
301  REPORT(2)<<"Model "<< greenText(geomModel)<<" is created.\n"<<endREPORT;
302  return objPtr;
303  }
304  else
305  {
306  printKeys
307  (
308  fatalError << "Ctor Selector "<< yellowText(geomModel) << " dose not exist. \n"
309  <<"Avaiable ones are: \n\n"
310  ,
311  dictionaryvCtorSelector_
312  );
313  fatalExit;
314  }
315  return nullptr;
316 }
pFlow::geometry::materialName_
wordField & materialName_
Definition: geometry.hpp:55
pFlow::motionModelFile__
const char * motionModelFile__
Definition: vocabs.hpp:45
pFlow::geometry::surface
auto & surface()
Definition: geometry.hpp:160
endREPORT
#define endREPORT
Definition: streams.hpp:41
pFlow::geometry::findPropertyId
bool findPropertyId()
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_
Definition: geometry.hpp:43
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
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
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::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
Definition: geometry.hpp:37
pFlow::demGeometry
Definition: demGeometry.hpp:31
pFlow::objectFile::READ_IF_PRESENT
@ READ_IF_PRESENT
Definition: objectFile.hpp:41
pFlow::triSurface
Definition: triSurface.hpp:38
pFlow::geometry::propertyId_
int8TriSurfaceField_D & propertyId_
Definition: geometry.hpp:57
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)
Definition: geometry.cpp:57