DSQSS
1.1
|
00001 #ifndef OBJECTS_H 00002 #define OBJECTS_H 00003 00004 //###################################################################### 00005 00006 #include <stdio.h> 00007 #include "name.h" 00008 #include "xml.h" 00009 #include "algorithm.hpp" 00010 00011 class BareSegment; 00012 class BareVertex; 00013 class Segment; 00014 class Vertex; 00015 class Worm; 00016 class Site; 00017 class Interaction; 00018 class UniformInterval; 00019 class RegisteredVertexInfo; 00020 00021 //###################################################################### 00022 //#### Object Declarations 00023 //###################################################################### 00024 00025 class BareSegment { 00026 00027 private: 00028 00029 static int lastID; 00030 int IDX; 00031 Vertex* _v[2]; 00032 int val; // the local state (0, 1, 2, ... , NX-1) 00033 Site* ONSITE; 00034 public: 00035 00036 void init() { 00037 val = 0; 00038 _v[0] = 0; 00039 _v[1] = 0; 00040 }; 00041 00042 void set(int x, Vertex& v0, Vertex& v1) { 00043 val = x; 00044 _v[0] = &v0; 00045 _v[1] = &v1; 00046 }; 00047 00048 BareSegment() { 00049 lastID++; 00050 IDX=lastID; 00051 init(); 00052 }; 00053 00054 ~BareSegment() { 00055 // printf("*** Destroying BareSegment\n"); 00056 }; 00057 00058 int id() const { return IDX; }; 00059 Vertex& V(int i) { return *_v[i]; }; 00060 Vertex& bottom() { return *_v[0]; }; 00061 Vertex& top() { return *_v[1]; }; 00062 void setV(int i, Vertex& v) { _v[i] = &v; }; 00063 void setBottom(Vertex& v) { _v[0] = &v; }; 00064 void setTop(Vertex& v) { _v[1] = &v; }; 00065 int X() { return val; }; 00066 void setX(int x) { val = x; }; 00067 double topTime(); 00068 double bottomTime(); 00069 double length(); 00070 void dump(); 00071 bool check(); 00072 00073 void dump_id(){cout << IDX << endl;}; 00074 00075 Site* getONSITE(){return ONSITE;}; 00076 void setONSITE(Site* on_site){ONSITE=on_site;}; 00077 00078 }; 00079 00080 int BareSegment::lastID = 0; 00081 00082 //###################################################################### 00083 00084 class Segment : public Linked<BareSegment> { 00085 00086 public: 00087 00088 Segment& cut( Vertex& V, int side); 00089 void erase(); 00090 void absorbNext(); 00091 Segment& prev() { return (Segment&)Linked<BareSegment>::prev(); }; 00092 Segment& next() { return (Segment&)Linked<BareSegment>::next(); }; 00093 bool operator==(Segment& s) { return this == &s; }; 00094 00095 }; 00096 00097 //###################################################################### 00098 00099 class BareVertex { 00100 00101 private: 00102 00103 static int lastID; 00104 int ID; 00105 VertexProperty* _VP; 00106 double TIME; 00107 Array<Segment*> _s; 00108 Interaction* ONINTERACTION; 00109 00110 public: 00111 00112 void init() { 00113 _VP = 0; 00114 TIME = -1.0; 00115 _s.init(); 00116 }; 00117 00118 void init_WORM(); 00119 00120 void init_TERM(Segment& S); 00121 00122 //Used when PlaceWorm 00123 void init(double t, VertexProperty& VP) { 00124 TIME = t; 00125 _s.init(1,VP.NLEG); // koko !!! 00126 _s.set_all(0); 00127 _VP = &VP; 00128 }; 00129 00130 void init(Interaction* O_I,double t, VertexProperty& VP) { 00131 TIME = t; 00132 _s.init(1,VP.NLEG); // koko !!! 00133 _s.set_all(0); 00134 _VP = &VP; 00135 ONINTERACTION = O_I; 00136 }; 00137 BareVertex() { 00138 _s.setLabel("BareVertex::_s"); 00139 lastID++; 00140 ID=lastID; 00141 init(); 00142 }; 00143 00144 ~BareVertex() { 00145 // printf("*** Destroying BareVertex (%d)\n", this); 00146 }; 00147 00148 int NBODY() const { 00149 if (isTerminal()) return 1; 00150 return (*_VP).NBODY; 00151 }; 00152 00153 int NLEG() const { 00154 return 2 * NBODY(); 00155 }; 00156 00157 bool isTerminal() const ; 00158 bool isTail() const ; 00159 00160 int id() const { return ID; }; 00161 00162 int size() const { return 2*NBODY(); }; 00163 00164 bool isKink(); 00165 00166 Segment& S(int i) { 00167 #ifdef DEB 00168 if ( _s[i] == 0 ) { 00169 printf("BareVertex::S> Error with i= %d\n", i); 00170 printf(" The segment pointer is not set ( _s[i]=0 ).\n"); 00171 } 00172 #endif 00173 return *_s[i]; 00174 }; 00175 00176 void setS(int dir, Segment& s) { _s[dir] = &s; }; 00177 00178 int X(int i); 00179 00180 double time() const { return TIME; }; 00181 00182 void setTime(double t) { TIME = t; }; 00183 00184 int which(Segment& s); 00185 00186 void replace(Segment& Sold, Segment& Snew); 00187 00188 bool check(); 00189 00190 void setProperty(VertexProperty& P) { _VP = &P; }; 00191 00192 int type() { 00193 if ( _VP == 0 ) { 00194 return VTYPE::UNDEF; 00195 } else { 00196 return property().id(); 00197 } 00198 } 00199 00200 int category() { 00201 if ( _VP == 0 ) { 00202 return VCAT::TERM; 00203 } else { 00204 return property().VCAT; 00205 } 00206 } 00207 00208 VertexProperty& property() { 00209 #ifdef DEB 00210 if ( _VP == 0 ) { 00211 printf("BareVertex::property> Error.\n"); 00212 printf(" Vertex property has not been set.\n"); 00213 exit(0); 00214 } 00215 #endif 00216 return *_VP; 00217 }; 00218 00219 VertexInitialConfiguration& getInitialConfiguration( int inc , int xinc ); 00220 00221 void dump(); 00222 Interaction* getONINTERACTION(){return ONINTERACTION;}; 00223 void setONINTERACTION( Interaction* on_interaction ){ONINTERACTION=on_interaction;}; 00224 00225 }; 00226 00227 int BareVertex::lastID = 0; 00228 00229 //###################################################################### 00230 00231 class Vertex : public Linked<BareVertex> { 00232 00233 public: 00234 00235 void reconnect(); // reconnect the segments attached to the vertex 00236 void erase(); // remove from the linked list and push back to the pool 00237 Vertex& prev() { return (Vertex&)Linked<BareVertex>::prev(); }; 00238 Vertex& next() { return (Vertex&)Linked<BareVertex>::next(); }; 00239 bool operator==(Vertex& v) { return this == &v; }; 00240 00241 }; 00242 00243 //###################################################################### 00244 00245 class Worm { 00246 00247 private: 00248 00249 int x_behind; // the local state just after a passage of the worm head 00250 Vertex* _vorg; // the vertex sitting at the creation point 00251 Vertex* _vcur; // the current vertex 00252 Segment* _scur; // the current segment 00253 00254 public: 00255 00256 Worm(); 00257 00258 ~Worm(); 00259 00260 Vertex& getNextVertex() { 00261 Vertex* _v = &(_scur->bottom()); 00262 if ( _v == _vcur ) _v = &(_scur->top()); 00263 return *_v; 00264 }; 00265 00266 Vertex& origin() { return *_vorg; }; 00267 00268 Vertex& getCurrentVertex() { return *_vcur; }; 00269 00270 void setCurrentVertex(Vertex& v) { _vcur = &v; }; 00271 00272 Segment& getCurrentSegment() { return *_scur; }; 00273 00274 void setCurrentSegment(Segment& s) { _scur = &s; }; 00275 00276 void setXBEHIND () { x_behind = STATE::UNDEF; }; 00277 00278 void setXBEHIND (int x) { x_behind = x; }; 00279 00280 int getXBEHIND() { 00281 #ifdef DEB 00282 if ( x_behind == STATE::UNDEF ) { 00283 printf("Worm::getXBEHIND> Error.\n x_behind = %d\n", x_behind); 00284 exit(0); 00285 } 00286 #endif 00287 return x_behind; 00288 }; 00289 00290 bool atOrigin() { return ( _vcur == _vorg ); }; 00291 00292 bool getUORD(){return ( _vcur == &( (*_scur).top() ));};//up -> false 0, down -> true 1 00293 bool getV(){printf("top,bottom = %d, %d ",(*_scur).top().id(),(*_scur).bottom().id());}; 00294 00295 void remove(); 00296 00297 void dump(); 00298 00299 }; 00300 00301 //###################################################################### 00302 00303 class Site : public Ring<Segment> { 00304 00305 private: 00306 00307 static int lastID; 00308 int ID; 00309 int MTYPE; // classification of sites used in measurements 00310 SiteProperty* _SP; 00311 Vertex* _vterm; 00312 00313 int NCI; // the number of connected interactions 00314 Interaction** ConnectedInteraction; //Interaction* ConnectedInteraction [ NCI ]; 00315 public: 00316 00317 void setNCI(int ni){ NCI = ni; ConnectedInteraction = new Interaction* [ni]; }; 00318 int getNCI(){ return NCI;}; 00319 void setCI(int nth, Interaction* CI){ ConnectedInteraction[nth] = CI; }; 00320 Interaction** getCI(){return ConnectedInteraction;}; 00321 00322 void init(SiteProperty& SP, int mt) { _SP = &SP; MTYPE = mt; }; 00323 00324 Site(); 00325 00326 ~Site(); 00327 00328 int id() { return ID; }; 00329 00330 int type() { 00331 if ( _SP == 0 ) return STYPE::UNDEF; 00332 return (*_SP).STYPE; 00333 }; 00334 00335 void setProperty(SiteProperty& sp) { _SP = &sp; }; 00336 00337 SiteProperty& Property() { return *_SP; }; 00338 00339 void setBeta(double b) { _vterm->setTime(b); }; 00340 00341 Segment& findS(double t); 00342 00343 void merge(Segment& S1); 00344 00345 int getMTYPE() { return MTYPE; }; 00346 00347 void dump() { 00348 // printf("Site::dump> Start.\n"); 00349 printf("Site(%2d) type= %d | ",id(),type()); 00350 Ring< Segment >::dump(); 00351 printf("\n"); 00352 }; 00353 00354 void idclear() { lastID=0; }; 00355 //void idclear() { cout << "dddd " << endl; }; 00356 00357 #ifdef CHAINJOB 00358 Vertex& getVterm(){return (*_vterm);}; 00359 #endif 00360 00361 }; 00362 00363 int Site::lastID = 0; 00364 00365 //###################################################################### 00366 00367 class Interaction : public Ring<Vertex> { 00368 00369 private: 00370 00371 static int lastID; 00372 int ID; 00373 InteractionProperty* _IP; 00374 Site** _s; 00375 00376 public: 00377 00378 void init() { 00379 _IP = 0; 00380 if ( _s != 0 ) { delete [] _s; } 00381 }; 00382 00383 void init(InteractionProperty& IP) { 00384 init(); 00385 _IP = &IP; 00386 _s = new Site* [(*_IP).NBODY]; 00387 }; 00388 00389 Interaction(); 00390 00391 ~Interaction(); 00392 00393 int id() { return ID; }; 00394 00395 int NBODY() { return (*_IP).NBODY; }; 00396 00397 int type() { return (*_IP).ITYPE; }; 00398 00399 void setProperty(InteractionProperty& ip) { _IP = &ip; }; 00400 00401 InteractionProperty& property() { 00402 #ifdef DEB 00403 if ( _IP == 0 ) { 00404 printf("InteractinProperty::property> Error.\n"); 00405 printf(" The property not defined.\n"); 00406 exit(0); 00407 } 00408 #endif 00409 return *_IP; 00410 }; 00411 00412 Site& site(int i) { return *(_s[i]); }; 00413 00414 void setSite(int i, Site& s) { 00415 #ifdef DEB 00416 if ( NBODY() == 0 ) { 00417 printf("Interaction::setSite> Error.\n"); 00418 printf(" Initialize before using!\n"); 00419 exit(0); 00420 } 00421 #endif 00422 _s[i] = &s; 00423 }; 00424 00425 void dump() { 00426 int* sid = new int [NBODY()]; 00427 for (int i=0; i<NBODY(); i++) { 00428 sid[i] = STYPE::UNDEF; 00429 if ( _s[i] != 0 ) sid[i] = site(i).id(); 00430 } 00431 printf("Interaction(%2d) = (", id()); 00432 for (int i=0; i<NBODY(); i++) printf(" %2d", sid[i]); 00433 printf(" ), type= %2d | ", type()); 00434 Ring<Vertex>::dump(); 00435 delete [] sid; 00436 }; 00437 00438 void idclear() { lastID=0; }; 00439 }; 00440 00441 int Interaction::lastID = 0; 00442 00443 //###################################################################### 00444 00445 Pool<Vertex> TheVertexPool; 00446 Pool<Segment> TheSegmentPool; 00447 00448 Interaction TerminalOfWorldline; 00449 Interaction TailOfWorm; 00450 00451 //###################################################################### 00452 //########### Member Functions ####################################### 00453 //###################################################################### 00454 00455 //###################################################################### 00456 00457 inline double BareSegment::topTime() { 00458 return top().time(); 00459 } 00460 00461 //====================================================================== 00462 00463 inline double BareSegment::bottomTime() { 00464 double t = bottom().time(); 00465 if ( bottom().isTerminal() ) t = 0.0; 00466 return t; 00467 } 00468 00469 //====================================================================== 00470 00471 inline double BareSegment::length() { 00472 return topTime() - bottomTime(); 00473 } 00474 00475 //====================================================================== 00476 00477 inline void BareSegment::dump() { 00478 // printf("\nBareSegment::dump> Start.\n"); 00479 fprintf(FERR," Segment [%3d] : ", id() ); 00480 double bt = 0.0; 00481 int bid = -1; 00482 if ( _v[0] != 0 ) { 00483 bt = bottomTime(); 00484 bid = bottom().id(); 00485 } 00486 double tt = 0.0; 00487 int tid = -1; 00488 if ( _v[1] != 0 ) { 00489 tt = topTime(); 00490 tid = top().id(); 00491 } 00492 if (bt >= tt) bt = 0.0; 00493 fprintf(FERR," <%3d>(%8.3f)---<%3d>(%8.3f)", bid, bt, tid, tt); 00494 fprintf(FERR," X=%d",X()); 00495 fprintf(FERR,"\n"); 00496 } 00497 00498 //====================================================================== 00499 00500 inline bool BareSegment::check() { 00501 bool ERROR = false; 00502 return ERROR; 00503 } 00504 00505 //###################################################################### 00506 00507 inline Segment& Segment::cut( Vertex& V , int side ) { 00508 // 00509 // before: --(V0)---------[S0]----------(V1)---> tau 00510 // 00511 // after: --<V0>---[S0]---<V>---[S1]---<V1>---> tau 00512 // 00513 int x = X(); //int X() { return val; }; 00514 00515 Vertex& V0 = bottom(); //Vertex& bottom() { return *_v[0]; }; Vertex* _v[2]; 00516 Vertex& V1 = top(); // Vertex& top() { return *_v[1]; }; 00517 Segment& S0 = *this; 00518 Segment& S1 = TheSegmentPool.pop(); 00519 insert_after(S1); 00520 S0.set( x, V0, V); 00521 S1.set( x, V, V1); 00522 S1.setONSITE( S0.getONSITE() ); 00523 int leg_below = 2 * side; 00524 int leg_above = leg_below + 1; 00525 V.setS( leg_below , S0); 00526 V.setS( leg_above , S1); 00527 // S1 は V1 の必ず下側なので0,2,4,...だけ調べればよい. 00528 for (int l=0; l<V1.NLEG(); l+=2) { 00529 if ( V1.S(l) == S0 ) { 00530 //printf(" gotcha!\n"); 00531 V1.setS( l , S1 ); 00532 } 00533 } 00534 return S1; 00535 } 00536 00537 //====================================================================== 00538 00539 inline void Segment::erase() { 00540 00541 Linked<BareSegment>::remove(); 00542 TheSegmentPool.push(*this); 00543 00544 } 00545 00546 //====================================================================== 00547 00548 inline void Segment::absorbNext() { 00549 00550 Segment& S0 = *this; 00551 Segment& S1 = S0.next(); 00552 Vertex& V1 = S1.top(); 00553 S0.setTop(V1); 00554 V1.replace(S1,S0); 00555 S1.erase(); 00556 00557 } 00558 00559 //###################################################################### 00560 00561 inline int BareVertex::X(int i) { 00562 return S(i).X(); 00563 } 00564 00565 //====================================================================== 00566 inline void BareVertex::init_WORM() { 00567 init(); 00568 _s.init(1,2); 00569 _s.set_all(0); 00570 ONINTERACTION = &TailOfWorm ; 00571 } 00572 //====================================================================== 00573 inline void BareVertex::init_TERM(Segment& S) { // initializer for a terminal vertex//katou 00574 init(); 00575 _s.init(1,2); 00576 _s.set_all(0); 00577 _s[0] = &S; 00578 _s[1] = &S; 00579 ONINTERACTION = &TerminalOfWorldline ; 00580 } 00581 //====================================================================== 00582 inline bool BareVertex::isTerminal() const { 00583 return (ONINTERACTION == &TerminalOfWorldline); 00584 } 00585 //====================================================================== 00586 inline bool BareVertex::isTail() const { 00587 return (ONINTERACTION == &TailOfWorm); 00588 } 00589 //====================================================================== 00590 00591 inline int BareVertex::which(Segment& s) { 00592 int i; 00593 for ( i=0; i<4; i++) { 00594 if ( _s[i] == &s ) return i; 00595 } 00596 printf("BareVertex::which> ERROR. No such segment.\n"); 00597 printf("tried to find the segment\n"); 00598 s.dump(); 00599 printf("in the vertex\n"); 00600 dump(); 00601 exit(0); 00602 } 00603 00604 //====================================================================== 00605 00606 void BareVertex::replace(Segment& Sold, Segment& Snew) { 00607 setS(which(Sold),Snew); 00608 } 00609 00610 //====================================================================== 00611 00612 inline bool BareVertex::isKink() { 00613 for (int i=0; i<NLEG(); i+=2) { 00614 if ( X(i) != X(i+1) ) return true; 00615 } 00616 return false; 00617 } 00618 00619 //====================================================================== 00620 00621 inline bool BareVertex::check() { 00622 00623 bool ERROR = false; 00624 for (int i=0; i<size(); i+=2) { 00625 Segment& S0 = S(i); 00626 Segment& S1 = S(i+1); 00627 if ( &S0.next() != &S1 ) ERROR = true; 00628 if ( &S1.prev() != &S0 ) ERROR = true; 00629 } 00630 if ( ERROR ) { 00631 printf("Vertex::check> ERROR.\n"); 00632 dump(); 00633 } 00634 return ERROR; 00635 00636 } 00637 00638 //====================================================================== 00639 00640 inline VertexInitialConfiguration& BareVertex::getInitialConfiguration( int inc , int xinc ) { 00641 00642 VertexProperty& P = property(); 00643 // int NLEG = 2 * P.NBODY; 00644 int NDIM = P.NLEG + 2; 00645 int* x = new int[NDIM]; //edit sakakura 00646 // int x[NDIM]; 00647 for (int i=0; i<P.NLEG; i++) x[i] = X(i); 00648 int st = P.StateCode(x); 00649 00650 #ifdef DEB 00651 if ( st == STATE::UNDEF ) { 00652 printf("BareVertex::getInitialConfiguration> Error.\n"); 00653 printf(" An forbidden state has been encountered.\n"); 00654 printf(" x= ("); 00655 for (int i=0; i<P.NLEG; i++) printf(" %d", x[i]); 00656 printf(") \n"); 00657 dump(); 00658 P.dump(); 00659 exit(0); 00660 } 00661 #endif 00662 delete []x; 00663 return P.getIC(st,inc,xinc); 00664 } 00665 00666 //====================================================================== 00667 00668 void BareVertex::dump() { 00669 int vt = type(); 00670 int vc = category(); 00671 // int n = size(); 00672 // double t = time(); 00673 00674 fprintf( FERR, 00675 " <%2d> ... vt=(%1d,%2d), nl=%1d, tau=%11.6f ", 00676 id(), vc, vt, size(), time() ); 00677 if ( _s.size() != 0 ) { 00678 for (int i=0; i<size(); i++) { 00679 int id = -1; 00680 if ( _s[i] != 0 ) id = _s[i]->id(); 00681 fprintf( FERR, "[%2d]", id); 00682 } 00683 fprintf( FERR, " X= ("); 00684 for (int i=0; i<size(); i++) { 00685 int x = -1; 00686 if ( _s[i] != 0 ) x = _s[i]->X(); 00687 fprintf( FERR, " %d", x); 00688 } 00689 fprintf( FERR, ")"); 00690 } else { 00691 fprintf( FERR, " segments not defined."); 00692 } 00693 fprintf( FERR, "\n"); 00694 } 00695 00696 //###################################################################### 00697 00698 inline void Vertex::reconnect() { 00699 for (int l=0; l<size(); l+=2) S(l).absorbNext(); 00700 } 00701 00702 //====================================================================== 00703 00704 inline void Vertex::erase() { 00705 reconnect(); 00706 //if (ALERT) { 00707 // printf("\nVertex::erase> ### Erasing\n"); 00708 // dump(); 00709 //} 00710 Linked<BareVertex>::remove(); 00711 //if (ALERT) { 00712 // printf("\nVertex::erase> ### Done\n"); 00713 // dump(); 00714 //} 00715 TheVertexPool.push(*this); 00716 } 00717 00718 //###################################################################### 00719 00720 inline Worm::Worm() { 00721 Vertex& V = TheVertexPool.pop(); 00722 V.init_WORM(); // 2本足なので初期化は TERM と同じでよい. 00723 _vorg = &V; 00724 _vcur = 0; 00725 _scur = 0; 00726 } 00727 00728 //====================================================================== 00729 00730 inline Worm::~Worm() { 00731 TheVertexPool.push(*_vorg); 00732 _vorg = 0; 00733 } 00734 00735 //====================================================================== 00736 00737 inline void Worm::remove() { 00738 Vertex& v = getCurrentVertex(); 00739 v.reconnect(); 00740 } 00741 00742 //====================================================================== 00743 00744 inline void Worm::dump() { 00745 fprintf(FERR,"\n"); 00746 fprintf(FERR,"Worm:\n"); 00747 fprintf(FERR," x_behind = %d\n", getXBEHIND() ); 00748 if ( _vorg == 0 ) { 00749 fprintf(FERR," _vorg (the worm tail) is not defined.\n"); 00750 } else { 00751 fprintf(FERR," Tail:\n"); 00752 _vorg->dump(); //barevertex.dump() 00753 } 00754 if ( _vcur == 0 ) { 00755 fprintf(FERR," _vcur (the current vertex) is not defined.\n"); 00756 } else { 00757 fprintf(FERR," The last visited vertex:\n"); 00758 _vcur->dump(); 00759 } 00760 if ( _scur == 0 ) { 00761 fprintf(FERR," _scur (the current segment) is not defined.\n"); 00762 } else { 00763 fprintf(FERR," The segment ahead of the head:\n"); 00764 _scur->dump(); 00765 } 00766 } 00767 00768 //###################################################################### 00769 00770 inline Site::Site() { 00771 //printf("Site::Site> Start.\n"); 00772 lastID++; 00773 ID = lastID; 00774 _SP = 0; 00775 Vertex& v = TheVertexPool.pop(); 00776 Segment& s = TheSegmentPool.pop(); 00777 v.BareVertex::init_TERM(s); 00778 s.set(0, v, v); 00779 s.setONSITE(this); 00780 _vterm = &v; 00781 add_head(s); 00782 } 00783 00784 //====================================================================== 00785 00786 inline Site::~Site() { 00787 /* 00788 for(int iCI = 0; iCI<NCI; ++iCI){ 00789 (*ConnectedInteraction[iCI]).dump(); 00790 } 00791 */ 00792 delete [] ConnectedInteraction; 00793 while( ! empty() ) { 00794 Segment& S = first(); 00795 S.remove(); 00796 TheSegmentPool.push(S); 00797 }; 00798 TheVertexPool.push(*_vterm); 00799 } 00800 00801 //====================================================================== 00802 00803 inline Segment& Site::findS(double t) { 00804 iterator p(*this); 00805 while ( (++p)->topTime() < t ) {} 00806 00807 return *p; 00808 00809 } 00810 00811 //###################################################################### 00812 00813 inline Interaction::Interaction() { 00814 lastID++; 00815 ID=lastID; 00816 _s = 0; 00817 } 00818 00819 //====================================================================== 00820 00821 inline Interaction::~Interaction() { 00822 // printf("*** Destroying Interaction\n"); 00823 while( ! empty() ) { 00824 Vertex& V = first(); 00825 V.remove(); 00826 TheVertexPool.push(V); 00827 }; 00828 if ( _s != 0 ) delete [] _s; 00829 } 00830 00831 //##########################katou####################################### 00832 class UniformInterval{ 00833 public: 00834 Interaction* I_n; 00835 VertexInitialConfiguration* VIC;// 00836 VertexProperty* VP; 00837 00838 //Segment* n_S[nbody] 00839 Segment** n_S; 00840 //int x[nbody] 00841 int* x; 00842 int inc;// 00843 int xinc; 00844 int nbody; 00845 bool DefinedVIC;//Defined StateCode yes no 00846 void init(Interaction* Ia, int xbehind){ 00847 I_n = Ia; 00848 nbody = (*I_n).NBODY(); 00849 VP = &((*I_n).property().getVertexProperty()); 00850 00851 00852 n_S = new Segment* [nbody]; 00853 x = new int [nbody]; 00854 xinc = xbehind; 00855 DefinedVIC = false; 00856 } 00857 void setVIC(){ 00858 int st =(*VP).SCNK(x); 00859 if(st < 0){ 00860 VIC = 0; 00861 DefinedVIC = false; 00862 }else{ 00863 VIC = &( (*VP).getIC( st, inc, xinc ) ); 00864 DefinedVIC = true; 00865 } 00866 } 00867 void setx(){ 00868 for(int i_body = 0; i_body < nbody; ++i_body){ 00869 x[i_body] = (*n_S[i_body]).X(); 00870 } 00871 } 00872 void setx(int i_body){ 00873 x[i_body] = (*n_S[i_body]).X(); 00874 } 00875 ~UniformInterval(){ 00876 delete [] n_S; 00877 delete [] x; 00878 } 00879 00880 }; 00881 //###################################################################### 00882 class RegisteredVertexInfo { 00883 public: 00884 Vertex* V_x; 00885 int i_UI; 00886 int i_body; 00887 double V_time; 00888 void setRVI(Vertex* Vx,int iUI, int ibody, double Vtime){ 00889 V_x = Vx; 00890 i_UI = iUI; 00891 i_body = ibody; 00892 V_time = Vtime; 00893 } 00894 void init(){}; 00895 00896 }; 00897 inline bool operator<(const RegisteredVertexInfo& obj0, const RegisteredVertexInfo& obj){ 00898 return obj0.V_time < obj.V_time; 00899 } 00900 inline bool operator>(const RegisteredVertexInfo& obj0, const RegisteredVertexInfo& obj){ 00901 return obj0.V_time > obj.V_time; 00902 } 00903 00904 //###################################################################### 00905 00906 class RegVInfo : public Linked<RegisteredVertexInfo> { 00907 00908 public: 00909 00910 void erase(); 00911 RegVInfo& prev() { return (RegVInfo&)Linked<RegisteredVertexInfo>::prev(); }; 00912 RegVInfo& next() { return (RegVInfo&)Linked<RegisteredVertexInfo>::next(); }; 00913 bool operator==(RegVInfo& s) { return this == &s; }; 00914 00915 00916 }; 00917 00918 Pool<RegVInfo> TheRVIPool; 00919 00920 inline void RegVInfo::erase(){ 00921 Linked<RegisteredVertexInfo>::remove(); 00922 TheRVIPool.push(*this); 00923 } 00924 00925 //##########################katou####################################### 00926 00927 #endif