www.cemf.ir
grainShape.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 "grainShape.hpp"
22 
23 
25 {
26 
27  grainDiameters_ = getVal<realVector>("grainDiameters");
28 
29  sphereDiameters_ = getVal<realVector>("sphereDiameters");
30 
32 
33 
34  if(grainDiameters_.size() != numShapes() )
35  {
37  " number of elements in grain diameters in "<< globalName()<<" is not consistent"<<endl;
38  return false;
39  }
40 
41  if(sphereDiameters_.size() != numShapes() )
42  {
44  " number of elements in sphere diameters in "<< globalName()<<" is not consistent"<<endl;
45  return false;
46  }
47 
48  return true;
49 }
50 
52 {
53 
54  if(!shape::writeToDict(dict))return false;
55 
56  return true;
57 }
58 
60 (
61  const word& fileName,
62  repository* owner,
63  const property& prop
64 )
65 :
66  shape(fileName, owner, prop)
67 {
68 
69  if(!readFromDictionary3())
70  {
71  fatalExit;
73  }
74 }
75 
77 {
78  return max(grainDiameters_);
79 }
80 
82 {
83  return min(grainDiameters_);
84 }
85 
87 {
88  if( indexValid(index))
89  {
90  bDiam = grainDiameters_[index];
91  return true;
92  }
93  return false;
94 }
95 
97 {
98  if(indexValid(index))
99  {
100  return grainDiameters_[index];
101  }
102  fatalErrorInFunction<<"Invalid index for diameter "<<
103  index<<endl;
104  fatalExit;
105  return 0.0;
106 }
107 
109 {
110  return grainDiameters_;
111 }
112 
114 {
115  if(indexValid(index))
116  {
117  return coarseGrainFactor_[index];
118  }
119  fatalErrorInFunction<<"Invalid index for coarse Grain Factor "<<
120  index<<endl;
121  fatalExit;
122  return 0.0;
123 }
124 
125 
127 {
128  return coarseGrainFactor_;
129 }
130 
132 {
133  if(indexValid(index))
134  {
135  return sphereDiameters_[index];
136  }
137  fatalErrorInFunction<<"Invalid index for sphere diameter "<<
138  index<<endl;
139  fatalExit;
140  return 0.0;
141 }
142 
143 
144 
146 {
147  return sphereDiameters_;
148 }
149 
151 {
152  if( indexValid(index) )
153  {
154  real d = grainDiameters_[index];
155  real rho = indexToDensity(index);
156  m = Pi/6.0*pow(d,3)*rho;
157  return true;
158  }
159  return false;
160 }
161 
163 {
164  if(real m; mass(index, m))
165  {
166  return m;
167  }
168  fatalErrorInFunction<<"bad index for mass "<< index<<endl;
169  fatalExit;
170  return 0;
171 }
172 
174 {
175  return realVector ("mass", Pi/6*pow(grainDiameters_,(real)3.0)*density());
176 }
177 
179 {
180  auto pids = shapePropertyIds();
181  realVector rho("rho", numShapes());
182  ForAll(i, pids)
183  {
184  rho[i] = properties().density(pids[i]);
185  }
186  return rho;
187 }
188 
190 {
191  if( indexValid(index) )
192  {
193  I = 0.4 * mass(index) * pow(grainDiameters_[index]/2.0,2.0);
194  return true;
195  }
196  return false;
197 }
198 
200 {
201  if(real I; Inertia(index, I))
202  {
203  return I;
204  }
205  fatalExit;
206  return 0;
207 }
208 
210 {
211  return realVector("I", (real)0.4*mass()*pow((real)0.5*grainDiameters_,(real)2.0));
212 }
213 
215 {
216  return Inertia(index,Ixx);
217 }
218 
220 {
221  return Inertia(index);
222 }
223 
225 {
226  return Inertia(index,Iyy);
227 }
228 
230 {
231  return Inertia(index);
232 }
233 
235 {
236  return Inertia(index,Izz);
237 }
238 
240 {
241  return Inertia(index);
242 }
pFlow::realVector
Vector< real > realVector
Definition: Vectors.hpp:46
pFlow::grainShape::writeToDict
bool writeToDict(dictionary &dict) const override
Definition: grainShape.cpp:51
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::pow
Vector< T, Allocator > pow(const Vector< T, Allocator > &v1, const Vector< T, Allocator > &v2)
Definition: VectorMath.hpp:89
pFlow::grainShape::mass
realVector mass() const override
Definition: grainShape.cpp:173
pFlow::grainShape::Inertial_zz
real Inertial_zz(uint32 index) const override
Definition: grainShape.cpp:239
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::grainShape::Inertial_yy
real Inertial_yy(uint32 index) const override
Definition: grainShape.cpp:229
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::max
T max(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:79
pFlow::grainShape::coarseGrainFactor
realVector coarseGrainFactor() const
Definition: grainShape.cpp:126
pFlow::dictionary::globalName
virtual word globalName() const
global name of entry, separated with dots
Definition: dictionary.cpp:356
pFlow::grainShape::Inertia_xx
bool Inertia_xx(uint32 index, real &Ixx) const override
Definition: grainShape.cpp:214
pFlow::Vector::size
auto size() const
Size of the vector.
Definition: Vector.hpp:265
pFlow::baseShapeNames::numShapes
size_t numShapes() const
Definition: baseShapeNames.hpp:93
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::grainShape::orginalDiameter
realVector orginalDiameter() const
Definition: grainShape.cpp:145
pFlow::shape::writeToDict
bool writeToDict(dictionary &dict) const override
Definition: shape.cpp:65
pFlow::grainShape::grainShape
grainShape(const word &fileName, repository *owner, const property &prop)
Definition: grainShape.cpp:60
pFlow::grainShape::density
realVector density() const override
Definition: grainShape.cpp:178
pFlow::grainShape::sphereDiameters_
realVector sphereDiameters_
Definition: grainShape.hpp:37
pFlow::grainShape::readFromDictionary3
bool readFromDictionary3()
Definition: grainShape.cpp:24
grainShape.hpp
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::grainShape::Inertial_xx
real Inertial_xx(uint32 index) const override
Definition: grainShape.cpp:219
pFlow::shape
Definition: shape.hpp:30
pFlow::grainShape::grainDiameters_
realVector grainDiameters_
Definition: grainShape.hpp:36
pFlow::grainShape::minBoundingSphere
real minBoundingSphere() const override
Definition: grainShape.cpp:81
pFlow::grainShape::Inertia_zz
bool Inertia_zz(uint32 index, real &Izz) const override
Definition: grainShape.cpp:234
ForAll
#define ForAll(i, container)
Definition: pFlowMacros.hpp:75
pFlow::min
T min(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:28
pFlow::property
property holds the pure properties of materials.
Definition: property.hpp:37
pFlow::grainShape::boundingDiameter
realVector boundingDiameter() const override
Definition: grainShape.cpp:108
pFlow::grainShape::Inertia
realVector Inertia() const override
Definition: grainShape.cpp:209
pFlow::grainShape::maxBoundingSphere
real maxBoundingSphere() const override
Definition: grainShape.cpp:76
pFlow::Pi
const real Pi
Definition: numericConstants.hpp:30
pFlow::repository
Definition: repository.hpp:34
pFlow::grainShape::Inertia_yy
bool Inertia_yy(uint32 index, real &Iyy) const override
Definition: grainShape.cpp:224
pFlow::Vector< real >
m
uint32 m
Definition: NBSLoop.hpp:22
pFlow::grainShape::coarseGrainFactor_
realVector coarseGrainFactor_
Definition: grainShape.hpp:38
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