TimeStepper.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 TIMESTEPPER_HPP_
00030 #define TIMESTEPPER_HPP_
00031 
00032 #include <vector>
00033 #include <climits>
00034 #include <boost/serialization/vector.hpp>
00035 
00036 #include "ChasteSerialization.hpp"
00037 #include "Exception.hpp"
00038 
00045 class TimeStepper
00046 {
00047     friend class TestTimeStepper;
00048 private:
00049     /*
00050      * Private default constructor for archiving
00051      */
00052      TimeStepper(){};
00053 
00054 public:
00055 
00069     TimeStepper(double startTime, double endTime, double dt, bool enforceConstantTimeStep=false, std::vector<double> additionalTimes=std::vector<double> ());
00070 
00077     void AdvanceOneTimeStep();
00078 
00082     double GetTime() const;
00083 
00087     double GetNextTime() const;
00088 
00093     double GetNextTimeStep();
00094 
00100     double GetIdealTimeStep();
00101 
00105     bool IsTimeAtEnd() const;
00106 
00111     unsigned EstimateTimeSteps() const;
00112 
00117     unsigned GetTotalTimeStepsTaken() const;
00118 
00126     void ResetTimeStep(double dt);
00127 
00128 private:
00129 
00131     double mStart;
00132 
00134     double mEnd;
00135 
00137     double mDt;
00138 
00140     unsigned mTotalTimeStepsTaken;
00141 
00143     unsigned mAdditionalTimesReached;
00144 
00146     double mTime;
00147 
00149     double mNextTime;
00150 
00156     double mEpsilon;
00157 
00159     double CalculateNextTime();
00160 
00162     std::vector<double> mAdditionalTimes;
00163 
00165     friend class boost::serialization::access;
00166 
00172     template<class Archive>
00173     void serialize(Archive & archive, const unsigned int version)
00174     {
00175         archive & mStart;
00176         archive & mEnd;
00177         archive & mDt;
00178         archive & mTotalTimeStepsTaken;
00179         archive & mTime;
00180         archive & mNextTime;
00181         archive & mEpsilon;
00182         archive & mAdditionalTimesReached;
00183         archive & mAdditionalTimes;
00184     }
00185 
00186 };
00187 
00188 #include "SerializationExportWrapper.hpp"
00189 // Declare identifier for the serializer
00190 CHASTE_CLASS_EXPORT(TimeStepper)
00191 
00192 #endif /*TIMESTEPPER_HPP_*/
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3