AbstractParameterisedSystem.hpp
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
00027
00028
00029 #ifndef ABSTRACTPARAMETERISEDSYSTEM_HPP_
00030 #define ABSTRACTPARAMETERISEDSYSTEM_HPP_
00031
00032 #include <vector>
00033 #include <string>
00034 #include <boost/shared_ptr.hpp>
00035
00036 #include "AbstractOdeSystemInformation.hpp"
00037
00046 class AbstractUntemplatedParameterisedSystem
00047 {
00048 public:
00054 AbstractUntemplatedParameterisedSystem(unsigned numberOfStateVariables);
00055
00057 virtual ~AbstractUntemplatedParameterisedSystem();
00058
00062 boost::shared_ptr<const AbstractOdeSystemInformation> GetSystemInformation() const;
00063
00067 std::string GetSystemName() const;
00068
00069
00070
00071
00072
00076 unsigned GetNumberOfAttributes() const;
00077
00082 bool HasAttribute(const std::string& rName) const;
00083
00088 double GetAttribute(const std::string& rName) const;
00089
00090
00091
00092
00093
00099 unsigned GetNumberOfStateVariables() const;
00100
00104 const std::vector<std::string>& rGetStateVariableNames() const;
00105
00109 const std::vector<std::string>& rGetStateVariableUnits() const;
00110
00121 unsigned GetStateVariableIndex(const std::string& rName) const;
00122
00131 bool HasStateVariable(const std::string& rName) const;
00132
00140 std::string GetStateVariableUnits(unsigned index) const;
00141
00142
00143
00144
00145
00149 unsigned GetNumberOfParameters() const;
00150
00154 const std::vector<std::string>& rGetParameterNames() const;
00155
00159 const std::vector<std::string>& rGetParameterUnits() const;
00160
00170 unsigned GetParameterIndex(const std::string& rName) const;
00171
00180 bool HasParameter(const std::string& rName) const;
00181
00189 std::string GetParameterUnits(unsigned index) const;
00190
00191
00192
00193
00194
00198 unsigned GetNumberOfDerivedQuantities() const;
00199
00203 const std::vector<std::string>& rGetDerivedQuantityNames() const;
00204
00208 const std::vector<std::string>& rGetDerivedQuantityUnits() const;
00209
00215 unsigned GetDerivedQuantityIndex(const std::string& rName) const;
00216
00225 bool HasDerivedQuantity(const std::string& rName) const;
00226
00233 std::string GetDerivedQuantityUnits(unsigned index) const;
00234
00235
00236
00237
00238
00247 unsigned GetAnyVariableIndex(const std::string& rName) const;
00248
00258 bool HasAnyVariable(const std::string& rName) const;
00259
00267 std::string GetAnyVariableUnits(unsigned index) const;
00268
00276 std::string GetAnyVariableUnits(const std::string& rName) const;
00277
00278
00279 protected:
00281 unsigned mNumberOfStateVariables;
00282
00289 boost::shared_ptr<AbstractOdeSystemInformation> mpSystemInfo;
00290
00291 };
00292
00293
00302 template<typename VECTOR>
00303 class AbstractParameterisedSystem : public AbstractUntemplatedParameterisedSystem
00304 {
00305 friend class TestAbstractCvodeSystem;
00306
00307 private:
00315 std::string GetStateMessage(const std::string& message, VECTOR Y);
00316
00317 protected:
00319 VECTOR mStateVariables;
00320
00322 VECTOR mParameters;
00323
00331 std::string DumpState(const std::string& rMessage);
00332
00341 std::string DumpState(const std::string& rMessage,
00342 VECTOR Y);
00343
00344 public:
00350 AbstractParameterisedSystem(unsigned numberOfStateVariables);
00351
00352
00353
00354
00355
00359 VECTOR& rGetStateVariables();
00360
00365 VECTOR GetStateVariables();
00366
00373 void SetStateVariables(const VECTOR& rStateVariables);
00374
00380 double GetStateVariable(unsigned index) const;
00381
00387 double GetStateVariable(const std::string& rName) const;
00388
00395 void SetStateVariable(unsigned index, double newValue);
00396
00403 void SetStateVariable(const std::string& rName, double newValue);
00404
00417 virtual void VerifyStateVariables()
00418 {}
00419
00420
00421
00422
00423
00433 void SetDefaultInitialConditions(const VECTOR& rInitialConditions);
00434
00445 void SetDefaultInitialCondition(unsigned index, double initialCondition);
00446
00452 VECTOR GetInitialConditions() const;
00453
00457 void ResetToInitialConditions();
00458
00459
00460
00461
00462
00468 double GetParameter(unsigned index) const;
00469
00475 double GetParameter(const std::string& rName) const;
00476
00483 void SetParameter(const std::string& rName, double value);
00484
00491 void SetParameter(unsigned index, double value);
00492
00493
00494
00495
00496
00510 double GetAnyVariable(unsigned index, double time=0.0,
00511 VECTOR* pDerivedQuantities=NULL);
00512
00526 double GetAnyVariable(const std::string& rName, double time=0.0,
00527 VECTOR* pDerivedQuantities=NULL);
00528
00536 void SetAnyVariable(unsigned index, double value);
00537
00545 void SetAnyVariable(const std::string& rName, double value);
00546
00547
00548
00549
00550
00558 virtual VECTOR ComputeDerivedQuantities(double time,
00559 const VECTOR& rState);
00560
00566 VECTOR ComputeDerivedQuantitiesFromCurrentState(double time);
00567 };
00568
00569
00570
00571 #endif