www.cemf.ir
nonLinearMod.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 __nonLinearModCF_hpp__
22 #define __nonLinearModCF_hpp__
23 
24 #include "types.hpp"
25 
26 namespace pFlow::cfModels
27 {
28 
29 template<bool limited=true>
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 etha_n = dict.getVal<realVector>("etha_n");
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 != etha_n.size())
92  {
94  "sizes of Yeff("<<nElem<<") and etha_n("<<etha_n.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  Vector<nonLinearProperties> prop("prop",nElem);
125  ForAll(i,Yeff)
126  {
127  prop[i] = {Yeff[i], Geff[i], etha_n[i], mu[i]};
128  }
129 
131 
132  return true;
133 
134  }
135 
136  static const char* modelName()
137  {
138  if constexpr (limited)
139  {
140  return "nonLinearModLimited";
141  }
142  else
143  {
144  return "nonLinearModNonLimited";
145  }
146  return "";
147  }
148 
149 public:
150 
152 
155 
157  int32 nMaterial,
158  const ViewType1D<real>& rho,
159  const dictionary& dict)
160  :
161  numMaterial_(nMaterial),
162  rho_("rho",nMaterial),
163  nonlinearProperties_("nonLinearProperties",nMaterial)
164  {
165 
166  Kokkos::deep_copy(rho_,rho);
167  if(!readNonLinearDictionary(dict))
168  {
169  fatalExit;
170  }
171  }
172 
174  nonLinearMod(const nonLinearMod&) = default;
175 
177  nonLinearMod(nonLinearMod&&) = default;
178 
180  nonLinearMod& operator=(const nonLinearMod&) = default;
181 
183  nonLinearMod& operator=(nonLinearMod&&) = default;
184 
185 
187  ~nonLinearMod()=default;
188 
191  {
192  return numMaterial_;
193  }
194 
196 
198  void contactForce
199  (
200  const real dt,
201  const uint32 i,
202  const uint32 j,
203  const uint32 propId_i,
204  const uint32 propId_j,
205  const real Ri,
206  const real Rj,
207  const real ovrlp_n,
208  const realx3& Vr,
209  const realx3& Nij,
210  contactForceStorage& history,
211  realx3& FCn,
212  realx3& FCt
213  )const
214  {
215 
216  auto prop = nonlinearProperties_(propId_i,propId_j);
217 
218 
219  real vrn = dot(Vr, Nij);
220  realx3 Vt = Vr - vrn*Nij;
221 
222  history.overlap_t_ += Vt*dt;
223 
224  real mi = 3*Pi/4*pow(Ri,static_cast<real>(3))*rho_[propId_i];
225  real mj = 3*Pi/4*pow(Rj,static_cast<real>(3))*rho_[propId_j];
226  real Reff = 1.0/(1/Ri + 1/Rj);
227 
228  real K_hertz = 4.0/3.0*prop.Yeff_*sqrt(Reff);
229  real sqrt_meff_K_hertz = sqrt((mi*mj)/(mi+mj) * K_hertz);
230 
231  FCn = (static_cast<real>(-4.0/3.0) * prop.Yeff_ * sqrt(Reff)* pow(ovrlp_n,static_cast<real>(1.5)) -
232  prop.ethan_*pow(ovrlp_n,static_cast<real>(0.5))*vrn)*Nij;
233 
234  FCt = (- static_cast<real>(16.0/3.0) * prop.Geff_ * sqrt(Reff*ovrlp_n) ) * history.overlap_t_;
235 
236  real ft = length(FCt);
237  real ft_fric = prop.mu_ * length(FCn);
238 
239  // apply friction
240  if(ft > ft_fric)
241  {
242  if( length(history.overlap_t_) >0.0)
243  {
244  if constexpr (limited)
245  {
246  real kt = static_cast<real>(16.0/3.0) * prop.Geff_ * sqrt(Reff*ovrlp_n);
247  FCt *= (ft_fric/ft);
248  history.overlap_t_ = - (FCt/kt);
249  }
250  else
251  {
252  FCt = (FCt/ft)*ft_fric;
253  }
254 
255  }
256  else
257  {
258  FCt = 0.0;
259  }
260  }
261 
262  }
263 
264 
265 };
266 
267 } //pFlow::CFModels
268 
269 #endif //__nonLinearModCF_hpp__
pFlow::cfModels::nonLinearMod::nonLinearProperties::Yeff_
real Yeff_
Definition: nonLinearMod.hpp:41
pFlow::cfModels::nonLinearMod::nonLinearProperties::Geff_
real Geff_
Definition: nonLinearMod.hpp:42
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::cfModels::nonLinearMod::nonLinearProperties::nonLinearProperties
INLINE_FUNCTION_HD nonLinearProperties(real Yeff, real Geff, real etha_n, real mu)
Definition: nonLinearMod.hpp:50
pFlow::cfModels::nonLinearMod::contactForceStorage
Definition: nonLinearMod.hpp:34
pFlow::cfModels::nonLinearMod::TypeInfoNV
TypeInfoNV(modelName())
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
pFlow::cfModels::nonLinearMod::nonLinearMod
INLINE_FUNCTION_HD nonLinearMod()
Definition: nonLinearMod.hpp:154
types.hpp
pFlow::cfModels::nonLinearMod::nonLinearProperties::mu_
real mu_
Definition: nonLinearMod.hpp:44
pFlow::cfModels::nonLinearMod::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 ovrlp_n, const realx3 &Vr, const realx3 &Nij, contactForceStorage &history, realx3 &FCn, realx3 &FCt) const
Definition: nonLinearMod.hpp:199
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::cfModels::nonLinearMod::numMaterial_
int32 numMaterial_
Definition: nonLinearMod.hpp:68
pFlow::Vector::size
auto size() const
Size of the vector.
Definition: Vector.hpp:265
pFlow::cfModels::nonLinearMod::~nonLinearMod
INLINE_FUNCTION_HD ~nonLinearMod()=default
pFlow::cfModels::nonLinearMod::nonLinearProperties::operator=
INLINE_FUNCTION_HD nonLinearProperties & operator=(const nonLinearProperties &)=default
pFlow::symArray< nonLinearProperties >::getN
static bool getN(uint32 nElem, uint32 &n)
Definition: symArrayHD.hpp:238
pFlow::cfModels::nonLinearMod::nonLinearProperties::ethan_
real ethan_
Definition: nonLinearMod.hpp:43
pFlow::cfModels::nonLinearMod::contactForceStorage::overlap_t_
realx3 overlap_t_
Definition: nonLinearMod.hpp:36
pFlow::cfModels::nonLinearMod::numMaterial
INLINE_FUNCTION_HD int32 numMaterial() const
Definition: nonLinearMod.hpp:190
pFlow::cfModels::nonLinearMod::nonLinearProperties
Definition: nonLinearMod.hpp:39
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
pFlow::cfModels::nonLinearMod
Definition: nonLinearMod.hpp:30
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::nonLinearMod::modelName
static const char * modelName()
Definition: nonLinearMod.hpp:136
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
ForAll
#define ForAll(i, container)
Definition: pFlowMacros.hpp:75
pFlow::cfModels::nonLinearMod::operator=
INLINE_FUNCTION_HD nonLinearMod & operator=(const nonLinearMod &)=default
pFlow::cfModels::nonLinearMod::readNonLinearDictionary
bool readNonLinearDictionary(const dictionary &dict)
Definition: nonLinearMod.hpp:74
pFlow::cfModels::nonLinearMod::rho_
ViewType1D< real > rho_
Definition: nonLinearMod.hpp:70
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::nonLinearMod::nonLinearProperties::nonLinearProperties
INLINE_FUNCTION_HD nonLinearProperties()
Definition: nonLinearMod.hpp:47
pFlow::cfModels::nonLinearMod::nonlinearProperties_
NonLinearArrayType nonlinearProperties_
Definition: nonLinearMod.hpp:72
pFlow::cfModels::nonLinearMod::nonLinearMod
nonLinearMod(int32 nMaterial, const ViewType1D< real > &rho, const dictionary &dict)
Definition: nonLinearMod.hpp:156
pFlow::cfModels::nonLinearMod::nonLinearProperties::~nonLinearProperties
INLINE_FUNCTION_HD ~nonLinearProperties()=default
pFlow::Pi
const real Pi
Definition: numericConstants.hpp:30
pFlow::cfModels
Definition: cGAbsoluteLinearCF.hpp:34
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple< real >
pFlow::Vector< real >
pFlow::symArray< nonLinearProperties >
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