www.cemf.ir
internalPoints.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 __internalPoints_hpp__
21 #define __internalPoints_hpp__
22 
23 #include "subscriber.hpp"
24 #include "Vectors.hpp"
25 #include "VectorSingles.hpp"
26 #include "Fields.hpp"
27 #include "pointFlag.hpp"
28 
29 
30 
31 namespace pFlow
32 {
33 
34 class domain;
35 class boundaryBase;
36 class Time;
37 
39 :
40  public subscriber
41 {
42 public:
43 
44  inline static const uint32 initialCapacity_ = 10000;
45 
47 
49 
51 
53 
55 
56 private:
57 
59 
60  friend boundaryBase;
61 
63 
66 
69 
72 
74  mutable bool pFlagSync_ = false;
75 
77 
78  bool deletePoints(const uint32Vector_D& delPoints);
79 
81  const uint32Vector_D& changePoints,
82  realx3 transferVector,
83  uint32 fromBoundaryIndex,
84  uint32 toBoundaryIndex);
85 
86 
87 protected:
88 
89  void syncPFlag()const;
90 
91  inline
92  void unSyncFlag()
93  {
94  pFlagSync_ = false;
95  }
96 
97  inline
98  void createDeviceFlag(uint32 cap, uint32 start, uint32 end)
99  {
100  unSyncFlag();
101  pFlagsD_ = pFlagTypeDevice(cap, start, end);
102  }
103 
104  bool sortPoints(const uint32IndexContainer& sortedIndices);
105 
106 public:
107 
108  //friend class dynamicinternalPoints;
109 
110  // - type info
111  TypeInfo("internalPoints");
112 
113 
115 
116  // - an empty internalPoints, good for reading from file
117  internalPoints();
118 
119 
121  explicit internalPoints(const realx3Vector& posVec);
122 
124  internalPoints(const internalPoints&) = delete;
125 
127  internalPoints(internalPoints&&) = default;
128 
130  internalPoints& operator=(const internalPoints&) = delete;
131 
134 
136  ~internalPoints()override = default;
137 
138 
140 
142 
143 
144  const pFlagTypeHost& activePointsMaskHost()const;
145 
146  // - Const access pointPosition
147  const PointsType& pointPosition()const;
148 
149 
151 
152  inline
153  auto pointPositionHost()const
154  {
155  return pointPosition_.hostView();
156  }
157 
158  inline
160  {
161  return pointPosition_.deviceView();
162  }
163 
165 
166  // - size of data structure
167  inline
168  uint32 size()const
169  {
170  return pFlagsD_.activeRange_.end();
171  }
172 
173  // - maximum capacity of data structure
174  inline
176  {
177  return pFlagsD_.capacity();
178  }
179 
180  inline
181  bool empty()const
182  {
183  return size()==0u;
184  }
185 
186  // - number of active points
187  inline
189  {
190  return pFlagsD_.numActive();
191  }
192 
193  // - if all points are active
194  inline
195  bool isAllActive()const
196  {
197  return pFlagsD_.isAllActive();
198  }
199 
200  inline
201  auto activeRange()const
202  {
203  return pFlagsD_.activeRange();
204  }
205 
206  virtual
207  Time& time() = 0;
208 
209  virtual
210  const Time& time() const = 0;
211 
212  virtual
213  boundaryBase& boundary(size_t boundaryIndex ) = 0;
214 
215  virtual
216  const boundaryBase& boundary(size_t boundaryIndex ) const = 0;
217 
220 
221  bool deletePoints(
223 
224 
226  const domain& dm,
227  const std::array<real,6>& dist);
228 
229 
230  void fillNeighborsLists(
237 
238 
239  bool insertPoints(const realx3Vector& points, anyList& varList);
240 
241  bool insertPointsOnly(const realx3Vector_D& points, message& msg, anyList& varList);
242 
243 
245 
247  bool read(iIstream& is);
248 
249 
251  bool write(iOstream& os)const;
252 
254  bool read(iIstream& is, const IOPattern& iop);
255 
256 
258  bool write(iOstream& os, const IOPattern& iop)const;
259 
260 };
261 
262 inline
264 {
265  if( !ip.write(os) )
266  {
267  ioErrorInFile(os.name(), os.lineNumber());
268  fatalExit;
269  }
270 
271  return os;
272 }
273 
274 } // pFlow
275 
276 
277 #endif //__internalPoints_hpp__
278 
pFlow::internalPoints::isAllActive
bool isAllActive() const
Definition: internalPoints.hpp:195
pFlow::internalPoints::activePointsHost
PointsTypeHost activePointsHost() const
Definition: internalPoints.cpp:222
subscriber.hpp
pFlow::internalPoints::pFlagsD_
pFlagTypeDevice pFlagsD_
flag of points on device
Definition: internalPoints.hpp:68
pFlow::pointFlag::capacity
INLINE_FUNCTION_HD uint32 capacity() const
Definition: pointFlag.hpp:185
pFlow::internalPoints
Definition: internalPoints.hpp:38
pFlow::scatteredFieldAccess
Definition: scatteredFieldAccess.hpp:32
pFlow::message
Definition: message.hpp:33
pFlow::internalPoints::execution_space
typename PointsType::execution_space execution_space
Definition: internalPoints.hpp:54
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::internalPoints::TypeInfo
TypeInfo("internalPoints")
pFlow::pointFlag::activeRange_
rangeU32 activeRange_
Definition: pointFlag.hpp:66
pFlow::realx3Field_D
Field< realx3 > realx3Field_D
Definition: Fields.hpp:65
pFlow::internalPoints::unSyncFlag
void unSyncFlag()
Definition: internalPoints.hpp:92
pFlow::Range::end
INLINE_FUNCTION_HD T & end()
End.
Definition: Range.hpp:101
pFlow::internalPoints::pointPosition
const PointsType & pointPosition() const
Definition: internalPoints.cpp:209
pFlow::internalPoints::pointPositionHost
auto pointPositionHost() const
Definition: internalPoints.hpp:153
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::internalPoints::deletePoints
bool deletePoints(const uint32Vector_D &delPoints)
Definition: internalPoints.cpp:37
pFlow::pointFlag::numActive
INLINE_FUNCTION_HD auto numActive() const
Definition: pointFlag.hpp:191
pFlow::internalPoints::pointPosition_
PointsType pointPosition_
Position of points on device.
Definition: internalPoints.hpp:65
pFlow::internalPoints::fillNeighborsLists
void fillNeighborsLists(ViewType1D< uint32, memory_space > leftList, ViewType1D< uint32, memory_space > rightList, ViewType1D< uint32, memory_space > bottomList, ViewType1D< uint32, memory_space > topList, ViewType1D< uint32, memory_space > rearList, ViewType1D< uint32, memory_space > frontList)
Definition: internalPoints.cpp:291
Vectors.hpp
pFlow::internalPoints::pFlagSync_
bool pFlagSync_
if both host and device flags sync
Definition: internalPoints.hpp:74
pFlow::internalPoints::pointPositionDevice
auto pointPositionDevice() const
Definition: internalPoints.hpp:159
pFlow::Field< realx3 >
pFlow::subscriber
Definition: subscriber.hpp:37
pFlow
Definition: demGeometry.hpp:27
VectorSingles.hpp
pFlow::VectorSingle::deviceView
INLINE_FUNCTION_H auto deviceView() const
Device view range [0, size)
Definition: VectorSingle.cpp:263
pFlow::internalPoints::boundary
virtual boundaryBase & boundary(size_t boundaryIndex)=0
pFlow::internalPoints::activeRange
auto activeRange() const
Definition: internalPoints.hpp:201
pFlow::anyList
Definition: anyList.hpp:35
pFlow::VectorSingle< realx3, void >::device_type
typename viewType::device_type device_type
Definition: VectorSingle.hpp:72
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::internalPoints::numActive
uint32 numActive() const
Definition: internalPoints.hpp:188
pFlow::internalPoints::activePointsMaskDevice
const pFlagTypeDevice & activePointsMaskDevice() const
Definition: internalPoints.cpp:194
pFlow::VectorSingle::hostView
INLINE_FUNCTION_H auto hostView() const
Return a view accessible on Host in range [0,size)
Definition: VectorSingle.cpp:281
Fields.hpp
pFlow::internalPoints::changePointsFlagPosition
bool changePointsFlagPosition(const uint32Vector_D &changePoints, realx3 transferVector, uint32 fromBoundaryIndex, uint32 toBoundaryIndex)
Definition: internalPoints.cpp:92
pFlow::internalPoints::operator=
internalPoints & operator=(const internalPoints &)=delete
No Copy assignment.
pFlow::internalPoints::empty
bool empty() const
Definition: internalPoints.hpp:181
pFlow::internalPoints::PointsTypeHost
typename PointsType::FieldTypeHost PointsTypeHost
Definition: internalPoints.hpp:48
pFlow::internalPoints::sortPoints
bool sortPoints(const uint32IndexContainer &sortedIndices)
Definition: internalPoints.cpp:145
pFlow::IOPattern
Definition: IOPattern.hpp:32
pFlow::pointFlag::isAllActive
INLINE_FUNCTION_HD bool isAllActive() const
Definition: pointFlag.hpp:173
pFlow::internalPoints::time
virtual Time & time()=0
pFlow::boundaryBase
Definition: boundaryBase.hpp:42
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::internalPoints::boundaryBase
friend boundaryBase
Definition: internalPoints.hpp:60
pFlow::pointFlag::activeRange
const INLINE_FUNCTION_HD auto & activeRange() const
Definition: pointFlag.hpp:179
pFlow::internalPoints::pFlagsH_
pFlagTypeHost pFlagsH_
flag of points on host
Definition: internalPoints.hpp:71
pFlow::VectorSingle< uint32 >
pFlow::internalPoints::updateFlag
uint32 updateFlag(const domain &dm, const std::array< real, 6 > &dist)
Definition: internalPoints.cpp:271
pFlow::IOstream::name
virtual const word & name() const
Return the name of the stream.
Definition: IOstream.cpp:31
pFlow::internalPoints::insertPoints
bool insertPoints(const realx3Vector &points, anyList &varList)
Definition: internalPoints.cpp:311
pFlow::internalPoints::device_type
typename PointsType::device_type device_type
Definition: internalPoints.hpp:50
pFlow::ViewType1D
Kokkos::View< T *, properties... > ViewType1D
1D veiw as a vector
Definition: KokkosTypes.hpp:93
pFlow::internalPoints::size
uint32 size() const
Definition: internalPoints.hpp:168
pFlow::internalPoints::syncPFlag
void syncPFlag() const
Definition: internalPoints.cpp:28
pFlow::internalPoints::memory_space
typename PointsType::memory_space memory_space
Definition: internalPoints.hpp:52
pFlow::internalPoints::PointsType
realx3Field_D PointsType
Definition: internalPoints.hpp:46
pFlow::internalPoints::read
bool read(iIstream &is)
Read.
Definition: internalPoints.cpp:530
pFlow::internalPoints::~internalPoints
~internalPoints() override=default
Destructor.
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Report an error in file operation with supplied fileName and lineNumber.
Definition: error.hpp:87
pFlow::internalPoints::createDeviceFlag
void createDeviceFlag(uint32 cap, uint32 start, uint32 end)
Definition: internalPoints.hpp:98
pFlow::internalPoints::write
bool write(iOstream &os) const
Write.
Definition: internalPoints.cpp:556
pFlow::IOstream::lineNumber
int32 lineNumber() const
Const access to the current stream line number.
Definition: IOstream.hpp:223
pFlow::domain
Definition: domain.hpp:31
pFlow::internalPoints::insertPointsOnly
bool insertPointsOnly(const realx3Vector_D &points, message &msg, anyList &varList)
Definition: internalPoints.cpp:427
pFlow::internalPoints::initialCapacity_
static const uint32 initialCapacity_
Definition: internalPoints.hpp:44
pFlow::internalPoints::activePointsMaskHost
const pFlagTypeHost & activePointsMaskHost() const
Definition: internalPoints.cpp:201
pFlow::triple< real >
pFlow::Field< realx3 >::memory_space
typename VectorType::memory_space memory_space
Definition: Field.hpp:48
pFlow::Vector< realx3 >
pFlow::pFlagTypeDevice
pointFlag< DefaultExecutionSpace > pFlagTypeDevice
Definition: pointFlag.hpp:387
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::Field< realx3 >::FieldTypeHost
Field< realx3, HostSpace > FieldTypeHost
Definition: Field.hpp:46
pFlow::internalPoints::internalPoints
internalPoints()
Definition: internalPoints.cpp:159
pFlow::Field< realx3 >::execution_space
typename VectorType::execution_space execution_space
Definition: Field.hpp:50
pFlow::pointFlag< DefaultExecutionSpace >
pFlow::indexContainer
It holds two vectors of indecis on Host and Device.
Definition: indexContainer.hpp:39
pFlow::internalPoints::capacity
uint32 capacity() const
Definition: internalPoints.hpp:175
pointFlag.hpp
pFlow::Time
Definition: Time.hpp:37