CellCycleModelOdeSolver.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 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 /*CELLCYCLEMODELODESOLVER_HPP_*/
Generated on Thu Dec 22 13:00:04 2011 for Chaste by  doxygen 1.6.3