#ifndef MY_UTILS #define MY_UTILS #include #include #include #include #define PlacementNewOffset 8 #ifdef _DEBUG #define Assert(condition, message)\ {\ if(!(condition)) std::cerr << (message) << std::endl;\ } #define Assert2(condition, message, message1)\ {\ if(!(condition)) std::cerr << (message) << " "<< (message1)<< std::endl;\ } #define Assert3(condition, message, message1, message2)\ {\ if(!(condition)) std::cerr << (message) << " " << (message1) << " "<< message2 << std::endl;\ } #define Assert5(condition, message, message1, message2, message3, message4)\ {\ if(!(condition)) std::cerr <<(message)<<" "<<(message1)<<" "<<(message2)<<" "<<(message3)<<" "<<(message4)<< std::endl;\ } #define _LOG(x) x #define CHECK(x) x #else /* NO_ARG_CHECK */ #define Assert(condition, message) #define Assert2(condition, message, message1) #define Assert3(condition, message, message1, message2) #define Assert5(condition, message, message1, message2, message3, message4) #define _LOG(x) #define CHECK(x) #endif /* NO_ARG_CHECK */ #define HPoffset 8 //************************************************// // Simple class used to exchange the data between // // functions and meshes when doing linear // // interpolation // //************************************************// class intpar{ public: int i; double p; intpar(int i_, double p_) : i(i_), p(p_){} intpar(){}; }; //template //inline T sqr(const T& x) {return x*x;} template bool ReadValue(T& a, const std::string& variable, const std::string& str){ std::string::size_type pos = str.find(variable); if (pos < std::string::npos){ std::string::size_type poseq = str.find("=",pos); if (poseq> a; } return true; } return false; } inline double ferm_f(double x) { if (x>100.) return 0.0; if (x<-36.) return 1.0; return 1.0/(1+exp(x)); } inline double nbose_f(double x) { if (x>100.) return 0.0; if (x<-36.) return -1.0; return 1.0/(exp(x)-1); } inline double exp_f(double x){ if (x<-100) return 0; return exp(x); } template double power(T p, int k) { T s = 1; for (int i=0; i