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
00060 std::string mDirPath;
00061
00063 out_stream mpVtkMetaFile;
00064
00069 bool mDeleteMesh;
00070
00072 out_stream mpVizElementsFile;
00073
00075 out_stream mpT1SwapLocationsFile;
00076
00078 out_stream mpT3SwapLocationsFile;
00079
00080 friend class boost::serialization::access;
00092 template<class Archive>
00093 void serialize(Archive & archive, const unsigned int version)
00094 {
00095 archive & boost::serialization::base_object<AbstractCellPopulation<DIM> >(*this);
00096 }
00097
00102 void Validate();
00103
00104 public:
00105
00118 VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh,
00119 std::vector<CellPtr>& rCells,
00120 bool deleteMesh=false,
00121 bool validate=true,
00122 const std::vector<unsigned> locationIndices=std::vector<unsigned>());
00123
00129 VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh);
00130
00134 virtual ~VertexBasedCellPopulation();
00135
00142 double GetDampingConstant(unsigned nodeIndex);
00143
00147 MutableVertexMesh<DIM, DIM>& rGetMesh();
00148
00152 const MutableVertexMesh<DIM, DIM>& rGetMesh() const;
00153
00161 VertexElement<DIM, DIM>* GetElement(unsigned elementIndex);
00162
00166 unsigned GetNumElements();
00167
00173 unsigned GetNumNodes();
00174
00187 c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
00188
00196 Node<DIM>* GetNode(unsigned index);
00197
00206 unsigned AddNode(Node<DIM>* pNewNode);
00207
00214 void UpdateNodeLocations(const std::vector< c_vector<double, DIM> >& rNodeForces, double dt);
00215
00224 void SetNode(unsigned index, ChastePoint<DIM>& rNewLocation);
00225
00233 VertexElement<DIM, DIM>* GetElementCorrespondingToCell(CellPtr pCell);
00234
00246 CellPtr AddCell(CellPtr pNewCell, const c_vector<double,DIM>& rCellDivisionVector, CellPtr pParentCell=CellPtr());
00247
00257 unsigned RemoveDeadCells();
00258
00265 bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
00266
00275 void Update(bool hasHadBirthsOrDeaths=true);
00276
00283 void CreateOutputFiles(const std::string& rDirectory, bool cleanOutputDirectory);
00287 void CloseOutputFiles();
00288
00292 void WriteResultsToFiles();
00293
00297 virtual void GenerateCellResultsAndWriteToFiles();
00298
00307 void OutputCellPopulationParameters(out_stream& rParamsFile);
00308
00318 double GetWidth(const unsigned& rDimension);
00319 };
00320
00321 #include "SerializationExportWrapper.hpp"
00322 EXPORT_TEMPLATE_CLASS_SAME_DIMS(VertexBasedCellPopulation)
00323
00324 namespace boost
00325 {
00326 namespace serialization
00327 {
00331 template<class Archive, unsigned DIM>
00332 inline void save_construct_data(
00333 Archive & ar, const VertexBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00334 {
00335
00336 const MutableVertexMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
00337 ar & p_mesh;
00338 }
00339
00344 template<class Archive, unsigned DIM>
00345 inline void load_construct_data(
00346 Archive & ar, VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
00347 {
00348
00349 MutableVertexMesh<DIM,DIM>* p_mesh;
00350 ar >> p_mesh;
00351
00352
00353 ::new(t)VertexBasedCellPopulation<DIM>(*p_mesh);
00354 }
00355 }
00356 }
00357
00358 #endif
00359