AbstractCellCycleModelOdeSolver.cpp

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 #include "AbstractCellCycleModelOdeSolver.hpp"
00030 #include "CvodeAdaptor.hpp"
00031 #include "Exception.hpp"
00032 
00033 AbstractCellCycleModelOdeSolver::AbstractCellCycleModelOdeSolver()
00034     : mSizeOfOdeSystem(UNSIGNED_UNSET)
00035 {
00036 }
00037 
00038 AbstractCellCycleModelOdeSolver::~AbstractCellCycleModelOdeSolver()
00039 {
00040 }
00041 
00042 void AbstractCellCycleModelOdeSolver::Reset()
00043 {
00044 }
00045 
00046 void AbstractCellCycleModelOdeSolver::SolveAndUpdateStateVariable(AbstractOdeSystem* pAbstractOdeSystem,
00047                                                                   double startTime,
00048                                                                   double endTime,
00049                                                                   double timeStep)
00050 {
00051     assert(IsSetUp());
00052     mpOdeSolver->SolveAndUpdateStateVariable(pAbstractOdeSystem, startTime, endTime, timeStep);
00053 }
00054 
00055 bool AbstractCellCycleModelOdeSolver::StoppingEventOccurred()
00056 {
00057     assert(IsSetUp());
00058     return mpOdeSolver->StoppingEventOccurred();
00059 }
00060 
00061 double AbstractCellCycleModelOdeSolver::GetStoppingTime()
00062 {
00063     assert(IsSetUp());
00064     return mpOdeSolver->GetStoppingTime();
00065 }
00066 
00067 void AbstractCellCycleModelOdeSolver::SetSizeOfOdeSystem(unsigned sizeOfOdeSystem)
00068 {
00069     mSizeOfOdeSystem = sizeOfOdeSystem;
00070 }
00071 
00072 unsigned AbstractCellCycleModelOdeSolver::GetSizeOfOdeSystem()
00073 {
00074     return mSizeOfOdeSystem;    
00075 }
00076 
00077 void AbstractCellCycleModelOdeSolver::CheckForStoppingEvents()
00078 {
00079 #ifdef CHASTE_CVODE
00080     assert(IsSetUp());
00081     if (boost::dynamic_pointer_cast<CvodeAdaptor>(mpOdeSolver))
00082     {
00083         (boost::static_pointer_cast<CvodeAdaptor>(mpOdeSolver))->CheckForStoppingEvents();
00084     }
00085 #endif //CHASTE_CVODE
00086 }
00087 
00088 void AbstractCellCycleModelOdeSolver::SetMaxSteps(long int numSteps)
00089 {
00090 #ifdef CHASTE_CVODE
00091     assert(IsSetUp());
00092     if (boost::dynamic_pointer_cast<CvodeAdaptor>(mpOdeSolver))
00093     {
00094         (boost::static_pointer_cast<CvodeAdaptor>(mpOdeSolver))->SetMaxSteps(numSteps);
00095     }
00096 #endif //CHASTE_CVODE
00097 }
00098 
00099 void AbstractCellCycleModelOdeSolver::SetTolerances(double relTol, double absTol)
00100 {
00101 #ifdef CHASTE_CVODE
00102     assert(IsSetUp());
00103     if (boost::dynamic_pointer_cast<CvodeAdaptor>(mpOdeSolver))
00104     {
00105         (boost::static_pointer_cast<CvodeAdaptor>(mpOdeSolver))->SetTolerances(relTol, absTol);
00106     }
00107 #endif //CHASTE_CVODE
00108 }
00109 
00110 bool AbstractCellCycleModelOdeSolver::IsAdaptive()
00111 {
00112     bool adaptive = false;
00113 #ifdef CHASTE_CVODE
00114     assert(IsSetUp());
00115     if (boost::dynamic_pointer_cast<CvodeAdaptor>(mpOdeSolver))
00116     {
00117         adaptive = true;
00118     }
00119 #endif //CHASTE_CVODE
00120     return adaptive;
00121 }

Generated on Tue May 31 14:31:40 2011 for Chaste by  doxygen 1.5.5