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 #ifndef VERTEXBASEDCELLPOPULATION_HPP_
00029 #define VERTEXBASEDCELLPOPULATION_HPP_
00030
00031
00032 #include "AbstractCellPopulation.hpp"
00033 #include "MutableVertexMesh.hpp"
00034 #include "ArchiveLocationInfo.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
00041
00042 #include "WildTypeCellMutationState.hpp"
00043
00051 template<unsigned DIM>
00052 class VertexBasedCellPopulation : public AbstractCellPopulation<DIM>
00053 {
00054 private:
00055
00057 MutableVertexMesh<DIM, DIM>& mrMesh;
00058
00063 bool mDeleteMesh;
00064
00066 out_stream mpVizElementsFile;
00067
00069 out_stream mpT1SwapLocationsFile;
00070
00072 out_stream mpT3SwapLocationsFile;
00073
00077 void WriteVtkResultsToFile();
00078
00079 friend class boost::serialization::access;
00091 template<class Archive>
00092 void serialize(Archive & archive, const unsigned int version)
00093 {
00094 archive & boost::serialization::base_object<AbstractCellPopulation<DIM> >(*this);
00095 }
00096
00101 void Validate();
00102
00103 public:
00104
00117 VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh,
00118 std::vector<CellPtr>& rCells,
00119 bool deleteMesh=false,
00120 bool validate=true,
00121 const std::vector<unsigned> locationIndices=std::vector<unsigned>());
00122
00128 VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh);
00129
00133 virtual ~VertexBasedCellPopulation();
00134
00141 double GetDampingConstant(unsigned nodeIndex);
00142
00146 MutableVertexMesh<DIM, DIM>& rGetMesh();
00147
00151 const MutableVertexMesh<DIM, DIM>& rGetMesh() const;
00152
00160 VertexElement<DIM, DIM>* GetElement(unsigned elementIndex);
00161
00165 unsigned GetNumElements();
00166
00172 unsigned GetNumNodes();
00173
00186 c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
00187
00195 Node<DIM>* GetNode(unsigned index);
00196
00205 unsigned AddNode(Node<DIM>* pNewNode);
00206
00213 void UpdateNodeLocations(const std::vector< c_vector<double, DIM> >& rNodeForces, double dt);
00214
00223 void SetNode(unsigned index, ChastePoint<DIM>& rNewLocation);
00224
00232 VertexElement<DIM, DIM>* GetElementCorrespondingToCell(CellPtr pCell);
00233
00245 CellPtr AddCell(CellPtr pNewCell, const c_vector<double,DIM>& rCellDivisionVector, CellPtr pParentCell=CellPtr());
00246
00256 unsigned RemoveDeadCells();
00257
00264 bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
00265
00274 void Update(bool hasHadBirthsOrDeaths=true);
00275
00282 void CreateOutputFiles(const std::string& rDirectory, bool cleanOutputDirectory);
00286 void CloseOutputFiles();
00287
00291 void WriteResultsToFiles();
00292
00296 virtual void GenerateCellResultsAndWriteToFiles();
00297
00306 void OutputCellPopulationParameters(out_stream& rParamsFile);
00307
00317 double GetWidth(const unsigned& rDimension);
00318 };
00319
00320 #include "SerializationExportWrapper.hpp"
00321 EXPORT_TEMPLATE_CLASS_SAME_DIMS(VertexBasedCellPopulation)
00322
00323 namespace boost
00324 {
00325 namespace serialization
00326 {
00330 template<class Archive, unsigned DIM>
00331 inline void save_construct_data(
00332 Archive & ar, const VertexBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00333 {
00334
00335 const MutableVertexMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
00336 ar & p_mesh;
00337 }
00338
00343 template<class Archive, unsigned DIM>
00344 inline void load_construct_data(
00345 Archive & ar, VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
00346 {
00347
00348 MutableVertexMesh<DIM,DIM>* p_mesh;
00349 ar >> p_mesh;
00350
00351
00352 ::new(t)VertexBasedCellPopulation<DIM>(*p_mesh);
00353 }
00354 }
00355 }
00356
00357 #endif
00358