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 #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
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
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
00235 AbstractCellPopulation<DIM>* p_cell_population;
00236 ar >> p_cell_population;
00237
00238
00239
00240 ::new(t)OffLatticeSimulation<DIM>(*p_cell_population, true, false);
00241 }
00242 }
00243 }
00244
00245 #endif