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  if( H2 < radius2_*axisVector2_)
94  {
95  real t = dot(p1Point, axisVector_)/axisVector2_;
96  if(t >= 0.0 && t <= 1.0)
97  return true;
98  else
99  return false;
100  }
101  else
102  {
103  return false;
104  }
105 
106  }
107 
109  const realx3& p1()const
110  {
111  return p1_;
112  }
113 
115  const realx3& p2()const
116  {
117  return p2_;
118  }
119 
122  {
123  return minPoint_;
124  }
125 
128  {
129  return maxPoint_;
130  }
131 
133  real radius()const
134  {
135  return sqrt(radius2_);
136  }
137 
139  FUNCTION_H
140  bool read(iIstream & is);
141 
142  FUNCTION_H
143  bool write(iOstream& os)const;
144 
145  FUNCTION_H
146  bool read(const dictionary& dict);
147 
148  FUNCTION_H
149  bool write(dictionary& dict)const;
150 };
151 
153 iIstream& operator >>(iIstream& is, cylinder& b);
154 
156 iOstream& operator << (iOstream& os, const cylinder& b);
157 
158 
159 } // pFlow
160 
161 
162 #endif // __cylinder_hpp__
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::cylinder::write
FUNCTION_H bool write(iOstream &os) const
Definition: cylinder.cpp:124
iIstream.hpp
pFlow::cylinder::~cylinder
~cylinder()=default
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:133
pFlow
Definition: demComponent.hpp:28
pFlow::cylinder::minPoint
INLINE_FUNCTION_HD realx3 minPoint() const
Definition: cylinder.hpp:121
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
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
Definition: iIstream.hpp:33
pFlow::cylinder::p2_
realx3 p2_
Definition: cylinder.hpp:40
pFlow::cylinder::p2
const INLINE_FUNCTION_HD realx3 & p2() const
Definition: cylinder.hpp:115
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:53
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
FUNCTION_HD
#define FUNCTION_HD
Definition: pFlowMacros.hpp:57
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:127
pFlow::cylinder::p1
const INLINE_FUNCTION_HD realx3 & p1() const
Definition: cylinder.hpp:109
pFlow::cylinder::read
FUNCTION_H bool read(iIstream &is)
Definition: cylinder.cpp:113
pFlow::cylinder::calculateParams
FUNCTION_H bool calculateParams()
Definition: cylinder.cpp:26
pFlow::cylinder::axisVector_
realx3 axisVector_
Definition: cylinder.hpp:45
pFlow::cylinder::minPoint_
realx3 minPoint_
Definition: cylinder.hpp:49
iOstream.hpp
pFlow::sqrt
INLINE_FUNCTION_HD real sqrt(real x)
Definition: math.hpp:148
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
pFlow::triple< real >
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::dictionary
Definition: dictionary.hpp:38