www.cemf.ir
shape.hpp
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 #ifndef __shape_hpp__
21 #define __shape_hpp__
22 
23 #include "baseShapeNames.hpp"
24 #include "property.hpp"
25 
26 namespace pFlow
27 {
28 
29 
30 class shape
31 :
32  public baseShapeNames
33 {
34 private:
35 
37  const property& property_;
38 
41 
44 
45 
46  bool findPropertyIds();
47 
48  bool readFromDictionary2();
49 
50 protected:
51 
52 
53  bool writeToDict(dictionary& dict)const override;
54 
55 public:
56 
57  TypeInfo("shape");
58 
59  shape(
60  const word& fileName,
62  const property& prop);
63 
64  ~shape() override=default;
65 
66  inline
67  const auto& properties()const
68  {
69  return property_;
70  }
71 
72 
73  inline
74  const wordVector& materialNames()const
75  {
76  return materialNames_;
77  }
78 
79  inline
80  const auto& shapePropertyIds()const
81  {
82  return shapePropertyIds_;
83  }
84 
85 
86 
87  inline
88  bool shapeNameToPropId(const word& name, int8& propId)const
89  {
90  if(uint32 index; shapeNameToIndex(name, index))
91  {
92  propId = shapePropertyIds_[index];
93  return true;
94  }
95  return false;
96  }
97 
98  inline
99  bool propIdValid(uint32 propId)const
100  {
101  return static_cast<uint32>(propId) < property_.numMaterials();
102  }
103 
104 
105  inline
106  bool indexToDensity(uint32 index, real& rho)const
107  {
108  if(indexValid(index))
109  return property_.density(shapePropertyIds_[index], rho);
110  return false;
111  }
112 
113  inline
115  {
116  if(indexValid(index))
117  {
118  return property_.density(shapePropertyIds_[index]);
119  }
120 
121  fatalExit;
122  return 0.0;
123  }
124 
125  inline
127  {
128  if(indexValid(index))
129  {
130  return shapePropertyIds_[index];
131  }
132  fatalExit;
133  return 0.0;
134  }
135 
136  virtual
137  real maxBoundingSphere()const = 0;
138 
139  virtual
140  real minBoundingSphere()const = 0;
141 
142  virtual
143  bool boundingDiameter(uint32 index, real& bDiam)const =0;
144 
145  virtual
146  real boundingDiameter(uint32 index)const = 0;
147 
148  virtual
149  realVector boundingDiameter()const = 0;
150 
151  virtual
152  bool mass(uint32 index, real& m)const = 0;
153 
154  virtual
155  real mass(uint32 index) const =0;
156 
157  virtual
158  realVector mass()const =0;
159 
160  virtual
161  realVector density()const =0;
162 
163  virtual
164  bool Inertia(uint32 index, real& I)const = 0;
165 
166  virtual
167  real Inertia(uint32 index)const = 0;
168 
169  virtual
170  realVector Inertia()const=0;
171 
172  virtual
173  bool Inertia_xx(uint32 index, real& Ixx)const = 0;
174 
175  virtual
176  real Inertial_xx(uint32 index)const =0;
177 
178  virtual
179  bool Inertia_yy(uint32 index, real& Iyy)const = 0;
180 
181  virtual
182  real Inertial_yy(uint32 index)const = 0;
183 
184  virtual
185  bool Inertia_zz(uint32 index, real& Izz)const = 0;
186 
187  virtual
188  real Inertial_zz(uint32 index)const = 0;
189 
190 };
191 
192 }
193 
194 #endif //__shape_hpp__
pFlow::shape::~shape
~shape() override=default
pFlow::shape::shapePropertyIds_
uint32Vector shapePropertyIds_
list of property ids of shapes (index)
Definition: shape.hpp:40
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::shape::propIdValid
bool propIdValid(uint32 propId) const
Definition: shape.hpp:99
pFlow::shape::Inertial_yy
virtual real Inertial_yy(uint32 index) const =0
pFlow::shape::indexToDensity
real indexToDensity(uint32 index) const
Definition: shape.hpp:114
pFlow::baseShapeNames
Definition: baseShapeNames.hpp:33
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::baseShapeNames::indexValid
bool indexValid(uint32 index) const
Definition: baseShapeNames.hpp:140
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::shape::shapePropertyIds
const auto & shapePropertyIds() const
Definition: shape.hpp:80
baseShapeNames.hpp
pFlow::shape::TypeInfo
TypeInfo("shape")
pFlow::shape::indexToDensity
bool indexToDensity(uint32 index, real &rho) const
Definition: shape.hpp:106
pFlow::shape::Inertia
virtual realVector Inertia() const =0
pFlow::shape::shape
shape(const word &fileName, repository *owner, const property &prop)
Definition: shape.cpp:41
pFlow::shape::materialNames
const wordVector & materialNames() const
Definition: shape.hpp:74
pFlow::shape::mass
virtual realVector mass() const =0
pFlow::shape::Inertia_xx
virtual bool Inertia_xx(uint32 index, real &Ixx) const =0
pFlow
Definition: demGeometry.hpp:27
pFlow::shape::writeToDict
bool writeToDict(dictionary &dict) const override
Definition: shape.cpp:65
pFlow::shape::property_
const property & property_
property of materials
Definition: shape.hpp:37
pFlow::shape::Inertia_yy
virtual bool Inertia_yy(uint32 index, real &Iyy) const =0
pFlow::shape::Inertial_xx
virtual real Inertial_xx(uint32 index) const =0
pFlow::shape
Definition: shape.hpp:30
pFlow::dictionary::dict
virtual dictionary & dict()
ref to this dictionary, if it is a dictionary
Definition: dictionary.cpp:369
pFlow::shape::Inertia_zz
virtual bool Inertia_zz(uint32 index, real &Izz) const =0
pFlow::baseShapeNames::shapeNameToIndex
bool shapeNameToIndex(const word &name, uint32 &index) const
Definition: baseShapeNames.hpp:100
pFlow::shape::maxBoundingSphere
virtual real maxBoundingSphere() const =0
pFlow::IOobject::owner
const repository * owner() const override
Definition: IOobject.hpp:76
pFlow::shape::minBoundingSphere
virtual real minBoundingSphere() const =0
pFlow::property::numMaterials
auto numMaterials() const
Return number of materials.
Definition: property.hpp:111
pFlow::shape::findPropertyIds
bool findPropertyIds()
Definition: shape.cpp:4
pFlow::iEntry::name
virtual word name() const
name/keyword of entry
Definition: iEntry.hpp:100
pFlow::property
property holds the pure properties of materials.
Definition: property.hpp:37
pFlow::shape::propertyId
uint32 propertyId(uint32 index) const
Definition: shape.hpp:126
pFlow::shape::materialNames_
wordVector materialNames_
list of material names
Definition: shape.hpp:43
pFlow::shape::density
virtual realVector density() const =0
pFlow::int8
signed char int8
Definition: builtinTypes.hpp:48
pFlow::repository
Definition: repository.hpp:34
pFlow::property::density
real density(uint32 i) const
Return density of material i.
Definition: property.hpp:149
pFlow::shape::properties
const auto & properties() const
Definition: shape.hpp:67
property.hpp
pFlow::Vector< uint32 >
m
uint32 m
Definition: NBSLoop.hpp:22
pFlow::shape::shapeNameToPropId
bool shapeNameToPropId(const word &name, int8 &propId) const
Definition: shape.hpp:88
pFlow::shape::Inertial_zz
virtual real Inertial_zz(uint32 index) const =0
pFlow::shape::boundingDiameter
virtual realVector boundingDiameter() const =0
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
pFlow::shape::readFromDictionary2
bool readFromDictionary2()
Definition: shape.cpp:24