www.cemf.ir
boundaryList.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 "boundaryList.hpp"
22 #include "pointStructure.hpp"
23 
24 void
26 {
27  if (!listSet_)
28  {
30  << "boundary list is not set yet and you used the objects." << endl;
31  fatalExit;
32  }
33 
34  realx3 lowerExt = boundary(0).boundaryExtensionLength() +
35  boundary(2).boundaryExtensionLength() +
36  boundary(4).boundaryExtensionLength();
37 
38  realx3 upperExt = boundary(1).boundaryExtensionLength() +
39  boundary(3).boundaryExtensionLength() +
40  boundary(5).boundaryExtensionLength();
41 
42  extendedDomain_ = pStruct_.simDomain().extendThisDomain(lowerExt, upperExt);
43 }
44 
45 bool
47 {
48  clear();
49  listSet_ = false;
50  return true;
51 }
52 
53 bool
55 {
56  if (!listSet_)
57  {
58  createBoundaries();
59  }
60 
61  std::array<real, 6> dist;
62  dist[0] = boundary(0).neighborLength();
63  dist[1] = boundary(1).neighborLength();
64  dist[2] = boundary(2).neighborLength();
65  dist[3] = boundary(3).neighborLength();
66  dist[4] = boundary(4).neighborLength();
67  dist[5] = boundary(5).neighborLength();
68 
69  pStruct_.updateFlag(extendedDomain_, dist);
70 
71  const auto& maskD = pStruct_.activePointsMaskDevice();
72  boundary(0).setSize(maskD.leftSize());
73  boundary(1).setSize(maskD.rightSize());
74  boundary(2).setSize(maskD.bottomSize());
75  boundary(3).setSize(maskD.topSize());
76  boundary(4).setSize(maskD.rearSize());
77  boundary(5).setSize(maskD.frontSize());
78 
79  pStruct_.fillNeighborsLists(
80  boundary(0).indexList().deviceViewAll(),
81  boundary(1).indexList().deviceViewAll(),
82  boundary(2).indexList().deviceViewAll(),
83  boundary(3).indexList().deviceViewAll(),
84  boundary(4).indexList().deviceViewAll(),
85  boundary(5).indexList().deviceViewAll()
86  );
87 
88  return true;
89 }
90 
92  : ListPtr<boundaryBase>(pStruct.simDomain().sizeOfBoundaries()),
93  pStruct_(pStruct)
94 {
95  const dictionary& dict= pStruct_.simDomain().thisBoundariesDict();
96 
98  "neighborListUpdateInterval",
99  1u
100  );
101 
102  updateInterval_ = dict.getVal<uint32>("updateInterval");
103 }
104 
105 bool
107 {
108  neighborListUpdate_ = false;
109  boundaryUpdate_ = false;
110  iterBeforeBoundaryUpdate_ = false;
111 
112  if(iter%neighborListUpdateInterval_==0u || iter == 0u || force)
113  {
114  if(updateNeighborLists())
115  {
116  neighborListUpdate_ = true;
117  lastNeighborUpdated_ = iter;
118  }
119  else
120  {
121  fatalErrorInFunction<<"error in updating neighbor lists of boundaries"<<endl;
122  return false;
123  }
124 
125  }
126 
127  if( iter%updateInterval_ == 0u || iter == 0u || force )
128  {
129  boundaryUpdate_ = true;
130  }
131 
132  if((iter+1)%updateInterval_ == 0u)
133  {
134  iterBeforeBoundaryUpdate_ = true;
135  }
136 
137  return true;
138 }
139 
140 bool
142 {
143  if (listSet_)
144  return true;
145 
146  for (auto i = 0; i < pStruct_.simDomain().sizeOfBoundaries(); i++)
147  {
148  this->set(
149  i,
151  pStruct_.simDomain().boundaryDict(i),
152  pStruct_.simDomain().boundaryPlane(i),
153  pStruct_,
154  *this,
155  i
156  )
157  );
158  }
159  listSet_ = true;
160  setExtendedDomain();
161  return true;
162 }
163 
166 {
167  const auto& thisBox = pStruct_.thisDomain().domainBox();
168 
169  const realx3 lowerPointDisplacement = {
170  boundary(0).neighborLengthIntoInternal(),
171  boundary(2).neighborLengthIntoInternal(),
172  boundary(4).neighborLengthIntoInternal()
173  };
174 
175  const realx3 upperPointDisplacement = {
176  boundary(1).neighborLengthIntoInternal(),
177  boundary(3).neighborLengthIntoInternal(),
178  boundary(5).neighborLengthIntoInternal()
179  };
180 
181  return { thisBox.minPoint() + lowerPointDisplacement,
182  thisBox.maxPoint() - upperPointDisplacement };
183 }
184 
185 bool
187 {
188  // it is time to update lists
189  if(!updateNeighborLists(ti.iter() , force) )
190  {
191  return false;
192  }
193 
194  auto callAgain = boundariesMask<6>(true);
195 
196  uint32 step = 1;
197 
198  while(callAgain.anyElement(true) && step <= 10u)
199  {
200  for(size_t i=0; i<6ul; i++)
201  {
202 
203  if(callAgain[i])
204  {
205  if(! boundary(i).beforeIteration(
206  step,
207  ti,
208  boundaryUpdate_,
209  iterBeforeBoundaryUpdate_,
210  callAgain[i]))
211  {
212  fatalErrorInFunction<<"error in performing beforeIteration for boundary"<<
213  boundary(i).name()<<" at step "<< step<<endl;
214  return false;
215  }
216  }
217  }
218 
219  step++;
220  }
221 
222 
223  for (auto bdry : *this)
224  {
225  bdry->updataBoundaryData(1);
226  }
227 
228  for (auto bdry : *this)
229  {
230  bdry->updataBoundaryData(2);
231  }
232 
233  return true;
234 }
235 
236 bool
238 {
239  for (auto& bdry : *this)
240  {
241  if (!bdry->iterate(ti))
242  {
243  fatalErrorInFunction << "Error in iterate in boundary "
244  << bdry->name() << endl;
245  return false;
246  }
247  }
248  return true;
249 }
250 
251 bool
253 {
254 
255  auto callAgain = boundariesMask<6>(true);
256 
257  int step = 1;
258  while(callAgain.anyElement(true)&& step <=10)
259  {
260  for(size_t i=0; i<6; i++)
261  {
262  if(callAgain[i])
263  {
264  if( !boundary(i).transferData(ti.iter(), step, callAgain[i]))
265  {
266  fatalErrorInFunction<<"Error in transfering data for boundary "<<
267  boundary(i).name()<<endl;
268  return false;
269  }
270  }
271  }
272  step++;
273  }
274 
275  return true;
276 }
pFlow::boundaryList::internalDomainBox
box internalDomainBox() const
Definition: boundaryList.cpp:165
pFlow::ListPtr
Definition: ListPtr.hpp:37
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::boundaryList::pStruct_
pointStructure & pStruct_
Definition: boundaryList.hpp:42
pFlow::boundaryList::iterate
bool iterate(const timeInfo &tf, bool force=false)
Definition: boundaryList.cpp:237
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::boundaryList::beforeIteration
bool beforeIteration(const timeInfo &tf, bool force=false)
Definition: boundaryList.cpp:186
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::boundaryList::extendedDomain_
domain extendedDomain_
Definition: boundaryList.hpp:56
pFlow::pointStructure::simDomain
const auto & simDomain() const
Definition: pointStructure.hpp:149
pFlow::timeInfo
Definition: timeInfo.hpp:28
pFlow::boundaryList::boundaryList
boundaryList(pointStructure &pStruct)
Definition: boundaryList.cpp:91
pFlow::boundaryList::afterIteration
bool afterIteration(const timeInfo &tf, bool force=false)
Definition: boundaryList.cpp:252
boundaryList.hpp
pFlow::pointStructure
Definition: pointStructure.hpp:34
pFlow::dictionary::getValMax
T getValMax(const word &keyword, const T &maxVal) const
get the value of data entry and return max(value, maxVal)
Definition: dictionary.hpp:395
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::boundaryList::boundary
auto & boundary(size_t i)
Definition: boundaryList.hpp:95
pFlow::boundaryList::createBoundaries
bool createBoundaries()
Definition: boundaryList.cpp:141
pFlow::boundaryBase
Definition: boundaryBase.hpp:42
pFlow::boundaryList::setExtendedDomain
void setExtendedDomain()
Definition: boundaryList.cpp:25
pFlow::boundaryList::listSet_
bool listSet_
Definition: boundaryList.hpp:60
pStruct
auto & pStruct
Definition: setPointStructure.hpp:24
pFlow::dictionary::getVal
T getVal(const word &keyword) const
get the value of data entry
Definition: dictionary.hpp:379
pFlow::boundariesMask< 6 >
pFlow::boundaryList::updateNeighborLists
bool updateNeighborLists()
update neighbor list of boundaries regardless of the time intervals
Definition: boundaryList.cpp:54
pFlow::box
Definition: box.hpp:32
pFlow::timeInfo::iter
const uint32 & iter() const
Definition: timeInfo.hpp:55
pFlow::boundaryList::updateInterval_
uint32 updateInterval_
Definition: boundaryList.hpp:46
pFlow::boundaryList::neighborListUpdateInterval_
uint32 neighborListUpdateInterval_
Definition: boundaryList.hpp:44
pFlow::triple< real >
pFlow::boundaryList::resetLists
bool resetLists()
Definition: boundaryList.cpp:46
pointStructure.hpp
pFlow::boundaryBase::create
static uniquePtr< boundaryBase > create(const dictionary &dict, const plane &bplane, internalPoints &internal, boundaryList &bndrs, uint32 thisIndex)
Definition: boundaryBase.cpp:308
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