www.cemf.ir
boundaryPeriodic.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 "boundaryPeriodic.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  mirrorBoundaryIndex_(dict.getVal<uint32>("mirrorBoundaryIndex")),
37  extensionLength_(dict.getVal<real>("boundaryExtntionLengthRatio"))
38 {
39  extensionLength_ = max(extensionLength_, static_cast<real>(0.1));
40 }
41 
43 {
45 }
46 
48 {
49  return -extensionLength_*neighborLengthIntoInternal()*boundaryBase::boundaryPlane().normal();
50 }
51 
52 
54  uint32 step,
55  const timeInfo& ti,
56  bool updateIter,
57  bool iterBeforeUpdate ,
58  bool& callAgain)
59 {
60  if(step==1)
61  {
62  callAgain = true;
63  }
64  else
65  {
66  callAgain = false;
67  // nothing have to be done
68  if(empty())
69  {
70  return true;
71  }
72 
73  if(!performBoundarytUpdate())
74  {
75  return true;
76  }
77 
78  uint32 s = size();
79  uint32Vector_D transferFlags("transferFlags",s+1, s+1, RESERVE());
80  transferFlags.fill(0u);
81 
82  auto points = thisPoints();
83  auto p = boundaryPlane().infPlane();
84  const auto & transferD = transferFlags.deviceViewAll();
85 
86  uint32 numTransfered = 0;
87 
88  Kokkos::parallel_reduce
89  (
90  "boundaryPeriodic::beforeIteration",
91  deviceRPolicyStatic(0u,s),
92  LAMBDA_HD(uint32 i, uint32& trnasToUpdate)
93  {
94  if(p.pointInNegativeSide(points(i)))
95  {
96  transferD(i)=1;
97  trnasToUpdate++;
98  }
99  },
100  numTransfered
101  );
102 
103  // no point to be transfered
104  if(numTransfered == 0 )
105  {
106  return true;
107  }
108 
109  // to obtain the transfer vector
110  realx3 transferVec = displacementVectroToMirror();
111 
112  return transferPointsToMirror
113  (
114  numTransfered,
115  transferFlags,
116  mirrorBoundaryIndex(),
117  transferVec
118  );
119  }
120 
121  return true;
122 
123 }
124 
126 {
127  return true;
128 }
129 
131 {
132  return true;
133 }
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::VectorSingle::fill
INLINE_FUNCTION_H void fill(const T &val)
Fill the range [0,size) with val.
Definition: VectorSingle.cpp:365
pFlow::internalPoints
Definition: internalPoints.hpp:38
pFlow::boundaryPeriodic::afterIteration
bool afterIteration(const timeInfo &ti) final
Definition: boundaryPeriodic.cpp:130
pFlow::infinitePlane::normal
const INLINE_FUNCTION_HD auto & normal() const
Definition: infinitePlane.hpp:155
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::plane
Definition: plane.hpp:30
pFlow::empty
Definition: empty.hpp:30
pFlow::boundaryPeriodic::boundaryExtensionLength
realx3 boundaryExtensionLength() const override
The extention length (in vector form) for the boundary as required by each boundary type.
Definition: boundaryPeriodic.cpp:47
pFlow::algorithms::KOKKOS::max
INLINE_FUNCTION_H Type max(const Type *first, uint32 numElems)
Definition: kokkosAlgorithms.hpp:104
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::boundaryList
Definition: boundaryList.hpp:35
pFlow::timeInfo
Definition: timeInfo.hpp:28
RESERVE
Definition: Vector.hpp:40
dictionary.hpp
boundaryPeriodic.hpp
pFlow::boundaryPeriodic::neighborLength
real neighborLength() const override
The distance length from boundary plane where neighbor particles still exist in that distance.
Definition: boundaryPeriodic.cpp:42
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
pFlow::dictionary::getVal
T getVal(const word &keyword) const
get the value of data entry
Definition: dictionary.hpp:379
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::boundaryPeriodic::iterate
bool iterate(const timeInfo &ti) final
Definition: boundaryPeriodic.cpp:125
pFlow::boundaryPeriodic::extensionLength_
real extensionLength_
Definition: boundaryPeriodic.hpp:38
pFlow::triple< real >
pFlow::boundaryPeriodic::boundaryPeriodic
boundaryPeriodic(const dictionary &dict, const plane &bplane, internalPoints &internal, boundaryList &bndrs, uint32 thisIndex)
Definition: boundaryPeriodic.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
pFlow::boundaryPeriodic::beforeIteration
bool beforeIteration(uint32 step, const timeInfo &ti, bool updateIter, bool iterBeforeUpdate, bool &callAgain) final
Definition: boundaryPeriodic.cpp:53