OnLatticeSimulation.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 ONLATTICESIMULATION_HPP_
00030 #define ONLATTICESIMULATION_HPP_
00031 
00032 #include "ChasteSerialization.hpp"
00033 #include <boost/serialization/base_object.hpp>
00034 
00035 #include "AbstractCellBasedSimulation.hpp"
00036 #include "AbstractCaUpdateRule.hpp"
00037 #include "AbstractPottsUpdateRule.hpp"
00038 
00051 template<unsigned DIM>
00052 class OnLatticeSimulation : public AbstractCellBasedSimulation<DIM>
00053 {
00054 private:
00055 
00057     friend class boost::serialization::access;
00064     template<class Archive>
00065     void serialize(Archive & archive, const unsigned int version)
00066     {
00067         archive & boost::serialization::base_object<AbstractCellBasedSimulation<DIM> >(*this);
00068         archive & mOutputCellVelocities;
00069     }
00070 
00071 protected:
00072 
00077     bool mOutputCellVelocities;
00078 
00080     out_stream mpCellVelocitiesFile;
00081 
00088     void UpdateCellPopulation();
00089 
00095     void UpdateCellLocationsAndTopology();
00096 
00106     virtual c_vector<double, DIM> CalculateCellDivisionVector(CellPtr pParentCell);
00107 
00111     virtual void WriteVisualizerSetupFile();
00112 
00113 
00114 public:
00115 
00125     OnLatticeSimulation(AbstractCellPopulation<DIM>& rCellPopulation,
00126                         bool deleteCellPopulationInDestructor=false,
00127                         bool initialiseCells=true);
00128 
00134     void AddCaUpdateRule(boost::shared_ptr<AbstractCaUpdateRule<DIM> > pUpdateRule);
00135 
00141     void AddPottsUpdateRule(boost::shared_ptr<AbstractPottsUpdateRule<DIM> > pUpdateRule);
00142 
00147     bool GetOutputCellVelocities();
00148 
00154     void SetOutputCellVelocities(bool outputCellVelocities);
00155 
00159     virtual void SetupSolve();
00160 
00164     virtual void AfterSolve();
00165 
00172     void OutputAdditionalSimulationSetup(out_stream& rParamsFile);
00173 
00179     void OutputSimulationParameters(out_stream& rParamsFile);
00180 };
00181 
00182 // Serialization for Boost >= 1.36
00183 #include "SerializationExportWrapper.hpp"
00184 EXPORT_TEMPLATE_CLASS_SAME_DIMS(OnLatticeSimulation)
00185 
00186 namespace boost
00187 {
00188 namespace serialization
00189 {
00193 template<class Archive, unsigned DIM>
00194 inline void save_construct_data(
00195     Archive & ar, const OnLatticeSimulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00196 {
00197     // Save data required to construct instance
00198     const AbstractCellPopulation<DIM>* p_cell_population = &(t->rGetCellPopulation());
00199     ar & p_cell_population;
00200 }
00201 
00205 template<class Archive, unsigned DIM>
00206 inline void load_construct_data(
00207     Archive & ar, OnLatticeSimulation<DIM> * t, const unsigned int file_version)
00208 {
00209     // Retrieve data from archive required to construct new instance
00210     AbstractCellPopulation<DIM>* p_cell_population;
00211     ar >> p_cell_population;
00212 
00213     // Invoke inplace constructor to initialise instance, last two variables set extra
00214     // member variables to be deleted as they are loaded from archive and to not initialise sells.
00215     ::new(t)OnLatticeSimulation<DIM>(*p_cell_population, true, false);
00216 }
00217 }
00218 } // namespace
00219 
00220 #endif /*ONLATTICESIMULATION_HPP_*/
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3