Allink  v0.1
Cubo.h
1 /***********************************************************************
2 Cubo: Header file for the Cubo class.
3  Copyright (C) 2008 by Giovanni Marelli <sabeiro@virgilio.it>
4 
5 
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ***********************************************************************/
20 #ifndef CUBO_H
21 #define CUBO_H
22 #include <list>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <assert.h>
26 #include <math.h>
27 #include <stdarg.h>
28 #include <signal.h>
29 #include "Matematica.h"
30 #define MAX_JOINT_VERTEX 16
31 
32 
33 using namespace std;
36  private:
37  public:
39  double BoundCond[27][3];
41  int cCurr;
43  int NeiListCurr[27];
45  int NNeiCurr;
47  int nNeiCurr;
49  int p1Curr;
51  int p2Curr;
55  int Mod10[3];
57  int NCell;
59  int NSect[3];
61  double Edge[3];
63  double InvEdge[3];
65  double CutOff;
67  double PosCurr[3];
69  int NAllocP;
71  int NPart;
75  DomDecBasics();
77  void SigErr(int Condition,const char * s, ...);
79  int PosRet(const double Pos[3]);
81  int pNPart();
83  int pNCell();
85  int pCella(const double Pos[3]);
87  void pCella(const double Pos[3],int c[4]);
89  int GetCoorNumb(double *Pos);
91  int GetCellCoord(int c,int Coord,int *NeiList);
93  int GetCellCoord(double *Pos,int *NeiList);
95  int GetCellCh(int c,int *NeiList);
97  int GetCell(double *Pos,int *NeiList);
99  void PrintCell(const int c);
101  void PrintCells();
103  void PrintList(const int c);
105  void PrintLists();
107  void CheckList();
109  void CheckNei(int p);
111  int SetCutOff(double CutOffExt);
112 };
114 class DomPart {
115  private:
116  int *Prev;
117  int *Next;
118  int NPart;
119  public:
120  DomPart(int NPart);
122  int operator[](int col);
123  DomPart& operator++();
124 };
126 typedef struct {
128  double Pos[3];
130  int Next;
132  int Prev;
134  int Coord;
136  int Cell;
138  //double Pos[3];
139 } DOMAIN_PART;
142 class DomCell{
144  friend void operator+(DomCell &Dc);
145  public:
146  DomCell(){};
148  int NPart;
150  int First;
152  int Last;
154  int Curr1;
156  int Curr2;
157  DomCell& operator=(const DomCell &Dc);
158  DomCell& operator+=(const int i);
159  DomCell& operator++();
160 };
162 class DdLinkedList : public DomDecBasics{
163 private:
164 public:
166  DdLinkedList(double Edge[3],int NPart,double CutOff);
168  void Erase();
170  void Clear(){Erase();};
172  int SwapPart(int p1,double *Pos1,int p2,double *Pos2);
174  void AddPart(const int p,double *Pos);
176  void RemPart(const int p,double *Pos);
178  void RemPart(const int p);
180  void AddPart(const int p,const int c);
182  void RemPart(const int p,const int c);
184  void MovePart(const int p,double *OldPos,double *NewPos);
186  void MovePart(const int p,double *NewPos);
188  int PosRet(const double Pos[3]);
190  int pNPart(const int c){return Cella[c].NPart;};
192  int pNPart(){return NPart;};
194  int pCell(const int p){return Pc[p].Cell;};
196  int First(const int c){return Cella[c].First;};
198  int Next(const int p){return Pc[p].Next;};
200  int ItCell(const int c);
202  int IfItCell(const int c);
204  int IfItCouple(const int c);
206  int SetCoorNumb(double *Pos,int p);
208  int GetNei(double *Pos,int *NeiList){
209  return GetCell(Pos,NeiList);
210  // return GetCellCoord(Pos,NeiList);
211  }
213  void SetCounters(int c);
215  void Couple(const int c,int *p1,int *p2);
217  void PrintCell(const int c);
219  void PrintCells();
221  void SetCurr(int p);
223  void SetCurrGhost(double *Pos);
225  void NextCurr();
227  void NextCurrGhost();
229  int IfCurr();
231  int IfCurrGhost();
233  void Dist2Curr(double *DistRel);
235  void Dist2CurrGhost(double *DistRel);
237  void PrintList(const int c);
239  void PrintLists();
241  void CheckList();
243  void CheckNei(int p);
245  void IncrCurr(const int c);
247  void IncrCurrList(const int c);
249  int FindClosest(int p1);
254 };
256 typedef struct{
258  list <int> Part;
259 }DdCell;
262 private:
264  double Edge[3];
266  int NSect[3];
268  int Mod10[3];
270  int NPart;
272  int NCell;
274  double CutOff;
276  list <int>::iterator NCurr;
278  list <int>::iterator NCurr2;
279 public:
281  DdArray(double EdgeExt[3],int NPart,double CutOff);
285  void Erase();
287  void Clear(){Erase();};
289  void AddPart(int p,double *Pos);
291  void RemPart(int p,double *Pos);
293  void MovePart(int p,double *OldPos,double *NewPos);
295  void SwapPart(int p1,double *Pos1,int p2,double *Pos2);
297  void SetCounters(int c);
299  int IfItCell(int c);
301  void IncrCurr(int c);
303  int ItCell(int c);
305  int GetNei(double *Pos,int *NeiList){
306  return GetCell(Pos,NeiList);
307  }
309  void Couple(const int c,int *p1,int *p2);
311  int IfItCouple(const int c);
313  void IncrCurrList(const int c);
315  int pNCell(){return NCell;};
317  void PrintCell(const int c);
319  void PrintCells();
320 };
322 typedef struct{
324  int NPart;
326  int *Part;
327 }DdFixCell;
330 private:
332  int NPCell;
334  int NCurr;
336  int NCurr2;
337 public:
339  DdFixedSize(double EdgeExt[3],int NPart,double CutOff);
343  void Erase();
345  void Clear(){Erase();};
347  void AddPart(int p,double *Pos);
349  void RemPart(int p,double *Pos);
351  void AddPart(int p,int c);
353  void RemPart(int p1,int c);
355  void MovePart(int p,double *OldPos,double *NewPos);
357  void SwapPart(int p1,double *Pos1,int p2,double *Pos2);
359  void SetCounters(int c);
361  int IfItCell(int c);
363  void IncrCurr(int c);
365  int ItCell(int c);
367  int GetNei(double *Pos,int *NeiList){
368  return GetCell(Pos,NeiList);
369  }
371  void Couple(const int c,int *p1,int *p2);
373  int IfItCouple(const int c);
375  void IncrCurrList(const int c);
377  void PrintCell(const int c);
379  void PrintCells();
380 };
382 class DdDoubleLoop : public DomDecBasics{
383 private:
384 public:
386  DdDoubleLoop(double Edge[3],int NPart,double CutOff);
388  void Erase();
390  void Clear(){Erase();};
392  int SwapPart(int p1,double *Pos1,int p2,double *Pos2);
394  void AddPart(const int p,double *Pos);
396  void RemPart(const int p,double *Pos);
398  void RemPart(const int p);
400  void AddPart(const int p,const int c);
402  void RemPart(const int p,const int c);
404  void MovePart(const int p,double *OldPos,double *NewPos);
406  void MovePart(const int p,double *NewPos);
408  int PosRet(const double Pos[3]);
410  int pNPart(const int c){return Cella[c].NPart;};
412  int pNPart(){return NPart;};
414  int pCell(const int p){return Pc[p].Cell;};
416  int First(const int c){return Cella[c].First;};
418  int Next(const int p){return Pc[p].Next;};
420  int ItCell(const int c);
422  int IfItCell(const int c);
424  int SetCoorNumb(double *Pos,int p);
426  int GetNei(double *Pos,int *NeiList){
427  return GetCell(Pos,NeiList);
428  // return GetCellCoord(Pos,NeiList);
429  }
431  void SetCounters(int c);
433  void PrintCell(const int c);
435  void PrintCells();
437  void SetCurr(int p);
439  void NextCurr();
441  int IfCurr();
443  void Dist2Curr(double *DistRel);
445  void PrintList(const int c);
447  void PrintLists();
449  void CheckList();
451  void CheckNei(int p);
453  void IncrCurr(const int c);
455  void IncrCurrList(const int c);
460 };
461 /* typedef struct { */
462 /* /// Position */
463 /* double Pos[3]; */
464 /* } PPOS; */
465 /* typedef struct { */
466 /* /// Vertex id */
467 /* list <int> v; */
468 /* } VERTEX; */
469 typedef struct {
471  double Pos[3];
473  int v;
475  int t[MAX_JOINT_VERTEX];
477  int NTria;
478 } VERTEX;
480 class NeiVertex{
481  private:
483  //list <int>::iterator tCurr;
484  int tCurr;
486  int vCurr;
489  VERTEX *Vertex;
490  /* /// List of positions */
491  /* list <PPOS> vPos; */
493  int *vMemPos;
495  double Edge[3];
497  int NGrid;
499  int NVert;
501  int NTria;
503  int NvPt;
504  public:
506  NeiVertex(int NTriaExt,int NvPtExt,int NGridExt,double *EdgeExt);
508  ~NeiVertex();
510  void Add(int v,int t,double *Pos);
512  void Add(double *Pos,int t);
514  void Rem(int v,int t);
516  void CopyVert2To1(VERTEX Vert1,VERTEX Vert2);
518  void Swap(int v1,int v2);
520  void Reorder();
522  void SetCounters(int v);
524  void SetCounters();
526  int GetVertex(double *Pos);
528  int IfItCell(int v);
530  void IncrCurr(int v);
532  int VertCurr(int v);
534  int TriaCurr(int v);
536  void PosVertex(int v,double *Pos);
538  void Print();
539 };
540 
541 #endif //CUBO_H
int Coord
Coordination number.
Definition: Cubo.h:134
int NCell
Number of cells.
Definition: Cubo.h:57
int GetNei(double *Pos, int *NeiList)
Choose among the different neighbouring lists.
Definition: Cubo.h:305
void Clear()
Clear the pairlist.
Definition: Cubo.h:287
int cCurr
Cell where the current particle sits.
Definition: Cubo.h:41
The array of particles in every cell.
Definition: Cubo.h:322
int pNCell()
Print the number of cells.
Definition: Cubo.h:315
int pCell(const int p)
Print the cell which the particle belong.
Definition: Cubo.h:414
int Next(const int p)
Next linked part.
Definition: Cubo.h:418
int pNPart()
part in the class
Definition: Cubo.h:412
int Curr1
First pointed particle;.
Definition: Cubo.h:154
void Clear()
Clear the pairlist.
Definition: Cubo.h:170
int NPart
Total number of particle.
Definition: Cubo.h:71
int First(const int c)
First part in the cell.
Definition: Cubo.h:196
STL namespace.
Connects the triangles by vertices.
Definition: Cubo.h:480
int Next(const int p)
Next linked part.
Definition: Cubo.h:198
int First
First particle in the cell.
Definition: Cubo.h:150
The previuos and consecutive particle in the cell linked list.
Definition: Cubo.h:126
int GetNei(double *Pos, int *NeiList)
Choose among the different neighbouring lists.
Definition: Cubo.h:367
Stupid double loop to check the other pair loops.
Definition: Cubo.h:382
int p1Curr
Reference particle.
Definition: Cubo.h:49
double CutOff
Cell CutOff.
Definition: Cubo.h:65
int GetNei(double *Pos, int *NeiList)
Choose among the different neighbouring lists.
Definition: Cubo.h:426
DomCell * Cella
Number of particles and iterators per cell.
Definition: Cubo.h:457
Domain decomposition using arrays.
Definition: Cubo.h:329
int v
Vertex id.
Definition: Cubo.h:473
DdFixCell * Cella
Cell structure.
Definition: Cubo.h:341
void Clear()
Clear the pairlist.
Definition: Cubo.h:345
DdCell * Cella
Cell structure.
Definition: Cubo.h:283
int IfLoopCurr
1 if the loop is over
Definition: Cubo.h:53
int * Part
Id of the particle.
Definition: Cubo.h:326
int Next
Next particle in the list.
Definition: Cubo.h:130
int pNPart(const int c)
part in the cell
Definition: Cubo.h:410
int Curr2
Second pointed particle;.
Definition: Cubo.h:156
int Last
Last particle in the cell.
Definition: Cubo.h:152
DomCell * Cella
Number of particles and iterators per cell.
Definition: Cubo.h:251
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
All the general functions shared among the different domain decomposition structures.
Definition: Cubo.h:35
int Cell
Which cell it&#39;s belonging.
Definition: Cubo.h:136
list< int > Part
Id of the particle.
Definition: Cubo.h:258
int nNeiCurr
Current number of neighbours.
Definition: Cubo.h:47
DOMAIN_PART * Pc
List of position of the particles.
Definition: Cubo.h:459
int GetNei(double *Pos, int *NeiList)
Choose among the different neighbouring lists.
Definition: Cubo.h:208
Definition: Cubo.h:469
DOMAIN_PART * Pc
List of position of the particles.
Definition: Cubo.h:253
Domain decomposition using arrays.
Definition: Cubo.h:261
int NAllocP
Number of allocated part.
Definition: Cubo.h:69
int pNPart(const int c)
part in the cell
Definition: Cubo.h:190
int First(const int c)
First part in the cell.
Definition: Cubo.h:416
For every cube how many particles and which are the first and the last.
Definition: Cubo.h:142
int NNeighbour
Number of neighbours.
Definition: Cubo.h:73
int NPart
Number of particles in the cell.
Definition: Cubo.h:146
int pNPart()
part in the class
Definition: Cubo.h:192
void Clear()
Clear the pairlist.
Definition: Cubo.h:390
int p2Curr
Current particle.
Definition: Cubo.h:51
Domain decomposition as pointer to linked particles.
Definition: Cubo.h:162
int Prev
Previous particle in the list.
Definition: Cubo.h:132
The previuos and consecutive particle in the cell linked list.
Definition: Cubo.h:114
int NPart
How many particles.
Definition: Cubo.h:324
int pCell(const int p)
Print the cell which the particle belong.
Definition: Cubo.h:194