Pspm.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00031
00032
00034
00035
00036 #ifndef __PSPM_ALGO_H__
00037 #define __PSPM_ALGO_H__
00038
00039 #ifdef MIP_HOST_APPLE
00040 #include <applePatch.h>
00041 #endif
00042
00043 #include <baselib.h>
00044
00045 #include <boost/numeric/ublas/vector.hpp>
00046 #include <boost/numeric/ublas/matrix.hpp>
00047 #include <boost/numeric/ublas/io.hpp>
00048
00049 #include <ublasTools.h>
00050
00051
00052 typedef boost::numeric::ublas::vector<Decimal> uvector;
00053 typedef boost::numeric::ublas::matrix<Decimal> umatrix;
00054
00055 using namespace MipBaselib;
00056
00060 class PspmOptions : public Options {
00061 public:
00062 DecimalOption *diagStiff;
00063 DecimalOption *diagDamp;
00064 DecimalOption *initEnergy;
00065 DecimalOption *maxEnergy;
00066
00067 PspmOptions();
00068
00069 string getObjectName() const {
00070 return "PspmOptions";
00071 }
00072 };
00073
00074
00079 class PspmPar : public MIPObject {
00080 private:
00081 Decimal _maxEnergy, _initEnergy;
00082 umatrix _dampMat, _stiffMat;
00083
00084 stringstream _ssfatal;
00085
00086 public:
00092 PspmPar(Decimal maxEnrg=0, Decimal initEnergy=0, umatrix B=boost::numeric::ublas::identity_matrix<Decimal>(3), umatrix K=boost::numeric::ublas::identity_matrix<Decimal>(3));
00093
00095 PspmPar(const PspmPar& p);
00096
00098 PspmPar& operator=(const PspmPar& rhs);
00099
00102 Decimal getMaxEnergy();
00103
00106 Decimal getInitEnergy();
00107
00110 umatrix getDampMat();
00111
00114 umatrix getStiffMat();
00115
00118 void setMaxEnergy(Decimal maxEnrg);
00119
00122 void setInitEnergy(Decimal maxEnrg);
00123
00126 void setDampMat(umatrix &dampMat);
00127
00130 void setStiffMat(umatrix &stiffMat);
00131
00133 string getObjectName() const {
00134 return "PspmPar";
00135 }
00136 };
00137
00138
00143 class Pspm : public MIPObject{
00144 private:
00145 PspmOptions _op;
00146
00147 PspmPar *_par;
00148
00149 stringstream _ssfatal;
00150
00151 Decimal _currEnrg;
00152 Decimal _currDampEnrg;
00153 Decimal _pastDampEnrg;
00154
00155 Decimal _oldTime;
00156
00157 uvector _oldY, _oldHatY, _xMax, _xMin;
00158
00159 int _dim;
00160
00161 bool _firstStep;
00162
00164 void _numIntDamp(uvector xDot, Decimal dT, bool reset=false);
00165
00166 void _commonConstr();
00167
00168 FILE* _logFile;
00169
00170 public:
00171
00173 Pspm();
00174
00176 Pspm(PspmPar &par);
00177
00179 Pspm(int argc, const char* argv[]);
00180
00182 ~Pspm();
00183
00185 Pspm(const Pspm& t);
00186
00188 Pspm& operator=(const Pspm& t);
00189
00202 void step(vector<Decimal> y_, vector<Decimal> x_, vector<Decimal> xDot, Decimal inEnergy, Decimal& outEnergy, Decimal time, Decimal dT,
00203 vector<Decimal>& out, bool newData=false, bool approxDamping=true, bool reset=false);
00204
00206 Decimal getEnergy();
00207
00209
00210
00212
00213
00214
00215
00216
00218 void setLogFile(FILE* logFile);
00219
00221 string getObjectName() const {
00222 return "Pspm";
00223 }
00224 };
00225
00226
00227 #endif
00228
00229
00230
00231
00232
00233
00234