OffLatticeSimulation.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 OFFLATTICESIMULATION_HPP_
00030 #define OFFLATTICESIMULATION_HPP_
00031 
00032 #include "AbstractCellBasedSimulation.hpp"
00033 #include "AbstractForce.hpp"
00034 #include "AbstractCellPopulationBoundaryCondition.hpp"
00035 
00036 #include "ChasteSerialization.hpp"
00037 #include <boost/serialization/base_object.hpp>
00038 #include <boost/serialization/set.hpp>
00039 #include <boost/serialization/vector.hpp>
00040 
00061 template<unsigned DIM>
00062 class OffLatticeSimulation : public AbstractCellBasedSimulation<DIM>
00063 {
00064 private:
00065 
00067     friend class boost::serialization::access;
00068 
00075     template<class Archive>
00076     void serialize(Archive & archive, const unsigned int version)
00077     {
00078         archive & boost::serialization::base_object<AbstractCellBasedSimulation<DIM> >(*this);
00079         archive & mForceCollection;
00080         archive & mBoundaryConditions;
00081         archive & mOutputNodeVelocities;
00082     }
00083 
00084 protected:
00085 
00087     std::vector<boost::shared_ptr<AbstractForce<DIM> > > mForceCollection;
00088 
00090     std::vector<boost::shared_ptr<AbstractCellPopulationBoundaryCondition<DIM> > > mBoundaryConditions;
00091 
00093     bool mOutputNodeVelocities;
00094 
00096     out_stream mpNodeVelocitiesFile;
00097 
00103     virtual void UpdateCellLocationsAndTopology();
00104 
00112     virtual void UpdateNodePositions(const std::vector< c_vector<double, DIM> >& rNodeForces);
00113 
00117     virtual void SetupSolve();
00118 
00122     virtual void AfterSolve();
00123 
00140     virtual c_vector<double, DIM> CalculateCellDivisionVector(CellPtr pParentCell);
00141 
00145     virtual void WriteVisualizerSetupFile();
00146 
00147 public:
00148 
00158     OffLatticeSimulation(AbstractCellPopulation<DIM>& rCellPopulation,
00159                          bool deleteCellPopulationInDestructor=false,
00160                          bool initialiseCells=true);
00161 
00167     void AddForce(boost::shared_ptr<AbstractForce<DIM> > pForce);
00168 
00174     void AddCellPopulationBoundaryCondition(boost::shared_ptr<AbstractCellPopulationBoundaryCondition<DIM> >  pBoundaryCondition);
00175 
00179     bool GetOutputNodeVelocities();
00180 
00186     void SetOutputNodeVelocities(bool outputNodeVelocities);
00187 
00194     void OutputAdditionalSimulationSetup(out_stream& rParamsFile);
00195 
00204     void OutputSimulationParameters(out_stream& rParamsFile);
00205 };
00206 
00207 // Serialization for Boost >= 1.36
00208 #include "SerializationExportWrapper.hpp"
00209 EXPORT_TEMPLATE_CLASS_SAME_DIMS(OffLatticeSimulation)
00210 
00211 namespace boost
00212 {
00213 namespace serialization
00214 {
00218 template<class Archive, unsigned DIM>
00219 inline void save_construct_data(
00220     Archive & ar, const OffLatticeSimulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00221 {
00222     // Save data required to construct instance
00223     const AbstractCellPopulation<DIM>* p_cell_population = &(t->rGetCellPopulation());
00224     ar & p_cell_population;
00225 }
00226 
00230 template<class Archive, unsigned DIM>
00231 inline void load_construct_data(
00232     Archive & ar, OffLatticeSimulation<DIM> * t, const unsigned int file_version)
00233 {
00234     // Retrieve data from archive required to construct new instance
00235     AbstractCellPopulation<DIM>* p_cell_population;
00236     ar >> p_cell_population;
00237 
00238     // Invoke inplace constructor to initialise instance, last two variables set extra
00239     // member variables to be deleted as they are loaded from archive and to not initialise sells.
00240     ::new(t)OffLatticeSimulation<DIM>(*p_cell_population, true, false);
00241 }
00242 }
00243 } // namespace
00244 
00245 #endif /*OFFLATTICESIMULATION_HPP_*/
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3