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
00075 out_stream mpCellVolumesFile;
00076
00080 void WriteVtkResultsToFile();
00081
00082 friend class boost::serialization::access;
00094 template<class Archive>
00095 void serialize(Archive & archive, const unsigned int version)
00096 {
00097 archive & boost::serialization::base_object<AbstractCellPopulation<DIM> >(*this);
00098 }
00099
00104 void Validate();
00105
00106 public:
00107
00120 VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh,
00121 std::vector<CellPtr>& rCells,
00122 bool deleteMesh=false,
00123 bool validate=true,
00124 const std::vector<unsigned> locationIndices=std::vector<unsigned>());
00125
00131 VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh);
00132
00136 virtual ~VertexBasedCellPopulation();
00137
00144 double GetDampingConstant(unsigned nodeIndex);
00145
00149 MutableVertexMesh<DIM, DIM>& rGetMesh();
00150
00154 const MutableVertexMesh<DIM, DIM>& rGetMesh() const;
00155
00163 VertexElement<DIM, DIM>* GetElement(unsigned elementIndex);
00164
00168 unsigned GetNumElements();
00169
00175 unsigned GetNumNodes();
00176
00189 c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
00190
00198 Node<DIM>* GetNode(unsigned index);
00199
00208 unsigned AddNode(Node<DIM>* pNewNode);
00209
00216 void UpdateNodeLocations(const std::vector< c_vector<double, DIM> >& rNodeForces, double dt);
00217
00226 void SetNode(unsigned index, ChastePoint<DIM>& rNewLocation);
00227
00235 VertexElement<DIM, DIM>* GetElementCorrespondingToCell(CellPtr pCell);
00236
00248 CellPtr AddCell(CellPtr pNewCell, const c_vector<double,DIM>& rCellDivisionVector, CellPtr pParentCell=CellPtr());
00249
00259 unsigned RemoveDeadCells();
00260
00267 bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
00268
00277 void Update(bool hasHadBirthsOrDeaths=true);
00278
00285 void CreateOutputFiles(const std::string& rDirectory, bool cleanOutputDirectory);
00289 void CloseOutputFiles();
00290
00294 void WriteResultsToFiles();
00295
00300 void WriteCellVolumeResultsToFile();
00301
00305 virtual void GenerateCellResultsAndWriteToFiles();
00306
00315 void OutputCellPopulationParameters(out_stream& rParamsFile);
00316
00326 double GetWidth(const unsigned& rDimension);
00327 };
00328
00329 #include "SerializationExportWrapper.hpp"
00330 EXPORT_TEMPLATE_CLASS_SAME_DIMS(VertexBasedCellPopulation)
00331
00332 namespace boost
00333 {
00334 namespace serialization
00335 {
00339 template<class Archive, unsigned DIM>
00340 inline void save_construct_data(
00341 Archive & ar, const VertexBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00342 {
00343
00344 const MutableVertexMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
00345 ar & p_mesh;
00346 }
00347
00352 template<class Archive, unsigned DIM>
00353 inline void load_construct_data(
00354 Archive & ar, VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
00355 {
00356
00357 MutableVertexMesh<DIM,DIM>* p_mesh;
00358 ar >> p_mesh;
00359
00360
00361 ::new(t)VertexBasedCellPopulation<DIM>(*p_mesh);
00362 }
00363 }
00364 }
00365
00366 #endif
00367