Chaste  Release::2018.1
AbstractParameterisedSystem.hpp
1 /*
2 
3 Copyright (c) 2005-2018, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
36 #ifndef ABSTRACTPARAMETERISEDSYSTEM_HPP_
37 #define ABSTRACTPARAMETERISEDSYSTEM_HPP_
38 
39 #include <vector>
40 #include <string>
41 #include <boost/shared_ptr.hpp>
42 
43 #include "AbstractUntemplatedParameterisedSystem.hpp"
44 
45 
54 template<typename VECTOR>
56 {
57 friend class TestAbstractCvodeSystem;
58 
59 private:
67  std::string GetStateMessage(const std::string& rMessage, VECTOR Y);
68 
69 protected:
72 
74  VECTOR mParameters;
75 
84  std::string DumpState(const std::string& rMessage);
85 
95  std::string DumpState(const std::string& rMessage,
96  VECTOR Y);
97 
109  std::string DumpState(const std::string& rMessage,
110  VECTOR Y,
111  double time);
112 
122  void CheckParametersOnLoad(const std::vector<double>& rParameters,
123  const std::vector<std::string>& rParameterNames);
124 
125 public:
131  AbstractParameterisedSystem(unsigned numberOfStateVariables);
132 
133  //
134  // State variable methods
135  //
136 
140  VECTOR& rGetStateVariables();
141 
146  VECTOR GetStateVariables();
147 
154  void SetStateVariables(const VECTOR& rStateVariables);
155 
161  double GetStateVariable(unsigned index) const;
162 
168  double GetStateVariable(const std::string& rName) const;
169 
176  void SetStateVariable(unsigned index, double newValue);
177 
184  void SetStateVariable(const std::string& rName, double newValue);
185 
198  virtual void VerifyStateVariables()
199  {}
200 
201  //
202  // Initial condition methods
203  //
204 
214  void SetDefaultInitialConditions(const VECTOR& rInitialConditions);
215 
226  void SetDefaultInitialCondition(unsigned index, double initialCondition);
227 
233  VECTOR GetInitialConditions() const;
234 
239 
240  //
241  // Parameter methods
242  //
243 
249  double GetParameter(unsigned index) const;
250 
256  double GetParameter(const std::string& rName) const;
257 
264  void SetParameter(const std::string& rName, double value);
265 
272  void SetParameter(unsigned index, double value);
273 
274  //
275  // "Any variable" methods
276  //
277 
291  double GetAnyVariable(unsigned index, double time=0.0,
292  VECTOR* pDerivedQuantities=NULL);
293 
307  double GetAnyVariable(const std::string& rName, double time=0.0,
308  VECTOR* pDerivedQuantities=NULL);
309 
317  void SetAnyVariable(unsigned index, double value);
318 
326  void SetAnyVariable(const std::string& rName, double value);
327 
328  //
329  // Derived quantity methods
330  //
331 
340  virtual VECTOR ComputeDerivedQuantities(double time,
341  const VECTOR& rState);
342 
349  VECTOR ComputeDerivedQuantitiesFromCurrentState(double time);
350 };
351 
352 #endif /*ABSTRACTPARAMETERISEDSYSTEM_HPP_*/
void SetDefaultInitialCondition(unsigned index, double initialCondition)
void SetDefaultInitialConditions(const VECTOR &rInitialConditions)
std::string DumpState(const std::string &rMessage)
void SetStateVariables(const VECTOR &rStateVariables)
double GetStateVariable(unsigned index) const
double GetParameter(unsigned index) const
void SetAnyVariable(unsigned index, double value)
void SetParameter(const std::string &rName, double value)
virtual VECTOR ComputeDerivedQuantities(double time, const VECTOR &rState)
void SetStateVariable(unsigned index, double newValue)
void CheckParametersOnLoad(const std::vector< double > &rParameters, const std::vector< std::string > &rParameterNames)
VECTOR ComputeDerivedQuantitiesFromCurrentState(double time)
std::string GetStateMessage(const std::string &rMessage, VECTOR Y)
double GetAnyVariable(unsigned index, double time=0.0, VECTOR *pDerivedQuantities=NULL)
AbstractParameterisedSystem(unsigned numberOfStateVariables)