VertexBasedCellPopulation.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 VERTEXBASEDCELLPOPULATION_HPP_
00037 #define VERTEXBASEDCELLPOPULATION_HPP_
00038
00039 #include "AbstractOffLatticeCellPopulation.hpp"
00040 #include "MutableVertexMesh.hpp"
00041 #include "AbstractVertexBasedDivisionRule.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
00048
00049 #include "WildTypeCellMutationState.hpp"
00050
00051 template<unsigned DIM> class AbstractVertexBasedDivisionRule;
00052
00060 template<unsigned DIM>
00061 class VertexBasedCellPopulation : public AbstractOffLatticeCellPopulation<DIM>
00062 {
00063 private:
00064
00068 friend class TestVertexBasedDivisionRules;
00069
00074 bool mDeleteMesh;
00075
00080 MutableVertexMesh<DIM, DIM>* mpMutableVertexMesh;
00081
00083 bool mOutputCellRearrangementLocations;
00084
00087 boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > mpVertexBasedDivisionRule;
00088
00094 virtual void WriteVtkResultsToFile(const std::string& rDirectory);
00095
00096 friend class boost::serialization::access;
00108 template<class Archive>
00109 void serialize(Archive & archive, const unsigned int version)
00110 {
00111 archive & boost::serialization::base_object<AbstractOffLatticeCellPopulation<DIM> >(*this);
00112 archive & mOutputCellRearrangementLocations;
00113 archive & mpVertexBasedDivisionRule;
00114 }
00115
00120 void Validate();
00121
00122 public:
00123
00136 VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh,
00137 std::vector<CellPtr>& rCells,
00138 bool deleteMesh=false,
00139 bool validate=true,
00140 const std::vector<unsigned> locationIndices=std::vector<unsigned>());
00141
00147 VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh);
00148
00152 virtual ~VertexBasedCellPopulation();
00153
00160 double GetDampingConstant(unsigned nodeIndex);
00161
00165 MutableVertexMesh<DIM, DIM>& rGetMesh();
00166
00170 const MutableVertexMesh<DIM, DIM>& rGetMesh() const;
00171
00179 VertexElement<DIM, DIM>* GetElement(unsigned elementIndex);
00180
00184 unsigned GetNumElements();
00185
00191 unsigned GetNumNodes();
00192
00204 c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
00205
00213 Node<DIM>* GetNode(unsigned index);
00214
00223 unsigned AddNode(Node<DIM>* pNewNode);
00224
00230 void UpdateNodeLocations(double dt);
00231
00240 void SetNode(unsigned index, ChastePoint<DIM>& rNewLocation);
00241
00249 VertexElement<DIM, DIM>* GetElementCorrespondingToCell(CellPtr pCell);
00250
00262 CellPtr AddCell(CellPtr pNewCell,
00263 const c_vector<double,DIM>& rCellDivisionVector,
00264 CellPtr pParentCell=CellPtr());
00265
00275 unsigned RemoveDeadCells();
00276
00283 bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
00284
00293 void Update(bool hasHadBirthsOrDeaths=true);
00294
00302 virtual void OpenWritersFiles(const std::string& rDirectory);
00303
00310 virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
00311
00319 virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
00320
00327 double GetVolumeOfCell(CellPtr pCell);
00328
00332 bool GetOutputCellRearrangementLocations();
00333
00339 void SetOutputCellRearrangementLocations(bool outputCellRearrangementLocations);
00340
00346 void OutputCellPopulationParameters(out_stream& rParamsFile);
00347
00357 double GetWidth(const unsigned& rDimension);
00358
00365 std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
00366
00372 TetrahedralMesh<DIM, DIM>* GetTetrahedralMeshUsingVertexMesh();
00373
00377 boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > GetVertexBasedDivisionRule();
00378
00384 void SetVertexBasedDivisionRule(boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > pVertexBasedDivisionRule);
00385 };
00386
00387 #include "SerializationExportWrapper.hpp"
00388 EXPORT_TEMPLATE_CLASS_SAME_DIMS(VertexBasedCellPopulation)
00389
00390 namespace boost
00391 {
00392 namespace serialization
00393 {
00397 template<class Archive, unsigned DIM>
00398 inline void save_construct_data(
00399 Archive & ar, const VertexBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00400 {
00401
00402 const MutableVertexMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
00403 ar & p_mesh;
00404 }
00405
00410 template<class Archive, unsigned DIM>
00411 inline void load_construct_data(
00412 Archive & ar, VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
00413 {
00414
00415 MutableVertexMesh<DIM,DIM>* p_mesh;
00416 ar >> p_mesh;
00417
00418
00419 ::new(t)VertexBasedCellPopulation<DIM>(*p_mesh);
00420 }
00421 }
00422 }
00423
00424 #endif
00425