sphere.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 __sphere_hpp__
22 #define __sphere_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 sphere
33 {
34 protected:
35 
36  // - center
38 
39  // - radius^2
41 
42 
43 public:
44 
45  // - type info
46  TypeInfoNV("sphere");
47 
49  FUNCTION_H
50  sphere(const realx3& center, const real radius);
51 
53  sphere(const dictionary& dict);
54 
56  sphere(iIstream& is);
57 
59  sphere(const sphere&) = default;
60 
62  sphere(sphere&&) = default;
63 
65  sphere& operator=(const sphere&) = default;
66 
68  sphere& operator=(sphere&&) = default;
69 
70  ~sphere()=default;
71 
73 
75  bool isInside(const realx3& point)const
76  {
77  auto cPoint = point-center_;
78  auto dist2 = dot(cPoint,cPoint);
79  return dist2 < radius2_;
80 
81  }
82 
84  const realx3& center()const
85  {
86  return center_;
87  }
88 
89 
92  {
93  return center_ - realx3(radius());
94  }
95 
98  {
99  return center_ + realx3(radius());
100  }
101 
103  real radius()const
104  {
105  return sqrt(radius2_);
106  }
107 
109  FUNCTION_H
110  bool read(iIstream & is);
111 
112  FUNCTION_H
113  bool write(iOstream& os)const;
114 
115  FUNCTION_H
116  bool read(const dictionary& dict);
117 
118  FUNCTION_H
119  bool write(dictionary& dict)const;
120 };
121 
123 iIstream& operator >>(iIstream& is, sphere& b);
124 
126 iOstream& operator << (iOstream& os, const sphere& b);
127 
128 
129 } // pFlow
130 
131 
132 #endif // __sphere_hpp__
pFlow::sphere::center
const INLINE_FUNCTION_HD realx3 & center() const
Definition: sphere.hpp:84
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::sphere::write
FUNCTION_H bool write(iOstream &os) const
Definition: sphere.cpp:77
iIstream.hpp
types.hpp
pFlow::sphere::maxPoint
INLINE_FUNCTION_HD realx3 maxPoint() const
Definition: sphere.hpp:97
pFlow::realx3
triple< real > realx3
Definition: types.hpp:48
pFlow
Definition: demComponent.hpp:28
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
dot
INLINE_FUNCTION_HD T dot(const quadruple< T > &oprnd1, const quadruple< T > &oprnd2)
pFlow::sphere::center_
realx3 center_
Definition: sphere.hpp:37
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::sphere::read
FUNCTION_H bool read(iIstream &is)
Definition: sphere.cpp:67
dictionary.hpp
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
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::sphere::~sphere
~sphere()=default
pFlow::sphere::minPoint
INLINE_FUNCTION_HD realx3 minPoint() const
Definition: sphere.hpp:91
pFlow::sphere::sphere
FUNCTION_H sphere(const realx3 &center, const real radius)
Definition: sphere.cpp:26
pFlow::sphere::radius2_
real radius2_
Definition: sphere.hpp:40
pFlow::sphere
Definition: sphere.hpp:32
iOstream.hpp
pFlow::sphere::TypeInfoNV
TypeInfoNV("sphere")
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
pFlow::sphere::radius
INLINE_FUNCTION_HD real radius() const
Definition: sphere.hpp:103
pFlow::sphere::operator=
FUNCTION_HD sphere & operator=(const sphere &)=default
pFlow::sphere::isInside
INLINE_FUNCTION_HD bool isInside(const realx3 &point) const
Definition: sphere.hpp:75