www.cemf.ir
box.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 __box_hpp__
22 #define __box_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 box
33 {
34 protected:
35 
36  // - min point
37  realx3 min_{0,0,0};
38 
39  // - max point
40  realx3 max_{1,1,1};
41 
42 public:
43 
44  // - type info
45  TypeInfoNV("box");
46 
49  box() = default;
50 
52  box(const realx3& minP, const realx3& maxP)
53  :
54  min_(minP),
55  max_(maxP)
56  {}
57 
58 
60  explicit box(const dictionary& dict);
61 
63  explicit box(iIstream& is);
64 
66  box(const box&) = default;
67 
69  box(box&&) = default;
70 
72  box& operator=(const box&) = default;
73 
75  box& operator=(box&&) = default;
76 
78  ~box()=default;
79 
81 
82 
84  bool isInside(const realx3& point)const
85  {
86  // box planes are also included as the inside of the box
87  return point >= min_ && point <=max_;
88  }
89 
91  const realx3& minPoint()const
92  {
93  return min_;
94  }
95 
97  const realx3& maxPoint()const
98  {
99  return max_;
100  }
101 
104  {
105  return min_;
106  }
107 
110  {
111  return max_;
112  }
113 
115  FUNCTION_H
116  bool read(iIstream & is);
117 
118  FUNCTION_H
119  bool write(iOstream& os)const;
120 
121  FUNCTION_H
122  bool read(const dictionary& dict);
123 
124  FUNCTION_H
125  bool write(dictionary& dict)const;
126 };
127 
129 iIstream& operator >>(iIstream& is, box& b);
130 
132 iOstream& operator << (iOstream& os, const box& b);
133 
135 bool equal(const box& b1, const box& b2, real tol = smallValue)
136 {
137  return equal(b1.minPoint(), b2.minPoint(), tol) &&
138  equal(b1.maxPoint(), b2.maxPoint(), tol);
139 }
140 
142 bool operator ==(const box& b1, const box& b2)
143 {
144  return equal(b1, b2);
145 }
146 
148 box extendBox(const box& b, const realx3& dl)
149 {
150  return box(b.minPoint()-dl , b.maxPoint()+dl);
151 }
152 
153 }
154 
155 
156 #endif
pFlow::box::box
INLINE_FUNCTION_HD box()=default
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::smallValue
const real smallValue
Definition: numericConstants.hpp:31
iIstream.hpp
types.hpp
pFlow::equal
INLINE_FUNCTION_HD bool equal(const box &b1, const box &b2, real tol=smallValue)
Definition: box.hpp:135
pFlow::operator==
INLINE_FUNCTION_HD bool operator==(const box &b1, const box &b2)
Definition: box.hpp:142
pFlow::box::max_
realx3 max_
Definition: box.hpp:40
pFlow::extendBox
INLINE_FUNCTION_HD box extendBox(const box &b, const realx3 &dl)
Definition: box.hpp:148
pFlow::box::operator=
INLINE_FUNCTION_HD box & operator=(const box &)=default
pFlow::box::box
INLINE_FUNCTION_HD box(const realx3 &minP, const realx3 &maxP)
Definition: box.hpp:52
pFlow::box::maxPoint
const INLINE_FUNCTION_HD realx3 & maxPoint() const
Definition: box.hpp:97
pFlow
Definition: demGeometry.hpp:27
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:62
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
dictionary.hpp
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::box::write
FUNCTION_H bool write(iOstream &os) const
Definition: box.cpp:65
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::box::minPoint
const INLINE_FUNCTION_HD realx3 & minPoint() const
Definition: box.hpp:91
pFlow::box
Definition: box.hpp:32
pFlow::box::minPoint
INLINE_FUNCTION_HD realx3 & minPoint()
Definition: box.hpp:103
pFlow::box::maxPoint
INLINE_FUNCTION_HD realx3 & maxPoint()
Definition: box.hpp:109
pFlow::box::~box
INLINE_FUNCTION_HD ~box()=default
pFlow::box::TypeInfoNV
TypeInfoNV("box")
iOstream.hpp
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple< real >
pFlow::box::isInside
INLINE_FUNCTION_HD bool isInside(const realx3 &point) const
Definition: box.hpp:84
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::box::read
FUNCTION_H bool read(iIstream &is)
Definition: box.cpp:57
pFlow::box::min_
realx3 min_
Definition: box.hpp:37
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