Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
AbstractCardiacCell.hpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, 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
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34*/
35
36#ifndef ABSTRACTCARDIACCELL_HPP_
37#define ABSTRACTCARDIACCELL_HPP_
38
41#include "ClassIsAbstract.hpp"
42#include <boost/serialization/base_object.hpp>
43#include <boost/shared_ptr.hpp>
44#include <boost/serialization/shared_ptr.hpp>
45
46
47// This is only needed to prevent compilation errors on PETSc 2.2/Boost 1.33.1 combo
49
50#include "AbstractCardiacCellInterface.hpp"
51#include "AbstractOdeSystem.hpp"
52#include "AbstractIvpOdeSolver.hpp"
53#include "AbstractStimulusFunction.hpp"
54
55#include <vector>
56
57typedef enum _CellModelState
58{
59 STATE_UNSET = 0,
60 FAST_VARS_ONLY,
61 ALL_VARS
62} CellModelState;
63
75{
76private:
85 template<class Archive>
86 void serialize(Archive & archive, const unsigned int version)
87 {
88 // This calls serialize on the base class.
89 archive & boost::serialization::base_object<AbstractOdeSystem>(*this);
90
91 if (version > 0)
92 {
93 archive & boost::serialization::base_object<AbstractCardiacCellInterface>(*this);
94 }
95 archive & mDt;
96
97 // For version 2 and above these move into AbstractCardiacCellInterface
98 // (AbstractCardiacCellInterface serialization moved to 1 at the same time as this moved to 2).
99 if (version <= 1)
100 {
101 archive & this->mSetVoltageDerivativeToZero;
102 if (version > 0)
103 {
104 // Note that when loading a version 0 archive, this will be initialised to
105 // false by our constructor. So we should get a consistent (wrong) answer
106 // with previous versions of Chaste when in tissue.
107 archive & this->mIsUsedInTissue;
108 archive & this->mHasDefaultStimulusFromCellML;
109 }
110 }
111
112 if (version == 0)
113 {
115 }
116
117 // Paranoia check
118 assert(this->mParameters.size() == this->rGetParameterNames().size());
119 }
120
133 void CheckForArchiveFix();
134
135protected:
137 double mDt;
138
139public:
151 AbstractCardiacCell(boost::shared_ptr<AbstractIvpOdeSolver> pOdeSolver,
152 unsigned numberOfStateVariables,
153 unsigned voltageIndex,
154 boost::shared_ptr<AbstractStimulusFunction> pIntracellularStimulus);
155
157 virtual ~AbstractCardiacCell();
158
166 void Init();
167
173 void SetTimestep(double dt);
174
182 virtual void SolveAndUpdateState(double tStart, double tEnd);
183
193 virtual OdeSolution Compute(double tStart, double tEnd, double tSamp=0.0);
194
202 virtual void ComputeExceptVoltage(double tStart, double tEnd);
203
207 void SetVoltage(double voltage);
208
213 double GetVoltage();
214
215
225 unsigned GetNumberOfStateVariables() const;
226
236 unsigned GetNumberOfParameters() const;
237
247 std::vector<double> GetStdVecStateVariables();
248
258 const std::vector<std::string>& rGetStateVariableNames() const;
259
260
270 void SetStateVariables(const std::vector<double>& rVariables);
271
282 void SetStateVariable(unsigned index, double newValue);
283
294 void SetStateVariable(const std::string& rName, double newValue);
295
307 double GetAnyVariable(const std::string& rName, double time=0.0);
308
319 double GetParameter(const std::string& rParameterName);
320
331 double GetParameter(unsigned parameterIndex);
332
343 void SetParameter(const std::string& rParameterName, double value);
344
346 // METHODS NEEDED BY FAST CARDIAC CELLS
348
360 virtual void SetState(CellModelState state);
361
369 virtual void SetSlowValues(const std::vector<double> &rSlowValues);
370
378 virtual void GetSlowValues(std::vector<double>& rSlowValues);
379
384 virtual bool IsFastOnly();
385
398 virtual void AdjustOutOfRangeSlowValues(std::vector<double>& rSlowValues);
399
406 virtual unsigned GetNumSlowValues();
407};
408
410BOOST_CLASS_VERSION(AbstractCardiacCell, 2)
411
412#endif /*ABSTRACTCARDIACCELL_HPP_*/
gcov doesn't like this file...
#define CLASS_IS_ABSTRACT(T)
virtual void SolveAndUpdateState(double tStart, double tEnd)
double GetParameter(const std::string &rParameterName)
virtual OdeSolution Compute(double tStart, double tEnd, double tSamp=0.0)
void serialize(Archive &archive, const unsigned int version)
virtual void AdjustOutOfRangeSlowValues(std::vector< double > &rSlowValues)
virtual void SetState(CellModelState state)
virtual void GetSlowValues(std::vector< double > &rSlowValues)
void SetVoltage(double voltage)
virtual void SetSlowValues(const std::vector< double > &rSlowValues)
void SetParameter(const std::string &rParameterName, double value)
const std::vector< std::string > & rGetStateVariableNames() const
std::vector< double > GetStdVecStateVariables()
double GetAnyVariable(const std::string &rName, double time=0.0)
unsigned GetNumberOfStateVariables() const
void SetStateVariables(const std::vector< double > &rVariables)
friend class boost::serialization::access
virtual unsigned GetNumSlowValues()
virtual void ComputeExceptVoltage(double tStart, double tEnd)
unsigned GetNumberOfParameters() const
void SetStateVariable(unsigned index, double newValue)