Chaste  Release::3.4
VertexBasedCellPopulation.hpp
1 /*
2 
3 Copyright (c) 2005-2016, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
36 #ifndef VERTEXBASEDCELLPOPULATION_HPP_
37 #define VERTEXBASEDCELLPOPULATION_HPP_
38 
39 #include "AbstractOffLatticeCellPopulation.hpp"
40 #include "MutableVertexMesh.hpp"
41 #include "AbstractVertexBasedDivisionRule.hpp"
42 
43 #include "ChasteSerialization.hpp"
44 #include <boost/serialization/base_object.hpp>
45 #include <boost/serialization/set.hpp>
46 #include <boost/serialization/vector.hpp>
47 
48 template<unsigned DIM> class AbstractVertexBasedDivisionRule; // Circular definition thing.
49 
57 template<unsigned DIM>
59 {
60 private:
61 
66 
72 
78 
81 
84  boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > mpVertexBasedDivisionRule;
85 
90  std::vector< c_vector<double, DIM> > mLocationsOfT2Swaps;
91 
96  std::vector< unsigned > mCellIdsOfT2Swaps;
97 
103  virtual void WriteVtkResultsToFile(const std::string& rDirectory);
104 
105  friend class boost::serialization::access;
117  template<class Archive>
118  void serialize(Archive & archive, const unsigned int version)
119  {
120  archive & boost::serialization::base_object<AbstractOffLatticeCellPopulation<DIM> >(*this);
122  archive & mpVertexBasedDivisionRule;
123  }
124 
129  void Validate();
130 
131 public:
132 
146  std::vector<CellPtr>& rCells,
147  bool deleteMesh=false,
148  bool validate=true,
149  const std::vector<unsigned> locationIndices=std::vector<unsigned>());
150 
157 
161  virtual ~VertexBasedCellPopulation();
162 
169  double GetDampingConstant(unsigned nodeIndex);
170 
175 
179  const MutableVertexMesh<DIM, DIM>& rGetMesh() const;
180 
188  VertexElement<DIM, DIM>* GetElement(unsigned elementIndex);
189 
193  unsigned GetNumElements();
194 
200  unsigned GetNumNodes();
201 
213  c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
214 
222  Node<DIM>* GetNode(unsigned index);
223 
232  std::set<unsigned> GetNeighbouringLocationIndices(CellPtr pCell);
233 
242  unsigned AddNode(Node<DIM>* pNewNode);
243 
249  void UpdateNodeLocations(double dt);
250 
259  void SetNode(unsigned index, ChastePoint<DIM>& rNewLocation);
260 
269 
281  CellPtr AddCell(CellPtr pNewCell,
282  const c_vector<double,DIM>& rCellDivisionVector,
283  CellPtr pParentCell=CellPtr());
284 
294  unsigned RemoveDeadCells();
295 
302  bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
303 
312  void Update(bool hasHadBirthsOrDeaths=true);
313 
321  virtual void OpenWritersFiles(OutputFileHandler& rOutputFileHandler);
322 
329  virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
330 
337  virtual void AcceptPopulationCountWriter(boost::shared_ptr<AbstractCellPopulationCountWriter<DIM, DIM> > pPopulationCountWriter);
338 
346  virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
347 
356  unsigned GetRosetteRankOfCell(CellPtr pCell);
357 
364  double GetVolumeOfCell(CellPtr pCell);
365 
371  std::vector< c_vector< double, DIM > > GetLocationsOfT2Swaps();
372 
378  std::vector< unsigned > GetCellIdsOfT2Swaps();
379 
385  void AddLocationOfT2Swap(c_vector< double, DIM> locationOfT2Swap);
386 
392  void AddCellIdOfT2Swap(unsigned idOfT2Swap);
393 
398 
403 
409  void SetOutputCellRearrangementLocations(bool outputCellRearrangementLocations);
410 
416  void OutputCellPopulationParameters(out_stream& rParamsFile);
417 
427  double GetWidth(const unsigned& rDimension);
428 
435  std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
436 
443 
447  boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > GetVertexBasedDivisionRule();
448 
454  void SetVertexBasedDivisionRule(boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > pVertexBasedDivisionRule);
455 };
456 
459 
460 namespace boost
461 {
462 namespace serialization
463 {
467 template<class Archive, unsigned DIM>
468 inline void save_construct_data(
469  Archive & ar, const VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
470 {
471  // Save data required to construct instance
472  const MutableVertexMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
473  ar & p_mesh;
474 }
475 
480 template<class Archive, unsigned DIM>
481 inline void load_construct_data(
482  Archive & ar, VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
483 {
484  // Retrieve data from archive required to construct new instance
486  ar >> p_mesh;
487 
488  // Invoke inplace constructor to initialise instance
489  ::new(t)VertexBasedCellPopulation<DIM>(*p_mesh);
490 }
491 }
492 } // namespace ...
493 
494 #endif /*VERTEXBASEDCELLPOPULATION_HPP_*/
495 
void SetOutputCellRearrangementLocations(bool outputCellRearrangementLocations)
std::vector< c_vector< double, DIM > > GetLocationsOfT2Swaps()
virtual void AcceptPopulationCountWriter(boost::shared_ptr< AbstractCellPopulationCountWriter< DIM, DIM > > pPopulationCountWriter)
Definition: Node.hpp:58
boost::shared_ptr< AbstractVertexBasedDivisionRule< DIM > > mpVertexBasedDivisionRule
virtual void AcceptCellWriter(boost::shared_ptr< AbstractCellWriter< DIM, DIM > > pCellWriter, CellPtr pCell)
void SetVertexBasedDivisionRule(boost::shared_ptr< AbstractVertexBasedDivisionRule< DIM > > pVertexBasedDivisionRule)
std::vector< unsigned > GetCellIdsOfT2Swaps()
std::vector< c_vector< double, DIM > > mLocationsOfT2Swaps
std::set< unsigned > GetNeighbouringNodeIndices(unsigned index)
std::vector< unsigned > mCellIdsOfT2Swaps
boost::shared_ptr< AbstractVertexBasedDivisionRule< DIM > > GetVertexBasedDivisionRule()
bool IsCellAssociatedWithADeletedLocation(CellPtr pCell)
double GetDampingConstant(unsigned nodeIndex)
std::set< unsigned > GetNeighbouringLocationIndices(CellPtr pCell)
unsigned GetRosetteRankOfCell(CellPtr pCell)
MutableVertexMesh< DIM, DIM > & rGetMesh()
TetrahedralMesh< DIM, DIM > * GetTetrahedralMeshUsingVertexMesh()
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
virtual void AcceptPopulationWriter(boost::shared_ptr< AbstractCellPopulationWriter< DIM, DIM > > pPopulationWriter)
void Update(bool hasHadBirthsOrDeaths=true)
void AddLocationOfT2Swap(c_vector< double, DIM > locationOfT2Swap)
VertexBasedCellPopulation(MutableVertexMesh< DIM, DIM > &rMesh, std::vector< CellPtr > &rCells, bool deleteMesh=false, bool validate=true, const std::vector< unsigned > locationIndices=std::vector< unsigned >())
Node< DIM > * GetNode(unsigned index)
void OutputCellPopulationParameters(out_stream &rParamsFile)
virtual void OpenWritersFiles(OutputFileHandler &rOutputFileHandler)
void SetNode(unsigned index, ChastePoint< DIM > &rNewLocation)
void AddCellIdOfT2Swap(unsigned idOfT2Swap)
double GetWidth(const unsigned &rDimension)
c_vector< double, DIM > GetLocationOfCellCentre(CellPtr pCell)
unsigned AddNode(Node< DIM > *pNewNode)
MutableVertexMesh< DIM, DIM > * mpMutableVertexMesh
virtual void WriteVtkResultsToFile(const std::string &rDirectory)
CellPtr AddCell(CellPtr pNewCell, const c_vector< double, DIM > &rCellDivisionVector, CellPtr pParentCell=CellPtr())
VertexElement< DIM, DIM > * GetElement(unsigned elementIndex)
void serialize(Archive &archive, const unsigned int version)
VertexElement< DIM, DIM > * GetElementCorrespondingToCell(CellPtr pCell)