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

pdyn.h

Go to the documentation of this file.
00001 
00002        //=======================================================//    _\|/_
00003       //  __  _____           ___                    ___       //      /|\ ~
00004      //  /      |      ^     |   \  |         ^     |   \     //          _\|/_
00005     //   \__    |     / \    |___/  |        / \    |___/    //            /|\ ~
00006    //       \   |    /___\   |  \   |       /___\   |   \   // _\|/_
00007   //     ___/   |   /     \  |   \  |____  /     \  |___/  //   /|\ ~
00008  //                                                       //            _\|/_
00009 //=======================================================//              /|\ ~
00010 
00012 //                Includes basic physical stellar data, for use in
00013 //                applications involving N-body systems using 4-D trees.
00014 //
00015 //
00016 // version 1:  May 2001   Steve McMillan
00017 // version 2:
00018 //
00019 // This file includes:
00020 // 1) definition of class _pdyn_ (physical dyn, pre-tdyn, partiview-dyn?)
00021 // 2) definition of class pdyn (pdyn with extra kepler data)
00022 
00023 #ifndef  STARLAB_PDYN_H
00024 #  define  STARLAB_PDYN_H
00025 
00026 #include "dyn.h"
00027 
00031 
00032 class  _pdyn_ : public dyn
00033 {
00034     protected:
00035 
00036         int worldline_index;    
00037 
00038         // Stellar stuff:
00039 
00040         int stellar_type;       
00041         real temperature;
00042         real luminosity;
00043 
00044     public:
00045 
00046         inline void _pdyn_init() {
00047             worldline_index = -1;
00048             stellar_type = -42;
00049             temperature = luminosity = 0;
00050         }
00051 
00052         _pdyn_(hbpfp the_hbpfp = new_hydrobase, sbpfp the_sbpfp = new_starbase,
00053              bool use_stories = true)
00054             : dyn(the_hbpfp, the_sbpfp, use_stories)    {_pdyn_init();}
00055 
00056         virtual ~_pdyn_() {}
00057 
00058         inline void set_worldline_index(int w)  {worldline_index = w;}
00059         inline int  get_worldline_index()       {return worldline_index;}
00060 
00061         inline void set_temperature(real t)     {temperature = t;}
00062         inline real get_temperature()           {return temperature;}
00063 
00064         inline void set_luminosity(real t)      {luminosity = t;}
00065         inline real get_luminosity()            {return luminosity;}
00066 
00067         inline void set_stellar_type(int s)     {stellar_type = s;}
00068         inline int  get_stellar_type()          {return stellar_type;}
00069 
00070         inline _pdyn_ * get_parent()
00071             {return (_pdyn_*) node::get_parent();}
00072         inline _pdyn_ * get_oldest_daughter()
00073             {return (_pdyn_*)node::get_oldest_daughter();}
00074         inline _pdyn_ * get_younger_sister()
00075             {return (_pdyn_*) node::get_younger_sister();}
00076         inline _pdyn_ * get_elder_sister()
00077             {return (_pdyn_*) node::get_elder_sister();}
00078 
00080 
00081         inline _pdyn_ * get_root()
00082             {return (_pdyn_*) node::get_root();}
00083 
00085 
00086         inline _pdyn_ * get_top_level_node()
00087             {return (_pdyn_*) node::get_top_level_node();}
00088 
00090 
00091         inline _pdyn_ * get_binary_sister()
00092             {return (_pdyn_*) node::get_binary_sister();}
00093 
00094         virtual real get_radius();
00095         virtual  ostream& print_dyn_story(ostream &s,
00096                                           bool print_xreal = true,
00097                                           int short_output = 0);
00098 };
00099 
00100 typedef _pdyn_ *_pdyn_ptr;         // to enable dynamic array declarations
00101 
00102 inline  node * new_pdyn_(hbpfp the_hbpfp, sbpfp the_sbpfp,
00103                          bool use_stories = true)
00104     {return (node *) new _pdyn_(the_hbpfp, the_sbpfp, use_stories);}
00105 
00106 inline  _pdyn_ * get_pdyn_(istream & s = cin,
00107                            hbpfp the_hbpfp = new_hydrobase,
00108                            sbpfp the_sbpfp = new_starbase,
00109                            bool use_stories = true)
00110     {return  (_pdyn_ *) get_node(s, new_pdyn_, the_hbpfp, the_sbpfp,
00111                                  use_stories);}
00112 
00113 #define  put_pdyn_  put_node
00114 
00115 class tdyn;
00116 
00118 
00119 class  pdyn : public _pdyn_
00120 {
00121     protected:
00122 
00123         tdyn *kepevent;
00124         kepler *kep2;
00125         tdyn *kepevent2;
00126 
00127     public:
00128 
00129         pdyn(hbpfp the_hbpfp = new_hydrobase, sbpfp the_sbpfp = new_starbase,
00130              bool use_stories = true)
00131             : _pdyn_(the_hbpfp, the_sbpfp, use_stories) {
00132                 kepevent = kepevent2 = NULL;
00133                 kep2 = NULL;
00134             }
00135 
00136         inline void rmkepler2() {
00137             if (kep2) {
00138                 pdyn* s = (pdyn*)get_binary_sister();
00139 
00140                 if (s && s->kep2 == kep2)
00141                     s->kep2 = NULL;
00142 
00143                 delete kep2;
00144                 kep2 = NULL;
00145             }
00146         }
00147 
00148         virtual ~pdyn()
00149         {
00150             if (kep2)
00151                 rmkepler2();    // see note on rmkepler() in dyn.h
00152         }
00153 
00154         inline kepler * get_kepler2()           {return kep2;}
00155         void  set_kepler2(kepler * new_kep)     {kep2 = new_kep;}
00156 
00157         inline tdyn *get_kepevent()             {return kepevent;}
00158         inline void set_kepevent(tdyn *t)       {kepevent = t;}
00159 
00160         inline tdyn *get_kepevent2()            {return kepevent2;}
00161         inline void set_kepevent2(tdyn *t)      {kepevent2 = t;}
00162 
00163         // The usual...
00164 
00165         inline pdyn * get_parent()
00166             {return (pdyn*) node::get_parent();}
00167         inline pdyn * get_oldest_daughter()
00168             {return (pdyn*)node::get_oldest_daughter();}
00169         inline pdyn * get_younger_sister()
00170             {return (pdyn*) node::get_younger_sister();}
00171         inline pdyn * get_elder_sister()
00172             {return (pdyn*) node::get_elder_sister();}
00173 
00174         inline pdyn * get_root()
00175             {return (pdyn*) node::get_root();}
00176         inline pdyn * get_top_level_node()
00177             {return (pdyn*) node::get_top_level_node();}
00178         inline pdyn * get_binary_sister()
00179             {return (pdyn*) node::get_binary_sister();}
00180 
00181         // Necessary virtual functions:
00182 
00183         virtual  istream& scan_star_story(istream&, int level = 0);
00184         virtual  istream& scan_dyn_story(istream&);
00185 
00186 #if 0
00187         virtual ostream& pdyn::print_star_story(ostream& s,
00188                                                 int short_output = 0)
00189 #endif
00190 
00191 };
00192 
00193 typedef pdyn *pdynptr;     // to enable dynamic array declarations
00194 
00195 inline  node * newpdyn(hbpfp the_hbpfp, sbpfp the_sbpfp,
00196                          bool use_stories = true)
00197     {return (node *) new pdyn(the_hbpfp, the_sbpfp, use_stories);}
00198 
00199 inline  pdyn * getpdyn(istream & s = cin,
00200                        hbpfp the_hbpfp = new_hydrobase,
00201                        sbpfp the_sbpfp = new_starbase,
00202                        bool use_stories = true)
00203     {return  (pdyn *) get_node(s, newpdyn, the_hbpfp, the_sbpfp,
00204                                  use_stories);}
00205 
00206 #define  put_pdyn  put_node
00207 
00208 #endif

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