www.cemf.ir
positionOrdered.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 "error.hpp"
22 #include "dictionary.hpp"
23 #include "positionOrdered.hpp"
24 
25 
27 {
28  if( axisOrder_.size() != 3 )
29  {
31  "axisOrder should have 3 components, but " << axisOrder_.size() <<
32  " has been provided. \n";
33  return false;
34  }
35 
36 
37  if( axisOrder_[0] == axisOrder_[1] ||
38  axisOrder_[0] == axisOrder_[2] ||
39  axisOrder_[1] == axisOrder_[2] )
40  {
42  "invalid/repeated axis names in axisOrder. This is provided: " << axisOrder_ <<endl;
43  return false;
44  }
45 
46  std::array<realx3,3> uV;
47  size_t i=0;
48  for(const auto& ca: axisOrder_)
49  {
50  if(ca == "x")
51  {
52  uV[i] = realx3(1.0, 0.0, 0.0);
53  }
54  else if(ca == "y")
55  {
56  uV[i] = realx3(0.0, 1.0, 0.0);
57  }
58  else if(ca == "z")
59  {
60  uV[i] = realx3(0.0, 0.0, 1.0);
61  }
62  else
63  {
65  "unknown name for axis in axisOrder: " << ca <<endl;
66  return false;
67  }
68  i++;
69  }
70 
71  uVector1_ = uV[0];
72  uVector2_ = uV[1];
73  uVector3_ = uV[2];
74 
75  return true;
76 }
77 
79 {
80  position_.clear();
81 
82  realx3 dl(diameter_);
83  const auto& region = pRegion();
84  auto minP = region.minPoint();
85  auto maxP = region.maxPoint();
86 
87  auto cntr = minP;
88 
89  size_t n = 0;
90  while( n < numPoints_ )
91  {
92  if(region.isInside(cntr))
93  {
94  position_.push_back(cntr);
95  n++;
96  }
97 
98  cntr += dl*uVector1_;
99 
100  if( dot(uVector1_, cntr) > dot(uVector1_, maxP) )
101  {
102  cntr = (minP*uVector1_) + ( (cntr+dl) * uVector2_) + (cntr*uVector3_);
103 
104  if( dot(uVector2_, cntr) > dot(uVector2_, maxP) )
105  {
106  cntr = (cntr*uVector1_) + (minP*uVector2_) + ((cntr+dl)*uVector3_);
107 
108  if( dot(uVector3_,cntr) > dot(uVector3_, maxP) )
109  {
111  "positioned " << n << " points in the domain and it is full. \n" <<
112  "request to position "<< numPoints_<< " points has failed.\n";
113  return false;
114  }
115  }
116  }
117 
118  }
119 
120  return true;
121 }
122 
124 (
125  systemControl& control,
126  const dictionary& dict
127 )
128 :
129  positionParticles(control, dict),
130  poDict_
131  (
132  dict.subDict("orderedInfo")
133  ),
134  diameter_
135  (
136  poDict_.getVal<real>("diameter")
137  ),
138  numPoints_
139  (
140  poDict_.getVal<uint64>("numPoints")
141  ),
142  axisOrder_
143  (
144  poDict_.getValOrSet("axisOrder", wordList{"x", "y", "z"})
145  ),
146  position_
147  (
148  "positionOrdered",
149  max(maxNumberOfParticles(), numPoints_),
150  numPoints_ ,
151  RESERVE()
152  )
153 {
154 
155  if( !findAxisIndex() )
156  {
157  fatalExit;
158  }
159 
160  if(!positionPointsOrdered())
161  {
162  fatalExit;
163  }
164 }
pFlow::positionOrdered::axisOrder_
wordList axisOrder_
Definition: positionOrdered.hpp:42
pFlow::List< word >
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::positionOrdered::findAxisIndex
bool findAxisIndex()
Definition: positionOrdered.cpp:26
pFlow::systemControl
Definition: systemControl.hpp:41
pFlow::max
T max(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:79
pFlow::positionOrdered::positionPointsOrdered
bool positionPointsOrdered()
Definition: positionOrdered.cpp:78
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::realx3
triple< real > realx3
Definition: types.hpp:43
pFlow::positionOrdered::uVector1_
realx3 uVector1_
Definition: positionOrdered.hpp:45
RESERVE
Definition: Vector.hpp:40
dot
INLINE_FUNCTION_HD T dot(const quadruple< T > &oprnd1, const quadruple< T > &oprnd2)
pFlow::positionOrdered::uVector2_
realx3 uVector2_
Definition: positionOrdered.hpp:48
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
dictionary.hpp
pFlow::dictionary::subDict
dictionary & subDict(const word &keyword)
ref to a subdictioanry fatalExit if not found
Definition: dictionary.cpp:560
n
uint32 n
Definition: NBSLoop.hpp:24
positionOrdered.hpp
pFlow::positionParticles
Definition: positionParticles.hpp:35
pFlow::List::size
size_t size() const
Definition: ListI.hpp:82
pFlow::positionOrdered::uVector3_
realx3 uVector3_
Definition: positionOrdered.hpp:51
pFlow::uint64
unsigned long long int uint64
Definition: builtinTypes.hpp:58
pFlow::positionOrdered::positionOrdered
positionOrdered(systemControl &control, const dictionary &dict)
Definition: positionOrdered.cpp:124
pFlow::triple< real >
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
error.hpp