nonLinearCF.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 __nonLinearCF_hpp__
22 #define __nonLinearCF_hpp__
23 
24 #include "types.hpp"
25 
26 namespace pFlow::cfModels
27 {
28 
29 template<bool limited=true>
30 class nonLinear
31 {
32 public:
33 
35  {
37  };
38 
40  {
41  real Yeff_ = 1000000.0;
42  real Geff_ = 8000000.0;
43  real ethan_= 0.0;
44  real mu_ = 0.00001;
45 
48 
50  nonLinearProperties(real Yeff, real Geff, real etha_n, real mu ):
51  Yeff_(Yeff), Geff_(Geff), ethan_(etha_n), mu_(mu)
52  {}
53 
56 
59 
61  ~nonLinearProperties() = default;
62  };
63 
64 protected:
65 
67 
69 
71 
73 
75  {
76  auto Yeff = dict.getVal<realVector>("Yeff");
77  auto Geff = dict.getVal<realVector>("Geff");
78  auto nu = dict.getVal<realVector>("nu");
79  auto en = dict.getVal<realVector>("en");
80  auto mu = dict.getVal<realVector>("mu");
81 
82  auto nElem = Yeff.size();
83 
84  if(nElem != nu.size())
85  {
87  "sizes of Yeff("<<nElem<<") and nu("<<nu.size()<<") do not match.\n";
88  return false;
89  }
90 
91  if(nElem != en.size())
92  {
94  "sizes of Yeff("<<nElem<<") and en("<<en.size()<<") do not match.\n";
95  return false;
96  }
97 
98 
99  if(nElem != mu.size())
100  {
102  "sizes of Yeff("<<nElem<<") and mu("<<mu.size()<<") do not match.\n";
103  return false;
104  }
105 
106 
107  // check if size of vector matchs a symetric array
108  uint32 nMat;
109  if( !NonLinearArrayType::getN(nElem, nMat) )
110  {
112  "sizes of properties do not match a symetric array with size ("<<
113  numMaterial_<<"x"<<numMaterial_<<").\n";
114  return false;
115  }
116  else if( numMaterial_ != nMat)
117  {
119  "size mismatch for porperties. \n";
120  return false;
121  }
122 
123 
124  realVector etha_n(nElem);
125 
126  ForAll(i , en)
127  {
128  //K_hertz = 4.0/3.0*Yeff*sqrt(Reff);
129  //-2.2664*log(en)*sqrt(meff*K_hertz)/sqrt( log(en)**2 + 10.1354);
130 
131  // we take out sqrt(meff*K_hertz) here and then consider this term
132  // when calculating damping part.
133  etha_n[i] = -2.2664*log(en[i])/
134  sqrt(pow(log(en[i]),2.0)+ pow(Pi,2.0));
135 
136  // no damping for tangential part
137 
138  }
139 
140  Vector<nonLinearProperties> prop(nElem);
141  ForAll(i,Yeff)
142  {
143  prop[i] = {Yeff[i], Geff[i], etha_n[i], mu[i]};
144  }
145 
147 
148  return true;
149 
150  }
151 
152  static const char* modelName()
153  {
154  if constexpr (limited)
155  {
156  return "nonLinearLimited";
157  }
158  else
159  {
160  return "nonLinearNonLimited";
161  }
162  return "";
163  }
164 
165 public:
166 
168 
171 
173  int32 nMaterial,
174  const ViewType1D<real>& rho,
175  const dictionary& dict)
176  :
177  numMaterial_(nMaterial),
178  rho_("rho",nMaterial),
179  nonlinearProperties_("nonLinearProperties",nMaterial)
180  {
181 
182  Kokkos::deep_copy(rho_,rho);
183  if(!readNonLinearDictionary(dict))
184  {
185  fatalExit;
186  }
187  }
188 
190  nonLinear(const nonLinear&) = default;
191 
193  nonLinear(nonLinear&&) = default;
194 
196  nonLinear& operator=(const nonLinear&) = default;
197 
199  nonLinear& operator=(nonLinear&&) = default;
200 
201 
203  ~nonLinear()=default;
204 
207  {
208  return numMaterial_;
209  }
210 
212 
214  void contactForce
215  (
216  const real dt,
217  const int32 i,
218  const int32 j,
219  const int32 propId_i,
220  const int32 propId_j,
221  const real Ri,
222  const real Rj,
223  const real ovrlp_n,
224  const realx3& Vr,
225  const realx3& Nij,
226  contactForceStorage& history,
227  realx3& FCn,
228  realx3& FCt
229  )const
230  {
231 
232  auto prop = nonlinearProperties_(propId_i,propId_j);
233 
234 
235  real vrn = dot(Vr, Nij);
236  realx3 Vt = Vr - vrn*Nij;
237 
238  history.overlap_t_ += Vt*dt;
239 
240  real mi = 3*Pi/4*pow(Ri,static_cast<real>(3))*rho_[propId_i];
241  real mj = 3*Pi/4*pow(Rj,static_cast<real>(3))*rho_[propId_j];
242  real Reff = 1.0/(1/Ri + 1/Rj);
243 
244  real K_hertz = 4.0/3.0*prop.Yeff_*sqrt(Reff);
245  real sqrt_meff_K_hertz = sqrt((mi*mj)/(mi+mj) * K_hertz);
246 
247  FCn = (static_cast<real>(-4.0/3.0) * prop.Yeff_ * sqrt(Reff)* pow(ovrlp_n,static_cast<real>(1.5)) -
248  sqrt_meff_K_hertz*prop.ethan_*pow(ovrlp_n,static_cast<real>(0.25))*vrn)*Nij;
249 
250  FCt = (- static_cast<real>(8.0) * prop.Geff_ * sqrt(Reff*ovrlp_n) ) * history.overlap_t_;
251 
252  real ft = length(FCt);
253  real ft_fric = prop.mu_ * length(FCn);
254 
255  // apply friction
256  if(ft > ft_fric)
257  {
258  if( length(history.overlap_t_) >0.0)
259  {
260  if constexpr (limited)
261  {
262  real kt = static_cast<real>(8.0) * prop.Geff_ * sqrt(Reff*ovrlp_n);
263  FCt *= (ft_fric/ft);
264  history.overlap_t_ = - (FCt/kt);
265  }
266  else
267  {
268  FCt = (FCt/ft)*ft_fric;
269  }
270 
271  }
272  else
273  {
274  FCt = 0.0;
275  }
276  }
277 
278  }
279 
280 
281 };
282 
283 } //pFlow::CFModels
284 
285 #endif
pFlow::cfModels::nonLinear::nonLinearProperties::~nonLinearProperties
INLINE_FUNCTION_HD ~nonLinearProperties()=default
pFlow::cfModels::nonLinear::TypeInfoNV
TypeInfoNV(modelName())
pFlow::real
float real
Definition: builtinTypes.hpp:46
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::cfModels::nonLinear::nonLinearProperties::Geff_
real Geff_
Definition: nonLinearCF.hpp:42
pFlow::cfModels::nonLinear::~nonLinear
INLINE_FUNCTION_HD ~nonLinear()=default
pFlow::cfModels::nonLinear::contactForce
INLINE_FUNCTION_HD void contactForce(const real dt, const int32 i, const int32 j, const int32 propId_i, const int32 propId_j, const real Ri, const real Rj, const real ovrlp_n, const realx3 &Vr, const realx3 &Nij, contactForceStorage &history, realx3 &FCn, realx3 &FCt) const
Definition: nonLinearCF.hpp:215
types.hpp
pFlow::cfModels::nonLinear::nonLinear
INLINE_FUNCTION_HD nonLinear()
Definition: nonLinearCF.hpp:170
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:59
pFlow::cfModels::nonLinear::nonLinearProperties::mu_
real mu_
Definition: nonLinearCF.hpp:44
pFlow::Vector::size
auto size() const
Definition: Vector.hpp:299
pFlow::cfModels::nonLinear::nonLinearProperties::nonLinearProperties
INLINE_FUNCTION_HD nonLinearProperties(real Yeff, real Geff, real etha_n, real mu)
Definition: nonLinearCF.hpp:50
pFlow::cfModels::nonLinear::nonLinearProperties::ethan_
real ethan_
Definition: nonLinearCF.hpp:43
pFlow::log
INLINE_FUNCTION_HD real log(real x)
Definition: math.hpp:119
pFlow::symArray< nonLinearProperties >::getN
static bool getN(uint32 nElem, uint32 &n)
Definition: symArrayHD.hpp:240
pFlow::cfModels::nonLinear::nonlinearProperties_
NonLinearArrayType nonlinearProperties_
Definition: nonLinearCF.hpp:72
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:177
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
length
INLINE_FUNCTION_HD T length(const triple< T > &v1)
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::pow
Vector< T, Allocator > pow(const Vector< T, Allocator > &v, T e)
Definition: VectorMath.hpp:109
pFlow::cfModels::nonLinear::rho_
ViewType1D< real > rho_
Definition: nonLinearCF.hpp:70
pFlow::cfModels::nonLinear::nonLinear
nonLinear(int32 nMaterial, const ViewType1D< real > &rho, const dictionary &dict)
Definition: nonLinearCF.hpp:172
ForAll
#define ForAll(i, container)
Definition: pFlowMacros.hpp:71
pFlow::cfModels::nonLinear::operator=
INLINE_FUNCTION_HD nonLinear & operator=(const nonLinear &)=default
pFlow::cfModels::nonLinear::contactForceStorage::overlap_t_
realx3 overlap_t_
Definition: nonLinearCF.hpp:36
pFlow::cfModels::nonLinear::modelName
static const char * modelName()
Definition: nonLinearCF.hpp:152
pFlow::cfModels::nonLinear
Definition: nonLinearCF.hpp:30
pFlow::dictionary::getVal
T getVal(const word &keyword) const
Definition: dictionary.hpp:309
pFlow::cfModels::nonLinear::nonLinearProperties
Definition: nonLinearCF.hpp:39
pFlow::ViewType1D
Kokkos::View< T *, properties... > ViewType1D
Definition: KokkosTypes.hpp:62
pFlow::cfModels::nonLinear::readNonLinearDictionary
bool readNonLinearDictionary(const dictionary &dict)
Definition: nonLinearCF.hpp:74
pFlow::Pi
const real Pi
Definition: numericConstants.hpp:32
pFlow::cfModels
Definition: linearCF.hpp:27
pFlow::cfModels::nonLinear::numMaterial
INLINE_FUNCTION_HD int32 numMaterial() const
Definition: nonLinearCF.hpp:206
pFlow::sqrt
INLINE_FUNCTION_HD real sqrt(real x)
Definition: math.hpp:148
pFlow::cfModels::nonLinear::nonLinearProperties::Yeff_
real Yeff_
Definition: nonLinearCF.hpp:41
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
pFlow::triple< real >
pFlow::Vector< real >
pFlow::cfModels::nonLinear::nonLinearProperties::operator=
INLINE_FUNCTION_HD nonLinearProperties & operator=(const nonLinearProperties &)=default
pFlow::cfModels::nonLinear::contactForceStorage
Definition: nonLinearCF.hpp:34
pFlow::cfModels::nonLinear::numMaterial_
int32 numMaterial_
Definition: nonLinearCF.hpp:68
pFlow::cfModels::nonLinear::nonLinearProperties::nonLinearProperties
INLINE_FUNCTION_HD nonLinearProperties()
Definition: nonLinearCF.hpp:47
pFlow::symArray< nonLinearProperties >
pFlow::dictionary
Definition: dictionary.hpp:38