www.cemf.ir
cylinder.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 
21 #ifndef __cylinder_hpp__
22 #define __cylinder_hpp__
23 
24 #include "types.hpp"
25 #include "dictionary.hpp"
26 #include "iIstream.hpp"
27 #include "iOstream.hpp"
28 
29 namespace pFlow
30 {
31 
32 class cylinder
33 {
34 protected:
35 
36  // - begin point
38 
39  // - end point
41 
42  // - radius^2
44 
46 
48 
50 
52 
54  bool calculateParams();
55 
56 public:
57 
58  // - type info
59  TypeInfoNV("cylinder");
60 
62  FUNCTION_H
63  cylinder(const realx3& p1, const realx3& p2, const real radius);
64 
66  cylinder(const dictionary& dict);
67 
69  cylinder(iIstream& is);
70 
72  cylinder(const cylinder&) = default;
73 
75  cylinder(cylinder&&) = default;
76 
78  cylinder& operator=(const cylinder&) = default;
79 
81  cylinder& operator=(cylinder&&) = default;
82 
83  ~cylinder()=default;
84 
86 
88  bool isInside(const realx3& point)const
89  {
90  auto p1Point = point-p1_;
91  auto H = cross(p1Point , axisVector_);
92  auto H2 = dot(H,H);
93 
94  // the shell itslef is considered as inside point
95  if( H2 <= radius2_*axisVector2_)
96  {
97  real t = dot(p1Point, axisVector_)/axisVector2_;
98  if(t >= 0.0 && t <= 1.0)
99  return true;
100  else
101  return false;
102  }
103  else
104  {
105  return false;
106  }
107 
108  }
109 
111  const realx3& p1()const
112  {
113  return p1_;
114  }
115 
117  const realx3& p2()const
118  {
119  return p2_;
120  }
121 
124  {
125  return minPoint_;
126  }
127 
130  {
131  return maxPoint_;
132  }
133 
135  real radius()const
136  {
137  return sqrt(radius2_);
138  }
139 
141  FUNCTION_H
142  bool read(iIstream & is);
143 
144  FUNCTION_H
145  bool write(iOstream& os)const;
146 
147  FUNCTION_H
148  bool read(const dictionary& dict);
149 
150  FUNCTION_H
151  bool write(dictionary& dict)const;
152 };
153 
155 iIstream& operator >>(iIstream& is, cylinder& b);
156 
158 iOstream& operator << (iOstream& os, const cylinder& b);
159 
160 
161 } // pFlow
162 
163 
164 #endif // __cylinder_hpp__
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::cylinder::write
FUNCTION_H bool write(iOstream &os) const
Definition: cylinder.cpp:128
iIstream.hpp
pFlow::cylinder::~cylinder
~cylinder()=default
pFlow::sqrt
Vector< T, Allocator > sqrt(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:90
pFlow::cylinder::maxPoint_
realx3 maxPoint_
Definition: cylinder.hpp:51
types.hpp
pFlow::cylinder::operator=
FUNCTION_HD cylinder & operator=(const cylinder &)=default
pFlow::cylinder::TypeInfoNV
TypeInfoNV("cylinder")
pFlow::cylinder::isInside
INLINE_FUNCTION_HD bool isInside(const realx3 &point) const
Definition: cylinder.hpp:88
pFlow::cylinder::radius
INLINE_FUNCTION_HD real radius() const
Definition: cylinder.hpp:135
pFlow
Definition: demGeometry.hpp:27
pFlow::cylinder::minPoint
INLINE_FUNCTION_HD realx3 minPoint() const
Definition: cylinder.hpp:123
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:62
dot
INLINE_FUNCTION_HD T dot(const quadruple< T > &oprnd1, const quadruple< T > &oprnd2)
pFlow::cylinder
Definition: cylinder.hpp:32
cross
INLINE_FUNCTION_HD triple< T > cross(const triple< T > &v1, const triple< T > &v2)
pFlow::cylinder::axisVector2_
real axisVector2_
Definition: cylinder.hpp:47
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::cylinder::p2_
realx3 p2_
Definition: cylinder.hpp:40
pFlow::cylinder::p2
const INLINE_FUNCTION_HD realx3 & p2() const
Definition: cylinder.hpp:117
dictionary.hpp
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::cylinder::cylinder
FUNCTION_H cylinder(const realx3 &p1, const realx3 &p2, const real radius)
Definition: cylinder.cpp:57
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
FUNCTION_HD
#define FUNCTION_HD
Definition: pFlowMacros.hpp:61
pFlow::cylinder::radius2_
real radius2_
Definition: cylinder.hpp:43
pFlow::cylinder::p1_
realx3 p1_
Definition: cylinder.hpp:37
pFlow::cylinder::maxPoint
INLINE_FUNCTION_HD realx3 maxPoint() const
Definition: cylinder.hpp:129
pFlow::cylinder::p1
const INLINE_FUNCTION_HD realx3 & p1() const
Definition: cylinder.hpp:111
pFlow::cylinder::read
FUNCTION_H bool read(iIstream &is)
Definition: cylinder.cpp:117
pFlow::cylinder::calculateParams
FUNCTION_H bool calculateParams()
Definition: cylinder.cpp:27
pFlow::cylinder::axisVector_
realx3 axisVector_
Definition: cylinder.hpp:45
pFlow::cylinder::minPoint_
realx3 minPoint_
Definition: cylinder.hpp:49
iOstream.hpp
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple< real >
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
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