OffLatticeSimulation.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef OFFLATTICESIMULATION_HPP_
00037 #define OFFLATTICESIMULATION_HPP_
00038
00039 #include "AbstractCellBasedSimulation.hpp"
00040 #include "AbstractForce.hpp"
00041 #include "AbstractCellPopulationBoundaryCondition.hpp"
00042
00043 #include "ChasteSerialization.hpp"
00044 #include <boost/serialization/base_object.hpp>
00045 #include <boost/serialization/set.hpp>
00046 #include <boost/serialization/vector.hpp>
00047
00068 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM=ELEMENT_DIM>
00069 class OffLatticeSimulation : public AbstractCellBasedSimulation<ELEMENT_DIM,SPACE_DIM>
00070 {
00071 private:
00072
00074 friend class boost::serialization::access;
00075 friend class TestOffLatticeSimulationWithNodeBasedCellPopulation;
00076
00083 template<class Archive>
00084 void serialize(Archive & archive, const unsigned int version)
00085 {
00086 archive & boost::serialization::base_object<AbstractCellBasedSimulation<ELEMENT_DIM,SPACE_DIM> >(*this);
00087 archive & mForceCollection;
00088 archive & mBoundaryConditions;
00089 }
00090
00091 protected:
00092
00094 std::vector<boost::shared_ptr<AbstractForce<ELEMENT_DIM, SPACE_DIM> > > mForceCollection;
00095
00097 std::vector<boost::shared_ptr<AbstractCellPopulationBoundaryCondition<ELEMENT_DIM,SPACE_DIM> > > mBoundaryConditions;
00098
00104 virtual void UpdateCellLocationsAndTopology();
00105
00112 virtual void UpdateNodePositions();
00113
00117 virtual void SetupSolve();
00118
00136 virtual c_vector<double, SPACE_DIM> CalculateCellDivisionVector(CellPtr pParentCell);
00137
00141 virtual void WriteVisualizerSetupFile();
00142
00143 public:
00144
00154 OffLatticeSimulation(AbstractCellPopulation<ELEMENT_DIM,SPACE_DIM>& rCellPopulation,
00155 bool deleteCellPopulationInDestructor=false,
00156 bool initialiseCells=true);
00157
00163 void AddForce(boost::shared_ptr<AbstractForce<ELEMENT_DIM,SPACE_DIM> > pForce);
00164
00168 void RemoveAllForces();
00169
00175 void AddCellPopulationBoundaryCondition(boost::shared_ptr<AbstractCellPopulationBoundaryCondition<ELEMENT_DIM,SPACE_DIM> > pBoundaryCondition);
00176
00180 void RemoveAllCellPopulationBoundaryConditions();
00181
00188 void OutputAdditionalSimulationSetup(out_stream& rParamsFile);
00189
00198 virtual void OutputSimulationParameters(out_stream& rParamsFile);
00199 };
00200
00201
00202 #include "SerializationExportWrapper.hpp"
00203 EXPORT_TEMPLATE_CLASS_ALL_DIMS(OffLatticeSimulation)
00204
00205 namespace boost
00206 {
00207 namespace serialization
00208 {
00212 template<class Archive, unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00213 inline void save_construct_data(
00214 Archive & ar, const OffLatticeSimulation<ELEMENT_DIM,SPACE_DIM> * t, const BOOST_PFTO unsigned int file_version)
00215 {
00216
00217 const AbstractCellPopulation<ELEMENT_DIM,SPACE_DIM>* p_cell_population = &(t->rGetCellPopulation());
00218 ar & p_cell_population;
00219 }
00220
00224 template<class Archive, unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00225 inline void load_construct_data(
00226 Archive & ar, OffLatticeSimulation<ELEMENT_DIM,SPACE_DIM> * t, const unsigned int file_version)
00227 {
00228
00229 AbstractCellPopulation<ELEMENT_DIM,SPACE_DIM>* p_cell_population;
00230 ar >> p_cell_population;
00231
00232
00233
00234 ::new(t)OffLatticeSimulation<ELEMENT_DIM,SPACE_DIM>(*p_cell_population, true, false);
00235 }
00236 }
00237 }
00238
00239 #endif