www.cemf.ir
sphereShape.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 "sphereShape.hpp"
22 
23 
25 {
26 
27  diameters_ = getVal<realVector>("diameters");
28 
29  if(diameters_.size() != numShapes() )
30  {
32  " number of elements in diameters in "<< globalName()<<" is not consistent"<<endl;
33  return false;
34  }
35 
36  return true;
37 }
38 
40 {
41 
42  if(!shape::writeToDict(dict))return false;
43 
44  if( !dict.add("diameters", diameters_) )
45  {
47  " Error in writing diameters to dictionary "<< dict.globalName()<<endl;
48  return false;
49  }
50 
51  return true;
52 }
53 
55 (
56  const word& fileName,
57  repository* owner,
58  const property& prop
59 )
60 :
61  shape(fileName, owner, prop)
62 {
63 
64  if(!readFromDictionary3())
65  {
66  fatalExit;
68  }
69 }
70 
72 {
73  return max(diameters_);
74 }
75 
77 {
78  return min(diameters_);
79 }
80 
82 {
83  if( indexValid(index))
84  {
85  bDiam = diameters_[index];
86  return true;
87  }
88  return false;
89 }
90 
92 {
93  if(indexValid(index))
94  {
95  return diameters_[index];
96  }
97  fatalErrorInFunction<<"Invalid index for diameter "<<
98  index<<endl;
99  fatalExit;
100  return 0.0;
101 }
102 
104 {
105  return diameters_;
106 }
107 
109 {
110  if( indexValid(index) )
111  {
112  real d = diameters_[index];
113  real rho = indexToDensity(index);
114  m = Pi/6.0*pow(d,3)*rho;
115  return true;
116  }
117  return false;
118 }
119 
121 {
122  if(real m; mass(index, m))
123  {
124  return m;
125  }
126  fatalErrorInFunction<<"bad index for mass "<< index<<endl;
127  fatalExit;
128  return 0;
129 }
130 
132 {
133  return realVector ("mass", Pi/6*pow(diameters_,(real)3.0)*density());
134 }
135 
137 {
138  auto pids = shapePropertyIds();
139  realVector rho("rho", numShapes());
140  ForAll(i, pids)
141  {
142  rho[i] = properties().density(pids[i]);
143  }
144  return rho;
145 }
146 
148 {
149  if( indexValid(index) )
150  {
151  I = 0.4 * mass(index) * pow(diameters_[index]/2.0,2.0);
152  return true;
153  }
154  return false;
155 }
156 
158 {
159  if(real I; Inertia(index, I))
160  {
161  return I;
162  }
163  fatalExit;
164  return 0;
165 }
166 
168 {
169  return realVector("I", (real)0.4*mass()*pow((real)0.5*diameters_,(real)2.0));
170 }
171 
173 {
174  return Inertia(index,Ixx);
175 }
176 
178 {
179  return Inertia(index);
180 }
181 
183 {
184  return Inertia(index,Iyy);
185 }
186 
188 {
189  return Inertia(index);
190 }
191 
193 {
194  return Inertia(index,Izz);
195 }
196 
198 {
199  return Inertia(index);
200 }
pFlow::realVector
Vector< real > realVector
Definition: Vectors.hpp:46
pFlow::sphereShape::writeToDict
bool writeToDict(dictionary &dict) const override
Definition: sphereShape.cpp:39
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::sphereShape::Inertia_xx
bool Inertia_xx(uint32 index, real &Ixx) const override
Definition: sphereShape.cpp:172
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::sphereShape::mass
realVector mass() const override
Definition: sphereShape.cpp:131
pFlow::sphereShape::maxBoundingSphere
real maxBoundingSphere() const override
Definition: sphereShape.cpp:71
pFlow::pow
Vector< T, Allocator > pow(const Vector< T, Allocator > &v1, const Vector< T, Allocator > &v2)
Definition: VectorMath.hpp:89
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::sphereShape::Inertial_yy
real Inertial_yy(uint32 index) const override
Definition: sphereShape.cpp:187
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::max
T max(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:79
pFlow::dictionary::globalName
virtual word globalName() const
global name of entry, separated with dots
Definition: dictionary.cpp:356
pFlow::Vector::size
auto size() const
Size of the vector.
Definition: Vector.hpp:265
pFlow::dictionary::add
bool add(const word &keyword, const float &v)
add a float dataEntry
Definition: dictionary.cpp:435
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::sphereShape::Inertial_zz
real Inertial_zz(uint32 index) const override
Definition: sphereShape.cpp:197
pFlow::sphereShape::Inertia_yy
bool Inertia_yy(uint32 index, real &Iyy) const override
Definition: sphereShape.cpp:182
pFlow::sphereShape::diameters_
realVector diameters_
Definition: sphereShape.hpp:36
pFlow::sphereShape::readFromDictionary3
bool readFromDictionary3()
Definition: sphereShape.cpp:24
pFlow::shape::writeToDict
bool writeToDict(dictionary &dict) const override
Definition: shape.cpp:65
pFlow::sphereShape::boundingDiameter
realVector boundingDiameter() const override
Definition: sphereShape.cpp:103
pFlow::sphereShape::minBoundingSphere
real minBoundingSphere() const override
Definition: sphereShape.cpp:76
sphereShape.hpp
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::shape
Definition: shape.hpp:30
pFlow::sphereShape::Inertia_zz
bool Inertia_zz(uint32 index, real &Izz) const override
Definition: sphereShape.cpp:192
pFlow::sphereShape::Inertia
realVector Inertia() const override
Definition: sphereShape.cpp:167
ForAll
#define ForAll(i, container)
Definition: pFlowMacros.hpp:75
pFlow::min
T min(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:28
pFlow::sphereShape::sphereShape
sphereShape(const word &fileName, repository *owner, const property &prop)
Definition: sphereShape.cpp:55
pFlow::property
property holds the pure properties of materials.
Definition: property.hpp:37
pFlow::sphereShape::density
realVector density() const override
Definition: sphereShape.cpp:136
pFlow::Pi
const real Pi
Definition: numericConstants.hpp:30
pFlow::repository
Definition: repository.hpp:34
pFlow::Vector< real >
m
uint32 m
Definition: NBSLoop.hpp:22
pFlow::sphereShape::Inertial_xx
real Inertial_xx(uint32 index) const override
Definition: sphereShape.cpp:177
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