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 template<unsigned DIM> class AbstractVertexBasedDivisionRule;
00049
00057 template<unsigned DIM>
00058 class VertexBasedCellPopulation : public AbstractOffLatticeCellPopulation<DIM>
00059 {
00060 private:
00061
00065 friend class TestVertexBasedDivisionRules;
00066
00071 bool mDeleteMesh;
00072
00077 MutableVertexMesh<DIM, DIM>* mpMutableVertexMesh;
00078
00080 bool mOutputCellRearrangementLocations;
00081
00084 boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > mpVertexBasedDivisionRule;
00085
00090 std::vector< c_vector<double, DIM> > mLocationsOfT2Swaps;
00091
00096 std::vector< unsigned > mCellIdsOfT2Swaps;
00097
00103 virtual void WriteVtkResultsToFile(const std::string& rDirectory);
00104
00105 friend class boost::serialization::access;
00117 template<class Archive>
00118 void serialize(Archive & archive, const unsigned int version)
00119 {
00120 archive & boost::serialization::base_object<AbstractOffLatticeCellPopulation<DIM> >(*this);
00121 archive & mOutputCellRearrangementLocations;
00122 archive & mpVertexBasedDivisionRule;
00123 }
00124
00129 void Validate();
00130
00131 public:
00132
00145 VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh,
00146 std::vector<CellPtr>& rCells,
00147 bool deleteMesh=false,
00148 bool validate=true,
00149 const std::vector<unsigned> locationIndices=std::vector<unsigned>());
00150
00156 VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh);
00157
00161 virtual ~VertexBasedCellPopulation();
00162
00169 double GetDampingConstant(unsigned nodeIndex);
00170
00174 MutableVertexMesh<DIM, DIM>& rGetMesh();
00175
00179 const MutableVertexMesh<DIM, DIM>& rGetMesh() const;
00180
00188 VertexElement<DIM, DIM>* GetElement(unsigned elementIndex);
00189
00193 unsigned GetNumElements();
00194
00200 unsigned GetNumNodes();
00201
00213 c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
00214
00222 Node<DIM>* GetNode(unsigned index);
00223
00232 std::set<unsigned> GetNeighbouringLocationIndices(CellPtr pCell);
00233
00242 unsigned AddNode(Node<DIM>* pNewNode);
00243
00249 void UpdateNodeLocations(double dt);
00250
00259 void SetNode(unsigned index, ChastePoint<DIM>& rNewLocation);
00260
00268 VertexElement<DIM, DIM>* GetElementCorrespondingToCell(CellPtr pCell);
00269
00281 CellPtr AddCell(CellPtr pNewCell,
00282 const c_vector<double,DIM>& rCellDivisionVector,
00283 CellPtr pParentCell=CellPtr());
00284
00294 unsigned RemoveDeadCells();
00295
00302 bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
00303
00312 void Update(bool hasHadBirthsOrDeaths=true);
00313
00321 virtual void OpenWritersFiles(OutputFileHandler& rOutputFileHandler);
00322
00329 virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
00330
00337 virtual void AcceptPopulationCountWriter(boost::shared_ptr<AbstractCellPopulationCountWriter<DIM, DIM> > pPopulationCountWriter);
00338
00346 virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
00347
00354 double GetVolumeOfCell(CellPtr pCell);
00355
00361 std::vector< c_vector< double, DIM > > GetLocationsOfT2Swaps();
00362
00368 std::vector< unsigned > GetCellIdsOfT2Swaps();
00369
00375 void AddLocationOfT2Swap(c_vector< double, DIM> locationOfT2Swap);
00376
00382 void AddCellIdOfT2Swap(unsigned idOfT2Swap);
00383
00387 void ClearLocationsAndCellIdsOfT2Swaps();
00388
00392 bool GetOutputCellRearrangementLocations();
00393
00399 void SetOutputCellRearrangementLocations(bool outputCellRearrangementLocations);
00400
00406 void OutputCellPopulationParameters(out_stream& rParamsFile);
00407
00417 double GetWidth(const unsigned& rDimension);
00418
00425 std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
00426
00432 TetrahedralMesh<DIM, DIM>* GetTetrahedralMeshUsingVertexMesh();
00433
00437 boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > GetVertexBasedDivisionRule();
00438
00444 void SetVertexBasedDivisionRule(boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > pVertexBasedDivisionRule);
00445 };
00446
00447 #include "SerializationExportWrapper.hpp"
00448 EXPORT_TEMPLATE_CLASS_SAME_DIMS(VertexBasedCellPopulation)
00449
00450 namespace boost
00451 {
00452 namespace serialization
00453 {
00457 template<class Archive, unsigned DIM>
00458 inline void save_construct_data(
00459 Archive & ar, const VertexBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00460 {
00461
00462 const MutableVertexMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
00463 ar & p_mesh;
00464 }
00465
00470 template<class Archive, unsigned DIM>
00471 inline void load_construct_data(
00472 Archive & ar, VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
00473 {
00474
00475 MutableVertexMesh<DIM,DIM>* p_mesh;
00476 ar >> p_mesh;
00477
00478
00479 ::new(t)VertexBasedCellPopulation<DIM>(*p_mesh);
00480 }
00481 }
00482 }
00483
00484 #endif
00485