CellCycleModelOdeSolver.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
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 
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 /*CELLCYCLEMODELODESOLVER_HPP_*/

Generated on Mon Nov 1 12:35:16 2010 for Chaste by  doxygen 1.5.5