Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

hop.h

Go to the documentation of this file.
00001 #ifndef     STARLAB_HOP_H
00002 #   define  STARLAB_HOP_H
00003 
00005 
00006 #include "dyn.h"
00007 #include "vector"
00008 
00009 real d_nn_sq, d_nn_sq2, d_nn_sq3;
00010 static dyn *nn2, *nn3;
00011 
00013 
00014 class nearest_neighbor {
00015 public:
00016   dyn* nn;              
00017   real d_nn_sq;         
00018   nearest_neighbor() {
00019     nn = NULL;
00020     d_nn_sq = VERY_LARGE_NUMBER;
00021   }
00022 };
00023 
00025 
00026 class cluster {
00027  protected:
00028 
00029   dyn *h;               
00030 
00031   int nstar;            
00032   real mass;            
00033   vec pos;              
00034   vec vel;              
00035 
00036  public:
00037 
00038   cluster() {
00039     h=NULL;
00040     nstar = 0;
00041     mass = 0;
00042   }
00043   cluster(dyn *b) {
00044     h=b;
00045     nstar = 1;
00046     mass = b->get_mass();
00047     pos = b->get_pos();
00048     vel = b->get_vel();
00049   }
00050   ~cluster() {}
00051 
00052   dyn *get_h() {return h;}
00053   void set_h(dyn *b) {h=b;}
00054   void set_nstar(int n) {nstar = n;}
00055   void set_mass(real m) {mass = m;}
00056   void set_pos(vec p) {pos = p;}
00057   void set_vel(vec p) {vel = p;}
00058 
00059   void increment(dyn *b) {
00060     nstar++;
00061     mass += b->get_mass();
00062   }
00063 
00064   void put(ostream &s = cerr) {
00065     s << "Cluster (id= " << h->get_index() 
00066       << "), N= " << nstar 
00067       << ", M= " << mass << endl; 
00068     s << "   pos= " << pos << "   vel= " << vel << endl;
00069   }
00070 
00071 };
00072 
00074 
00075 class hop {
00076  protected:
00077 
00078   int nn_search;        
00079   vector<cluster> cl;   
00080  public:
00081 
00082   hop() {}
00083   ~hop() {}
00084 
00085   void set_nn_search(int n) {nn_search = n;}
00086 
00087   dyn *densest_nth_nn(dyn *b);
00088   void find_clump_center(dyn *b);
00089   void find_primary_cluster(dyn *b);
00090   void add_cluster_center(dyn* bc);
00091 
00092   void put(ostream &s = cerr) {
00093     vector<cluster>::iterator ic;
00094     for (ic = cl.begin(); ic<cl.end(); ic++) {
00095       ic->put(s);
00096     }
00097   }
00098 
00099   void put_snap(ostream &s) {
00100     vector<cluster>::iterator ic;
00101     for (ic = cl.begin(); ic<cl.end(); ic++) {
00102       put_dyn(ic->get_h());
00103     }
00104   }
00105 };
00106 
00107 #endif    //STARLAB_HOP_H
00108 

Generated on Wed Jul 20 12:43:35 2005 for Starlab by  doxygen 1.4.3