www.cemf.ir
boundaryBase.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 __boundaryBase_hpp__
21 #define __boundaryBase_hpp__
22 
23 #include "virtualConstructor.hpp"
24 #include "subscriber.hpp"
25 #include "VectorSingles.hpp"
26 #include "plane.hpp"
27 #include "scatteredFieldAccess.hpp"
28 #include "timeInfo.hpp"
29 
30 
31 namespace pFlow
32 {
33 
34 // forward
35 
36 class internalPoints;
37 class dictionary;
38 class boundaryList;
39 class pointStructure;
40 class Time;
41 
43 :
44  public subscriber
45 {
46 public:
47 
48  using pointFieldAccessType =
50 
51 private:
52 
53  // friend et al.
54  friend boundaryList;
55 
57 
60 
63 
65  mutable bool listsSync_ = false;
66 
69 
70  bool updateTime_ = false;
71 
72  bool iterBeforeUpdate_ = false;
73 
76 
79 
83 
85 
87 
89 
91 
93 
94 protected:
95 
101  virtual void setSize(uint32 newSize);
102 
103 
104  void setUpdateTime(bool val)
105  {
106  updateTime_ = val;
107  }
108 
109  void setNewIndices(const uint32Vector_D& newIndices);
110 
111  bool appendNewIndices(const uint32Vector_D& newIndices);
112 
113  bool removeIndices(
114  uint32 numRemove,
115  const uint32Vector_D& removeMask);
116 
119  const uint32Vector_D& keepIndices);
120 
122  uint32 numTransfer,
123  const uint32Vector_D& transferMask,
124  uint32 transferBoundaryIndex,
125  realx3 transferVector);
126 
127  void unSyncLists()
128  {
129  listsSync_ = false;
130  }
131 
132  void syncLists()const
133  {
134  if(!listsSync_)
135  {
137  listsSync_ = true;
138  }
139  }
140 
147  virtual
148  bool updataBoundaryData(int step)
149  {
150  return true;
151  }
152 
160  virtual
161  bool transferData(uint32 iter, int step, bool& callAgain)
162  {
163  callAgain = false;
164  return true;
165  }
166 
167 
168 public:
169 
170  uint32 markInNegativeSide(const word& name, uint32Vector_D& markedIndices )const;
171 
172 
173  TypeInfo("boundaryBase");
174 
175  boundaryBase(
176  const dictionary &dict,
177  const plane &bplane,
178  internalPoints &internal,
179  boundaryList &bndrs,
180  uint32 thisIndex);
181 
182  boundaryBase(const boundaryBase&) = delete;
183 
184  boundaryBase& operator=(const boundaryBase&) = delete;
185 
186  boundaryBase(boundaryBase&&) = default;
187 
188  boundaryBase& operator=(boundaryBase&&) = default;
189 
190  ~boundaryBase() override = default;
191 
192 
194  (
195  boundaryBase,
196  dictionary,
197  (
198  const dictionary &dict,
199  const plane &bplane,
200  internalPoints &internal,
201  boundaryList &bndrs,
202  uint32 thisIndex
203  ),
204  (dict, bplane, internal, bndrs, thisIndex)
205  );
206 
210  inline
212  {
213  return neighborLength_;
214  }
215 
221  virtual
223  {
225  }
226 
232  virtual
234  {
236  }
237 
239  inline
241  {
242  return updateTime_;
243  }
244 
245  inline
247  {
248  return iterBeforeUpdate_;
249  }
250 
251  inline
252  const word& type()const
253  {
254  return type_;
255  }
256 
257  inline
258  const word& name()const
259  {
260  return name_;
261  }
262 
263  inline
264  bool empty()const
265  {
266  return indexList_.size()==0;
267  }
268 
269  inline
270  auto size()const
271  {
272  return indexList_.size();
273  }
274 
275  inline
276  auto capacity()const
277  {
278  return indexList_.capacity();
279  }
280 
281  inline
283  {
284  return neighborProcessorNo_;
285  }
286 
287  inline
288  int thisProcessorNo()const
289  {
290  return pFlowProcessors().localRank();
291  }
292 
293  inline
294  bool isBoundaryMaster()const
295  {
296  return isBoundaryMaster_;
297  }
298 
299  inline
301  {
302  return thisBoundaryIndex_;
303  }
304 
305  inline
307  {
309  }
310 
311  inline
312  const internalPoints& internal()const
313  {
314  return internal_;
315  }
316 
317  inline
318  internalPoints& internal()
319  {
320  return internal_;
321  }
322 
323  const pointStructure& pStruct()const;
324 
325  const Time& time()const;
326 
327  inline
328  const auto& indexList()const
329  {
330  return indexList_;
331  }
332 
333  inline
334  const auto& indexListHost()const
335  {
336  syncLists();
337  return indexListHost_;
338  }
339 
341 
342  const boundaryBase& mirrorBoundary()const;
343 
345  const plane& boundaryPlane()const
346  {
347  return boundaryPlane_;
348  }
349 
354  virtual
356 
357 
358  virtual
360  uint32 step,
361  const timeInfo& ti,
362  bool updateIter,
363  bool iterBeforeUpdate ,
364  bool& callAgain
365  )
366  {
367  updateTime_ = updateIter;
368  iterBeforeUpdate_ = iterBeforeUpdate;
369  return true;
370  }
371 
372  virtual
373  bool iterate(const timeInfo& ti) = 0;
374 
375  virtual
376  bool afterIteration(const timeInfo& ti) = 0;
377 
379 
381  virtual
383  {
384  return 0;
385  }
386 
389  virtual
391 
394  virtual
395  const realx3Vector_D& neighborProcPoints()const;
396 
397  virtual
399  {
400  return 0u;
401  }
402 
403  virtual
405  {
406  return 0u;
407  }
408 
410  static
412  (
413  const dictionary &dict,
414  const plane &bplane,
415  internalPoints &internal,
416  boundaryList &bndrs,
417  uint32 thisIndex
418  );
419 
420 
421 };
422 
423 }
424 
425 
426 #endif //__boundaryBase_hpp__
pFlow::boundaryBase::neighborProcSize
virtual uint32 neighborProcSize() const
Return number of points in the neighbor processor boundary.
Definition: boundaryBase.hpp:382
subscriber.hpp
pFlow::boundaryBase::neighborLengthIntoInternal
real neighborLengthIntoInternal() const
The length from boundary plane into the domain where beyond that distance internal points exist.
Definition: boundaryBase.hpp:211
pFlow::boundaryBase::pStruct
const pointStructure & pStruct() const
Definition: boundaryBase.cpp:249
pFlow::internalPoints
Definition: internalPoints.hpp:38
pFlow::boundaryBase::indexListHost
const auto & indexListHost() const
Definition: boundaryBase.hpp:334
pFlow::boundaryBase::displacementVectroToMirror
virtual realx3 displacementVectroToMirror() const
displacement vector that transfers points to a distance that is equal to the distance between this ...
Definition: boundaryBase.cpp:299
pFlow::boundaryBase::name_
word name_
Definition: boundaryBase.hpp:90
pFlow::infinitePlane::normal
const INLINE_FUNCTION_HD auto & normal() const
Definition: infinitePlane.hpp:155
pFlow::boundaryBase::syncLists
void syncLists() const
Definition: boundaryBase.hpp:132
pFlow::scatteredFieldAccess
Definition: scatteredFieldAccess.hpp:32
pFlow::boundaryBase::TypeInfo
TypeInfo("boundaryBase")
pFlow::real
float real
Definition: builtinTypes.hpp:45
timeInfo.hpp
pFlow::plane
Definition: plane.hpp:30
pFlow::localProcessors::localRank
auto localRank() const
Definition: localProcessors.hpp:88
pFlow::boundaryBase::thisBoundaryIndex
uint32 thisBoundaryIndex() const
Definition: boundaryBase.hpp:300
pFlow::VectorSingle::assignFromDevice
INLINE_FUNCTION_H void assignFromDevice(const VectorSingle< T, MSpace > &src, bool srcCapacity=true)
Definition: VectorSingle.cpp:487
pFlow::boundaryBase::type_
word type_
Definition: boundaryBase.hpp:92
pFlow::boundaryBase::transferPointsToMirror
bool transferPointsToMirror(uint32 numTransfer, const uint32Vector_D &transferMask, uint32 transferBoundaryIndex, realx3 transferVector)
Definition: boundaryBase.cpp:149
pFlow::boundaryBase::empty
bool empty() const
Definition: boundaryBase.hpp:264
pFlow::boundaryBase::neighborProcPoints
virtual realx3Vector_D & neighborProcPoints()
Return a reference to point positions in the neighbor processor boundary.
Definition: boundaryBase.cpp:282
pFlow::boundaryBase::markInNegativeSide
uint32 markInNegativeSide(const word &name, uint32Vector_D &markedIndices) const
Definition: boundaryBase.cpp:193
pFlow::boundaryBase::boundaryPlane
const plane & boundaryPlane() const
the actual boundary plane of this boundary
Definition: boundaryBase.hpp:345
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::boundaryBase::updataBoundaryData
virtual bool updataBoundaryData(int step)
Update this boundary data in two steps (1 and 2).
Definition: boundaryBase.hpp:148
pFlow::boundaryBase::neighborProcessorNo_
int neighborProcessorNo_
Definition: boundaryBase.hpp:86
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::boundaryBase::neighborProcessorNo
int neighborProcessorNo() const
Definition: boundaryBase.hpp:282
pFlow::boundaryList
Definition: boundaryList.hpp:35
pFlow::boundaryBase::mirrorBoundary
boundaryBase & mirrorBoundary()
Definition: boundaryBase.cpp:259
pFlow::boundaryBase::name
const word & name() const
Definition: boundaryBase.hpp:258
pFlow::boundaryBase::beforeIteration
virtual bool beforeIteration(uint32 step, const timeInfo &ti, bool updateIter, bool iterBeforeUpdate, bool &callAgain)
Definition: boundaryBase.hpp:359
pFlow::boundaryBase::thisProcessorNo
int thisProcessorNo() const
Definition: boundaryBase.hpp:288
pFlow::boundaryBase::listsSync_
bool listsSync_
device and host list are sync
Definition: boundaryBase.hpp:65
plane.hpp
pFlow::boundaryBase::boundaryExtensionLength
virtual realx3 boundaryExtensionLength() const
The extention length (in vector form) for the boundary as required by each boundary type.
Definition: boundaryBase.hpp:233
pFlow::subscriber
Definition: subscriber.hpp:37
pFlow::timeInfo
Definition: timeInfo.hpp:28
pFlow::boundaryBase::transferData
virtual bool transferData(uint32 iter, int step, bool &callAgain)
This method is called when a transfer of data is to be performed between processors (in afterIteratio...
Definition: boundaryBase.hpp:161
pFlow::boundaryBase::boundaryPlane_
const plane & boundaryPlane_
Definition: boundaryBase.hpp:56
pFlow::boundaryBase::boundaryList
friend boundaryList
Definition: boundaryBase.hpp:54
pFlow::boundaryBase::time
const Time & time() const
Definition: boundaryBase.cpp:254
pFlow
Definition: demGeometry.hpp:27
VectorSingles.hpp
pFlow::boundaryBase::type
const word & type() const
Definition: boundaryBase.hpp:252
pFlow::pointStructure
Definition: pointStructure.hpp:34
pFlow::boundaryBase::indexList
const auto & indexList() const
Definition: boundaryBase.hpp:328
pFlow::boundaryBase::thisBoundaryIndex_
uint32 thisBoundaryIndex_
Definition: boundaryBase.hpp:84
pFlow::boundaryBase::afterIteration
virtual bool afterIteration(const timeInfo &ti)=0
pFlow::boundaryBase::boundaries_
boundaryList & boundaries_
a reference to the list of boundaries (never use this in the constructor).
Definition: boundaryBase.hpp:82
pFlow::boundaryBase::internal_
internalPoints & internal_
a reference to internal points
Definition: boundaryBase.hpp:78
pFlow::boundaryBase::isBoundaryMaster
bool isBoundaryMaster() const
Definition: boundaryBase.hpp:294
virtualConstructor.hpp
pFlow::boundaryBase
Definition: boundaryBase.hpp:42
pFlow::boundaryBase::isBoundaryMaster_
bool isBoundaryMaster_
Definition: boundaryBase.hpp:88
pFlow::boundaryBase::setSize
virtual void setSize(uint32 newSize)
Set the size of indexList.
Definition: boundaryBase.cpp:30
pFlow::boundaryBase::performBoundarytUpdate
bool performBoundarytUpdate() const
Is this iter the right time for updating bounday list.
Definition: boundaryBase.hpp:240
pFlow::VectorSingle< uint32 >
pFlow::boundaryBase::unSyncLists
void unSyncLists()
Definition: boundaryBase.hpp:127
pFlow::boundaryBase::size
auto size() const
Definition: boundaryBase.hpp:270
pFlow::boundaryBase::pointFieldAccessType
deviceScatteredFieldAccess< realx3 > pointFieldAccessType
Definition: boundaryBase.hpp:49
pFlow::boundaryBase::numToTransfer
virtual uint32 numToTransfer() const
Definition: boundaryBase.hpp:398
pFlow::boundaryBase::setUpdateTime
void setUpdateTime(bool val)
Definition: boundaryBase.hpp:104
pFlow::boundaryBase::iterBeforeUpdate_
bool iterBeforeUpdate_
Definition: boundaryBase.hpp:72
pFlow::boundaryBase::neighborLength_
real neighborLength_
The length defined for creating neighbor list.
Definition: boundaryBase.hpp:68
pFlow::boundaryBase::indexList_
uint32Vector_D indexList_
list of particles indices on device
Definition: boundaryBase.hpp:59
pFlow::pFlowProcessors
localProcessors & pFlowProcessors()
Definition: pFlowProcessors.cpp:5
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
pFlow::boundaryBase::indexListHost_
uint32Vector_H indexListHost_
list of particles indieces on host
Definition: boundaryBase.hpp:62
pFlow::boundaryBase::iterBeforeBoundaryUpdate
bool iterBeforeBoundaryUpdate() const
Definition: boundaryBase.hpp:246
pFlow::boundaryBase::setNewIndices
void setNewIndices(const uint32Vector_D &newIndices)
Definition: boundaryBase.cpp:37
pFlow::VectorSingle::capacity
INLINE_FUNCTION_H uint32 capacity() const
Definition: VectorSingle.cpp:304
pFlow::boundaryBase::boundaryBase
boundaryBase(const dictionary &dict, const plane &bplane, internalPoints &internal, boundaryList &bndrs, uint32 thisIndex)
Definition: boundaryBase.cpp:225
pFlow::boundaryBase::capacity
auto capacity() const
Definition: boundaryBase.hpp:276
pFlow::boundaryBase::create_vCtor
create_vCtor(boundaryBase, dictionary,(const dictionary &dict, const plane &bplane, internalPoints &internal, boundaryList &bndrs, uint32 thisIndex),(dict, bplane, internal, bndrs, thisIndex))
pFlow::boundaryBase::setRemoveKeepIndices
bool setRemoveKeepIndices(const uint32Vector_D &removeIndices, const uint32Vector_D &keepIndices)
Definition: boundaryBase.cpp:130
pFlow::boundaryBase::appendNewIndices
bool appendNewIndices(const uint32Vector_D &newIndices)
Definition: boundaryBase.cpp:47
pFlow::boundaryBase::numToRecieve
virtual uint32 numToRecieve() const
Definition: boundaryBase.hpp:404
pFlow::boundaryBase::~boundaryBase
~boundaryBase() override=default
pFlow::triple< real >
scatteredFieldAccess.hpp
pFlow::boundaryBase::operator=
boundaryBase & operator=(const boundaryBase &)=delete
pFlow::boundaryBase::updateTime_
bool updateTime_
Definition: boundaryBase.hpp:70
pFlow::boundaryBase::boundaryExtntionLengthRatio_
real boundaryExtntionLengthRatio_
the extra boundary extension beyound actual limits of boundary
Definition: boundaryBase.hpp:75
pFlow::boundaryBase::thisPoints
pointFieldAccessType thisPoints() const
Definition: boundaryBase.cpp:270
pFlow::boundaryBase::create
static uniquePtr< boundaryBase > create(const dictionary &dict, const plane &bplane, internalPoints &internal, boundaryList &bndrs, uint32 thisIndex)
Definition: boundaryBase.cpp:308
pFlow::boundaryBase::mirrorBoundaryIndex
uint32 mirrorBoundaryIndex() const
Definition: boundaryBase.hpp:306
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
pFlow::VectorSingle::size
INLINE_FUNCTION_H uint32 size() const
Size of the vector.
Definition: VectorSingle.cpp:297
pFlow::boundaryBase::iterate
virtual bool iterate(const timeInfo &ti)=0
pFlow::Time
Definition: Time.hpp:37
pFlow::boundaryBase::neighborLength
virtual real neighborLength() const
The distance length from boundary plane where neighbor particles still exist in that distance.
Definition: boundaryBase.hpp:222
pFlow::boundaryBase::removeIndices
bool removeIndices(uint32 numRemove, const uint32Vector_D &removeMask)
Definition: boundaryBase.cpp:79