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) {}
27 template <
class Archive>
29 ar(
Fn,
Ft,
Torquei,
Torquej,
vn,
vt,
Fn_el,
Fn_visc,
Ft_el,
Ft_visc,
Ft_fric,
Ft_isfric) ;
36 for (
int dd=0 ; dd<
d ; dd++)
Fn[dd]=
Ft[dd]=
vn[dd]=
vt[dd]=0 ;
50 template <
class Archive>
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 ; }
78 if (c.
i<0)
return *this ;
105 infos->Fn_visc =
a.Fn_visc ;
107 infos->Ft_visc =
a.Ft_visc ;
108 infos->Ft_fric =
a.Ft_fric ;
109 infos->Torquei =
a.Torquei ;
110 infos->Torquej =
a.Torquej ;
123 template <
class Archive>
124 void save (Archive &ar)
const {
129 template <
class Archive>
141 vector <double> loc (
d, 0), branch (
d, 0) ;
146 for (
int n=0 ; gh>0 ; gh>>=1, ghd>>=1, n++)
148 loc[n] += P.
Boundaries[n].delta * ((ghd&1)?-1:1) ;
154 loc[0] += P.
Boundaries[0].delta * ((ghd&1)?-1:1) ;
155 loc[1] += (ghd&1?-1:1)*P.
Boundaries[0].displacement ;
158 double additionaldelta = 0 ;
161 loc[1] += additionaldelta ;
165 for (
int n=1 ; gh>0 ; gh>>=1, ghd>>=1, n++)
167 loc[n] += P.
Boundaries[n].delta * ((ghd&1)?-1:1) ;
169 for (
int dd = 0 ; dd<
d ; dd++) branch[dd] = X[
i][dd]-loc[dd] ;
170 for (
int dd = 0 ; dd<
d ; dd++) loc[dd] = (X[
i][dd]+loc[dd]*(P.
r[
i]/(P.
r[
i]+P.
r[
j]) )) ;
171 return {loc, branch} ;
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){}
193 template <
class Archive>
197 template <
class Archive>
198 void save (Archive &ar)
const {
268 int startd=0,
double partialsum=0,
bitdim mask=0) ;
274 template <
class Archive>
282 typename list<cp<d>>::iterator
it ;
307 template <
class Archive>
312 std::vector<double> dotproducts (
d) ;
331 std::vector<double> coefficient (
d, 0) ;
334 for (
int dd=0 ; dd<
d ; dd++)
336 dstsqr += coefficient[i]*coefficient[i] ;
337 if (dstsqr > r*r)
goto submeshesprocessing ;
341 double coefficient_sum = 0 ;
344 for (
int dd=0 ; dd<
d ; dd++)
346 if (coefficient[i]<0 || coefficient[i]>1)
goto submeshesprocessing ;
347 coefficient_sum+=coefficient[i] ;
348 if (coefficient_sum > 1)
goto submeshesprocessing ;
350 if (coefficient_sum < 1)
356 for (
int dd=0 ; dd<
d ; dd++)
405 for (
size_t j=0 ; j<mesh.
submeshes[i].size() ; j++)
408 if (res)
return true ;
414 typename list<cpm<d>>::iterator
it ;
432 while (it!=v.end() && (*it) <
a)
433 { it= v.erase(it) ; }
434 if (it==v.end()) {v.push_back(
a) ; it=v.end() ; }
439 it->contactlength=
a.contactlength ;
441 it->ghostdir=
a.ghostdir ;
442 it->persisting = true ;
445 else {it=v.insert(it,
a) ; it++ ; }
453 while (it!=v.end() && (*it) <
a)
454 { it= v.erase(it) ; }
455 if (it==v.end()) {v.push_back(
a) ; it=v.end() ; }
460 it->contactlength=
a.contactlength ;
462 it->ghostdir=
a.ghostdir ;
463 it->contactpoint =
a.contactpoint ;
464 it->submeshid =
a.submeshid ;
467 else {it=v.insert(it,
a) ; it++ ; }
475 cv1d &X1,
cv1d &X2,
double r1,
double r2,
476 cp<d> & tmpcp,
int startd,
double partialsum,
bitdim mask)
478 double sum=partialsum ;
479 double rr = (r1+r2)*(r1+r2) ;
480 for (
int dd=startd ; sum<rr && dd<d ; dd++, gst>>=1)
482 sum += (X1[dd]-X2[dd]) * (X1[dd]-X2[dd]) ;
486 double sumspawn = partialsum + (X1[dd]-X2[dd]-Delta) * (X1[dd]-X2[dd]-Delta) ;
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 ;
510 [[maybe_unused]]
int startd, [[maybe_unused]]
double partialsum, [[maybe_unused]]
bitdim mask)
513 return check_ghost_regular(gst, P, X1, X2, r1, r2, tmpcp) ;
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) ;
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) ;
531 partialsum = (X1[0]-X2[0]-Delta) * (X1[0]-X2[0]-Delta) ;
533 newgst &= (~(1<<1)) ;
534 newgst |= ((gst>>30)<<1) ;
535 newgst &= (~(1<<30)) ;
543 check_ghost_regular(newgst>>1, P, X1, tmpX2, r1, r2, tmpcp, 1, partialsum, 1) ;
558 for ( ;(gst&1)==0; gst>>=1,n++) ;
559 check_ghost_dst(gst-1, n, partialsum, mask, P, X1, X2, contact) ;
561 partialsum = partialsum + Delta*(2*(X2[n]-X1[n]) + Delta) ;
565 contact.
ghost = mask|(1<<n) ;
567 check_ghost_dst(gst-1, n, partialsum, mask|(1<<n), P, X1, X2, contact) ;
577 Z[w.i]++ ; Z[w.j] ++ ;
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
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
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