www.cemf.ir
cGAbsoluteLinearCF.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 
21 #ifndef __cGAbsoluteLinearCF_hpp__
22 #define __cGAbsoluteLinearCF_hpp__
23 
24 #include "types.hpp"
25 #include "symArrays.hpp"
26 
27 
28 
29 
30 
31 
32 
33 
34 namespace pFlow::cfModels
35 {
36 
37 template<bool limited=true>
39 {
40 public:
41 
43  {
45  };
46 
47 
49  {
50  real kn_ = 1000.0;
51  real kt_ = 800.0;
52  real en_ = 0.0;
53  real ethat_ = 0.0;
54  real mu_ = 0.00001;
55 
58 
60  linearProperties(real kn, real kt, real en, real etha_t, real mu ):
61  kn_(kn), kt_(kt), en_(en),ethat_(etha_t), mu_(mu)
62  {}
63 
65  linearProperties(const linearProperties&)=default;
66 
69 
71  ~linearProperties() = default;
72  };
73 
74 
75 
76 protected:
77 
79 
81 
83 
85 
87 
88 
89  bool readLinearDictionary(const dictionary& dict)
90  {
91 
92 
93  auto kn = dict.getVal<realVector>("kn");
94  auto kt = dict.getVal<realVector>("kt");
95  auto en = dict.getVal<realVector>("en");
96  auto et = dict.getVal<realVector>("et");
97  auto mu = dict.getVal<realVector>("mu");
98 
99  auto nElem = kn.size();
100 
101  if(nElem != kt.size())
102  {
104  "sizes of kn("<<nElem<<") and kt("<<kt.size()<<") do not match.\n";
105  return false;
106  }
107 
108  if(nElem != kt.size())
109  {
111  "sizes of kn("<<nElem<<") and kt("<<kt.size()<<") do not match.\n";
112  return false;
113  }
114 
115  if(nElem != en.size())
116  {
118  "sizes of kn("<<nElem<<") and en("<<en.size()<<") do not match.\n";
119  return false;
120  }
121 
122  if(nElem != et.size())
123  {
125  "sizes of kn("<<nElem<<") and et("<<et.size()<<") do not match.\n";
126  return false;
127  }
128 
129  if(nElem != mu.size())
130  {
132  "sizes of kn("<<nElem<<") and mu("<<mu.size()<<") do not match.\n";
133  return false;
134  }
135 
136 
137  // check if size of vector matchs a symetric array
138  uint32 nMat;
139  if( !LinearArrayType::getN(nElem, nMat) )
140  {
142  "sizes of properties do not match a symetric array with size ("<<
143  numMaterial_<<"x"<<numMaterial_<<").\n";
144  return false;
145  }
146  else if( numMaterial_ != nMat)
147  {
149  "size mismatch for porperties. \n"<<
150  "you supplied "<< numMaterial_<<" items in materials list and "<<
151  nMat << " for other properties.\n";
152  return false;
153  }
154 
155 
156  realVector etha_t("etha_t", nElem);
157 
158  ForAll(i , kn)
159  {
160 
161  etha_t[i] = -2.0*log( et[i])*sqrt(kt[i]*2/7) /
162  sqrt(log(pow(et[i],2.0))+ pow(Pi,2.0));
163  }
164 
165  Vector<linearProperties> prop("prop", nElem);
166  ForAll(i,kn)
167  {
168  prop[i] = {kn[i], kt[i], en[i], etha_t[i], mu[i] };
169  }
170 
172 
173  auto adm = dict.getVal<word>("additionalDissipationModel");
174 
175 
176  if(adm == "none")
177  {
179  }
180  else if(adm == "LU")
181  {
183  }
184  else if (adm == "GB")
185  {
187  }
188  else
189  {
191  }
192 
193  return true;
194 
195  }
196 
197  static const char* modelName()
198  {
199  if constexpr (limited)
200  {
201  return "cGAbsoluteLinearLimited";
202  }
203  else
204  {
205  return "cGAbsoluteLinearNonLimited";
206  }
207  return "";
208  }
209 
210 public:
211 
212 
214 
217 
218  cGAbsoluteLinear(int32 nMaterial, const ViewType1D<real>& rho, const dictionary& dict)
219  :
220  numMaterial_(nMaterial),
221  rho_("rho",nMaterial),
222  linearProperties_("linearProperties",nMaterial)
223  {
224 
225  Kokkos::deep_copy(rho_,rho);
226  if(!readLinearDictionary(dict))
227  {
228  fatalExit;
229  }
230  }
231 
233  cGAbsoluteLinear(const cGAbsoluteLinear&) = default;
234 
236  cGAbsoluteLinear(cGAbsoluteLinear&&) = default;
237 
239  cGAbsoluteLinear& operator=(const cGAbsoluteLinear&) = default;
240 
243 
244 
246  ~cGAbsoluteLinear()=default;
247 
250  {
251  return numMaterial_;
252  }
253 
256  void contactForce
257  (
258  const real dt,
259  const uint32 i,
260  const uint32 j,
261  const uint32 propId_i,
262  const uint32 propId_j,
263  const real Ri,
264  const real Rj,
265  const real cGFi,
266  const real cGFj,
267  const real ovrlp_n,
268  const realx3& Vr,
269  const realx3& Nij,
270  contactForceStorage& history,
271  realx3& FCn,
272  realx3& FCt
273  )const
274  {
275 
276 
277  auto prop = linearProperties_(propId_i,propId_j);
278 
279 
280  real f_ = ( cGFi + cGFj )/2 ;
281 
282 
283  real vrn = dot(Vr, Nij);
284  realx3 Vt = Vr - vrn*Nij;
285 
286  history.overlap_t_ += Vt*dt;
287 
288  real mi = 3*Pi/4*pow(Ri,3.0)*rho_[propId_i];
289  real mj = 3*Pi/4*pow(Rj,3.0)*rho_[propId_j];
290 
291  real sqrt_meff = sqrt((mi*mj)/(mi+mj));
292 
293 
294  // disipation model
295  if (addDissipationModel_==2)
296  {
297  prop.en_ = sqrt(1+((pow(prop.en_,2)-1)*f_));
298  }
299  else if (addDissipationModel_==3)
300  {
301  auto pie =3.14;
302  prop.en_ = exp((pow(f_,1.5)*log(prop.en_)*sqrt( (1-((pow(log(prop.en_),2))/(pow(log(prop.en_),2)+pow(pie,2))))/(1-(pow(f_,3)*(pow(log(prop.en_),2))/(pow(log(prop.en_),2)+pow(pie,2)))) ) ));
303  }
304 
305 
306 
307 
308  real ethan_ = -2.0*log(prop.en_)*sqrt(prop.kn_)/
309  sqrt(pow(log(prop.en_),2.0)+ pow(Pi,2.0));
310 
311  //REPORT(0)<<"\n en n is : "<<END_REPORT;
312  //REPORT(0)<< prop.en_ <<END_REPORT;
313 
314  FCn = ( -pow(f_,3.0)*prop.kn_ * ovrlp_n - sqrt_meff * pow(f_,1.5) * ethan_ * vrn)*Nij;
315  FCt = ( -pow(f_,3.0)*prop.kt_ * history.overlap_t_ - sqrt_meff * pow(f_,1.5) * prop.ethat_*Vt);
316 
317 
318 
319  real ft = length(FCt);
320  real ft_fric = prop.mu_ * length(FCn);
321 
322  if(ft > ft_fric)
323  {
324  if( length(history.overlap_t_) >static_cast<real>(0.0))
325  {
326  if constexpr (limited)
327  {
328  FCt *= (ft_fric/ft);
329  history.overlap_t_ = - (FCt/prop.kt_);
330  }
331  else
332  {
333  FCt = (FCt/ft)*ft_fric;
334  }
335  //cout<<"friction is applied here \n";
336 
337  }
338  else
339  {
340  FCt = 0.0;
341  }
342  }
343 
344  }
345 
346 };
347 
348 } //pFlow::cfModels
349 
350 #endif
pFlow::exp
Vector< T, Allocator > exp(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:86
pFlow::cfModels::cGAbsoluteLinear::rho_
ViewType1D< real > rho_
Definition: cGAbsoluteLinearCF.hpp:82
pFlow::cfModels::cGAbsoluteLinear::linearProperties::ethat_
real ethat_
Definition: cGAbsoluteLinearCF.hpp:53
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::cfModels::cGAbsoluteLinear::cGAbsoluteLinear
cGAbsoluteLinear(int32 nMaterial, const ViewType1D< real > &rho, const dictionary &dict)
Definition: cGAbsoluteLinearCF.hpp:218
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::cfModels::cGAbsoluteLinear
Definition: cGAbsoluteLinearCF.hpp:38
pFlow::cfModels::cGAbsoluteLinear::~cGAbsoluteLinear
INLINE_FUNCTION_HD ~cGAbsoluteLinear()=default
pFlow::pow
Vector< T, Allocator > pow(const Vector< T, Allocator > &v1, const Vector< T, Allocator > &v2)
Definition: VectorMath.hpp:89
pFlow::sqrt
Vector< T, Allocator > sqrt(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:90
types.hpp
pFlow::cfModels::cGAbsoluteLinear::linearProperties::operator=
INLINE_FUNCTION_HD linearProperties & operator=(const linearProperties &)=default
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::cfModels::cGAbsoluteLinear::linearProperties::en_
real en_
Definition: cGAbsoluteLinearCF.hpp:52
pFlow::cfModels::cGAbsoluteLinear::readLinearDictionary
bool readLinearDictionary(const dictionary &dict)
Definition: cGAbsoluteLinearCF.hpp:89
pFlow::cfModels::cGAbsoluteLinear::linearProperties::linearProperties
INLINE_FUNCTION_HD linearProperties()
Definition: cGAbsoluteLinearCF.hpp:57
pFlow::Vector::size
auto size() const
Size of the vector.
Definition: Vector.hpp:265
pFlow::cfModels::cGAbsoluteLinear::operator=
INLINE_FUNCTION_HD cGAbsoluteLinear & operator=(const cGAbsoluteLinear &)=default
pFlow::cfModels::cGAbsoluteLinear::linearProperties::mu_
real mu_
Definition: cGAbsoluteLinearCF.hpp:54
pFlow::cfModels::cGAbsoluteLinear::linearProperties::kn_
real kn_
Definition: cGAbsoluteLinearCF.hpp:50
pFlow::symArray< linearProperties >::getN
static bool getN(uint32 nElem, uint32 &n)
Definition: symArrayHD.hpp:238
pFlow::cfModels::cGAbsoluteLinear::linearProperties::~linearProperties
INLINE_FUNCTION_HD ~linearProperties()=default
pFlow::cfModels::cGAbsoluteLinear::linearProperties::kt_
real kt_
Definition: cGAbsoluteLinearCF.hpp:51
pFlow::cfModels::cGAbsoluteLinear::contactForce
INLINE_FUNCTION_HD void contactForce(const real dt, const uint32 i, const uint32 j, const uint32 propId_i, const uint32 propId_j, const real Ri, const real Rj, const real cGFi, const real cGFj, const real ovrlp_n, const realx3 &Vr, const realx3 &Nij, contactForceStorage &history, realx3 &FCn, realx3 &FCt) const
Definition: cGAbsoluteLinearCF.hpp:257
dot
INLINE_FUNCTION_HD T dot(const quadruple< T > &oprnd1, const quadruple< T > &oprnd2)
pFlow::symArray::assign
bool assign(const Vector< T > src)
Definition: symArrayHD.hpp:175
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
length
INLINE_FUNCTION_HD T length(const triple< T > &v1)
pFlow::cfModels::cGAbsoluteLinear::modelName
static const char * modelName()
Definition: cGAbsoluteLinearCF.hpp:197
pFlow::cfModels::cGAbsoluteLinear::cGAbsoluteLinear
INLINE_FUNCTION_HD cGAbsoluteLinear()
Definition: cGAbsoluteLinearCF.hpp:216
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::cfModels::cGAbsoluteLinear::TypeInfoNV
TypeInfoNV(modelName())
pFlow::log
Vector< T, Allocator > log(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:87
ForAll
#define ForAll(i, container)
Definition: pFlowMacros.hpp:75
pFlow::cfModels::cGAbsoluteLinear::contactForceStorage::overlap_t_
realx3 overlap_t_
Definition: cGAbsoluteLinearCF.hpp:44
pFlow::cfModels::cGAbsoluteLinear::linearProperties_
LinearArrayType linearProperties_
Definition: cGAbsoluteLinearCF.hpp:84
pFlow::cfModels::cGAbsoluteLinear::linearProperties::linearProperties
INLINE_FUNCTION_HD linearProperties(real kn, real kt, real en, real etha_t, real mu)
Definition: cGAbsoluteLinearCF.hpp:60
pFlow::cfModels::cGAbsoluteLinear::numMaterial_
int32 numMaterial_
Definition: cGAbsoluteLinearCF.hpp:80
pFlow::ViewType1D
Kokkos::View< T *, properties... > ViewType1D
1D veiw as a vector
Definition: KokkosTypes.hpp:93
pFlow::dictionary::getVal
T getVal(const word &keyword) const
get the value of data entry
Definition: dictionary.hpp:379
pFlow::cfModels::cGAbsoluteLinear::addDissipationModel_
int32 addDissipationModel_
Definition: cGAbsoluteLinearCF.hpp:86
pFlow::Pi
const real Pi
Definition: numericConstants.hpp:30
pFlow::cfModels::cGAbsoluteLinear::linearProperties
Definition: cGAbsoluteLinearCF.hpp:48
pFlow::cfModels
Definition: cGAbsoluteLinearCF.hpp:34
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple< real >
pFlow::cfModels::cGAbsoluteLinear::numMaterial
INLINE_FUNCTION_HD int32 numMaterial() const
Definition: cGAbsoluteLinearCF.hpp:249
pFlow::Vector< real >
pFlow::symArray< linearProperties >
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
symArrays.hpp
pFlow::cfModels::cGAbsoluteLinear::contactForceStorage
Definition: cGAbsoluteLinearCF.hpp:42