www.cemf.ir
cGRelativeLinearCF.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 __cGRelativeLinearCF_hpp__
22 #define __cGRelativeLinearCF_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 
100  auto nElem = kn.size();
101 
102 
103  if(nElem != kt.size())
104  {
106  "sizes of kn("<<nElem<<") and kt("<<kt.size()<<") do not match.\n";
107  return false;
108  }
109 
110  if(nElem != en.size())
111  {
113  "sizes of kn("<<nElem<<") and en("<<en.size()<<") do not match.\n";
114  return false;
115  }
116 
117  if(nElem != et.size())
118  {
120  "sizes of kn("<<nElem<<") and et("<<et.size()<<") do not match.\n";
121  return false;
122  }
123 
124  if(nElem != mu.size())
125  {
127  "sizes of kn("<<nElem<<") and mu("<<mu.size()<<") do not match.\n";
128  return false;
129  }
130 
131 
132  // check if size of vector matchs a symetric array
133  uint32 nMat;
134  if( !LinearArrayType::getN(nElem, nMat) )
135  {
137  "sizes of properties do not match a symetric array with size ("<<
138  numMaterial_<<"x"<<numMaterial_<<").\n";
139  return false;
140  }
141  else if( numMaterial_ != nMat)
142  {
144  "size mismatch for porperties. \n"<<
145  "you supplied "<< numMaterial_<<" items in materials list and "<<
146  nMat << " for other properties.\n";
147  return false;
148  }
149 
150 
151  realVector etha_t("etha_t", nElem);
152 
153 
154  ForAll(i , kn)
155  {
156 
157 
158  etha_t[i] = -2.0*log( et[i])*sqrt(kt[i]*2/7) /
159  sqrt(log(pow(et[i],2.0))+ pow(Pi,2.0));
160 
161 
162  }
163 
164  Vector<linearProperties> prop("prop", nElem);
165  ForAll(i,kn)
166  {
167  prop[i] = {kn[i], kt[i], en[i], etha_t[i], mu[i] };
168  }
169 
171 
172  auto adm = dict.getVal<word>("additionalDissipationModel");
173 
174 
175  if(adm == "none")
176  {
178  }
179  else if(adm == "LU")
180  {
182  }
183  else if (adm == "GB")
184  {
186  }
187  else
188  {
190  }
191 
192  return true;
193 
194  }
195 
196  static const char* modelName()
197  {
198  if constexpr (limited)
199  {
200  return "cGRelativeLinearLimited";
201  }
202  else
203  {
204  return "cGRelativeLinearNonLimited";
205  }
206  return "";
207  }
208 
209 public:
210 
211 
213 
216 
217  cGRelativeLinear(int32 nMaterial, const ViewType1D<real>& rho, const dictionary& dict)
218  :
219  numMaterial_(nMaterial),
220  rho_("rho",nMaterial),
221  linearProperties_("linearProperties",nMaterial)
222  {
223 
224  Kokkos::deep_copy(rho_,rho);
225  if(!readLinearDictionary(dict))
226  {
227  fatalExit;
228  }
229  }
230 
232  cGRelativeLinear(const cGRelativeLinear&) = default;
233 
235  cGRelativeLinear(cGRelativeLinear&&) = default;
236 
238  cGRelativeLinear& operator=(const cGRelativeLinear&) = default;
239 
242 
243 
245  ~cGRelativeLinear()=default;
246 
249  {
250  return numMaterial_;
251  }
252 
255  void contactForce
256  (
257  const real dt,
258  const uint32 i,
259  const uint32 j,
260  const uint32 propId_i,
261  const uint32 propId_j,
262  const real Ri,
263  const real Rj,
264  const real cGFi,
265  const real cGFj,
266  const real ovrlp_n,
267  const realx3& Vr,
268  const realx3& Nij,
269  contactForceStorage& history,
270  realx3& FCn,
271  realx3& FCt
272  )const
273  {
274 
275  auto prop = linearProperties_(propId_i,propId_j);
276 
277  real f_ = ( cGFi + cGFj )/2 ;
278 
279 
280  real vrn = dot(Vr, Nij);
281  realx3 Vt = Vr - vrn*Nij;
282 
283  history.overlap_t_ += Vt*dt;
284 
285  real mi = 3*Pi/4*pow(Ri,3.0)*rho_[propId_i];
286  real mj = 3*Pi/4*pow(Rj,3.0)*rho_[propId_j];
287 
288  real sqrt_meff = sqrt((mi*mj)/(mi+mj));
289 
290 
291  if (addDissipationModel_==2)
292  {
293  prop.en_ = sqrt(1+((pow(prop.en_,2)-1)*f_));
294  }
295  else if (addDissipationModel_==3)
296  {
297  auto pie =3.14;
298  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)))) ) ));
299  }
300  real ethan_ = -2.0*log(prop.en_)*sqrt(prop.kn_)/
301  sqrt(pow(log(prop.en_),2.0)+ pow(Pi,2.0));
302 
303 
304  FCn = ( -pow(f_,1.0)*prop.kn_ * ovrlp_n - sqrt_meff * pow(f_,0.5) * ethan_ * vrn)*Nij;
305  FCt = ( -pow(f_,1.0)*prop.kt_ * history.overlap_t_ - sqrt_meff * pow(f_,0.5) * prop.ethat_*Vt);
306 
307 
308 
309  real ft = length(FCt);
310  real ft_fric = prop.mu_ * length(FCn);
311 
312  if(ft > ft_fric)
313  {
314  if( length(history.overlap_t_) >static_cast<real>(0.0))
315  {
316  if constexpr (limited)
317  {
318  FCt *= (ft_fric/ft);
319  history.overlap_t_ = - (FCt/prop.kt_);
320  }
321  else
322  {
323  FCt = (FCt/ft)*ft_fric;
324  }
325  //cout<<"friction is applied here \n";
326 
327  }
328  else
329  {
330  FCt = 0.0;
331  }
332  }
333 
334  }
335 
336 };
337 
338 } //pFlow::cfModels
339 
340 #endif
pFlow::exp
Vector< T, Allocator > exp(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:86
pFlow::cfModels::cGRelativeLinear
Definition: cGRelativeLinearCF.hpp:38
pFlow::cfModels::cGRelativeLinear::numMaterial
INLINE_FUNCTION_HD int32 numMaterial() const
Definition: cGRelativeLinearCF.hpp:248
pFlow::cfModels::cGRelativeLinear::cGRelativeLinear
cGRelativeLinear(int32 nMaterial, const ViewType1D< real > &rho, const dictionary &dict)
Definition: cGRelativeLinearCF.hpp:217
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::cfModels::cGRelativeLinear::linearProperties_
LinearArrayType linearProperties_
Definition: cGRelativeLinearCF.hpp:84
pFlow::cfModels::cGRelativeLinear::linearProperties::ethat_
real ethat_
Definition: cGRelativeLinearCF.hpp:53
pFlow::cfModels::cGRelativeLinear::contactForceStorage::overlap_t_
realx3 overlap_t_
Definition: cGRelativeLinearCF.hpp:44
pFlow::cfModels::cGRelativeLinear::linearProperties
Definition: cGRelativeLinearCF.hpp:48
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::cGRelativeLinear::~cGRelativeLinear
INLINE_FUNCTION_HD ~cGRelativeLinear()=default
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::cfModels::cGRelativeLinear::linearProperties::linearProperties
INLINE_FUNCTION_HD linearProperties()
Definition: cGRelativeLinearCF.hpp:57
pFlow::cfModels::cGRelativeLinear::linearProperties::~linearProperties
INLINE_FUNCTION_HD ~linearProperties()=default
pFlow::Vector::size
auto size() const
Size of the vector.
Definition: Vector.hpp:265
pFlow::cfModels::cGRelativeLinear::addDissipationModel_
int32 addDissipationModel_
Definition: cGRelativeLinearCF.hpp:86
pFlow::cfModels::cGRelativeLinear::TypeInfoNV
TypeInfoNV(modelName())
pFlow::symArray< linearProperties >::getN
static bool getN(uint32 nElem, uint32 &n)
Definition: symArrayHD.hpp:238
dot
INLINE_FUNCTION_HD T dot(const quadruple< T > &oprnd1, const quadruple< T > &oprnd2)
pFlow::cfModels::cGRelativeLinear::rho_
ViewType1D< real > rho_
Definition: cGRelativeLinearCF.hpp:82
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::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::log
Vector< T, Allocator > log(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:87
pFlow::cfModels::cGRelativeLinear::linearProperties::en_
real en_
Definition: cGRelativeLinearCF.hpp:52
ForAll
#define ForAll(i, container)
Definition: pFlowMacros.hpp:75
pFlow::cfModels::cGRelativeLinear::linearProperties::kn_
real kn_
Definition: cGRelativeLinearCF.hpp:50
pFlow::cfModels::cGRelativeLinear::linearProperties::linearProperties
INLINE_FUNCTION_HD linearProperties(real kn, real kt, real en, real etha_t, real mu)
Definition: cGRelativeLinearCF.hpp:60
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::cGRelativeLinear::linearProperties::mu_
real mu_
Definition: cGRelativeLinearCF.hpp:54
pFlow::cfModels::cGRelativeLinear::modelName
static const char * modelName()
Definition: cGRelativeLinearCF.hpp:196
pFlow::Pi
const real Pi
Definition: numericConstants.hpp:30
pFlow::cfModels
Definition: cGAbsoluteLinearCF.hpp:34
pFlow::cfModels::cGRelativeLinear::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: cGRelativeLinearCF.hpp:256
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple< real >
pFlow::cfModels::cGRelativeLinear::linearProperties::operator=
INLINE_FUNCTION_HD linearProperties & operator=(const linearProperties &)=default
pFlow::cfModels::cGRelativeLinear::operator=
INLINE_FUNCTION_HD cGRelativeLinear & operator=(const cGRelativeLinear &)=default
pFlow::Vector< real >
pFlow::cfModels::cGRelativeLinear::cGRelativeLinear
INLINE_FUNCTION_HD cGRelativeLinear()
Definition: cGRelativeLinearCF.hpp:215
pFlow::cfModels::cGRelativeLinear::contactForceStorage
Definition: cGRelativeLinearCF.hpp:42
pFlow::symArray< linearProperties >
pFlow::cfModels::cGRelativeLinear::readLinearDictionary
bool readLinearDictionary(const dictionary &dict)
Definition: cGRelativeLinearCF.hpp:89
pFlow::cfModels::cGRelativeLinear::numMaterial_
int32 numMaterial_
Definition: cGRelativeLinearCF.hpp:80
pFlow::cfModels::cGRelativeLinear::linearProperties::kt_
real kt_
Definition: cGRelativeLinearCF.hpp:51
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