Files Classes Functions Hierarchy
00001 #ifndef PARTICLESAMPLER_H 00002 #define PARTICLESAMPLER_H 00003 00004 00005 #include <cassert> 00006 #include <string> 00007 #include <iostream> 00008 #include <fstream> 00009 using namespace std; 00010 00011 #include <histogram.h> 00012 #include <particle.h> 00013 #include <typedefs.h> 00014 00015 00016 /* 00017 \brief Periodically sample points in the particle simulation. 00018 00019 Use: 00020 Configure the state to sample different data. 00021 eg 00022 0 No sampling 00023 1 Samples the magnitude of overall veclocity 00024 2 Samples the speed in the x-axis 00025 3 Samples the speed in the y-axis 00026 00027 The samplecountermax is the number of times this object 00028 is iterated over before it samples. 00029 The filecountermax is then the number of times that 00030 sampling occures before writing to the file. 00031 */ 00032 class particlesampler 00033 { 00034 uintc & state; 00035 00036 uint samplecounter; 00037 uint filecounter; 00038 histogram<double> hist; 00039 string filename; 00040 00041 particle const * & pi; 00042 uintc & numParticles; 00043 00044 void sample(); 00045 void writefile(); 00046 public: 00047 00049 uint samplecountermax; 00050 00054 uint filecountermax; 00055 00056 particlesampler 00057 ( 00058 uintc & state_, 00059 uintc samplecountermax_, 00060 uintc filecountermax_, 00061 histogram<double> const hist_, 00062 string const filename_, 00063 particle const * & pi_, 00064 uintc & numParticles_ 00065 ); 00066 00067 void set(histogram<double> const hist_) 00068 { hist=hist_; } 00069 00070 void reset(); 00071 00072 void operator ++ (); 00073 // { ++samplecounter; if ((samplecounter%samplecountermax)==0) sample(); } 00074 00075 }; 00076 00077 00078 00079 #endif 00080
1.5.8