HG-MD
1
|
00001 #ifndef FSTAT_H 00002 #define FSTAT_H 00003 #include "MD.h" 00004 #include "Matrix.h" 00005 #include <string.h> 00007 enum StatType {O, X, Y, Z, XY, XZ, YZ, XYZ}; 00008 #include "Polynomial.h" 00009 #include "StatisticsPoint.h" 00010 00020 template <StatType T> 00021 class StatisticsVector : public virtual MD 00022 { 00023 public: 00025 void constructor(); 00026 void constructor(string name); 00027 00029 StatisticsVector() {constructor();} 00030 StatisticsVector(string name) {constructor(name);} 00031 00033 StatisticsVector(StatisticsVector& other); 00034 00036 StatisticsVector(unsigned int argc, char *argv[]); 00037 void readStatArguments(unsigned int argc, char *argv[]); 00038 00040 string print(); 00041 00042 void set_statType(); 00043 00044 void print_help(); 00045 00046 //set functions should be called before executing the statistical routine 00047 void set_nx(int new_) { nx = new_;}; 00048 void set_hx(Mdouble hx) { set_nx( ceil((get_xmaxStat()-get_xminStat())/hx) ); }; 00049 void set_ny(int new_) { ny = new_;}; 00050 void set_hy(Mdouble hy) { set_ny( ceil((get_ymaxStat()-get_yminStat())/hy) ); }; 00051 void set_nz(int new_) { nz = new_; if (get_dim()<3) cerr << "Warning in set_nz: dimension less than 3"<<endl; }; 00052 void set_hz(Mdouble hz) { set_nz( ceil((get_zmaxStat()-get_zminStat())/hz) ); }; 00053 void set_n(int n) { set_nx(n); set_ny(n); set_nz(n); }; 00054 void set_h(Mdouble h) { set_hx(h); set_hy(h); set_hz(h);}; 00055 int get_nx() {return nx;}; 00056 int get_ny() {return ny;}; 00057 int get_nz() {return nz;}; 00058 void set_tminStat(Mdouble t) {tminStat=t;}; 00059 void set_tmaxStat(Mdouble t) {tmaxStat=t;}; 00060 void set_tintStat(Mdouble t) {tintStat=t;}; 00061 Mdouble get_tminStat() {return tminStat;}; 00062 Mdouble get_tmaxStat() {if(isnan(tmaxStat)) return get_tmax(); else return tmaxStat;}; 00063 Mdouble get_tintStat() {return tintStat;}; 00064 bool check_current_time_for_statistics(){return (get_t()>get_tminStat()&&get_t()<=get_tmaxStat()+get_dt());}; 00065 00066 void set_CG_type(const char* new_); 00067 void set_CG_type(CG new_); 00068 CG get_CG_type() {return CG_type;}; 00069 00070 void set_n(int nx_, int ny_, int nz_) {nx=nx_; ny=ny_; nz=nz_;}; 00071 void get_n(int& nx_, int& ny_, int& nz_) {nx_=nx; ny_=ny; nz_=nz;}; 00072 00074 void set_w(Mdouble w) {set_w2(sqr(w));}; 00075 00077 void set_w2(Mdouble new_); 00078 00079 Mdouble get_w() {return sqrt(w2);}; 00080 Mdouble get_w2() {return w2;}; 00081 Mdouble get_cutoff() {return cutoff;}; 00082 Mdouble get_cutoff2() {return sqr(cutoff);}; 00083 00084 //~ bool get_boundedDomain() {return boundedDomain;}; 00085 //~ void set_boundedDomain(bool new_) {boundedDomain=new_;}; 00086 00088 string print_CG(); 00089 00091 StatisticsPoint<T> average(vector<StatisticsPoint<T> > &P); 00092 00094 void reset_statistics(); 00095 00097 void statistics_from_fstat_and_data(); 00098 00099 void set_doTimeAverage(bool new_) {doTimeAverage = new_;}; 00100 bool get_doTimeAverage() {return doTimeAverage;}; 00101 00102 void set_StressTypeForFixedParticles(int new_) {StressTypeForFixedParticles = new_;}; 00103 int get_StressTypeForFixedParticles() {return StressTypeForFixedParticles;}; 00104 00105 // to keep compatible with older versions 00106 void set_infiniteStressForFixedParticles(bool new_) {StressTypeForFixedParticles = 2+new_;}; 00107 00108 void set_mirrorAtDomainBoundary(Mdouble new_) {mirrorAtDomainBoundary = new_;}; 00109 Mdouble get_mirrorAtDomainBoundary() {return mirrorAtDomainBoundary;}; 00110 00111 void set_doVariance(bool new_) {doVariance = new_;}; 00112 bool get_doVariance() {return doVariance;}; 00113 00114 void set_doGradient(bool new_) {doGradient = new_;}; 00115 bool get_doGradient() {return doGradient;}; 00116 00117 void set_superexact(bool new_) {superexact = new_;}; 00118 bool get_superexact() {return superexact;}; 00119 00120 void set_ignoreFixedParticles(bool new_) {ignoreFixedParticles = new_;}; 00121 bool get_ignoreFixedParticles() {return ignoreFixedParticles;}; 00122 00123 void verbose() {verbosity = 2;}; 00124 void set_verbosity(int new_) {verbosity = new_;}; 00125 int get_verbosity() {return verbosity;}; 00126 00127 void set_walls(bool new_) {walls = new_;}; 00128 bool get_walls() {return walls;}; 00129 00130 void set_periodicWalls(bool new_) {periodicWalls = new_;}; 00131 bool get_periodicWalls() {return periodicWalls;}; 00132 00133 void set_w_over_rmax(Mdouble new_) {w_over_rmax = new_;}; 00134 Mdouble get_w_over_rmax() {return w_over_rmax;}; 00135 00137 void set_Positions(); 00138 00139 bool read_next_from_data_file (unsigned int format); 00140 00141 void gather_force_statistics_from_fstat_and_data(); 00142 void evaluate_force_statistics(int wp=0); 00143 void evaluate_wall_force_statistics(Vec3D P, int wp=0); 00144 void jump_fstat(); 00145 00147 void initialize_statistics(); 00148 00150 void output_statistics(); 00152 void gather_statistics_collision(int index1,int index2, Vec3D Contact, Mdouble delta, Mdouble ctheta, Mdouble fdotn, Mdouble fdott, Vec3D P1_P2_normal_, Vec3D P1_P2_tangential); 00154 void process_statistics(bool usethese); 00156 void finish_statistics(); 00157 00159 void write_statistics(); 00161 void write_time_average_statistics(); 00162 00164 void evaluate_particle_statistics(vector<Particle*>::iterator P, int wp=0); 00165 00166 vector<StatisticsPoint<T> > get_Points(){return Points;}; 00167 00169 Mdouble get_xminStat() {if(isnan(xminStat)) return get_xmin(); else return xminStat;}; 00170 Mdouble get_yminStat() {if(isnan(yminStat)) return get_ymin(); else return yminStat;}; 00171 Mdouble get_zminStat() {if(isnan(zminStat)) return get_zmin(); else return zminStat;}; 00172 Mdouble get_xmaxStat() {if(isnan(xmaxStat)) return get_xmax(); else return xmaxStat;}; 00173 Mdouble get_ymaxStat() {if(isnan(ymaxStat)) return get_ymax(); else return ymaxStat;}; 00174 Mdouble get_zmaxStat() {if(isnan(zmaxStat)) return get_zmax(); else return zmaxStat;}; 00175 void set_xminStat(Mdouble xminStat_){xminStat=xminStat_;}; 00176 void set_yminStat(Mdouble yminStat_){yminStat=yminStat_;}; 00177 void set_zminStat(Mdouble zminStat_){zminStat=zminStat_;}; 00178 void set_xmaxStat(Mdouble xmaxStat_){xmaxStat=xmaxStat_;}; 00179 void set_ymaxStat(Mdouble ymaxStat_){ymaxStat=ymaxStat_;}; 00180 void set_zmaxStat(Mdouble zmaxStat_){zmaxStat=zmaxStat_;}; 00181 int get_nTimeAverage() {return nTimeAverage;}; 00182 00183 Mdouble setInfinitelyLongDistance(); 00184 00185 void set_Polynomial(vector<Mdouble> new_coefficients, unsigned int new_dim) { 00186 Polynomial.set_polynomial(new_coefficients, new_dim); 00187 } 00188 00189 void set_Polynomial(Mdouble* new_coefficients, unsigned int num_coeff, unsigned int new_dim) { 00190 Polynomial.set_polynomial(new_coefficients, num_coeff, new_dim); 00191 } 00192 00193 void set_PolynomialName(const char* new_name) { 00194 Polynomial.set_name(new_name); 00195 } 00196 00197 string get_PolynomialName() { 00198 return Polynomial.get_name(); 00199 } 00200 00201 void set_rmin(Mdouble new_) {rmin=new_;} 00202 void set_rmax(Mdouble new_) {rmax=new_;} 00203 void set_hmax(Mdouble new_) {hmax=new_;} 00204 00205 Mdouble evaluatePolynomial(Mdouble r) { 00206 return Polynomial.evaluate(r); 00207 } 00208 00209 Mdouble evaluateIntegral(Mdouble n1, Mdouble n2, Mdouble t) { 00210 return Polynomial.evaluateIntegral(n1,n2,t); 00211 } 00212 00213 00214 //Member Variables 00215 private: 00216 00217 //General Variables 00219 StatType statType; 00221 int nx; 00223 int ny; 00225 int nz; 00228 Mdouble xminStat, xmaxStat, yminStat, ymaxStat, zminStat, zmaxStat; 00230 int nxMirrored, nyMirrored, nzMirrored; 00231 00232 //Storage of points and gradients 00234 vector<StatisticsPoint<T> > Points; 00236 vector<StatisticsPoint<T> > dx; 00238 vector<StatisticsPoint<T> > dy; 00240 vector<StatisticsPoint<T> > dz; 00241 00242 //For time averaging 00244 vector<StatisticsPoint<T> > timeAverage; 00246 vector<StatisticsPoint<T> > timeVariance; 00248 vector<StatisticsPoint<T> > dxTimeAverage; 00250 vector<StatisticsPoint<T> > dyTimeAverage; 00252 vector<StatisticsPoint<T> > dzTimeAverage; 00254 bool doTimeAverage; 00256 int nTimeAverageReset; 00258 bool doVariance; 00260 bool doGradient; 00262 int nTimeAverage; 00263 00264 //Coarse graining variables 00266 CG CG_type; 00268 NORMALIZED_POLYNOMIAL<T> Polynomial; 00269 // ///<if true, then the course-graining function will be cut at the domain boundaries and resized to satisfy int(W) = 1 00270 // bool boundedDomain; 00272 Mdouble w2; 00274 Mdouble cutoff, cutoff2; 00276 Mdouble w_over_rmax; 00277 00278 //Options that can be set before evaluation 00279 00281 Mdouble tminStat; 00283 Mdouble tmaxStat; 00285 Mdouble tintStat; 00287 Mdouble indSpecies; 00290 Mdouble rmin; 00292 Mdouble rmax; 00294 Mdouble hmax; 00296 bool walls; 00298 bool periodicWalls; 00300 bool ignoreFixedParticles; 00305 int StressTypeForFixedParticles; 00309 00310 int verbosity; //<Determines how much is outputted to the terminal 00311 int format; //< format of the data input file 00312 Mdouble mirrorAtDomainBoundary; //< 0: Statistics near the wall are equal to statistics away from the wall; 1: Statistics are mirrored at the domain boundaries; up to a maximum depth specified by this number 00313 00314 bool isMDCLR; 00316 bool superexact; 00317 00318 00319 00320 00321 //Variables communicate values between member functions #evaluate_force_statistics and #gather_statistics_collision)used to communicate values between member functions evaluate_force_statistics and gather_force_statistics 00323 Vec3D P1; 00325 Vec3D P2; 00327 Vec3D P1_P2_normal; 00329 Mdouble P1_P2_distance; 00331 Matrix3D P1_P2_NormalStress; 00333 Matrix3D P1_P2_TangentialStress; 00335 Vec3D P1_P2_NormalTraction; 00337 Vec3D P1_P2_TangentialTraction; 00339 MatrixSymmetric3D P1_P2_Fabric; 00341 Vec3D P1_P2_CollisionalHeatFlux; 00343 Mdouble P1_P2_Dissipation; 00345 Mdouble P1_P2_Potential; 00346 00347 }; 00348 00349 #include "StatisticsPoint.hcc" 00350 #include "StatisticsVector.hcc" 00351 00352 #endif