NDDEM
ContactList.h
Go to the documentation of this file.
1 
4 #include <vector>
5 #include <array>
6 #include <list>
7 #include "Typedefs.h"
8 #include "Parameters.h"
9 #include "Tools.h"
10 
11 
12 #ifndef CONTACTLIST
13 #define CONTACTLIST
14 
15 // ------------------------------------ Action class -------------------------------------------
18 template <int d>
19 class Action {
20 public :
21  Action() : Fn(d,0), Ft(d,0), Torquei(d*(d-1)/2,0), Torquej(d*(d-1)/2,0), vn(d,0), vt(d,0) {}
22  vector <double> Fn, Ft, Torquei, Torquej ;
23  vector <double> vn, vt ;
24  vector<double> Fn_el, Fn_visc, Ft_el, Ft_visc, Ft_fric ;
25  bool Ft_isfric ;
26 
27  template <class Archive>
28  void serialize(Archive &ar) {
30  }
31 
32  void set (cv1d &a, cv1d &b, cv1d &c, cv1d &dd) {Fn=a ; Ft=b ; Torquei=c ; Torquej=dd ; }
33  void setvel(cv1d &vvn, cv1d &vvt) {vn=vvn; vt=vvt ;}
34  void setzero ()
35  {
36  for (int dd=0 ; dd<d ; dd++) Fn[dd]=Ft[dd]=vn[dd]=vt[dd]=0 ;
37  for (int dd=0 ; dd<d*(d-1)/2 ; dd++) Torquei[dd]=Torquej[dd]=0 ;
38  }
39 
40  //void set_fwd (v1d a, v1d b, v1d c) {Fni=a; Fti=b; Torquei=c ;}
41  // void set_rev (v1d a, v1d b, v1d c) {Fnj=a; Ftj=b; Torquej=c ;}
42 } ;
45 template <int d>
46 class SpecificAction: public Action<d> {
47 public :
48  int id ;
49  int duration ;
50  template <class Archive>
51  void serialize(Archive &ar) {
52  ar(cereal::base_class<Action<d>>(this), id, duration) ;
53  }
54 } ;
55 
56 // ------------------------------------ Contact properties class -------------------------------------------
67 template <int d>
68 class cp
69 {
70 public:
71  cp () {}
72  cp (int ii, int jj, double ctlength, Action<d> * default_action) : i(ii), j(jj), contactlength(ctlength), tspr (vector <double> (d, 0)), infos(default_action), owninfos(false), persisting(true) {}
73  cp(const cp& v) { *this=v ; }
74  ~cp () { if (owninfos) delete(infos) ; }
75  cp & operator= (const cp & c)
76  {
77  i=c.i ;
78  if (c.i<0) return *this ; //is a deleted element, just keep moving
79  j=c.j ; // copy everything else if it is not a deleted element
80  ghost=c.ghost ;
81  ghostdir=c.ghostdir ;
82  tspr=c.tspr ;
84  owninfos = c.owninfos ;
85  infos=c.infos ;
86  persisting = c.persisting ;
87  return *this ;
88  }
89 
90  Action<d> & getinfo () {return *infos ; }
91  //void setinfo (Action & a) {if (!infos) infos = new Action ; *infos=a ; }
92  void setinfo (Action<d> * a) {infos=a ; }
93  void saveinfo (Action<d> & a) {
94  if (!owninfos)
95  {
96  infos = new Action<d> ;
97  owninfos = true ;
98  }
99  infos->Fn = a.Fn ;
100  //printf("%g %g %g\n",a.Fn[0], a.Fn[1], a.Fn[2]) ;
101  infos->Ft = a.Ft ;
102  infos->vn = a.vn ;
103  infos->vt = a.vt ;
104  infos->Fn_el = a.Fn_el ;
105  infos->Fn_visc = a.Fn_visc ;
106  infos->Ft_el = a.Ft_el ;
107  infos->Ft_visc = a.Ft_visc ;
108  infos->Ft_fric = a.Ft_fric ;
109  infos->Torquei = a.Torquei ;
110  infos->Torquej = a.Torquej ;
111  }
112 
113  int i ;
114  int j ;
115  double contactlength ;
118  std::vector<double> tspr ;
120  bool owninfos ;
121  bool persisting ;
122 
123  template <class Archive>
124  void save (Archive &ar) const {
126  if (owninfos)
127  ar(*infos) ;
128  }
129  template <class Archive>
130  void load (Archive &ar) {
132  if (owninfos)
133  {
134  infos = new Action<d> ;
135  ar(*infos) ;
136  }
137  }
138 
139  std::pair<vector<double>,vector<double>> compute_branchvector (cv2d &X, Parameters<d> &P)
140  {
141  vector <double> loc (d, 0), branch (d, 0) ;
142  if ( P.Boundaries[0].Type != WallType::PBC_LE || (ghost & 1)==0)
143  {
144  loc=X[j] ;
145  uint32_t gh=ghost, ghd=ghostdir ;
146  for (int n=0 ; gh>0 ; gh>>=1, ghd>>=1, n++)
147  if (gh&1)
148  loc[n] += P.Boundaries[n].delta * ((ghd&1)?-1:1) ;
149  }
150  else
151  {
152  uint32_t gh=ghost, ghd=ghostdir ; // Handle pbc in first dim
153  loc=X[j] ;
154  loc[0] += P.Boundaries[0].delta * ((ghd&1)?-1:1) ;
155  loc[1] += (ghd&1?-1:1)*P.Boundaries[0].displacement ;
157  {
158  double additionaldelta = 0 ;
159  if (loc[1] > P.Boundaries[1].xmax) {additionaldelta = -P.Boundaries[1].delta ;}
160  if (loc[1] < P.Boundaries[1].xmin) {additionaldelta = P.Boundaries[1].delta ;}
161  loc[1] += additionaldelta ;
162  }
163 
164  gh>>=1 ; ghd>>=1 ;
165  for (int n=1 ; gh>0 ; gh>>=1, ghd>>=1, n++)
166  if (gh&1)
167  loc[n] += P.Boundaries[n].delta * ((ghd&1)?-1:1) ;
168  }
169  for (int dd = 0 ; dd<d ; dd++) branch[dd] = X[i][dd]-loc[dd] ; //j->i
170  for (int dd = 0 ; dd<d ; dd++) loc[dd] = (X[i][dd]+loc[dd]*(P.r[i]/(P.r[i]+P.r[j]) )) ; // This location is wrong for sphere with different radius.
171  return {loc, branch} ;
172  }
173 } ;
174 
176 template <int d>
177 class cpm : public cp<d> {
178 public:
179  cpm () {}
180  cpm (int ii, int jj, int sid, double ctlength, Action<d> * default_action) : cp<d>(ii,jj,ctlength,default_action), contactpoint(std::vector<double>(d,0)), submeshid(sid){}
181  cpm(const cpm& v): cp<d>(v) {*this=v ;}
182  ~cpm () {}
183  cpm & operator= (const cpm & c)
184  {
185  cp<d>::operator=(c);
187  submeshid = c.submeshid ;
188  return *this ;
189  }
190  vector <double> contactpoint;
191  int submeshid ;
192 
193  template <class Archive>
194  void load (Archive &ar) {
196  }
197  template <class Archive>
198  void save (Archive &ar) const {
200  }
201 } ;
202 
203 // ------------------------------------ Contact List class -------------------------------------------
206 template <int d>
208 {
209 public:
211  void reset() {it = v.begin() ;}
212  int insert(const cp<d>& a) ;
213  void finalise () { while (it!=v.end()) it=v.erase(it) ; }
214 
215  // Functions for Cell contact detections
216  /*int init_for_cells(int N)
217  {
218  it_array_beg.resize(N,null_list.begin()) ;
219  it_array_end.resize(N,null_list.begin()) ;
220  return 0 ;
221  }
222  int make_iterator_array(int N)
223  {
224  for (int i=0 ; i<N ; i++) it_array_beg[i] = null_list.begin() ;
225  while (v.begin()!=v.end() && !(v.begin()->persisting)) v.erase(v.begin()) ;
226 
227  int curi = -1 ; int n=0 ;
228  auto tmpit = v.begin() ;
229  for (auto it = v.begin() ; it!=v.end() ; it++, n++)
230  {
231  if (it->i != curi)
232  {
233  it_array_beg[it->i] = it ;
234  if (curi!= -1) it_array_end[curi] = it ;
235  curi = it->i ;
236  }
237  tmpit = it ;
238  while (++tmpit != v.end() && !tmpit->persisting) {v.erase(tmpit) ; tmpit = it ; }
239  }
240  if (curi!= -1) it_array_end[curi] = v.end() ;
241  return 0 ;
242  }
243  std::pair<typename list<cp<d>>::iterator, typename list<cp<d>>::iterator> it_bounds (int nmin, int nmax, int N)
244  {
245  for ( ; nmin < N && it_array_beg[nmin] == null_list.begin() ; nmin++) ;
246  for (--nmax ; nmax >=0 && it_array_beg[nmax] == null_list.begin() ; nmax--) ;
247 
248  if (nmax<nmin) return {v.end(), v.end()} ;
249  return {it_array_beg[nmin], it_array_end[nmax]} ;
250  }
251  void coalesce_list ()
252  {
253  std::vector<cp<d>> vtmp ;
254  vtmp.reserve(v.size()) ;
255  printf("%ld ", v.size()) ; fflush(stdout) ;
256  int i = 0 ;
257  for (auto& element : v) { printf("\r%d", i++) ; fflush(stdout) ; vtmp.push_back(std::move(element)); }
258  v.clear();
259  printf("\n") ; fflush(stdout) ;
260  i=0 ;
261  for (auto& element : vtmp) {printf("\r%d", i++) ; fflush(stdout) ; v.push_back(element); }
262  return ;
263  }*/
264 
265  //void check_ghost (uint32_t gst, double partialsum, const Parameters & P, cv1d &X1, cv1d &X2, double R, cp & tmpcp) ;
266  void check_ghost_dst(uint32_t gst, int n, double partialsum, uint32_t mask, const Parameters<d> & P, cv1d &X1, cv1d &X2, cp<d> & contact) ;
267  bool check_ghost_regular (bitdim gst, const Parameters<d> & P, cv1d &X1, cv1d &X2, double r1, double r2, cp<d> & tmpcp,
268  int startd=0, double partialsum=0, bitdim mask=0) ;
269  bool check_ghost_LE (bitdim gst, const Parameters<d> & P, cv1d &X1, cv1d &X2, double r1, double r2, cp<d> & tmpcp, int startd=0, double partialsum=0, bitdim mask=0) ;
270  bool (ContactList::*check_ghost) (bitdim , const Parameters<d> & , cv1d &, cv1d &, double, double, cp<d> &,int startd, double partialsum, bitdim mask) ;
271  void coordinance (v1d &Z) ;
272  Action<d> * default_action () {return (&def) ; }
273 
274  template <class Archive>
275  void serialize(Archive &ar) {ar(v, cid) ; }
276 
277  list <cp<d>> v ;
278  int cid=0 ;
279  //std::vector<typename list<cp<d>>::iterator> it_array_beg, it_array_end ;
280 
281 private:
282  typename list<cp<d>>::iterator it ;
284 
285  list<cp<d>> null_list ;
286 };
287 
288 template <int d>
289 inline bool operator< (const cp<d> &a, const cp<d> &b) {if (a.i==b.i) return (a.j<b.j) ; return a.i<b.i ; }
290 template <int d>
291 inline bool operator== (const cp<d> &a, const cp<d> &b) {return (a.i==b.i && a.j==b.j) ; }
292 
293 //-------------------------------------------------
296 template <int d>
298 {
299 public:
300  list <cpm<d>> v ;
301  Action<d> * default_action () {return (&def) ; }
302  void reset() {it = v.begin() ;}
303  void finalise () { while (it!=v.end()) it=v.erase(it) ; }
304  int insert(const cpm<d>& a) ;
305  int cid=0 ;
306 
307  template <class Archive>
308  void serialize(Archive &ar) {ar(v, cid) ; }
309 
310  bool check_mesh_dst_contact (Mesh<d> &mesh, cv1d & Xo, double r, cpm<d> & c)
311  {
312  std::vector<double> dotproducts (d) ;
313  auto X = Xo-mesh.origin ;
314 
315  // Treating the special case of having a single point
316  if (mesh.dimensionality == 0)
317  {
318  double dst=Tools<d>::norm(X) ;
319  if (dst<r) // We got a contact
320  {
321  c.contactlength = dst ;
322  c.contactpoint=mesh.origin ;
323  c.submeshid=mesh.dimensionality ;
324  return true ;
325  }
326  return false ; // There can't be any submesh for a 0-dimensionality mesh
327  }
328 
329  // All other cases.
330  double dstsqr=0 ;
331  std::vector<double> coefficient (d, 0) ;
332  for (int i=0 ; i<d-mesh.dimensionality ; i++)
333  {
334  for (int dd=0 ; dd<d ; dd++)
335  coefficient[i] += mesh.invertbase[i*d+dd]*X[dd] ;
336  dstsqr += coefficient[i]*coefficient[i] ;
337  if (dstsqr > r*r) goto submeshesprocessing ;
338  }
339  if (dstsqr<r*r)
340  {
341  double coefficient_sum = 0 ;
342  for (int i=d-mesh.dimensionality ; i<d ; i++)
343  {
344  for (int dd=0 ; dd<d ; dd++)
345  coefficient[i] += mesh.invertbase[i*d+dd]*X[dd] ;
346  if (coefficient[i]<0 || coefficient[i]>1) goto submeshesprocessing ;
347  coefficient_sum+=coefficient[i] ;
348  if (coefficient_sum > 1) goto submeshesprocessing ;
349  }
350  if (coefficient_sum < 1)
351  {
352  c.contactlength = sqrt(dstsqr) ;
353  c.contactpoint=mesh.origin ;
354  c.submeshid=mesh.dimensionality ;
355  for (int i=d-mesh.dimensionality ; i<d ; i++)
356  for (int dd=0 ; dd<d ; dd++)
357  c.contactpoint[dd] += mesh.mixedbase[i*d+dd]*coefficient[i] ;
358  //for (int i=0 ; i<d-mesh.dimensionality ; i++) printf("%g ", coefficient[i]) ;
359  //printf("#") ;
360  //for (int i=d-mesh.dimensionality ; i<d; i++) printf("%g ", coefficient[i]) ;
361 
362  //Tools<d>::print(mesh.mixedbase) ;
363 
364  return true ;
365  }
366  }
367 
368 
369 
370 
371 
372  /*for (int i=0; i<d-mesh.dimensionality ; i++)
373  {
374  dotproducts[i]=Tools<d>::dot(mesh.mixedbase[i], X) ;
375  dstsqr+= dotproducts[i]*dotproducts[i] ;
376  //if (mesh.dimensionality==2) printf("%g %g %g %g|", mesh.mixedbase[i][0], mesh.mixedbase[i][1], mesh.mixedbase[i][2], dotproducts[i]) ;
377  }
378  if (dstsqr<r*r) //Potential contact
379  {
380  std::vector<double> coefficient(d) ;
381  double coefficient_sum = 0 ;
382  //printf("-> %g | [%g %g %g | %g %g %g | %g %g %g] ", sqrt(dstsqr), mesh.mixedbase[0][0], mesh.mixedbase[0][1], mesh.mixedbase[0][2], mesh.mixedbase[1][0], mesh.mixedbase[1][1], mesh.mixedbase[1][2],mesh.mixedbase[2][0], mesh.mixedbase[2][1], mesh.mixedbase[2][2]) ;
383  for (int i=d-mesh.dimensionality ; i<d ; i++)
384  {
385  dotproducts[i] = Tools<d>::dot(mesh.mixedbase[i], X) ;
386  coefficient[i] = dotproducts[i]/mesh.norms[i]/mesh.norms[i] ;
387  //printf("/%d %g ", i, coefficient[i]) ; fflush(stdout) ;
388  if (coefficient[i]<0 || coefficient[i]>1) goto submeshesprocessing ; // We are outside
389  coefficient_sum += coefficient[i] ;
390  if (coefficient_sum>1) goto submeshesprocessing ;
391  }
392  if (coefficient_sum>=0 && coefficient_sum<=1) // Seems like we got a contact!
393  {
394  c.contactlength = sqrt(dstsqr) ;
395  c.contactpoint=mesh.origin ;
396  for (int i=d-mesh.dimensionality ; i<d ; i++)
397  c.contactpoint += mesh.mixedbase[i]*coefficient[i] ;
398  return true ;
399  }
400  }*/
401 
402  submeshesprocessing: // yeah yeah, using goto ... sue me
403  if (mesh.submeshes.size()>0)
404  for (int i=mesh.dimensionality-1 ; i>=0 ; i--)
405  for (size_t j=0 ; j<mesh.submeshes[i].size() ; j++)
406  {
407  bool res = check_mesh_dst_contact(mesh.submeshes[i][j], Xo, r, c) ;
408  if (res) return true ;
409  }
410  return false ;
411  }
412 
413 private:
414  typename list<cpm<d>>::iterator it ;
416 } ;
417 
418 
419 /*****************************************************************************************************
420  * *
421  * *
422  * *
423  * IMPLEMENTATIONS *
424  * *
425  * *
426  * *
427  * ***************************************************************************************************/
428 
429 template <int d>
431 {
432  while (it!=v.end() && (*it) < a)
433  { it= v.erase(it) ; }
434  if (it==v.end()) {v.push_back(a) ; it=v.end() ; }
435  else
436  {
437  if ((*it)==a)
438  {
439  it->contactlength=a.contactlength ;
440  it->ghost=a.ghost ;
441  it->ghostdir=a.ghostdir ;
442  it->persisting = true ;
443  it++ ;
444  }
445  else {it=v.insert(it,a) ; it++ ; }
446  }
447  return (cid++) ;
448 }
449 //----------------------------------------------
450 template <int d>
452 {
453  while (it!=v.end() && (*it) < a)
454  { it= v.erase(it) ; }
455  if (it==v.end()) {v.push_back(a) ; it=v.end() ; }
456  else
457  {
458  if ((*it)==a)
459  {
460  it->contactlength=a.contactlength ;
461  it->ghost=a.ghost ;
462  it->ghostdir=a.ghostdir ;
463  it->contactpoint = a.contactpoint ;
464  it->submeshid = a.submeshid ;
465  it++ ;
466  }
467  else {it=v.insert(it,a) ; it++ ; }
468  }
469  return (cid++) ;
470 }
471 
472 //-----------------------------------Fastest version so far ...
473 template <int d>
475  cv1d &X1, cv1d &X2, double r1, double r2,
476  cp<d> & tmpcp, int startd, double partialsum, bitdim mask)
477 {
478  double sum=partialsum ;
479  double rr = (r1+r2)*(r1+r2) ;
480  for (int dd=startd ; sum<rr && dd<d ; dd++, gst>>=1)
481  {
482  sum += (X1[dd]-X2[dd]) * (X1[dd]-X2[dd]) ;
483  if (gst & 1)
484  {
485  double Delta= (tmpcp.ghostdir&(1<<dd)?-1:1) * P.Boundaries[dd].delta ;
486  double sumspawn = partialsum + (X1[dd]-X2[dd]-Delta) * (X1[dd]-X2[dd]-Delta) ;
487  //printf("/%g %g %g %g %g %g %g/", partialsum, sumspawn, X1[0], X1[1], X2[0], X2[1], Delta ) ;
488  if (sumspawn<rr)
489  {
490  bool res = check_ghost_regular (gst>>1, P, X1, X2, r1, r2, tmpcp, dd+1, sumspawn, mask | (1<<dd)) ;
491  if (res) return true ;
492  }
493  }
494  partialsum = sum ;
495  }
496  if (sum<rr)
497  {
498  tmpcp.contactlength=sqrt(sum) ;
499  tmpcp.ghost=mask ;
500  insert(tmpcp) ;
501  return true ;
502  //printf("[%d %d %X %X %g]\n", tmpcp.i, tmpcp.j, tmpcp.ghost, tmpcp.ghostdir, tmpcp.contactlength) ;
503  }
504  return false ;
505 }
506 
507 //--------------------------------------------------------------------
508 template <int d>
509 bool ContactList<d>::check_ghost_LE (bitdim gst, const Parameters<d> & P, cv1d &X1, cv1d &X2, double r1, double r2, cp<d> & tmpcp,
510  [[maybe_unused]] int startd, [[maybe_unused]]double partialsum, [[maybe_unused]]bitdim mask)
511 {
512  if (P.Boundaries[0].Type != WallType::PBC_LE)
513  return check_ghost_regular(gst, P, X1, X2, r1, r2, tmpcp) ;
514  else
515  {
516  if ((gst & 1)==0)
517  {
518  double partialsum = (X1[0]-X2[0]) * (X1[0]-X2[0]) ;
519  assert (((gst>>30 & 1) ==0)) ;
520  check_ghost_regular(gst>>1, P, X1, X2, r1, r2, tmpcp, 1, partialsum, 0) ;
521  }
522  else //There is an image through the LE
523  {
524  //1 : case without taking that image
525  double partialsum = (X1[0]-X2[0]) * (X1[0]-X2[0]) ;
526  bitdim newgst = gst ; newgst &= (~(1<<30)) ;
527  check_ghost_regular(newgst>>1, P, X1, X2, r1, r2, tmpcp, 1, partialsum, 0) ;
528 
529  //2: now is the hard case: we take the image path
530  double Delta= (tmpcp.ghostdir&1?-1:1) * P.Boundaries[0].delta ;
531  partialsum = (X1[0]-X2[0]-Delta) * (X1[0]-X2[0]-Delta) ;
532  newgst = gst ;
533  newgst &= (~(1<<1)) ; // Clearing bit 1
534  newgst |= ((gst>>30)<<1) ; // Setting bit 1 to the value of bit 30
535  newgst &= (~(1<<30)) ; // Clearing bit 30
536  tmpcp.ghostdir &= (~(1<<1)) ; //Clearing bit 1
537  tmpcp.ghostdir |= ((tmpcp.ghostdir>>30)<<1) ; // Setting the value of bit 1 to the value of bit 30. No need for clearing in the ghostdir.
538  auto tmpX2 = X2 ;
539  tmpX2[1] += (tmpcp.ghostdir&1?-1:1)*P.Boundaries[0].displacement ;
540  if (tmpX2[1] > P.Boundaries[1].xmax) tmpX2[1] -= P.Boundaries[1].delta ;
541  if (tmpX2[1] < P.Boundaries[1].xmin) tmpX2[1] += P.Boundaries[1].delta ;
542  //printf("{%g %g %X %X", tmpX2[0], tmpX2[1], newgst>>1, tmpcp.ghostdir) ;
543  check_ghost_regular(newgst>>1, P, X1, tmpX2, r1, r2, tmpcp, 1, partialsum, 1) ;
544  //printf("}") ;
545  }
546  }
547 
548  return false ;
549 }
550 
551 //----------------------------------------
552 template <int d>
553 void ContactList<d>::check_ghost_dst(uint32_t gst, int n, double partialsum, uint32_t mask, const Parameters<d> & P, cv1d &X1, cv1d &X2, cp<d> & contact)
554 {
555  if (gst==0) return ;
556  else
557  {
558  for ( ;(gst&1)==0; gst>>=1,n++) ;
559  check_ghost_dst(gst-1, n, partialsum, mask, P, X1, X2, contact) ;
560  double Delta= (contact.ghostdir&(1<<n)?-1:1) * P.Boundaries[n].delta ;
561  partialsum = partialsum + Delta*(2*(X2[n]-X1[n]) + Delta) ;
562  if (partialsum<contact.contactlength) // Found a lower distance with this ghost
563  {
564  contact.contactlength=partialsum ;
565  contact.ghost = mask|(1<<n) ;
566  }
567  check_ghost_dst(gst-1, n, partialsum, mask|(1<<n), P, X1, X2, contact) ;
568  }
569 }
570 
571 //-----------------------------------
572 template <int d>
574 {
575  for (auto & w : v)
576  {
577  Z[w.i]++ ; Z[w.j] ++ ;
578  }
579 }
580 
581 #endif
Handle force and torque contact information.
Definition: ContactList.h:19
void setvel(cv1d &vvn, cv1d &vvt)
Definition: ContactList.h:33
vector< double > Ft_el
Definition: ContactList.h:24
vector< double > Fn_visc
Definition: ContactList.h:24
void setzero()
Definition: ContactList.h:34
vector< double > vn
Definition: ContactList.h:23
vector< double > Ft_fric
Definition: ContactList.h:24
vector< double > Ft
Definition: ContactList.h:22
vector< double > Fn_el
Definition: ContactList.h:24
vector< double > Torquei
Definition: ContactList.h:22
void serialize(Archive &ar)
Definition: ContactList.h:28
vector< double > Torquej
Definition: ContactList.h:22
void set(cv1d &a, cv1d &b, cv1d &c, cv1d &dd)
Definition: ContactList.h:32
bool Ft_isfric
Definition: ContactList.h:25
vector< double > Ft_visc
Definition: ContactList.h:24
Action()
Definition: ContactList.h:21
vector< double > Fn
Definition: ContactList.h:22
vector< double > vt
Definition: ContactList.h:23
Handles lists of contacts with meshes.
Definition: ContactList.h:298
Action< d > def
Default action.
Definition: ContactList.h:415
bool check_mesh_dst_contact(Mesh< d > &mesh, cv1d &Xo, double r, cpm< d > &c)
Definition: ContactList.h:310
Action< d > * default_action()
Easy allocation of a default contact to initialise new contacts.
Definition: ContactList.h:301
void serialize(Archive &ar)
Definition: ContactList.h:308
list< cpm< d > > v
Definition: ContactList.h:300
int cid
Definition: ContactList.h:305
void reset()
Go to the contact list beginning.
Definition: ContactList.h:302
list< cpm< d > >::iterator it
Iterator to the list to allow easy traversal, insertion & deletion while maintening ordering.
Definition: ContactList.h:414
void finalise()
Definition: ContactList.h:303
Handles lists of contacts.
Definition: ContactList.h:208
void serialize(Archive &ar)
Definition: ContactList.h:275
bool(ContactList::* check_ghost)(bitdim, const Parameters< d > &, cv1d &, cv1d &, double, double, cp< d > &, int startd, double partialsum, bitdim mask)
Definition: ContactList.h:270
Action< d > def
Default action.
Definition: ContactList.h:283
list< cp< d > > v
Contains the list of contact.
Definition: ContactList.h:277
void finalise()
Go to the end of the contact list, erasing any remaining contact which opened.
Definition: ContactList.h:213
int cid
Definition: ContactList.h:278
Action< d > * default_action()
Easy allocation of a default contact to initialise new contacts.
Definition: ContactList.h:272
list< cp< d > > null_list
Definition: ContactList.h:285
ContactList()
Definition: ContactList.h:210
void reset()
Go to the contact list beginning.
Definition: ContactList.h:211
list< cp< d > >::iterator it
Iterator to the list to allow easy traversal, insertion & deletion while maintening ordering.
Definition: ContactList.h:282
Definition: Mesh.h:11
int dimensionality
Definition: Mesh.h:86
std::vector< double > invertbase
Inverted base: inverse(transpose(mixedbase)).
Definition: Mesh.h:90
std::vector< double > origin
Definition: Mesh.h:87
std::vector< std::vector< Mesh > > submeshes
Definition: Mesh.h:92
std::vector< double > mixedbase
Mixed based: first n=dimensionality vectors are neither normalised nor unit vectors,...
Definition: Mesh.h:89
Generic class to handle the simulation set up.
Definition: Parameters.h:128
ContactStrategies contact_strategy
Strategy for the contact detection.
Definition: Parameters.h:188
vector< double > r
Particle radii.
Definition: Parameters.h:192
vector< Boundary< d > > Boundaries
List of boundaries. Second dimension is {min, max, length, type}.
Definition: Parameters.h:197
Action on a specific particle for a specific duration.
Definition: ContactList.h:46
void serialize(Archive &ar)
Definition: ContactList.h:51
int id
Definition: ContactList.h:48
int duration
Definition: ContactList.h:49
Contact properties class.
Definition: ContactList.h:69
double contactlength
Length of the contact.
Definition: ContactList.h:115
cp & operator=(const cp &c)
Affect contact.
Definition: ContactList.h:75
void load(Archive &ar)
Definition: ContactList.h:130
int j
Index of second contacting particle or wall. If this is a wall contact, j=2*walldimension + (0 or 1 i...
Definition: ContactList.h:114
bool persisting
True if the contact is still maintained for the current ts.
Definition: ContactList.h:121
int i
Index of contacting particle.
Definition: ContactList.h:113
void setinfo(Action< d > *a)
Set information for contact force.
Definition: ContactList.h:92
uint32_t ghost
Contain ghost information about ghost contact, cf detailed description.
Definition: ContactList.h:116
void save(Archive &ar) const
Definition: ContactList.h:124
bool owninfos
True if the contact contains stored information for dump retrieval.
Definition: ContactList.h:120
cp()
Only for use when restarting.
Definition: ContactList.h:71
Action< d > & getinfo()
Returning stored information.
Definition: ContactList.h:90
~cp()
Remove & clean contact.
Definition: ContactList.h:74
cp(const cp &v)
Definition: ContactList.h:73
void saveinfo(Action< d > &a)
Save information regarding the contact forces for later write down.
Definition: ContactList.h:93
std::vector< double > tspr
Vector of tangential contact history.
Definition: ContactList.h:118
std::pair< vector< double >, vector< double > > compute_branchvector(cv2d &X, Parameters< d > &P)
Compute the location & branch vector of the contact.
Definition: ContactList.h:139
uint32_t ghostdir
Contain ghost information about ghost direction, cf detailed description.
Definition: ContactList.h:117
Action< d > * infos
stores contact information if contact storing is requires
Definition: ContactList.h:119
cp(int ii, int jj, double ctlength, Action< d > *default_action)
New contact creation.
Definition: ContactList.h:72
Contact properties for mesh contacts (mainly), including contact point location, specialising cp.
Definition: ContactList.h:177
cpm()
Only for use when restarting.
Definition: ContactList.h:179
vector< double > contactpoint
Location of the contact, used only for Mesh at this point, to avoid recalculating.
Definition: ContactList.h:190
int submeshid
Definition: ContactList.h:191
void save(Archive &ar) const
Definition: ContactList.h:198
~cpm()
Remove & clean contact.
Definition: ContactList.h:182
cpm(const cpm &v)
Definition: ContactList.h:181
cpm(int ii, int jj, int sid, double ctlength, Action< d > *default_action)
New contact creation.
Definition: ContactList.h:180
cpm & operator=(const cpm &c)
Affect contact.
Definition: ContactList.h:183
void load(Archive &ar)
Definition: ContactList.h:194
void check_ghost_dst(uint32_t gst, int n, double partialsum, uint32_t mask, const Parameters< d > &P, cv1d &X1, cv1d &X2, cp< d > &contact)
Definition: ContactList.h:553
bool operator==(const cp< d > &a, const cp< d > &b)
Contact equivalence is based solely on the index of objects in contact i and j.
Definition: ContactList.h:291
void coordinance(v1d &Z)
Calculate and store coordination number in Z.
Definition: ContactList.h:573
int insert(const cpm< d > &a)
Insert a contact, maintaining sorting with increasing i, and removing missing contacts on traversal.
Definition: ContactList.h:451
const vector< double > cv1d
Definition: Typedefs.h:13
int insert(const cp< d > &a)
Insert a contact, maintaining sorting with increasing i, and removing missing contacts on traversal.
Definition: ContactList.h:430
const vector< vector< double > > cv2d
Definition: Typedefs.h:14
unsigned int bitdim
Definition: Typedefs.h:17
bool check_ghost_regular(bitdim gst, const Parameters< d > &P, cv1d &X1, cv1d &X2, double r1, double r2, cp< d > &tmpcp, int startd=0, double partialsum=0, bitdim mask=0)
Find ghost-particle contact, going though pbc recursively. A beautiful piece of optimised algorithm i...
Definition: ContactList.h:474
bool operator<(const cp< d > &a, const cp< d > &b)
The contact list is order in increasing order of index i, and for two identical i in increasing order...
Definition: ContactList.h:289
bool check_ghost_LE(bitdim gst, const Parameters< d > &P, cv1d &X1, cv1d &X2, double r1, double r2, cp< d > &tmpcp, int startd=0, double partialsum=0, bitdim mask=0)
Definition: ContactList.h:509
vector< double > v1d
Definition: Typedefs.h:9
static double norm(const vector< double > &a)
Norm of a vector.
Definition: Tools.h:119
@ CELLS
Definition: Typedefs.h:22
uint d
Definition: json.hpp:5678
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1181
unsigned int uint32_t
Definition: stdint.h:126
Casts a derived class to its non-virtual base class in a way that safely supports abstract classes.
Definition: base_class.hpp:101