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
00146 template<class CELL_CYCLE_MODEL>
00147 class CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver> : public AbstractCellCycleModelOdeSolver, private boost::noncopyable
00148 {
00149 private:
00151 static boost::shared_ptr<CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver> > mpInstance;
00152
00154 CellCycleModelOdeSolver();
00155
00157 friend class boost::serialization::access;
00164 template<class Archive>
00165 void serialize(Archive & archive, const unsigned int version)
00166 {
00167 archive & boost::serialization::base_object<AbstractCellCycleModelOdeSolver>(*this);
00168 archive & mpInstance;
00169 }
00170
00171 public:
00173 static boost::shared_ptr<CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver> > Instance();
00174
00176 bool IsSetUp();
00177
00179 void Initialise();
00180
00182 void Reset();
00183 };
00184
00185 template<class CELL_CYCLE_MODEL>
00186 boost::shared_ptr<CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver> > CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver>::mpInstance;
00187
00188 template<class CELL_CYCLE_MODEL>
00189 CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver>::CellCycleModelOdeSolver()
00190 : AbstractCellCycleModelOdeSolver()
00191 {
00192 }
00193
00194 template<class CELL_CYCLE_MODEL>
00195 boost::shared_ptr<CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver> > CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver>::Instance()
00196 {
00197 if (!mpInstance)
00198 {
00199 mpInstance.reset(new CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver>);
00200 }
00201 return mpInstance;
00202 }
00203
00204 template<class CELL_CYCLE_MODEL>
00205 bool CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver>::IsSetUp()
00206 {
00207 return mpOdeSolver && (mSizeOfOdeSystem != UNSIGNED_UNSET);
00208 }
00209
00210 template<class CELL_CYCLE_MODEL>
00211 void CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver>::Initialise()
00212 {
00213 if (mSizeOfOdeSystem == UNSIGNED_UNSET)
00214 {
00215 EXCEPTION("SetSizeOfOdeSystem() must be called before calling Initialise()");
00216 }
00217 mpOdeSolver.reset(new BackwardEulerIvpOdeSolver(mSizeOfOdeSystem));
00218 }
00219
00220 template<class CELL_CYCLE_MODEL>
00221 void CellCycleModelOdeSolver<CELL_CYCLE_MODEL, BackwardEulerIvpOdeSolver>::Reset()
00222 {
00223 mSizeOfOdeSystem = UNSIGNED_UNSET;
00224 mpOdeSolver.reset();
00225 }
00226
00227 #endif