Chaste  Release::2017.1
VertexBasedCellPopulation.hpp
1 /*
2 
3 Copyright (c) 2005-2017, 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 
42 #include "ChasteSerialization.hpp"
43 #include <boost/serialization/base_object.hpp>
44 #include <boost/serialization/set.hpp>
45 #include <boost/serialization/vector.hpp>
46 
47 template<unsigned DIM>
48 class AbstractVertexBasedDivisionRule; // Forward declaration to prevent circular include chain
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 
109  virtual void WriteVtkResultsToFile(const std::string& rDirectory);
110 
111  friend class boost::serialization::access;
123  template<class Archive>
124  void serialize(Archive & archive, const unsigned int version)
125  {
126  archive & boost::serialization::base_object<AbstractOffLatticeCellPopulation<DIM> >(*this);
128  archive & mpVertexBasedDivisionRule;
129  archive & mRestrictVertexMovement;
130  }
131 
136  void Validate();
137 
138 public:
139 
153  std::vector<CellPtr>& rCells,
154  bool deleteMesh=false,
155  bool validate=true,
156  const std::vector<unsigned> locationIndices=std::vector<unsigned>());
157 
164 
168  virtual ~VertexBasedCellPopulation();
169 
176  double GetDampingConstant(unsigned nodeIndex);
177 
182 
186  const MutableVertexMesh<DIM, DIM>& rGetMesh() const;
187 
195  VertexElement<DIM, DIM>* GetElement(unsigned elementIndex);
196 
200  unsigned GetNumElements();
201 
207  unsigned GetNumNodes();
208 
220  c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
221 
229  Node<DIM>* GetNode(unsigned index);
230 
239  std::set<unsigned> GetNeighbouringLocationIndices(CellPtr pCell);
240 
249  unsigned AddNode(Node<DIM>* pNewNode);
250 
260  virtual void CheckForStepSizeException(unsigned nodeIndex, c_vector<double,DIM>& rDisplacement, double dt);
261 
270  void SetNode(unsigned index, ChastePoint<DIM>& rNewLocation);
271 
280 
290  CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr());
291 
301  unsigned RemoveDeadCells();
302 
309  bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
310 
319  void Update(bool hasHadBirthsOrDeaths=true);
320 
328  virtual void OpenWritersFiles(OutputFileHandler& rOutputFileHandler);
329 
336  virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
337 
344  virtual void AcceptPopulationCountWriter(boost::shared_ptr<AbstractCellPopulationCountWriter<DIM, DIM> > pPopulationCountWriter);
345 
353  virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
354 
363  unsigned GetRosetteRankOfCell(CellPtr pCell);
364 
371  double GetVolumeOfCell(CellPtr pCell);
372 
378  std::vector< c_vector< double, DIM > > GetLocationsOfT2Swaps();
379 
385  std::vector< unsigned > GetCellIdsOfT2Swaps();
386 
392  void AddLocationOfT2Swap(c_vector< double, DIM> locationOfT2Swap);
393 
399  void AddCellIdOfT2Swap(unsigned idOfT2Swap);
400 
405 
410 
416  void SetOutputCellRearrangementLocations(bool outputCellRearrangementLocations);
417 
423  void OutputCellPopulationParameters(out_stream& rParamsFile);
424 
434  double GetWidth(const unsigned& rDimension);
435 
442  std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
443 
454 
464  virtual bool IsPdeNodeAssociatedWithNonApoptoticCell(unsigned pdeNodeIndex);
465 
481  virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex,
482  std::string& rVariableName,
483  bool dirichletBoundaryConditionApplies=false,
484  double dirichletBoundaryValue=0.0);
485 
489  boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > GetVertexBasedDivisionRule();
490 
496  void SetVertexBasedDivisionRule(boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > pVertexBasedDivisionRule);
497 
508  virtual double GetDefaultTimeStep();
509 
517  virtual void WriteDataToVisualizerSetupFile(out_stream& pVizSetupFile);
518 
533 
540 
546  void SetRestrictVertexMovementBoolean(bool restrictVertexMovement);
547 };
548 
551 
552 namespace boost
553 {
554 namespace serialization
555 {
559 template<class Archive, unsigned DIM>
560 inline void save_construct_data(
561  Archive & ar, const VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
562 {
563  // Save data required to construct instance
564  const MutableVertexMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
565  ar & p_mesh;
566 }
567 
572 template<class Archive, unsigned DIM>
573 inline void load_construct_data(
574  Archive & ar, VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
575 {
576  // Retrieve data from archive required to construct new instance
578  ar >> p_mesh;
579 
580  // Invoke inplace constructor to initialise instance
581  ::new(t)VertexBasedCellPopulation<DIM>(*p_mesh);
582 }
583 }
584 } // namespace ...
585 
586 #endif /*VERTEXBASEDCELLPOPULATION_HPP_*/
587 
void SetOutputCellRearrangementLocations(bool outputCellRearrangementLocations)
std::vector< c_vector< double, DIM > > GetLocationsOfT2Swaps()
std::vector< unsigned > mCellIdsOfT2Swaps
virtual void AcceptPopulationCountWriter(boost::shared_ptr< AbstractCellPopulationCountWriter< DIM, DIM > > pPopulationCountWriter)
Definition: Node.hpp:58
std::vector< c_vector< double, DIM > > mLocationsOfT2Swaps
virtual void SimulationSetupHook(AbstractCellBasedSimulation< DIM, DIM > *pSimulation)
boost::shared_ptr< AbstractVertexBasedDivisionRule< DIM > > mpVertexBasedDivisionRule
MutableVertexMesh< DIM, DIM > * mpMutableVertexMesh
virtual void AcceptCellWriter(boost::shared_ptr< AbstractCellWriter< DIM, DIM > > pCellWriter, CellPtr pCell)
void SetVertexBasedDivisionRule(boost::shared_ptr< AbstractVertexBasedDivisionRule< DIM > > pVertexBasedDivisionRule)
std::vector< unsigned > GetCellIdsOfT2Swaps()
virtual bool IsPdeNodeAssociatedWithNonApoptoticCell(unsigned pdeNodeIndex)
void serialize(Archive &archive, const unsigned int version)
virtual void WriteDataToVisualizerSetupFile(out_stream &pVizSetupFile)
std::set< unsigned > GetNeighbouringNodeIndices(unsigned index)
boost::shared_ptr< AbstractVertexBasedDivisionRule< DIM > > GetVertexBasedDivisionRule()
bool IsCellAssociatedWithADeletedLocation(CellPtr pCell)
double GetDampingConstant(unsigned nodeIndex)
void SetRestrictVertexMovementBoolean(bool restrictVertexMovement)
std::set< unsigned > GetNeighbouringLocationIndices(CellPtr pCell)
unsigned GetRosetteRankOfCell(CellPtr pCell)
MutableVertexMesh< DIM, DIM > & rGetMesh()
#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)
virtual TetrahedralMesh< DIM, DIM > * GetTetrahedralMeshForPdeModifier()
virtual void CheckForStepSizeException(unsigned nodeIndex, c_vector< double, DIM > &rDisplacement, double dt)
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)
CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr())
virtual void WriteVtkResultsToFile(const std::string &rDirectory)
virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex, std::string &rVariableName, bool dirichletBoundaryConditionApplies=false, double dirichletBoundaryValue=0.0)
gcov doesn&#39;t like this file...
VertexElement< DIM, DIM > * GetElement(unsigned elementIndex)
VertexElement< DIM, DIM > * GetElementCorrespondingToCell(CellPtr pCell)