Allink  v0.1
Cubo.cpp
1 #include <Cubo.h>
2 #define MASK_X 0
3 #define MASK_Y 4
4 #define MASK_Z 8
5 #define GET_MASK_X 0x00f
6 #define GET_MASK_Y 0x0f0
7 #define GET_MASK_Z 0xf00
8 #define DOM_CENTER 0
9 #define DOM_LEFT 1
10 #define DOM_RIGHT 2
11 #define DOM_SET_POS(n,p,m) ( (n)|=((p)<<(m)) )
12 #define DOM_GET_POS(n,m,g) ( ((n)&(g))>>(m) )
13 //FIXME
14 #define DOM_IF_POS(n,m,d) ( ((n)>>(m))==(d) )
15 //-----------------BASICS-----------------------------
18  // signal(SIGSTOP,StopProg);
19 }
20 // void DomDecBasics::StopProg(int sig){
21 // printf("Program stopped\n");
22 // }
24 void DomDecBasics::SigErr(int IsWrong,const char * s, ...){
25 #ifdef DEBUG
26  if(IsWrong){
27  va_list args;
28  va_start(args, s);
29  fprintf(stderr, "Dom Dec error: ");
30  vfprintf(stderr, s, args);
31  fprintf(stderr, "exiting the program\n");
32  va_end(args);
33  abort();
34  }
35 #else
36  return;
37 #endif
38 }
40 int DomDecBasics::SetCutOff(double CutOffExt){
41  for(int d=0;d<3;d++){
42  if(CutOffExt > Edge[d]/(double)NSect[d]){
43  printf("CutOff larger than the cell size\n");
44  return 1;
45  }
46  }
47  CutOff = CutOffExt;
48  return 0;
49 }
52  return NPart;
53 }
56  return NCell;
57 }
59 int DomDecBasics::GetCell(double *Pos,int *NeiList){
60  int c = pCella(Pos);
61  return GetCellCh(c,NeiList);
62 }
64 int DomDecBasics::GetCellCh(int c,int *NeiList){
65  SigErr(c < 0 || c > NCell,"cell value %d over the ranges\n",c);
66  if(NCell == 1){
67  return 1;
68  }
69  int NeiMod[3];
70  int NeiCell[3];
71  int NNei = 0;
72  NeiMod[2] = (int)(c/(double)Mod10[2]);
73  NeiMod[1] = (int)((c-NeiMod[2]*Mod10[2])/(double)Mod10[1]);
74  NeiMod[0] = (int)(c-NeiMod[1]*Mod10[1]-NeiMod[2]*Mod10[2]);
75  for(int n=0;n<27;n++) for(int d=0;d<3;d++) BoundCond[n][d] = 0.;
76  for(int cx=-1;cx<=1;cx++){
77  NeiCell[0] = NeiMod[0] + cx;
78  if(NeiCell[0] >= NSect[0]){
79  NeiCell[0] -= NSect[0];
80  BoundCond[NNei][0] = -1.;
81  }
82  if(NeiCell[0] < 0){
83  NeiCell[0] += NSect[0];
84  BoundCond[NNei][0] = 1.;
85  }
86  for(int cy=-1;cy<=1;cy++){
87  NeiCell[1] = NeiMod[1] + cy;
88  if(NeiCell[1] >= NSect[1]){
89  NeiCell[1] -= NSect[1];
90  BoundCond[NNei][1] = -1.;
91  }
92  if(NeiCell[1] < 0){
93  NeiCell[1] += NSect[1];
94  BoundCond[NNei][1] = 1.;
95  }
96  for(int cz=-1;cz<=1;cz++){
97  NeiCell[2] = NeiMod[2] + cz;
98  if(NeiCell[2] >= NSect[2]){
99  NeiCell[2] -= NSect[2];
100  BoundCond[NNei][2] = -1.;
101  }
102  if(NeiCell[2] < 0){
103  NeiCell[2] += NSect[2];
104  BoundCond[NNei][2] = 1.;
105  }
106  NeiList[NNei] = NeiCell[0]*Mod10[0] + NeiCell[1]*Mod10[1] + NeiCell[2]*Mod10[2];
107  NNei++;
108  }
109  }
110  }
111  //printf("\n %d) ",c);for(int i=0;i<NNei;i++) printf("%d ",NeiList[i]);
112  return NNei;
113 }
115 int DomDecBasics::GetCellCoord(double *Pos,int *NeiList){
116  int c = pCella(Pos);
117  int Coord = GetCoorNumb(Pos);
118  return GetCellCoord(c,Coord,NeiList);
119 }
121 int DomDecBasics::GetCellCoord(int c,int Coord,int *NeiList){
122  SigErr(c < 0,"Probably the particle position is not a number cell %d\n",c);
123  int NNei = 0;
124  int nNei[3];
125  int NeiCell[3];
126  int Mask[3] = {MASK_X,MASK_Y,MASK_Z};
127  int GetMask[3] = {GET_MASK_X,GET_MASK_Y,GET_MASK_Z};
128  int Move[3] = {0,0,0};
129  NeiCell[2] = (int)(c/(double)Mod10[2]);
130  NeiCell[1] = (int)((c-NeiCell[2]*Mod10[2])/(double)Mod10[1]);
131  NeiCell[0] = (int)(c-NeiCell[1]*Mod10[1]-NeiCell[2]*Mod10[2]);
132  for(int n=0;n<27;n++)for(int d=0;d<3;d++) BoundCond[n][d] = 0.;
133  for(int d=0;d<3;d++){
134  int d1 = (d+1)%3;
135  int d2 = (d+2)%3;
136  if( DOM_GET_POS(Coord,Mask[d],GetMask[d]) == DOM_RIGHT ){
137  Move[d] = DOM_RIGHT;
138  int nc = NeiCell[d] + 1.;
139  if(nc >= NSect[d]){
140  nc = 0;
141  BoundCond[NNei][d] = -1.;
142  }
143  NeiList[NNei++] = nc*Mod10[d] + NeiCell[d1]*Mod10[d1] + NeiCell[d2]*Mod10[d2];
144  }
145  else if( DOM_GET_POS(Coord,Mask[d],GetMask[d]) == DOM_LEFT ){
146  Move[d] = DOM_LEFT;
147  int nc = NeiCell[d] - 1.;
148  if(nc < 0){
149  nc = NSect[d]-1;
150  BoundCond[NNei][d] = 1.;
151  }
152  NeiList[NNei++] = nc*Mod10[d] + NeiCell[d1]*Mod10[d1] + NeiCell[d2]*Mod10[d2];
153  }
154  }
155  if(NNei > 1){
156  for(int d=0;d<3;d++){
157  nNei[d] = NeiCell[d];
158  if(Move[d] == DOM_LEFT){
159  nNei[d] = NeiCell[d] - 1;
160  if(nNei[d] < 0) nNei[d] = NSect[d] - 1;
161  }
162  if(Move[d] == DOM_RIGHT){
163  nNei[d] = NeiCell[d] + 1;
164  if(nNei[d] >= NSect[d]) nNei[d] = 0;
165  }
166  }
167  NeiList[NNei++] = nNei[0]*Mod10[0] + nNei[1]*Mod10[1] + nNei[2]*Mod10[2];
168  }
169  if(NNei == 4){
170  for(int dd=0;dd<3;dd++){
171  for(int d=0;d<3;d++){
172  nNei[d] = NeiCell[d];
173  if(d == dd) continue;
174  if(Move[d] == DOM_LEFT){
175  nNei[d] = NeiCell[d] - 1;
176  if(nNei[d] < 0) nNei[d] = NSect[d] - 1;
177  }
178  if(Move[d] == DOM_RIGHT){
179  nNei[d] = NeiCell[d] + 1;
180  if(nNei[d] >= NSect[d]) nNei[d] = 0;
181  }
182  }
183  NeiList[NNei++] = nNei[0]*Mod10[0] + nNei[1]*Mod10[1] + nNei[2]*Mod10[2];
184  }
185  }
186  NeiList[NNei++] = c;
187  // for(int n=0;n<NNei;n++) assert(NeiList[n] < NCell);
188  // for(int n=0;n<NNei;n++) assert(NeiList[n] >= 0);
189  return NNei;
190 }
192 int DomDecBasics::pCella(const double Pos[3]){
193  int ris[3];
194  for(int d=0;d<3;d++){
195  double PosBox = Pos[d] - floor(Pos[d]*InvEdge[d])*Edge[d];
196  ris[d] = (int)(PosBox/Edge[d]*NSect[d]);
197  }
198  int risp = ris[0]*Mod10[0]+ris[1]*Mod10[1]+ris[2]*Mod10[2];
199  SigErr(risp >= NCell,"Probably the particle position is not a number\n");
200  return risp;
201 }
203 void DomDecBasics::pCella(const double Pos[3],int c[4]){
204  for(int d=0;d<3;d++){
205  double PosBox = Pos[d];// - floor(Pos[d]*InvEdge[d])*Edge[d];
206  c[d] = (int)(PosBox/Edge[d]*NSect[d]);
207  }
208  c[4] = c[0]*Mod10[0]+c[1]*Mod10[1]+c[2]*Mod10[2];
209  SigErr(c[4] >= NCell,"Probably the particle position is not a number\n");
210 }
212 int DomDecBasics::GetCoorNumb(double *Pos){
213  double CellLen[3];
214  int Border[3];
215  double BorderR[3];
216  int Mask[3] = {MASK_X,MASK_Y,MASK_Z};
217  int Coord = 0;
218  for(int d=0;d<3;d++){
219  Border[d] = (int)(Pos[d]/Edge[d]*NSect[d]);
220  CellLen[d] = (Edge[d]/(double)NSect[d]);
221  if(Pos[d] - Border[d]*CellLen[d] < CutOff){
222  DOM_SET_POS(Coord,DOM_LEFT,Mask[d]);
223  }
224  if(-Pos[d] + (Border[d]+1)*CellLen[d] < CutOff){
225  DOM_SET_POS(Coord,DOM_RIGHT,Mask[d]);
226  }
227  }
228  return Coord;
229 }
230 //-------------------LINKED-LIST-------------------------------
232 DdLinkedList::DdLinkedList(double EdgeExt[3],int NPartExt,double CutOffExt){
233  for(int d=0;d<3;d++){
234  Edge[d] = EdgeExt[d];
235  InvEdge[d] = 1./Edge[d];
236  //NSect[d] = (int)(Edge[d]/(2.*CutOffExt));
237  NSect[d] = (int)(Edge[d]/CutOffExt);
238  SigErr(CutOffExt > 2.*Edge[d],"Insufficient number of cells \n");
239  }
240  NPart = 0;
241  SetCutOff(CutOffExt);
242  Mod10[0] = 1;
243  Mod10[1] = NSect[0];
244  Mod10[2] = NSect[1]*Mod10[1];
245  NCell = NSect[0]*NSect[1]*NSect[2];
246  Cella = new DomCell[NCell];
247  SigErr(Cella==NULL,"DomCell not allocated\n");
248  for(int c=0;c<NCell;c++){
249  Cella[c].NPart = 0;
250  Cella[c].First = Cella[c].Last = -2;
251  }
252  NAllocP = NPartExt + 2000;
253  Pc = new DOMAIN_PART[NAllocP];
254  SigErr(Pc == NULL,"DOMAIN_PART not allocated\n");
255  printf("%d\n",NCell);
256 }
259  for(int c=0;c<NCell;c++){
260  Cella[c].NPart = 0;
261  Cella[c].Last = -1;
262  }
263  for(int p=0;p<NPart;p++){
264  Pc[p].Cell = -1;
265  Pc[p].Next = -1;
266  Pc[p].Prev = -2;
267  }
268  NPart = 0;
269 }
271 int DdLinkedList::SetCoorNumb(double *Pos,int p){
272  Pc[p].Coord = GetCoorNumb(Pos);
273  return Pc[p].Coord;
274 }
276 void DdLinkedList::AddPart(const int p,double *Pos){
277  // for(int d=0;d<3;d++){
278  // SigErr(Pos[d] < 0. || Pos[d] > Edge[d],"particle %d over the boudaries 0< %lf < %lf\n",p,Pos[d],Edge[d]);}
279  int c = pCella(Pos);
280  SetCoorNumb(Pos,p);
281  for(int d=0;d<3;d++) Pc[p].Pos[d] = Pos[d];
282  AddPart(p,c);
283 }
285 void DdLinkedList::AddPart(const int p,const int c){
286  //PrintCell(c);
287  int pl = Cella[c].Last;
288  SigErr(pl == p,"The particle %d is already the last in the cell %d\n",p,c);
289  SigErr(p >= NAllocP,"More particle than allocated %d > %d\n",p,NAllocP);
290  SigErr(Cella[c].NPart >= NAllocP,"More particle than allocated\n");
291  Cella[c].NPart++;
292  NPart++;
293  Cella[c].Last = p;
294  Pc[p].Cell = c;
295  Pc[p].Next = -1;
296  if(Cella[c].NPart == 1){
297  Cella[c].First = p;
298  Pc[p].Prev = -2;
299  }
300  else{
301  if(pl >= 0) Pc[pl].Next = p;
302  Pc[p].Prev = pl;
303  }
304  //printf("%d - %d - %d c) %d last %d coord %x cell %d (%lf %lf %lf)\n",Pc[p].Prev,p,Pc[p].Next,c,Cella[c].Last,Pc[p].Coord,Pc[p].Cell,Pc[p].Pos[0],Pc[p].Pos[1],Pc[p].Pos[2]);
305 }
307 void DdLinkedList::RemPart(const int p,double *Pos){
308  int c = pCella(Pos);
309  RemPart(p,c);
310 }
312 void DdLinkedList::RemPart(const int p,const int c){
313  SigErr(p >= NAllocP,"More particles than allocated\n");
314  //assert(Cella[c].NPart > 0);
315  SigErr(Cella[c].NPart <= 0,"Cannot remove, the cell is already empty\n");
316  SigErr(c < 0,"The cell %d does not exist\n",c);
317  Cella[c].NPart--;
318  NPart--;
319  if(Cella[c].NPart == 0){
320  Cella[c].First = -2;
321  Cella[c].Last = -1;
322  }
323  else{
324  int pp = Pc[p].Prev;
325  int pn = Pc[p].Next;
326  if(pp == -2) Cella[c].First = pn;
327  else Pc[pp].Next = pn;
328  if(pn == -1) Cella[c].Last = pp;
329  else Pc[pn].Prev = pp;
330  Pc[p].Cell = -1;
331  }
332  //printf("%d - %d - %d c) %d last %d coord %x cell %d\n",pp,p,pn,c,Cella[c].Last,Pc[p].Coord,Pc[p].Cell);
333  // assert(pp != -2 && Pc[pp].Next != pp);
334 }
336 void DdLinkedList::RemPart(const int p){
337  int c = Pc[p].Cell;
338  SigErr(c < 0,"The cell %d or the particle %d does not exist\n",c,p);
339  RemPart(p,c);
340 }
342 int DdLinkedList::SwapPart(int p1,double *Pos1,int p2,double *Pos2){
343  if(p1==p2) return 0;
344  DOMAIN_PART Pn;
345  int c1 = Pc[p1].Cell;
346  int c2 = Pc[p2].Cell;
347  for(int d=0;d<3;d++){
348  Pc[p1].Pos[d] = Pos2[d];
349  Pc[p2].Pos[d] = Pos1[d];
350  }
351  if(c1!=c2){
352  if(Cella[c2].First == p2)
353  Cella[c2].First = p1;
354  if(Cella[c2].Last == p2)
355  Cella[c2].Last = p1;
356  if(Cella[c1].First == p1)
357  Cella[c1].First = p2;
358  if(Cella[c1].Last == p1)
359  Cella[c1].Last = p2;
360  }
361  if(c1==c2){
362  if(Cella[c1].First == p2)
363  Cella[c1].First = p1;
364  else if(Cella[c1].First == p1)
365  Cella[c1].First = p2;
366  if(Cella[c1].Last == p2)
367  Cella[c1].Last = p1;
368  else if(Cella[c1].Last == p1)
369  Cella[c1].Last = p2;
370  }
371  int p1p = Pc[p1].Prev;
372  int p2p = Pc[p2].Prev;
373  int p1n = Pc[p1].Next;
374  int p2n = Pc[p2].Next;
375  if(p1p >= 0) Pc[p1p].Next = p2;
376  if(p1n >= 0) Pc[p1n].Prev = p2;
377  if(p2p >= 0) Pc[p2p].Next = p1;
378  if(p2n >= 0) Pc[p2n].Prev = p1;
379  Pn.Prev = Pc[p1].Prev;
380  Pn.Next = Pc[p1].Next;
381  Pn.Coord = Pc[p1].Coord;
382  Pn.Cell = Pc[p1].Cell;
383  Pc[p1].Prev = Pc[p2].Prev;
384  Pc[p1].Next = Pc[p2].Next;
385  Pc[p1].Coord = Pc[p2].Coord;
386  Pc[p1].Cell = Pc[p2].Cell;
387  Pc[p2].Prev = Pn.Prev;
388  Pc[p2].Next = Pn.Next;
389  Pc[p2].Coord = Pn.Coord;
390  Pc[p2].Cell = Pn.Cell;
391 }
393 void DdLinkedList::MovePart(const int p,double *NewPos){
394  int cn = pCella(NewPos);
395  int co = pCell(p);
396  SetCoorNumb(NewPos,p);
397  for(int d=0;d<3;d++)Pc[p].Pos[d] = NewPos[d];
398  if(cn == co) return;
399  RemPart(p,co);
400  AddPart(p,cn);
401 }
403 void DdLinkedList::MovePart(const int p,double *OldPos,double *NewPos){
404  int cn = pCella(NewPos);
405  int co = pCella(OldPos);
406  SetCoorNumb(NewPos,p);
407  for(int d=0;d<3;d++)Pc[p].Pos[d] = NewPos[d];
408  if(cn == co) return ;
409  RemPart(p,co);
410  AddPart(p,cn);
411 }
414  for(int c=0;c<NCell;c++){
415  Cella[c].Curr1 = Cella[c].First;
416  Cella[c].Curr2 = Cella[c].First;
417  if(Cella[c].NPart > 1)
418  Cella[c].Curr2 = Pc[Cella[c].Curr1].Next;
419  }
420 }
421 int DdLinkedList::ItCell(const int c){
422  SigErr(c >= NCell,"The cell %d does not exist\n",c);
423  SigErr(Cella[c].Curr1 >= NAllocP,"Poiting to a particle %d over the number of allocated particles\n",Cella[c].Curr1,NAllocP);
424  return Cella[c].Curr1;
425 }
427 int DdLinkedList::IfItCell(const int c){
428  if(Cella[c].Curr1 < 0 || Cella[c].NPart == 0){
429  Cella[c].Curr1 = Cella[c].First;
430  return 0;
431  }
432  return 1;
433 }
435 void DdLinkedList::IncrCurr(const int c){
436  Cella[c].Curr1 = Pc[Cella[c].Curr1].Next;
437 }
439 void DdLinkedList::PrintCell(const int c){
440  for(SetCounters(c);IfItCell(c);IncrCurr(c)){
441  int p = ItCell(c);
442  printf("%d) # %d %d_%d_%d %x\n",c,Cella[c].NPart,Pc[p].Prev,ItCell(c),Pc[p].Next,Pc[p].Coord);
443  }
444 }
447  for(int c=0;c<NCell;c++)
448  PrintCell(c);
449 }
454  cCurr = Pc[p].Cell;
455  SigErr(cCurr < 0,"The cell %d or the particle %d does not exists\n",cCurr,p);
456  NNeiCurr = GetNei(Pc[p].Pos,NeiListCurr);
457  nNeiCurr = 0;
458  IfLoopCurr = 1;
460  p1Curr = p;
461  p2Curr = Cella[cCurr].First;
462  if(p2Curr == p1Curr) Pc[p2Curr].Next;
463  while(p2Curr < 0){
464  nNeiCurr++;
465  //printf(" %d) %d/%d %d %d\n",p,nNeiCurr,NNeiCurr,cCurr,p2Curr);
466  if(nNeiCurr==NNeiCurr){
467  IfLoopCurr = 0;
468  break;
469  }
471  p2Curr = Cella[cCurr].First;
472  }
473  //printf("%d) %d %d/%d %d\n",p,p2Curr,nNeiCurr,NNeiCurr,cCurr);
474  //for(int n=0;n<27;n++)printf(" %d] %0.f %0.f %0.f\n",n,BoundCond[n][0],BoundCond[n][1],BoundCond[n][2]);
475  //PrintCell(cCurr);
476  Cella[cCurr].Curr1 = p1Curr;
477  Cella[cCurr].Curr2 = p2Curr;
478 }
480  p2Curr = Pc[p2Curr].Next;
481  if(p2Curr == p1Curr) Pc[p2Curr].Next;
482  while(p2Curr < 0){
483  nNeiCurr++;
484  if(nNeiCurr==NNeiCurr){
485  IfLoopCurr = 0;
486  break;
487  }
489  p2Curr = Cella[cCurr].First;
490  }
491  //printf(" %d) %d %d\n",p1Curr,p2Curr,nNeiCurr);
492  Cella[cCurr].Curr1 = p1Curr;
493  Cella[cCurr].Curr2 = p2Curr;
494 }
499  return IfLoopCurr;
500 }
502 void DdLinkedList::Dist2Curr(double *DistRel){
503  for(int d=0;d<3;d++){
504  DistRel[d] = Pc[p1Curr].Pos[d] - Pc[p2Curr].Pos[d];
505  //TOFIX
506  //printf("%d-%d) %.0f %.0f %d %d-%d\n",p1Curr,p2Curr,BoundCond[nNeiCurr][d]*Edge[d],-floor(DistRel[d]*InvEdge[d] + .5)*Edge[d],nNeiCurr,Pc[p1Curr].Cell,Pc[p2Curr].Cell);
507  //DistRel[d] += BoundCond[nNeiCurr][d]*Edge[d];
508  DistRel[d] -= floor(DistRel[d]*InvEdge[d] + .5)*Edge[d];
509  }
510  DistRel[3] = SQR(DistRel[0]) + SQR(DistRel[1]) + SQR(DistRel[2]);
511 }
512 void DdLinkedList::SetCurrGhost(double *Pos){
513  cCurr = pCella(Pos);
514  SigErr(cCurr < 0,"The cell %d does not exists\n",cCurr);
515  NNeiCurr = GetNei(Pos,NeiListCurr);
516  nNeiCurr = 0;
517  IfLoopCurr = 1;
519  for(int d=0;d<3;d++) PosCurr[d] = Pos[d];
520  p2Curr = Cella[cCurr].First;
521  while(p2Curr < 0){
522  nNeiCurr++;
523  //printf(" %d) %d/%d %d %d\n",p,nNeiCurr,NNeiCurr,cCurr,p2Curr);
524  if(nNeiCurr==NNeiCurr){
525  IfLoopCurr = 0;
526  break;
527  }
529  p2Curr = Cella[cCurr].First;
530  }
531  //printf("%d) %d %d/%d %d\n",p,p2Curr,nNeiCurr,NNeiCurr,cCurr);
532  //for(int n=0;n<27;n++)printf(" %d] %0.f %0.f %0.f\n",n,BoundCond[n][0],BoundCond[n][1],BoundCond[n][2]);
533  //PrintCell(cCurr);
534  Cella[cCurr].Curr2 = p2Curr;
535 }
537  p2Curr = Pc[p2Curr].Next;
538  while(p2Curr < 0){
539  nNeiCurr++;
540  if(nNeiCurr==NNeiCurr){
541  IfLoopCurr = 0;
542  break;
543  }
545  p2Curr = Cella[cCurr].First;
546  }
547  //printf(" %d) %d %d\n",p1Curr,p2Curr,nNeiCurr);
548  Cella[cCurr].Curr2 = p2Curr;
549 }
551  return IfLoopCurr;
552 }
554 void DdLinkedList::Dist2CurrGhost(double *DistRel){
555  for(int d=0;d<3;d++){
556  DistRel[d] = PosCurr[d] - Pc[p2Curr].Pos[d];
557  //TOFIX
558  //printf("%d-%d) %.0f %.0f %d %d-%d\n",p1Curr,p2Curr,BoundCond[nNeiCurr][d]*Edge[d],-floor(DistRel[d]*InvEdge[d] + .5)*Edge[d],nNeiCurr,Pc[p1Curr].Cell,Pc[p2Curr].Cell);
559  //DistRel[d] += BoundCond[nNeiCurr][d]*Edge[d];
560  DistRel[d] -= floor(DistRel[d]*InvEdge[d] + .5)*Edge[d];
561  }
562  DistRel[3] = SQR(DistRel[0]) + SQR(DistRel[1]) + SQR(DistRel[2]);
563 }
565 void DdLinkedList::Couple(const int c,int *p1,int *p2){
566  SigErr(Cella[c].Curr1 >= NAllocP,"Poiting to a particle %d over the number of allocated particles\n",Cella[c].Curr1,NAllocP);
567  SigErr(Cella[c].Curr2 >= NAllocP,"Poiting to a particle %d over the number of allocated particles\n",Cella[c].Curr2,NAllocP);
568  *p1 = Cella[c].Curr1;
569  *p2 = Cella[c].Curr2;
570 }
572 int DdLinkedList::IfItCouple(const int c){
573  if(Cella[c].NPart < 2) return 0;
574  if(Cella[c].Curr1 == -1){
575  Cella[c].Curr1 = Cella[c].First;
576  Cella[c].Curr2 = Pc[Cella[c].First].Next;
577  return 0;
578  }
579  return 1;
580 }
582 void DdLinkedList::IncrCurrList(const int c){
583  int p2 = Cella[c].Curr2;
584  Cella[c].Curr2 = Pc[p2].Next;
585  if(Pc[p2].Next == -1){
586  int p1 = Cella[c].Curr1;
587  Cella[c].Curr1 = Pc[p1].Next;
588  Cella[c].Curr2 = Pc[Pc[p1].Next].Next;
589  if(Cella[c].Curr2 == -1){
590  Cella[c].Curr1 = -1;
591  }
592  }
593  SigErr(Cella[c].Curr2 >= NAllocP,"Poiting to a particle %d over the number of allocated particles\n",Cella[c].Curr2,NAllocP);
594 }
596  double DistRel[4];
597  int pCloser = -1;
598  double DistCurr = 1000000.;
599  for(SetCurr(p1);IfCurr();NextCurr()){
600  if(p2Curr <= p1Curr) continue;
601  Dist2Curr(DistRel);
602  if(DistRel[3] < DistCurr){
603  DistCurr = DistRel[3];
604  pCloser = p2Curr;
605  }
606  }
607  return pCloser;
608 }
609 //--------------------DomPart-----DomCell---------------------
612  //It++;
613  return *this;
614 }
617 }
620  return *this;
621 }
622 DomPart::DomPart(int ExtNPart){
623  NPart = ExtNPart;
624  Next = new int[NPart];
625  Prev = new int[NPart];
626 }
627 int DomPart::operator[](int col){
628  return Next[col];
629 }
630 //-------------------------------DdArray------------------------
634 DdArray::DdArray(double EdgeExt[3],int NPartExt,double CutOffExt){
635  for(int d=0;d<3;d++){
636  Edge[d] = EdgeExt[d];
637  InvEdge[d] = 1./Edge[d];
638  NSect[d] = (int)(Edge[d]/(double)(CutOffExt));
639  }
640  NPart = 0;
641  CutOff = CutOffExt;
642  Mod10[0] = 1;
643  Mod10[1] = NSect[0];
644  Mod10[2] = NSect[1]*Mod10[1];
645  NCell = NSect[0]*NSect[1]*NSect[2];
646  Cella = new DdCell[NCell];
647  if(Cella == NULL) {printf("DomCell not allocated\n");}
648 }
650  for(int c=0;c<NCell;c++){
651  Cella[c].Part.clear();
652  }
653 }
654 void DdArray::AddPart(int p,double *Pos){
655  int c = pCella(Pos);
656  Cella[c].Part.push_back(p);
657  NPart++;
658 }
659 void DdArray::RemPart(int p,double *Pos){
660  int c = pCella(Pos);
661  Cella[c].Part.remove(p);
662  NPart--;
663 }
664 void DdArray::MovePart(int p,double *OldPos,double *NewPos){
665  int c1 = pCella(OldPos);
666  int c2 = pCella(NewPos);
667  if(c1 == c2) return;
668  Cella[c1].Part.remove(p);
669  Cella[c2].Part.push_back(p);
670 }
671 void DdArray::SwapPart(int p1,double *Pos1,int p2,double *Pos2){
672  int c1 = pCella(Pos1);
673  int c2 = pCella(Pos2);
674  if(c1 == c2) return;
675  Cella[c1].Part.remove(p1);
676  Cella[c1].Part.push_back(p2);
677  Cella[c2].Part.remove(p2);
678  Cella[c2].Part.push_back(p2);
679 }
681  //if(Cella[c].Part.size() == 0) return;
682  NCurr = Cella[c].Part.begin();
683  NCurr2 = Cella[c].Part.begin();
684  if(Cella[c].Part.size() > 1)
685  ++NCurr2;
686 };
687 int DdArray::IfItCell(int c){
688  if(NCurr == Cella[c].Part.end()) return 0;
689  return 1;
690 };
691 void DdArray::IncrCurr(int c){
692  ++NCurr;
693 }
694 int DdArray::ItCell(int c){
695  return *NCurr;
696 }
697 void DdArray::Couple(const int c,int *p1,int *p2){
698  *p1 = *NCurr;
699  *p2 = *NCurr2;
700 }
701 int DdArray::IfItCouple(const int c){
702  if(NCurr == Cella[c].Part.end())
703  return 0;
704  return 1;
705 }
706 void DdArray::IncrCurrList(const int c){
707  ++NCurr2;
708  if(NCurr2 == Cella[c].Part.end()){
709  NCurr2 = NCurr;
710  ++NCurr2;
711  ++NCurr;
712  }
713 }
714 void DdArray::PrintCell(const int c){
715  for(SetCounters(c);IfItCell(c);IncrCurr(c)){
716  int p = ItCell(c);
717  printf("%d) # %d %d\n",c,Cella[c].Part.size(),ItCell(c));
718  }
719 }
721  for(int c=0;c<NCell;c++)
722  PrintCell(c);
723 }
724 //--------------------------------DdFixedSize----------------------------
728 DdFixedSize::DdFixedSize(double EdgeExt[3],int NPartExt,double CutOffExt){
729  for(int d=0;d<3;d++){
730  Edge[d] = EdgeExt[d];
731  InvEdge[d] = 1./Edge[d];
732  NSect[d] = (int)(Edge[d]/(double)(CutOffExt));
733  }
734  NPart = 0;
735  NPCell = 30;
736  CutOff = CutOffExt;
737  Mod10[0] = 1;
738  Mod10[1] = NSect[0];
739  Mod10[2] = NSect[1]*Mod10[1];
740  NCell = NSect[0]*NSect[1]*NSect[2];
741  Cella = new DdFixCell[NCell];
742  for(int c=0;c<NCell;c++){
743  Cella[c].Part = new int[NPCell];
744  }
745  if(Cella == NULL) {printf("DomCell not allocated\n");}
746 }
748  for(int c=0;c<NCell;c++){
749  for(int p=0;p<Cella[c].NPart;p++){
750  Cella[c].Part[p] = -1;
751  }
752  Cella[c].NPart = 0;
753  }
754 }
755 void DdFixedSize::AddPart(int p,double *Pos){
756  int c = pCella(Pos);
757  AddPart(p,c);
758 }
759 void DdFixedSize::AddPart(int p,int c){
760  //printf("Adding %d in %d\n",p,c);
761  if(Cella[c].NPart > NPCell){
762  printf("Maximum allocated size in the domain decomposition (%d) reached, terminating\n",NPCell);
763  assert(Cella[c].NPart < NPCell);
764  }
765  Cella[c].Part[Cella[c].NPart++] = p;
766  NPart++;
767 }
768 void DdFixedSize::RemPart(int p1,double *Pos){
769  int c = pCella(Pos);
770  RemPart(p1,c);
771 }
772 void DdFixedSize::RemPart(int p1,int c){
773  //PrintCell(c);
774  //printf("removing %d from %d\n",p1,c);
775  int FoundPartInCell = 0;
776  int Temp = 0;
777  for(int p=0;p<Cella[c].NPart;p++){
778  if(p1==Cella[c].Part[p]){
779  for(int pp=p;pp<Cella[c].NPart-1;pp++){
780  Temp = Cella[c].Part[pp];
781  Cella[c].Part[pp] = Cella[c].Part[pp+1];
782  Cella[c].Part[pp+1] = Temp;
783  }
784  Cella[c].NPart--;
785  NPart--;
786  FoundPartInCell = 1;
787  break;
788  }
789  }
790  //PrintCell(c);
791  assert(FoundPartInCell);
792 }
793 void DdFixedSize::MovePart(int p,double *OldPos,double *NewPos){
794  int c1 = pCella(OldPos);
795  int c2 = pCella(NewPos);
796  if(c1 == c2) return;
797  RemPart(p,c1);
798  AddPart(p,c2);
799 }
800 void DdFixedSize::SwapPart(int p1,double *Pos1,int p2,double *Pos2){
801  int c1 = pCella(Pos1);
802  int c2 = pCella(Pos2);
803  if(c1 == c2) return;
804  RemPart(p1,c1);
805  RemPart(p2,c2);
806  AddPart(p1,c2);
807  AddPart(p2,c1);
808 }
810  //if(Cella[c].Part.size() == 0) return;
811  NCurr = 0;
812  NCurr2 = 0;
813  if(Cella[c].NPart > 0) NCurr2++;
814 };
816  if(NCurr == Cella[c].NPart) return 0;
817  return 1;
818 };
820  NCurr++;
821 }
823  return Cella[c].Part[NCurr];
824 }
825 void DdFixedSize::Couple(const int c,int *p1,int *p2){
826  // printf("%d %d %d\n",NCurr,NCurr2,Cella[c].NPart);
827  *p1 = Cella[c].Part[NCurr];
828  *p2 = Cella[c].Part[NCurr2];
829 }
830 int DdFixedSize::IfItCouple(const int c){
831  if(NCurr >= Cella[c].NPart)
832  return 0;
833  return 1;
834 }
835 void DdFixedSize::IncrCurrList(const int c){
836  NCurr2++;
837  if(NCurr2 >= Cella[c].NPart){
838  NCurr2 = NCurr;
839  NCurr2++;
840  NCurr++;
841  }
842 }
843 void DdFixedSize::PrintCell(const int c){
844  for(SetCounters(c);IfItCell(c);IncrCurr(c)){
845  int p = ItCell(c);
846  printf("%d) # %d %d\n",c,Cella[c].NPart,ItCell(c));
847  }
848 }
850  for(int c=0;c<NCell;c++)
851  PrintCell(c);
852 }
853 //-------------------DOUBLE-LOOP-------------------------------
855 DdDoubleLoop::DdDoubleLoop(double EdgeExt[3],int NPartExt,double CutOffExt){
856  for(int d=0;d<3;d++){
857  Edge[d] = EdgeExt[d];
858  InvEdge[d] = 1./Edge[d];
859  NSect[d] = 1;
860  }
861  NPart = 0;
862  SetCutOff(CutOffExt);
863  Mod10[0] = 1;
864  Mod10[1] = 1;
865  Mod10[2] = 1;
866  NCell = 0;
867  Cella = new DomCell[NCell];
868  SigErr(Cella==NULL,"DomCell not allocated\n");
869  for(int c=0;c<NCell;c++){
870  Cella[c].NPart = 0;
871  Cella[c].First = Cella[c].Last = -2;
872  }
873  NAllocP = NPartExt + 2000;
874  Pc = new DOMAIN_PART[NAllocP];
875  SigErr(Pc == NULL,"DOMAIN_PART not allocated\n");
876 }
879  for(int c=0;c<NCell;c++){
880  Cella[c].NPart = 0;
881  Cella[c].Last = -1;
882  }
883  for(int p=0;p<NPart;p++){
884  Pc[p].Cell = -1;
885  Pc[p].Next = -1;
886  Pc[p].Prev = -2;
887  }
888  NPart = 0;
889 }
891 int DdDoubleLoop::SetCoorNumb(double *Pos,int p){
892  Pc[p].Coord = GetCoorNumb(Pos);
893  return Pc[p].Coord;
894 }
896 void DdDoubleLoop::AddPart(const int p,double *Pos){
897  for(int d=0;d<3;d++) Pc[p].Pos[d] = Pos[d];
898  AddPart(p,0);
899 }
901 void DdDoubleLoop::AddPart(const int p,const int c){
902  Cella[c].NPart++;
903  NPart++;
904  Cella[c].Last = p;
905  Pc[p].Cell = c;
906  Pc[p].Next = -1;
907 }
909 void DdDoubleLoop::RemPart(const int p,double *Pos){
910  RemPart(p,0);
911 }
913 void DdDoubleLoop::RemPart(const int p,const int c){
914  Cella[c].NPart--;
915  NPart--;
916  if(Cella[c].NPart == 0){
917  Cella[c].First = -2;
918  Cella[c].Last = -1;
919  }
920  else{
921  int pp = Pc[p].Prev;
922  int pn = Pc[p].Next;
923  if(pp == -2) Cella[c].First = pn;
924  else Pc[pp].Next = pn;
925  if(pn == -1) Cella[c].Last = pp;
926  else Pc[pn].Prev = pp;
927  Pc[p].Cell = -1;
928  }
929 }
931 void DdDoubleLoop::RemPart(const int p){
932  RemPart(p,0);
933 }
935 int DdDoubleLoop::SwapPart(int p1,double *Pos1,int p2,double *Pos2){
936  printf("Swap part disabled\n");
937 }
939 void DdDoubleLoop::MovePart(const int p,double *NewPos){
940  printf("Move part disabled\n");
941 }
943 void DdDoubleLoop::MovePart(const int p,double *OldPos,double *NewPos){
944  printf("Move part disabled\n");
945 }
948  p1Curr = 0;
949  p2Curr = 1;
950  cCurr = 0;
951 }
952 int DdDoubleLoop::ItCell(const int c){
953  return 0;
954 }
956 int DdDoubleLoop::IfItCell(const int c){
957  if(p1Curr == NPart) return 0;
958  return 1;
959 }
961 void DdDoubleLoop::IncrCurr(const int c){
962  p2Curr++;
963  if(p2Curr <= NPart){
964  p1Curr++;
965  p2Curr = p1Curr+1;
966  }
967 }
969 void DdDoubleLoop::PrintCell(const int c){
970  for(SetCounters(c);IfItCell(c);IncrCurr(c)){
971  int p = ItCell(c);
972  printf("%d) # %d %d_%d_%d %x\n",c,Cella[c].NPart,Pc[p].Prev,ItCell(c),Pc[p].Next,Pc[p].Coord);
973  }
974 }
977  for(int c=0;c<NCell;c++)
978  PrintCell(c);
979 }
982  cCurr = 0;
983  p1Curr = p;
984  p2Curr = p+1;
985 }
987  p2Curr++;
988 }
990  if(p2Curr == NPart) return 0;
991  return 1;
992 }
994 void DdDoubleLoop::Dist2Curr(double *DistRel){
995  for(int d=0;d<3;d++){
996  DistRel[d] = Pc[p1Curr].Pos[d] - Pc[p2Curr].Pos[d];
997  //TOFIX
998  //DistRel[d] += BoundCond[nNeiCurr][d]*Edge[d];
999  DistRel[d] -= floor(DistRel[d]*InvEdge[d] + .5)*Edge[d];
1000  }
1001  DistRel[3] = SQR(DistRel[0]) + SQR(DistRel[1]) + SQR(DistRel[2]);
1002 }
1003 //-----------------------------NeiVertex------------------------
1007 NeiVertex::NeiVertex(int NTriaExt,int NvPtExt,int NGridExt,double *EdgeExt){
1008  NTria = NTriaExt;
1009  NvPt = NvPtExt;
1010  NVert = NTria*NvPt;
1011  NGrid = 2*NGridExt-1;
1012  for(int d=0;d<3;d++){
1013  Edge[d] = EdgeExt[d];
1014  }
1015  Vertex = new VERTEX[NVert];
1016  vMemPos = new int[NVert];
1017  for(int v=0;v<NVert;v++){
1018  Vertex[v].NTria = 0;
1019  }
1020  NVert = 0;
1021 }
1023  delete [] Vertex;
1024 }
1025 int NeiVertex::GetVertex(double *Pos){
1026  int s[3] = {0,0,0};
1027  for(int d=0;d<3;d++){
1028  s[d] = (int)(Pos[d]/Edge[d]*NGrid);
1029  }
1030  return (s[0]*NGrid+s[1])*NGrid+s[2];
1031 }
1032 void NeiVertex::Add(double *Pos,int t){
1033  int v = GetVertex(Pos);
1034  Add(v,t,Pos);
1035 }
1036 void NeiVertex::Add(int v,int t,double *Pos){
1037  Vertex[NVert].v = v;
1038  for(int d=0;d<3;d++)
1039  Vertex[NVert].Pos[d] = Pos[d];
1040  Vertex[NVert].t[0] = t;
1041  //printf("Add %d %d %d\n",NVert,Vertex[NVert].v,Vertex[NVert].t[0]);
1042  NVert++;
1043 }
1045  Vert1.v = Vert2.v;
1046  Vert1.NTria = Vert2.NTria;
1047  for(int d=0;d<3;d++) Vert1.Pos[d] = Vert2.Pos[d];
1048  for(int t=0;t<Vert1.NTria;t++) Vert1.t[t] = Vert2.t[t];
1049 }
1050 void NeiVertex::Swap(int v1,int v2){
1051  VERTEX Vert = Vertex[v1];
1052  Vertex[v1] = Vertex[v2];
1053  Vertex[v2] = Vert;
1054  CopyVert2To1(Vert,Vertex[v1]);
1055  CopyVert2To1(Vertex[v1],Vertex[v2]);
1056  CopyVert2To1(Vertex[v2],Vert);
1057 }
1059  //sorting
1060  for(int i=0;i<NVert;i++){
1061  for(int j=i;j>0;j--){
1062  if(Vertex[j].v < Vertex[j-1].v){
1063  Swap(j-1,j);
1064  }
1065  else
1066  break;
1067  }
1068  }
1069  for(int v=0;v<NVert;v++){
1070  int NDel = 0;
1071  Vertex[v].NTria = 1;
1072  for(int vv=v+1;Vertex[vv].v == Vertex[vv-1].v;vv++){
1073  if(vv > NVert) break;
1074  int t = vv-v;
1075  Vertex[v].t[t] = Vertex[vv].t[0];
1076  Vertex[v].NTria = t+1;
1077  NDel++;
1078  SigErr(NDel>MAX_JOINT_VERTEX,"Neighbour Vertices: the vertex has more conjunction points than expected\n");
1079  }
1080  for(int d=1;d<NDel+1;d++){
1081  for(int vv=v+1;vv<NVert-1;vv++){
1082  Swap(vv,vv+1);
1083  }
1084  }
1085  NVert -= NDel;
1086  }
1087 }
1089  vCurr = 0;
1090  tCurr = 0;
1091 }
1094  for(int vv=vCurr;vv<NVert;vv++){
1095  if(Vertex[vv].v == v){
1096  vCurr = vv;
1097  break;
1098  }
1099  }
1100  tCurr = 0;
1101 }
1103  if(tCurr == Vertex[vCurr].NTria) return 0;
1104  return 1;
1105 }
1107  tCurr++;
1108 }
1110  return vCurr;
1111 }
1113  return Vertex[vCurr].t[tCurr];
1114 }
1116  SetCounters();
1117  for(int v=0;v<NVert;v++){
1118  printf("---- (%d) ----\n",Vertex[v].v);
1119  for(SetCounters(v);IfItCell(v);IncrCurr(v)){
1120  printf("%d - ",VertCurr(v));
1121  }
1122  printf("\n");
1123  }
1124  SetCounters();
1125 }
int Coord
Coordination number.
Definition: Cubo.h:134
void AddPart(const int p, double *Pos)
Add a particle to the cell c.
Definition: Cubo.cpp:276
int IfItCouple(const int c)
Tell when the loop is over.
Definition: Cubo.cpp:701
DdLinkedList(double Edge[3], int NPart, double CutOff)
Allocate.
Definition: Cubo.cpp:232
void SigErr(int Condition, const char *s,...)
Handle errors.
Definition: Cubo.cpp:24
void PrintCells()
Print the the particles in the cells.
Definition: Cubo.cpp:446
void MovePart(int p, double *OldPos, double *NewPos)
Move a part.
Definition: Cubo.cpp:793
void Couple(const int c, int *p1, int *p2)
Returns the pointed couple of particle.
Definition: Cubo.cpp:825
int NCell
Number of cells.
Definition: Cubo.h:57
int VertCurr(int v)
Current vertex iterator for the vertex v.
Definition: Cubo.cpp:1109
void RemPart(int p, double *Pos)
Remove a part from the cell.
Definition: Cubo.cpp:768
int GetCellCoord(int c, int Coord, int *NeiList)
Get the number of the neighbouring cells for the particles close to a wall.
Definition: Cubo.cpp:121
int SetCutOff(double CutOffExt)
Set the CutOff.
Definition: Cubo.cpp:40
DdFixedSize(double EdgeExt[3], int NPart, double CutOff)
Allocate.
Definition: Cubo.cpp:728
void Erase()
Erase the content of the cells.
Definition: Cubo.cpp:747
void SetCounters(int c)
Set the counters to the initial position.
Definition: Cubo.cpp:413
int cCurr
Cell where the current particle sits.
Definition: Cubo.h:41
int IfItCell(int c)
End the iteration in the cell.
Definition: Cubo.cpp:815
void Erase()
Erase the pairlist.
Definition: Cubo.cpp:258
The array of particles in every cell.
Definition: Cubo.h:322
double BoundCond[27][3]
Boundary condition for the cell consider.
Definition: Cubo.h:39
void IncrCurrList(const int c)
Increment the pointers.
Definition: Cubo.cpp:706
void PrintCell(const int c)
Print the content of one cell.
Definition: Cubo.cpp:843
int NSect[3]
Number of cells per direction.
Definition: Cubo.h:59
int IfItCouple(const int c)
Stop the loop and set the counter to zero.
Definition: Cubo.cpp:572
DomPart & operator++()
Increase the iterator, deactivated.
Definition: Cubo.cpp:616
int GetCellCh(int c, int *NeiList)
Get the number of the neighbouring cells.
Definition: Cubo.cpp:64
void PrintCell(const int c)
Print the particles in a cell.
Definition: Cubo.cpp:439
void Dist2CurrGhost(double *DistRel)
Retrun the squared current interparticle distance.
Definition: Cubo.cpp:554
~NeiVertex()
Delete the class.
Definition: Cubo.cpp:1022
void AddPart(int p, double *Pos)
Add a part to the cell.
Definition: Cubo.cpp:654
void SetCounters(int c)
Set the counters to the initial pointer.
Definition: Cubo.cpp:809
NeiVertex(int NTriaExt, int NvPtExt, int NGridExt, double *EdgeExt)
Alloc NVertices.
Definition: Cubo.cpp:1007
int IfItCell(int v)
End of the counters.
Definition: Cubo.cpp:1102
void RemPart(const int p, double *Pos)
Remove a particle form the cell c.
Definition: Cubo.cpp:307
int NPart
Total number of particle.
Definition: Cubo.h:71
void SwapPart(int p1, double *Pos1, int p2, double *Pos2)
Swap two parts.
Definition: Cubo.cpp:800
int ItCell(int c)
Value of the current particle in the cell c.
Definition: Cubo.cpp:694
DomCell & operator=(const DomCell &Dc)
Return the cell class.
Definition: Cubo.cpp:619
void Print()
Print the entire structure.
Definition: Cubo.cpp:1115
void PrintCells()
Print the content of every cell.
Definition: Cubo.cpp:849
void SetCounters()
Set all the counters to zero.
Definition: Cubo.cpp:1088
int SetCoorNumb(double *Pos, int p)
Set the coordination umber to the part p.
Definition: Cubo.cpp:271
void PrintCell(const int c)
Print the content of one cell.
Definition: Cubo.cpp:714
void IncrCurr(int c)
Increase the counters.
Definition: Cubo.cpp:691
void IncrCurrList(const int c)
Increment the pointers.
Definition: Cubo.cpp:835
double Pos[3]
xyz Position of the particle
Definition: VarData.h:216
int IfItCell(int c)
End the iteration in the cell.
Definition: Cubo.cpp:687
The previuos and consecutive particle in the cell linked list.
Definition: Cubo.h:126
int FindClosest(int p1)
Find the closest neighbour.
Definition: Cubo.cpp:595
int IfItCell(const int c)
Stop the loop and set the counter to zero.
Definition: Cubo.cpp:427
int SetCoorNumb(double *Pos, int p)
Stop the loop and set the counter to zero.
Definition: Cubo.cpp:891
void Dist2Curr(double *DistRel)
Retrun the squared current interparticle distance.
Definition: Cubo.cpp:502
void AddPart(int p, double *Pos)
Add a part to the cell.
Definition: Cubo.cpp:755
double Pos[3]
Vertex postion.
Definition: Cubo.h:471
void Erase()
Erase the pairlist.
Definition: Cubo.cpp:878
int p1Curr
Reference particle.
Definition: Cubo.h:49
void PrintCell(const int c)
Print the content of a cell.
double CutOff
Cell CutOff.
Definition: Cubo.h:65
int ItCell(const int c)
Iterate in the cell.
Definition: Cubo.cpp:952
DdDoubleLoop(double Edge[3], int NPart, double CutOff)
Allocate.
Definition: Cubo.cpp:855
void IncrCurr(int c)
Increase the counters.
Definition: Cubo.cpp:819
void MovePart(const int p, double *OldPos, double *NewPos)
Move a particle form the cell c1 to the cell c2.
Definition: Cubo.cpp:943
int v
Vertex id.
Definition: Cubo.h:473
void Add(int v, int t, double *Pos)
Add the triangle t at the vertex v.
Definition: Cubo.cpp:1036
int IfCurrGhost()
Tell when the curr loop is over.
Definition: Cubo.cpp:550
void NextCurrGhost()
Increase the iterator to the next couple.
Definition: Cubo.cpp:536
void Couple(const int c, int *p1, int *p2)
Returns the pointed couple of particle.
Definition: Cubo.cpp:697
DomCell & operator++()
Increase the iterator, deactivated.
Definition: Cubo.cpp:611
void IncrCurr(const int c)
Increment the current part in the cell.
Definition: Cubo.cpp:961
int pNPart()
part in the class
Definition: Cubo.cpp:51
void IncrCurrList(const int c)
Increment the current iterators in the cell.
Definition: Cubo.cpp:582
void SetCurr(int p)
Gather information of the neighbouring cells.
Definition: Cubo.cpp:981
int IfLoopCurr
1 if the loop is over
Definition: Cubo.h:53
void IncrCurr(int v)
Increment the counter.
Definition: Cubo.cpp:1106
int * Part
Id of the particle.
Definition: Cubo.h:326
void IncrCurr(const int c)
Increment the current part in the cell.
Definition: Cubo.cpp:435
void CopyVert2To1(VERTEX Vert1, VERTEX Vert2)
Copy two vertices.
Definition: Cubo.cpp:1044
int pCella(const double Pos[3])
(x,y,z)->n
Definition: Cubo.cpp:192
int Mod10[3]
Module 10 (nx,ny,nz) -> nc.
Definition: Cubo.h:55
double Edge[3]
Box sizes.
Definition: Cubo.h:61
void PrintCell(const int c)
Print the particles in a cell.
Definition: Cubo.cpp:969
void Reorder()
Reorder and fill the vertices.
Definition: Cubo.cpp:1058
int Next
Next particle in the list.
Definition: Cubo.h:130
int IfItCell(const int c)
Stop the loop and set the counter to zero.
Definition: Cubo.cpp:956
void NextCurr()
Increase the iterator to the next couple.
Definition: Cubo.cpp:479
void RemPart(const int p, double *Pos)
Remove a particle form the cell c.
Definition: Cubo.cpp:909
int NeiListCurr[27]
Neighbouring list.
Definition: Cubo.h:43
void PrintCells()
Print the the particles in the cells.
Definition: Cubo.cpp:976
int NNeiCurr
Number of neighbouring cells.
Definition: Cubo.h:45
The array of particles in every cell.
Definition: Cubo.h:256
int NTria
Number of triangles connected to the vertex.
Definition: Cubo.h:477
int Cell
Which cell it&#39;s belonging.
Definition: Cubo.h:136
void RemPart(int p, double *Pos)
Remove a part from the cell.
Definition: Cubo.cpp:659
int operator[](int col)
Returns a entry.
Definition: Cubo.cpp:627
void Swap(int v1, int v2)
Swap to vertices.
Definition: Cubo.cpp:1050
int nNeiCurr
Current number of neighbours.
Definition: Cubo.h:47
void AddPart(const int p, double *Pos)
Add a particle to the cell c.
Definition: Cubo.cpp:896
int IfCurr()
Tell when the curr loop is over.
Definition: Cubo.cpp:989
int TriaCurr(int v)
Current triangle for the vertex v.
Definition: Cubo.cpp:1112
void SetCurrGhost(double *Pos)
Gather information of the neighbouring cells.
Definition: Cubo.cpp:512
DomDecBasics()
Allocate.
Definition: Cubo.cpp:17
int ItCell(const int c)
Iterate in the cell.
Definition: Cubo.cpp:421
Definition: Cubo.h:469
void SetCounters(int c)
Set the counters to the initial position.
Definition: Cubo.cpp:947
int t[MAX_JOINT_VERTEX]
Triangles/lines connected (fixed size!!! should be enough)
Definition: Cubo.h:475
int SwapPart(int p1, double *Pos1, int p2, double *Pos2)
Swap two particles.
Definition: Cubo.cpp:342
void SetCounters(int c)
Set the counters to the initial pointer.
Definition: Cubo.cpp:680
int GetCoorNumb(double *Pos)
Get the coordination number.
Definition: Cubo.cpp:212
int NAllocP
Number of allocated part.
Definition: Cubo.h:69
void SwapPart(int p1, double *Pos1, int p2, double *Pos2)
Swap two parts.
Definition: Cubo.cpp:671
void MovePart(int p, double *OldPos, double *NewPos)
Move a part.
Definition: Cubo.cpp:664
DdArray(double EdgeExt[3], int NPart, double CutOff)
Allocate.
Definition: Cubo.cpp:634
For every cube how many particles and which are the first and the last.
Definition: Cubo.h:142
void Dist2Curr(double *DistRel)
Retrun the squared current interparticle distance.
Definition: Cubo.cpp:994
int SwapPart(int p1, double *Pos1, int p2, double *Pos2)
Swap two particles.
Definition: Cubo.cpp:935
int IfCurr()
Tell when the curr loop is over.
Definition: Cubo.cpp:498
double InvEdge[3]
Inverse box size.
Definition: Cubo.h:63
int p2Curr
Current particle.
Definition: Cubo.h:51
void Erase()
Erase the content of the cells.
Definition: Cubo.cpp:649
int pNCell()
Print the number of cells.
Definition: Cubo.cpp:55
void MovePart(const int p, double *OldPos, double *NewPos)
Move a particle form the cell c1 to the cell c2.
Definition: Cubo.cpp:403
int IfItCouple(const int c)
Tell when the loop is over.
Definition: Cubo.cpp:830
void SetCurr(int p)
Gather information of the neighbouring cells.
Definition: Cubo.cpp:453
int Prev
Previous particle in the list.
Definition: Cubo.h:132
void NextCurr()
Increase the iterator to the next couple.
Definition: Cubo.cpp:986
double PosCurr[3]
Position of the current particle.
Definition: Cubo.h:67
The previuos and consecutive particle in the cell linked list.
Definition: Cubo.h:114
int GetVertex(double *Pos)
Correspondent vertes for Pos.
Definition: Cubo.cpp:1025
int ItCell(int c)
Value of the current particle in the cell c.
Definition: Cubo.cpp:822
void PrintCells()
Print the content of every cell.
Definition: Cubo.cpp:720
void Couple(const int c, int *p1, int *p2)
Iterates along all couples.
Definition: Cubo.cpp:565
int GetCell(double *Pos, int *NeiList)
Get the number of the neighbouring cells for a ghost particle.
Definition: Cubo.cpp:59