Allink
v0.1
|
00001 /*********************************************************************** 00002 Cubo: Header file for the Cubo class. 00003 Copyright (C) 2008 by Giovanni Marelli <sabeiro@virgilio.it> 00004 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 ***********************************************************************/ 00020 #ifndef CUBO_H 00021 #define CUBO_H 00022 #include <list> 00023 #include <stdio.h> 00024 #include <stdlib.h> 00025 #include <assert.h> 00026 #include <math.h> 00027 #include <stdarg.h> 00028 #include <signal.h> 00029 #include "Matematica.h" 00030 #define MAX_JOINT_VERTEX 16 00031 00032 00033 using namespace std; 00035 class DomDecBasics{ 00036 private: 00037 public: 00039 double BoundCond[27][3]; 00041 int cCurr; 00043 int NeiListCurr[27]; 00045 int NNeiCurr; 00047 int nNeiCurr; 00049 int p1Curr; 00051 int p2Curr; 00053 int IfLoopCurr; 00055 int Mod10[3]; 00057 int NCell; 00059 int NSect[3]; 00061 double Edge[3]; 00063 double InvEdge[3]; 00065 double CutOff; 00067 double PosCurr[3]; 00069 int NAllocP; 00071 int NPart; 00073 int NNeighbour; 00075 DomDecBasics(); 00077 void SigErr(int Condition,const char * s, ...); 00079 int PosRet(const double Pos[3]); 00081 int pNPart(); 00083 int pNCell(); 00085 int pCella(const double Pos[3]); 00087 void pCella(const double Pos[3],int c[4]); 00089 int GetCoorNumb(double *Pos); 00091 int GetCellCoord(int c,int Coord,int *NeiList); 00093 int GetCellCoord(double *Pos,int *NeiList); 00095 int GetCellCh(int c,int *NeiList); 00097 int GetCell(double *Pos,int *NeiList); 00099 void PrintCell(const int c); 00101 void PrintCells(); 00103 void PrintList(const int c); 00105 void PrintLists(); 00107 void CheckList(); 00109 void CheckNei(int p); 00111 int SetCutOff(double CutOffExt); 00112 }; 00114 class DomPart { 00115 private: 00116 int *Prev; 00117 int *Next; 00118 int NPart; 00119 public: 00120 DomPart(int NPart); 00122 int operator[](int col); 00123 DomPart& operator++(); 00124 }; 00126 typedef struct { 00128 double Pos[3]; 00130 int Next; 00132 int Prev; 00134 int Coord; 00136 int Cell; 00138 //double Pos[3]; 00139 } DOMAIN_PART; 00142 class DomCell{ 00144 friend void operator+(DomCell &Dc); 00145 public: 00146 DomCell(){}; 00148 int NPart; 00150 int First; 00152 int Last; 00154 int Curr1; 00156 int Curr2; 00157 DomCell& operator=(const DomCell &Dc); 00158 DomCell& operator+=(const int i); 00159 DomCell& operator++(); 00160 }; 00162 class DdLinkedList : public DomDecBasics{ 00163 private: 00164 public: 00166 DdLinkedList(double Edge[3],int NPart,double CutOff); 00168 void Erase(); 00170 void Clear(){Erase();}; 00172 int SwapPart(int p1,double *Pos1,int p2,double *Pos2); 00174 void AddPart(const int p,double *Pos); 00176 void RemPart(const int p,double *Pos); 00178 void RemPart(const int p); 00180 void AddPart(const int p,const int c); 00182 void RemPart(const int p,const int c); 00184 void MovePart(const int p,double *OldPos,double *NewPos); 00186 void MovePart(const int p,double *NewPos); 00188 int PosRet(const double Pos[3]); 00190 int pNPart(const int c){return Cella[c].NPart;}; 00192 int pNPart(){return NPart;}; 00194 int pCell(const int p){return Pc[p].Cell;}; 00196 int First(const int c){return Cella[c].First;}; 00198 int Next(const int p){return Pc[p].Next;}; 00200 int ItCell(const int c); 00202 int IfItCell(const int c); 00204 int IfItCouple(const int c); 00206 int SetCoorNumb(double *Pos,int p); 00208 int GetNei(double *Pos,int *NeiList){ 00209 return GetCell(Pos,NeiList); 00210 // return GetCellCoord(Pos,NeiList); 00211 } 00213 void SetCounters(int c); 00215 void Couple(const int c,int *p1,int *p2); 00217 void PrintCell(const int c); 00219 void PrintCells(); 00221 void SetCurr(int p); 00223 void SetCurrGhost(double *Pos); 00225 void NextCurr(); 00227 void NextCurrGhost(); 00229 int IfCurr(); 00231 int IfCurrGhost(); 00233 void Dist2Curr(double *DistRel); 00235 void Dist2CurrGhost(double *DistRel); 00237 void PrintList(const int c); 00239 void PrintLists(); 00241 void CheckList(); 00243 void CheckNei(int p); 00245 void IncrCurr(const int c); 00247 void IncrCurrList(const int c); 00249 int FindClosest(int p1); 00251 DomCell *Cella; 00253 DOMAIN_PART *Pc; 00254 }; 00256 typedef struct{ 00258 list <int> Part; 00259 }DdCell; 00261 class DdArray : DomDecBasics{ 00262 private: 00264 double Edge[3]; 00266 int NSect[3]; 00268 int Mod10[3]; 00270 int NPart; 00272 int NCell; 00274 double CutOff; 00276 list <int>::iterator NCurr; 00278 list <int>::iterator NCurr2; 00279 public: 00281 DdArray(double EdgeExt[3],int NPart,double CutOff); 00283 DdCell *Cella; 00285 void Erase(); 00287 void Clear(){Erase();}; 00289 void AddPart(int p,double *Pos); 00291 void RemPart(int p,double *Pos); 00293 void MovePart(int p,double *OldPos,double *NewPos); 00295 void SwapPart(int p1,double *Pos1,int p2,double *Pos2); 00297 void SetCounters(int c); 00299 int IfItCell(int c); 00301 void IncrCurr(int c); 00303 int ItCell(int c); 00305 int GetNei(double *Pos,int *NeiList){ 00306 return GetCell(Pos,NeiList); 00307 } 00309 void Couple(const int c,int *p1,int *p2); 00311 int IfItCouple(const int c); 00313 void IncrCurrList(const int c); 00315 int pNCell(){return NCell;}; 00317 void PrintCell(const int c); 00319 void PrintCells(); 00320 }; 00322 typedef struct{ 00324 int NPart; 00326 int *Part; 00327 }DdFixCell; 00329 class DdFixedSize : DomDecBasics{ 00330 private: 00332 int NPCell; 00334 int NCurr; 00336 int NCurr2; 00337 public: 00339 DdFixedSize(double EdgeExt[3],int NPart,double CutOff); 00341 DdFixCell *Cella; 00343 void Erase(); 00345 void Clear(){Erase();}; 00347 void AddPart(int p,double *Pos); 00349 void RemPart(int p,double *Pos); 00351 void AddPart(int p,int c); 00353 void RemPart(int p1,int c); 00355 void MovePart(int p,double *OldPos,double *NewPos); 00357 void SwapPart(int p1,double *Pos1,int p2,double *Pos2); 00359 void SetCounters(int c); 00361 int IfItCell(int c); 00363 void IncrCurr(int c); 00365 int ItCell(int c); 00367 int GetNei(double *Pos,int *NeiList){ 00368 return GetCell(Pos,NeiList); 00369 } 00371 void Couple(const int c,int *p1,int *p2); 00373 int IfItCouple(const int c); 00375 void IncrCurrList(const int c); 00377 void PrintCell(const int c); 00379 void PrintCells(); 00380 }; 00382 class DdDoubleLoop : public DomDecBasics{ 00383 private: 00384 public: 00386 DdDoubleLoop(double Edge[3],int NPart,double CutOff); 00388 void Erase(); 00390 void Clear(){Erase();}; 00392 int SwapPart(int p1,double *Pos1,int p2,double *Pos2); 00394 void AddPart(const int p,double *Pos); 00396 void RemPart(const int p,double *Pos); 00398 void RemPart(const int p); 00400 void AddPart(const int p,const int c); 00402 void RemPart(const int p,const int c); 00404 void MovePart(const int p,double *OldPos,double *NewPos); 00406 void MovePart(const int p,double *NewPos); 00408 int PosRet(const double Pos[3]); 00410 int pNPart(const int c){return Cella[c].NPart;}; 00412 int pNPart(){return NPart;}; 00414 int pCell(const int p){return Pc[p].Cell;}; 00416 int First(const int c){return Cella[c].First;}; 00418 int Next(const int p){return Pc[p].Next;}; 00420 int ItCell(const int c); 00422 int IfItCell(const int c); 00424 int SetCoorNumb(double *Pos,int p); 00426 int GetNei(double *Pos,int *NeiList){ 00427 return GetCell(Pos,NeiList); 00428 // return GetCellCoord(Pos,NeiList); 00429 } 00431 void SetCounters(int c); 00433 void PrintCell(const int c); 00435 void PrintCells(); 00437 void SetCurr(int p); 00439 void NextCurr(); 00441 int IfCurr(); 00443 void Dist2Curr(double *DistRel); 00445 void PrintList(const int c); 00447 void PrintLists(); 00449 void CheckList(); 00451 void CheckNei(int p); 00453 void IncrCurr(const int c); 00455 void IncrCurrList(const int c); 00457 DomCell *Cella; 00459 DOMAIN_PART *Pc; 00460 }; 00461 /* typedef struct { */ 00462 /* /// Position */ 00463 /* double Pos[3]; */ 00464 /* } PPOS; */ 00465 /* typedef struct { */ 00466 /* /// Vertex id */ 00467 /* list <int> v; */ 00468 /* } VERTEX; */ 00469 typedef struct { 00471 double Pos[3]; 00473 int v; 00475 int t[MAX_JOINT_VERTEX]; 00477 int NTria; 00478 } VERTEX; 00480 class NeiVertex{ 00481 private: 00483 //list <int>::iterator tCurr; 00484 int tCurr; 00486 int vCurr; 00489 VERTEX *Vertex; 00490 /* /// List of positions */ 00491 /* list <PPOS> vPos; */ 00493 int *vMemPos; 00495 double Edge[3]; 00497 int NGrid; 00499 int NVert; 00501 int NTria; 00503 int NvPt; 00504 public: 00506 NeiVertex(int NTriaExt,int NvPtExt,int NGridExt,double *EdgeExt); 00508 ~NeiVertex(); 00510 void Add(int v,int t,double *Pos); 00512 void Add(double *Pos,int t); 00514 void Rem(int v,int t); 00516 void CopyVert2To1(VERTEX Vert1,VERTEX Vert2); 00518 void Swap(int v1,int v2); 00520 void Reorder(); 00522 void SetCounters(int v); 00524 void SetCounters(); 00526 int GetVertex(double *Pos); 00528 int IfItCell(int v); 00530 void IncrCurr(int v); 00532 int VertCurr(int v); 00534 int TriaCurr(int v); 00536 void PosVertex(int v,double *Pos); 00538 void Print(); 00539 }; 00540 00541 #endif //CUBO_H