BIE |
/home/weinberg/src/BIE/include/RunSimulation.h00001 // This is really -*- C++ -*- 00002 00003 #ifndef RunSimulation_h 00004 #define RunSimulation_h 00005 00006 #include <vector> 00007 #include <string> 00008 #include "Tessellation.h" 00009 #include "gvariable.h" 00010 #include "BIEmpi.h" 00011 #include "TessToolSender.h" 00012 00013 #include <cc++/thread.h> 00014 00015 #include "Serializable.h" 00016 00017 00018 using namespace ost; 00019 00020 namespace BIE { 00021 //+ CLICLASS RunSimulation 00025 class RunSimulation : public Serializable, 00026 public Thread { 00027 public: 00028 //+ CLICONSTR 00030 RunSimulation() : tesstool(0), resume(false) {}; 00032 virtual ~RunSimulation() { simulationInProgress=0; }; 00034 virtual void Run() {}; 00038 virtual void Resume() {}; 00039 00040 //+ CLIMETHOD void RunThread 00042 void RunThread() 00043 { 00044 resume = false; 00045 // make it mpi aware 00046 if ((mpi_used == false) || ((mpi_used == true) && (myid == 0))) { 00047 // use thread when no mpi or mpi root only 00048 start(); 00049 } else { 00050 //Run(); 00051 start(); 00052 } 00053 simulationInProgress=1; // firstCommandChar=1; 00054 } 00055 00056 //+ CLIMETHOD void ResumeThread 00058 void ResumeThread() 00059 { 00060 resume = true; 00061 start(); 00062 } 00063 00064 // common c++ messed up capitalization 00065 // lowercase version is preferred; capitalized is legacy 00067 virtual void run() 00068 { 00069 if (!resume) { 00070 Run(); 00071 } else { 00072 Resume(); 00073 } 00074 } 00075 00077 void final() 00078 { 00079 simulationInProgress=0; 00080 cout << "Simulation exiting . . . \n" << endl; 00081 } 00082 00083 //+ CLIMETHOD void SetControlFlags bool 00094 void SetControlFlags(bool finish); 00095 00097 bool finish(void); 00098 00100 void printFrontier(vector<int> frontier_value); 00102 void inputNodes(vector<int> *input_vector); 00103 00104 //+ CLIMETHOD void SetThreshold double 00106 void SetThreshold(double v) { threshval = v; } 00107 00108 //+ CLIMETHOD void SetTessTool TessToolSender* 00110 virtual void SetTessTool(TessToolSender *tt); 00111 00112 //+ CLIMETHOD void SampleNext 00114 virtual void SampleNext(); 00115 00116 //+ CLIMETHOD void SwitchOnCLI 00118 virtual void SwitchOnCLI(); 00119 00120 //+ CLIMETHOD void SuspendSimulation 00122 virtual void SuspendSimulation(); 00123 00124 //+ CLIMETHOD void ResumeSimulation 00126 virtual void ResumeSimulation(); 00127 00128 protected: 00129 00131 double threshval; 00133 TessToolSender *tesstool; 00134 00136 int tesstoolfreq; 00137 00138 private: 00139 00140 bool finish_readfile(void); 00141 bool resume; 00142 00143 // AUTO GENERATED BY ../persistence/autopersist.py 00144 private: 00145 friend class boost::serialization::access; 00146 template<class Archive> 00147 void serialize(Archive & ar, const unsigned int version) { 00148 this->pre_serialize(ar, version); 00149 try { 00150 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Serializable); 00151 BIE_CATCH_BOOST_SERIALIZATION_EXCEPTION; 00152 } 00153 try { 00154 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Thread); 00155 BIE_CATCH_BOOST_SERIALIZATION_EXCEPTION; 00156 } 00157 try { 00158 ar & BOOST_SERIALIZATION_NVP(threshval); 00159 BIE_CATCH_BOOST_SERIALIZATION_EXCEPTION; 00160 } 00161 try { 00162 ar & BOOST_SERIALIZATION_NVP(tesstoolfreq); 00163 BIE_CATCH_BOOST_SERIALIZATION_EXCEPTION; 00164 } 00165 this->post_serialize(ar, version); 00166 } 00167 00168 }; 00169 00170 } // namespace BIE 00171 00172 // non-intrusive persistence code for Thread class 00173 namespace boost { 00174 namespace serialization { 00175 template<class Archive> 00176 inline void serialize(Archive& ar, 00177 Thread& t, 00178 const unsigned int file_version) { 00179 /* Sun Apr 27 03:55:12 EDT 2008 -- bchoi 00180 * not sure what to do with this.. 00181 */ 00182 } 00183 } 00184 } 00185 00186 BIE_CLASS_TYPE_INFO(BIE::RunSimulation) 00187 BIE_CLASS_EXPORT_KEY(BIE::RunSimulation) 00188 #endif Send suggestions, questions, and feedback to WEINBERG at ASTRO dot UMASS dot EDU. Documentation generated at Fri Mar 26 00:35:10 2010 by
|