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
00050 #include "WildTypeCellMutationState.hpp"
00051
00052 template<unsigned DIM>
00053 class AbstractPottsUpdateRule;
00054
00065 template<unsigned DIM>
00066 class PottsBasedCellPopulation : public AbstractOnLatticeCellPopulation<DIM>
00067 {
00068 friend class TestPottsBasedCellPopulation;
00069
00070 private:
00071
00077 VertexMesh<DIM,DIM>* mpElementTessellation;
00078
00083 PottsMesh<DIM>* mpPottsMesh;
00084
00089 MutableMesh<DIM,DIM>* mpMutableMesh;
00090
00092 std::vector<boost::shared_ptr<AbstractPottsUpdateRule<DIM> > > mUpdateRuleCollection;
00093
00095 double mTemperature;
00096
00101 unsigned mNumSweepsPerTimestep;
00102
00103 friend class boost::serialization::access;
00115 template<class Archive>
00116 void serialize(Archive & archive, const unsigned int version)
00117 {
00118 #define COVERAGE_IGNORE
00119 archive & boost::serialization::base_object<AbstractOnLatticeCellPopulation<DIM> >(*this);
00120
00121
00122
00123
00124
00125 delete mpElementTessellation;
00126 mpElementTessellation = NULL;
00127
00128 archive & mUpdateRuleCollection;
00129 archive & mTemperature;
00130 archive & mNumSweepsPerTimestep;
00131
00132 #undef COVERAGE_IGNORE
00133 }
00134
00139 void Validate();
00140
00146 virtual void WriteVtkResultsToFile(const std::string& rDirectory);
00147
00148 public:
00149
00163 PottsBasedCellPopulation(PottsMesh<DIM>& rMesh,
00164 std::vector<CellPtr>& rCells,
00165 bool deleteMesh=false,
00166 bool validate=true,
00167 const std::vector<unsigned> locationIndices=std::vector<unsigned>());
00168
00174 PottsBasedCellPopulation(PottsMesh<DIM>& rMesh);
00175
00179 virtual ~PottsBasedCellPopulation();
00180
00184 PottsMesh<DIM>& rGetMesh();
00185
00189 const PottsMesh<DIM>& rGetMesh() const;
00190
00198 PottsElement<DIM>* GetElement(unsigned elementIndex);
00199
00203 unsigned GetNumElements();
00204
00212 Node<DIM>* GetNode(unsigned index);
00213
00219 unsigned GetNumNodes();
00220
00229 c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
00230
00238 PottsElement<DIM>* GetElementCorrespondingToCell(CellPtr pCell);
00239
00250 CellPtr AddCell(CellPtr pNewCell, const c_vector<double,DIM>& rCellDivisionVector, CellPtr pParentCell=CellPtr());
00251
00261 unsigned RemoveDeadCells();
00262
00268 void UpdateCellLocations(double dt);
00269
00276 bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
00277
00284 void Update(bool hasHadBirthsOrDeaths=true);
00285
00293 virtual void OpenWritersFiles(const std::string& rDirectory);
00294
00300 virtual void WriteResultsToFiles(const std::string& rDirectory);
00301
00308 virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
00309
00317 virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
00318
00325 double GetVolumeOfCell(CellPtr pCell);
00326
00336 double GetWidth(const unsigned& rDimension);
00337
00343 void AddUpdateRule(boost::shared_ptr<AbstractPottsUpdateRule<DIM> > pUpdateRule);
00344
00348 void RemoveAllUpdateRules();
00349
00355 const std::vector<boost::shared_ptr<AbstractPottsUpdateRule<DIM> > >& rGetUpdateRuleCollection() const;
00356
00365 void OutputCellPopulationParameters(out_stream& rParamsFile);
00366
00372 void SetTemperature(double temperature);
00373
00377 double GetTemperature();
00378
00384 void SetNumSweepsPerTimestep(unsigned numSweepsPerTimestep);
00385
00389 unsigned GetNumSweepsPerTimestep();
00390
00394 void CreateElementTessellation();
00395
00399 VertexMesh<DIM,DIM>* GetElementTessellation();
00400
00404 void CreateMutableMesh();
00405
00409 MutableMesh<DIM,DIM>* GetMutableMesh();
00410 };
00411
00412 #include "SerializationExportWrapper.hpp"
00413 EXPORT_TEMPLATE_CLASS_SAME_DIMS(PottsBasedCellPopulation)
00414
00415 namespace boost
00416 {
00417 namespace serialization
00418 {
00422 template<class Archive, unsigned DIM>
00423 inline void save_construct_data(
00424 Archive & ar, const PottsBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00425 {
00426
00427 const PottsMesh<DIM>* p_mesh = &(t->rGetMesh());
00428 ar & p_mesh;
00429 }
00430
00435 template<class Archive, unsigned DIM>
00436 inline void load_construct_data(
00437 Archive & ar, PottsBasedCellPopulation<DIM> * t, const unsigned int file_version)
00438 {
00439
00440 PottsMesh<DIM>* p_mesh;
00441 ar >> p_mesh;
00442
00443
00444 ::new(t)PottsBasedCellPopulation<DIM>(*p_mesh);
00445 }
00446 }
00447 }
00448
00449 #endif