CaBasedCellPopulation.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 #ifndef CABASEDCELLPOPULATION_HPP_
00030 #define CABASEDCELLPOPULATION_HPP_
00031
00032 #include <vector>
00033 #include <set>
00034 #include <string>
00035
00036 #include "UblasVectorInclude.hpp"
00037
00038 #include "ChasteSerialization.hpp"
00039 #include <boost/serialization/base_object.hpp>
00040 #include <boost/serialization/vector.hpp>
00041
00042
00043 #include "WildTypeCellMutationState.hpp"
00044
00045 #include "AbstractOnLatticeCellPopulation.hpp"
00046 #include "TetrahedralMesh.hpp"
00047 #include "AbstractCaUpdateRule.hpp"
00048
00049 template<unsigned DIM>
00050 class AbstractCaUpdateRule;
00051
00058 template<unsigned DIM>
00059 class CaBasedCellPopulation : public AbstractOnLatticeCellPopulation<DIM>
00060 {
00061 friend class TestCaBasedCellPopulation;
00062
00063 private:
00064
00066 TetrahedralMesh<DIM, DIM>& mrMesh;
00067
00069 std::vector<boost::shared_ptr<AbstractCaUpdateRule<DIM> > > mUpdateRuleCollection;
00070
00072 std::vector<bool> mIsEmptySite;
00073
00079 bool mOnlyUseNearestNeighboursForDivision;
00080
00086 bool mUseVonNeumannNeighbourhoods;
00087
00093 void SetEmptySites(const std::set<unsigned>& rEmptySiteIndices);
00094
00095 friend class boost::serialization::access;
00107 template<class Archive>
00108 void serialize(Archive & archive, const unsigned int version)
00109 {
00110 archive & boost::serialization::base_object<AbstractOnLatticeCellPopulation<DIM> >(*this);
00111 archive & mUpdateRuleCollection;
00112 archive & mIsEmptySite;
00113 archive & mOnlyUseNearestNeighboursForDivision;
00114 archive & mUseVonNeumannNeighbourhoods;
00115 }
00116
00121 void Validate();
00122
00126 void WriteVtkResultsToFile();
00127
00128 public:
00129
00142 CaBasedCellPopulation(TetrahedralMesh<DIM, DIM>& rMesh,
00143 std::vector<CellPtr>& rCells,
00144 const std::vector<unsigned> locationIndices=std::vector<unsigned>(),
00145 bool deleteMesh=false,
00146 bool validate=true);
00147
00153 CaBasedCellPopulation(TetrahedralMesh<DIM, DIM>& rMesh);
00154
00158 ~CaBasedCellPopulation();
00159
00163 TetrahedralMesh<DIM, DIM>& rGetMesh();
00164
00168 const TetrahedralMesh<DIM, DIM>& rGetMesh() const;
00169
00175 void UpdateCellLocations(double dt);
00176
00183 void SetOnlyUseNearestNeighboursForDivision(bool onlyUseNearestNeighboursForDivision);
00184
00188 bool GetOnlyUseNearestNeighboursForDivision();
00189
00195 void AddUpdateRule(boost::shared_ptr<AbstractCaUpdateRule<DIM> > pUpdateRule);
00196
00202 const std::vector<boost::shared_ptr<AbstractCaUpdateRule<DIM> > >& rGetUpdateRuleCollection() const;
00203
00209 void SetUseVonNeumannNeighbourhoods(bool useVonNeumannNeighbourhoods);
00210
00214 bool GetUseVonNeumannNeighbourhoods();
00215
00219 std::vector<bool>& rGetEmptySites();
00220
00229 bool IsEmptySite(unsigned index);
00230
00234 std::set<unsigned> GetEmptySiteIndices();
00235
00241 unsigned GetNumNodes();
00242
00250 virtual Node<DIM>* GetNode(unsigned index);
00251
00289 virtual CellPtr AddCell(CellPtr pNewCell, const c_vector<double,DIM>& rCellDivisionVector, CellPtr pParentCell=CellPtr());
00290
00299 std::vector<unsigned> GetNeighbouringNodeIndicesVector(unsigned nodeIndex);
00300
00312 std::set<unsigned> GetFreeNeighbouringNodeIndices(unsigned nodeIndex);
00313
00325 std::vector<unsigned> GetMaximumDegreeInEachDirection(unsigned nodeIndex);
00326
00338 std::set<unsigned> GetNthDegreeNeighbouringNodeIndices(unsigned nodeIndex, unsigned degree);
00339
00352 unsigned RemoveDeadCells();
00353
00361 void Update(bool hasHadBirthsOrDeaths=true);
00362
00366 void WriteCellVolumeResultsToFile();
00367
00376 void GenerateCellResults(unsigned locationIndex,
00377 std::vector<unsigned>& rCellProliferativeTypeCounter,
00378 std::vector<unsigned>& rCellCyclePhaseCounter);
00379
00383 virtual void GenerateCellResultsAndWriteToFiles();
00384
00398 bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
00399
00406 void MoveCell(CellPtr pCell, unsigned newLocationIndex);
00407
00415 c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
00416
00425 void OutputCellPopulationParameters(out_stream& rParamsFile);
00426
00436 double GetWidth(const unsigned& rDimension);
00437
00448 std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
00449 };
00450 #undef COVERAGE_IGNORE // Avoid prototypes being treated as code by gcov
00451
00452 #include "SerializationExportWrapper.hpp"
00453 EXPORT_TEMPLATE_CLASS_SAME_DIMS(CaBasedCellPopulation)
00454
00455 namespace boost
00456 {
00457 namespace serialization
00458 {
00462 template<class Archive, unsigned DIM>
00463 inline void save_construct_data(
00464 Archive & ar, const CaBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00465 {
00466
00467 const TetrahedralMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
00468 ar & p_mesh;
00469 }
00470
00475 template<class Archive, unsigned DIM>
00476 inline void load_construct_data(
00477 Archive & ar, CaBasedCellPopulation<DIM> * t, const unsigned int file_version)
00478 {
00479
00480 TetrahedralMesh<DIM,DIM>* p_mesh;
00481 ar >> p_mesh;
00482
00483
00484 ::new(t)CaBasedCellPopulation<DIM>(*p_mesh);
00485 }
00486 }
00487 }
00488
00489 #endif