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 #ifndef POTTSBASEDCELLPOPULATION_HPP_
00030 #define POTTSBASEDCELLPOPULATION_HPP_
00031
00032 #include "AbstractOnLatticeCellPopulation.hpp"
00033 #include "PottsMesh.hpp"
00034 #include "VertexMesh.hpp"
00035 #include "AbstractPottsUpdateRule.hpp"
00036
00037 #include "ChasteSerialization.hpp"
00038 #include <boost/serialization/base_object.hpp>
00039 #include <boost/serialization/vector.hpp>
00040
00041
00042 #include "WildTypeCellMutationState.hpp"
00043
00044 template<unsigned DIM>
00045 class AbstractPottsUpdateRule;
00046
00057 template<unsigned DIM>
00058 class PottsBasedCellPopulation : public AbstractOnLatticeCellPopulation<DIM>
00059 {
00060 friend class TestPottsBasedCellPopulation;
00061
00062 private:
00063
00065 PottsMesh<DIM>& mrMesh;
00066
00072 VertexMesh<DIM,DIM>* mpElementTessellation;
00073
00075 out_stream mpVizElementsFile;
00076
00078 std::vector<boost::shared_ptr<AbstractPottsUpdateRule<DIM> > > mUpdateRuleCollection;
00079
00081 double mTemperature;
00082
00087 unsigned mNumSweepsPerTimestep;
00088
00089 friend class boost::serialization::access;
00101 template<class Archive>
00102 void serialize(Archive & archive, const unsigned int version)
00103 {
00104 #define COVERAGE_IGNORE
00105 archive & boost::serialization::base_object<AbstractOnLatticeCellPopulation<DIM> >(*this);
00106
00107
00108
00109
00110
00111 delete mpElementTessellation;
00112 mpElementTessellation = NULL;
00113
00114 archive & mUpdateRuleCollection;
00115 archive & mTemperature;
00116 archive & mNumSweepsPerTimestep;
00117
00118 #undef COVERAGE_IGNORE
00119 }
00120
00125 void Validate();
00126
00130 void WriteVtkResultsToFile();
00131
00132 public:
00133
00147 PottsBasedCellPopulation(PottsMesh<DIM>& rMesh,
00148 std::vector<CellPtr>& rCells,
00149 bool deleteMesh=false,
00150 bool validate=true,
00151 const std::vector<unsigned> locationIndices=std::vector<unsigned>());
00152
00158 PottsBasedCellPopulation(PottsMesh<DIM>& rMesh);
00159
00163 virtual ~PottsBasedCellPopulation();
00164
00168 PottsMesh<DIM>& rGetMesh();
00169
00173 const PottsMesh<DIM>& rGetMesh() const;
00174
00182 PottsElement<DIM>* GetElement(unsigned elementIndex);
00183
00187 unsigned GetNumElements();
00188
00196 Node<DIM>* GetNode(unsigned index);
00197
00203 unsigned GetNumNodes();
00204
00213 c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
00214
00222 PottsElement<DIM>* GetElementCorrespondingToCell(CellPtr pCell);
00223
00234 CellPtr AddCell(CellPtr pNewCell, const c_vector<double,DIM>& rCellDivisionVector, CellPtr pParentCell=CellPtr());
00235
00245 unsigned RemoveDeadCells();
00246
00252 void UpdateCellLocations(double dt);
00253
00260 bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
00261
00268 void Update(bool hasHadBirthsOrDeaths=true);
00269
00276 void CreateOutputFiles(const std::string& rDirectory, bool cleanOutputDirectory);
00277
00281 void CloseOutputFiles();
00282
00286 void WriteResultsToFiles();
00287
00291 void WriteCellVolumeResultsToFile();
00292
00296 virtual void GenerateCellResultsAndWriteToFiles();
00297
00307 double GetWidth(const unsigned& rDimension);
00308
00314 void AddUpdateRule(boost::shared_ptr<AbstractPottsUpdateRule<DIM> > pUpdateRule);
00315
00321 const std::vector<boost::shared_ptr<AbstractPottsUpdateRule<DIM> > >& rGetUpdateRuleCollection() const;
00322
00331 void OutputCellPopulationParameters(out_stream& rParamsFile);
00332
00342 std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
00343
00349 void SetTemperature(double temperature);
00350
00354 double GetTemperature();
00355
00361 void SetNumSweepsPerTimestep(unsigned numSweepsPerTimestep);
00362
00366 unsigned GetNumSweepsPerTimestep();
00367
00371 void CreateElementTessellation();
00372
00376 VertexMesh<DIM,DIM>* GetElementTessellation();
00377 };
00378
00379 #include "SerializationExportWrapper.hpp"
00380 EXPORT_TEMPLATE_CLASS_SAME_DIMS(PottsBasedCellPopulation)
00381
00382
00383 #define COVERAGE_IGNORE
00384 namespace boost
00385 {
00386 namespace serialization
00387 {
00391 template<class Archive, unsigned DIM>
00392 inline void save_construct_data(
00393 Archive & ar, const PottsBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00394 {
00395
00396 const PottsMesh<DIM>* p_mesh = &(t->rGetMesh());
00397 ar & p_mesh;
00398 }
00399
00404 template<class Archive, unsigned DIM>
00405 inline void load_construct_data(
00406 Archive & ar, PottsBasedCellPopulation<DIM> * t, const unsigned int file_version)
00407 {
00408
00409 PottsMesh<DIM>* p_mesh;
00410 ar >> p_mesh;
00411
00412
00413 ::new(t)PottsBasedCellPopulation<DIM>(*p_mesh);
00414 }
00415 }
00416 }
00417 #undef COVERAGE_IGNORE
00418
00419 #endif