AbstractParameterisedSystem.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
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     // Attribute methods
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     // State variable methods
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     // Parameter methods
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     // Derived quantity methods
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     // "Any variable" methods
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     // State variable methods
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     // Initial condition methods
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     // Parameter methods
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     // "Any variable" methods
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     // Derived quantity methods
00549     //
00550 
00558     virtual VECTOR ComputeDerivedQuantities(double time,
00559                                             const VECTOR& rState);
00560 
00566     VECTOR ComputeDerivedQuantitiesFromCurrentState(double time);
00567 };
00568 
00569 
00570 
00571 #endif /*ABSTRACTPARAMETERISEDSYSTEM_HPP_*/
Generated on Thu Dec 22 13:00:16 2011 for Chaste by  doxygen 1.6.3