00001 //--------------------------------------------------------------------------- 00002 // Storm 00003 //--------------------------------------------------------------------------- 00004 #if !defined(Storm_H) 00005 #define Storm_H 00006 00007 #include "BehaviorBase.h" 00008 #include "ModelMath.h" 00009 00010 class clGridBase; 00011 class xercesc::DOMDocument; 00012 00069 class clStorm : virtual public clBehaviorBase { 00070 00074 friend class clTestStorm; 00075 00076 public: 00077 00082 clStorm(clSimManager *p_oSimManager); 00083 00087 ~clStorm(); 00088 00101 void GetData(xercesc::DOMDocument *p_oDoc); 00102 00106 void TimestepCleanup(); 00107 00115 void Action(); 00116 00117 protected: 00118 00130 clGridBase *mp_oStormGrid; 00131 00146 clGridBase *mp_oSusceptibilityMap; 00147 00149 float (clStorm::*RandomDraw)(const float &fNumber); 00150 00154 float *mp_fStormProbabilities; 00155 00160 float mp_fStdDev; 00161 00166 float mp_fClump; 00167 00169 int m_iNumSeverityClasses; 00171 int m_iDmgIndexCode; 00173 int m_iSusceptIndexCode; 00174 00177 enum susceptibility {mapped, 00178 uniform 00179 } 00180 m_iSusceptibility; 00187 enum stochasticity {deterministic, 00188 stochastic 00189 } 00190 m_iStochasticity; 00197 enum distribution_func {lognormal, 00198 normal, 00199 negative_binomial 00200 } m_iDistribution; 00228 void DoGridSetup(); 00229 00236 void CalculateStormProbabilities(); 00237 00268 void ApplyDamage(int iSeverityClass); 00269 00288 void ReadParFile(xercesc::DOMDocument *p_oDoc); 00289 00296 void SetStochFuncPointer(); 00297 00304 inline float NormalDraw(const float &fMean) { 00305 float fVal = fMean + clModelMath::NormalRandomDraw(mp_fStdDev); 00306 if (fVal < 0) fVal = 0; if (fVal > 1) fVal = 1; 00307 return fVal; 00308 }; 00309 00316 inline float LognormalDraw(const float &fMean) { 00317 return clModelMath::LognormalRandomDraw(fMean, mp_fStdDev); 00318 }; 00319 00326 inline float NegBinomialDraw(const float &fMean) { 00327 return clModelMath::NegBinomialRandomDraw(fMean, mp_fClump); 00328 }; 00329 00330 }; 00331 //--------------------------------------------------------------------------- 00332 #endif // Storm_H