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 CELLCYCLEMODELODESOLVER_HPP_
00030 #define CELLCYCLEMODELODESOLVER_HPP_
00031
00032 #include <boost/utility.hpp>
00033
00034 #include "ChasteSerialization.hpp"
00035
00036 #include "AbstractCellCycleModelOdeSolver.hpp"
00037 #include "BackwardEulerIvpOdeSolver.hpp"
00038
00049 template <class CELL_CYCLE_MODEL, class ODE_SOLVER>
00050 class CellCycleModelOdeSolver : public AbstractCellCycleModelOdeSolver, private boost::noncopyable
00051 {
00052 private:
00054 static boost::shared_ptr<CellCycleModelOdeSolver<CELL_CYCLE_MODEL, ODE_SOLVER> > mpInstance;
00055
00057 CellCycleModelOdeSolver();
00058
00060 friend class boost::serialization::access;
00067 template<class Archive>
00068 void serialize(Archive & archive, const unsigned int version)
00069 {
00070 archive & boost::serialization::base_object<AbstractCellCycleModelOdeSolver>(*this);
00071 archive & mpInstance;
00072 }
00073
00074 public:
00076 static boost::shared_ptr<CellCycleModelOdeSolver<CELL_CYCLE_MODEL, ODE_SOLVER> > Instance();
00077
00079 bool IsSetUp();
00080
00082 void Initialise();
00083
00091 virtual bool IsAdaptive();
00092 };
00093
00095 template<class CELL_CYCLE_MODEL, class ODE_SOLVER>
00096 boost::shared_ptr<CellCycleModelOdeSolver<CELL_CYCLE_MODEL, ODE_SOLVER> > CellCycleModelOdeSolver<CELL_CYCLE_MODEL, ODE_SOLVER>::mpInstance;
00097
00098
00099 template<class CELL_CYCLE_MODEL, class ODE_SOLVER>
00100 CellCycleModelOdeSolver<CELL_CYCLE_MODEL, ODE_SOLVER>::CellCycleModelOdeSolver()
00101 : AbstractCellCycleModelOdeSolver()
00102 {
00110 }
00111
00112 template<class CELL_CYCLE_MODEL, class ODE_SOLVER>
00113 boost::shared_ptr<CellCycleModelOdeSolver<CELL_CYCLE_MODEL, ODE_SOLVER> > CellCycleModelOdeSolver<CELL_CYCLE_MODEL, ODE_SOLVER>::Instance()
00114 {
00115 if (!mpInstance)
00116 {
00117 mpInstance.reset(new CellCycleModelOdeSolver<CELL_CYCLE_MODEL, ODE_SOLVER>);
00118 }
00119 return mpInstance;
00120 }
00121
00122 template<class CELL_CYCLE_MODEL, class ODE_SOLVER>
00123 bool CellCycleModelOdeSolver<CELL_CYCLE_MODEL, ODE_SOLVER>::IsSetUp()
00124 {
00125 return mpOdeSolver;
00126 }
00127
00128 template<class CELL_CYCLE_MODEL, class ODE_SOLVER>
00129 void CellCycleModelOdeSolver<CELL_CYCLE_MODEL, ODE_SOLVER>::Initialise()
00130 {
00131 mpOdeSolver.reset(new ODE_SOLVER);
00132 }
00133
00134 template<class CELL_CYCLE_MODEL, class ODE_SOLVER>
00135 bool CellCycleModelOdeSolver<CELL_CYCLE_MODEL, ODE_SOLVER>::IsAdaptive()
00136 {
00137 return AbstractCellCycleModelOdeSolver::IsAdaptive();
00138 }
00139
00140
00145 template<class CELL_CYCLE_MODEL>
00146 class CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver> : public AbstractCellCycleModelOdeSolver, private boost::noncopyable
00147 {
00148 private:
00150 static boost::shared_ptr<CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver> > mpInstance;
00151
00153 CellCycleModelOdeSolver();
00154
00156 friend class boost::serialization::access;
00163 template<class Archive>
00164 void serialize(Archive & archive, const unsigned int version)
00165 {
00166 archive & boost::serialization::base_object<AbstractCellCycleModelOdeSolver>(*this);
00167 archive & mpInstance;
00168 }
00169
00170 public:
00172 static boost::shared_ptr<CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver> > Instance();
00173
00175 bool IsSetUp();
00176
00178 void Initialise();
00179
00181 void Reset();
00182 };
00183
00184 template<class CELL_CYCLE_MODEL>
00185 boost::shared_ptr<CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver> > CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver>::mpInstance;
00186
00187 template<class CELL_CYCLE_MODEL>
00188 CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver>::CellCycleModelOdeSolver()
00189 : AbstractCellCycleModelOdeSolver()
00190 {
00191 }
00192
00193 template<class CELL_CYCLE_MODEL>
00194 boost::shared_ptr<CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver> > CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver>::Instance()
00195 {
00196 if (!mpInstance)
00197 {
00198 mpInstance.reset(new CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver>);
00199 }
00200 return mpInstance;
00201 }
00202
00203 template<class CELL_CYCLE_MODEL>
00204 bool CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver>::IsSetUp()
00205 {
00206 return mpOdeSolver && (mSizeOfOdeSystem != UNSIGNED_UNSET);
00207 }
00208
00209 template<class CELL_CYCLE_MODEL>
00210 void CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver>::Initialise()
00211 {
00212 if (mSizeOfOdeSystem == UNSIGNED_UNSET)
00213 {
00214 EXCEPTION("SetSizeOfOdeSystem() must be called before calling Initialise()");
00215 }
00216 mpOdeSolver.reset(new BackwardEulerIvpOdeSolver(mSizeOfOdeSystem));
00217 }
00218
00219 template<class CELL_CYCLE_MODEL>
00220 void CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver>::Reset()
00221 {
00222 mSizeOfOdeSystem = UNSIGNED_UNSET;
00223 mpOdeSolver.reset();
00224 }
00225
00226 #endif