www.cemf.ir
boundaryExit.cpp
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 #include "boundaryExit.hpp"
22 #include "internalPoints.hpp"
23 #include "dictionary.hpp"
24 
25 
27 (
28  const dictionary &dict,
29  const plane &bplane,
30  internalPoints &internal,
31  boundaryList &bndrs,
32  uint32 thisIndex
33 )
34 :
35  boundaryBase(dict, bplane, internal, bndrs, thisIndex)
36 {
37  exitMarginLength_ = max(
38  dict.getValOrSet("exitMarginLength",(real)0.0), (real)0.0);
39  checkForExitInterval_ = max(
40  dict.getValOrSet("checkForExitInterval", 1), 1);
41 }
42 
44 (
45  uint32 step,
46  const timeInfo& ti,
47  bool updateIter,
48  bool iterBeforeUpdate ,
49  bool& callAgain
50 )
51 {
52 
53  if(step == 1)
54  {
55  boundaryBase::beforeIteration(step, ti, updateIter, iterBeforeUpdate, callAgain);
56  callAgain = true;
57  return true;
58  }
59  else if(step == 2 )
60  {
61  callAgain = false;
62 
63  if( !performBoundarytUpdate())
64  {
65  return true;
66  }
67 
68  // nothing have to be done
69  if(empty())
70  {
71  return true;
72  }
73 
74  uint32 s = size();
75  uint32Vector_D deleteFlags("deleteFlags",s+1, s+1, RESERVE());
76  deleteFlags.fill(0u);
77 
78  const auto& deleteD = deleteFlags.deviceViewAll();
79  auto points = thisPoints();
80  auto p = boundaryPlane().infPlane();
81 
82  uint32 numDeleted = 0;
83 
84  Kokkos::parallel_reduce
85  (
86  "boundaryExit::beforeIteration",
88  LAMBDA_HD(uint32 i, uint32& delToUpdate)
89  {
90  if(p.pointInNegativeSide(points(i)))
91  {
92  deleteD(i)=1;
93  delToUpdate++;
94  }
95  },
96  numDeleted
97  );
98 
99  // no point is deleted
100  if(numDeleted == 0 )
101  {
102  return true;
103  }
104 
105  return this->removeIndices(numDeleted, deleteFlags);
106 
107  }
108 
109  return true;
110 
111 }
112 
114 {
115  return true;
116 }
117 
119 {
120  return true;
121 }
pFlow::VectorSingle::fill
INLINE_FUNCTION_H void fill(const T &val)
Fill the range [0,size) with val.
Definition: VectorSingle.cpp:365
pFlow::dictionary::getValOrSet
T getValOrSet(const word &keyword, const T &setVal) const
get the value of data entry or if not found, set the value to setVal
Definition: dictionary.hpp:415
pFlow::internalPoints
Definition: internalPoints.hpp:38
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::plane
Definition: plane.hpp:30
pFlow::empty
Definition: empty.hpp:30
pFlow::boundaryExit::afterIteration
bool afterIteration(const timeInfo &ti) final
Definition: boundaryExit.cpp:118
pFlow::algorithms::KOKKOS::max
INLINE_FUNCTION_H Type max(const Type *first, uint32 numElems)
Definition: kokkosAlgorithms.hpp:104
pFlow::boundaryExit::beforeIteration
bool beforeIteration(uint32 step, const timeInfo &ti, bool updateIter, bool iterBeforeUpdate, bool &callAgain) final
Definition: boundaryExit.cpp:44
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
boundaryExit.hpp
pFlow::boundaryList
Definition: boundaryList.hpp:35
pFlow::timeInfo
Definition: timeInfo.hpp:28
RESERVE
Definition: Vector.hpp:40
dictionary.hpp
pFlow::boundaryExit::iterate
bool iterate(const timeInfo &ti) final
Definition: boundaryExit.cpp:113
pFlow::boundaryBase
Definition: boundaryBase.hpp:42
pFlow::VectorSingle< uint32 >
pFlow::VectorSingle::deviceViewAll
INLINE_FUNCTION_H auto & deviceViewAll()
Device view range [0,capcity)
Definition: VectorSingle.cpp:249
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:58
pFlow::deviceRPolicyStatic
Kokkos::RangePolicy< Kokkos::DefaultExecutionSpace, Kokkos::Schedule< Kokkos::Static >, Kokkos::IndexType< pFlow::uint32 > > deviceRPolicyStatic
Definition: KokkosTypes.hpp:66
pFlow::boundaryExit::boundaryExit
boundaryExit(const dictionary &dict, const plane &bplane, internalPoints &internal, boundaryList &bndrs, uint32 thisIndex)
Definition: boundaryExit.cpp:27
internalPoints.hpp
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