PottsBasedCellPopulation.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 POTTSBASEDCELLPOPULATION_HPP_
00037 #define POTTSBASEDCELLPOPULATION_HPP_
00038
00039 #include "AbstractOnLatticeCellPopulation.hpp"
00040 #include "PottsMesh.hpp"
00041 #include "VertexMesh.hpp"
00042 #include "AbstractPottsUpdateRule.hpp"
00043 #include "MutableMesh.hpp"
00044
00045 #include "ChasteSerialization.hpp"
00046 #include <boost/serialization/base_object.hpp>
00047 #include <boost/serialization/vector.hpp>
00048
00049 template<unsigned DIM>
00050 class AbstractPottsUpdateRule;
00051
00062 template<unsigned DIM>
00063 class PottsBasedCellPopulation : public AbstractOnLatticeCellPopulation<DIM>
00064 {
00065 friend class TestPottsBasedCellPopulation;
00066
00067 private:
00068
00074 VertexMesh<DIM,DIM>* mpElementTessellation;
00075
00080 PottsMesh<DIM>* mpPottsMesh;
00081
00086 MutableMesh<DIM,DIM>* mpMutableMesh;
00087
00089 std::vector<boost::shared_ptr<AbstractPottsUpdateRule<DIM> > > mUpdateRuleCollection;
00090
00092 double mTemperature;
00093
00098 unsigned mNumSweepsPerTimestep;
00099
00100 friend class boost::serialization::access;
00112 template<class Archive>
00113 void serialize(Archive & archive, const unsigned int version)
00114 {
00115 #define COVERAGE_IGNORE
00116 archive & boost::serialization::base_object<AbstractOnLatticeCellPopulation<DIM> >(*this);
00117
00118
00119
00120
00121
00122 delete mpElementTessellation;
00123 mpElementTessellation = NULL;
00124
00125 archive & mUpdateRuleCollection;
00126 archive & mTemperature;
00127 archive & mNumSweepsPerTimestep;
00128
00129 #undef COVERAGE_IGNORE
00130 }
00131
00136 void Validate();
00137
00147 virtual void WriteVtkResultsToFile(const std::string& rDirectory);
00148
00149 public:
00150
00164 PottsBasedCellPopulation(PottsMesh<DIM>& rMesh,
00165 std::vector<CellPtr>& rCells,
00166 bool deleteMesh=false,
00167 bool validate=true,
00168 const std::vector<unsigned> locationIndices=std::vector<unsigned>());
00169
00175 PottsBasedCellPopulation(PottsMesh<DIM>& rMesh);
00176
00180 virtual ~PottsBasedCellPopulation();
00181
00185 PottsMesh<DIM>& rGetMesh();
00186
00190 const PottsMesh<DIM>& rGetMesh() const;
00191
00199 PottsElement<DIM>* GetElement(unsigned elementIndex);
00200
00204 unsigned GetNumElements();
00205
00213 Node<DIM>* GetNode(unsigned index);
00214
00220 unsigned GetNumNodes();
00221
00230 std::set<unsigned> GetNeighbouringLocationIndices(CellPtr pCell);
00231
00240 c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
00241
00249 PottsElement<DIM>* GetElementCorrespondingToCell(CellPtr pCell);
00250
00261 CellPtr AddCell(CellPtr pNewCell, const c_vector<double,DIM>& rCellDivisionVector, CellPtr pParentCell=CellPtr());
00262
00272 unsigned RemoveDeadCells();
00273
00279 void UpdateCellLocations(double dt);
00280
00287 bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
00288
00295 void Update(bool hasHadBirthsOrDeaths=true);
00296
00304 virtual void OpenWritersFiles(OutputFileHandler& rOutputFileHandler);
00305
00311 virtual void WriteResultsToFiles(const std::string& rDirectory);
00312
00319 virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
00320
00327 virtual void AcceptPopulationCountWriter(boost::shared_ptr<AbstractCellPopulationCountWriter<DIM, DIM> > pPopulationCountWriter);
00328
00336 virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
00337
00344 double GetVolumeOfCell(CellPtr pCell);
00345
00355 double GetWidth(const unsigned& rDimension);
00356
00362 void AddUpdateRule(boost::shared_ptr<AbstractPottsUpdateRule<DIM> > pUpdateRule);
00363
00367 void RemoveAllUpdateRules();
00368
00374 const std::vector<boost::shared_ptr<AbstractPottsUpdateRule<DIM> > >& rGetUpdateRuleCollection() const;
00375
00384 void OutputCellPopulationParameters(out_stream& rParamsFile);
00385
00391 void SetTemperature(double temperature);
00392
00396 double GetTemperature();
00397
00403 void SetNumSweepsPerTimestep(unsigned numSweepsPerTimestep);
00404
00408 unsigned GetNumSweepsPerTimestep();
00409
00413 void CreateElementTessellation();
00414
00418 VertexMesh<DIM,DIM>* GetElementTessellation();
00419
00423 void CreateMutableMesh();
00424
00428 MutableMesh<DIM,DIM>* GetMutableMesh();
00429 };
00430
00431 #include "SerializationExportWrapper.hpp"
00432 EXPORT_TEMPLATE_CLASS_SAME_DIMS(PottsBasedCellPopulation)
00433
00434 namespace boost
00435 {
00436 namespace serialization
00437 {
00441 template<class Archive, unsigned DIM>
00442 inline void save_construct_data(
00443 Archive & ar, const PottsBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00444 {
00445
00446 const PottsMesh<DIM>* p_mesh = &(t->rGetMesh());
00447 ar & p_mesh;
00448 }
00449
00454 template<class Archive, unsigned DIM>
00455 inline void load_construct_data(
00456 Archive & ar, PottsBasedCellPopulation<DIM> * t, const unsigned int file_version)
00457 {
00458
00459 PottsMesh<DIM>* p_mesh;
00460 ar >> p_mesh;
00461
00462
00463 ::new(t)PottsBasedCellPopulation<DIM>(*p_mesh);
00464 }
00465 }
00466 }
00467
00468 #endif