Chaste  Release::2024.1
VertexBasedCellPopulation.hpp
1 /*
2 
3 Copyright (c) 2005-2021, 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 
110 
116  virtual void WriteVtkResultsToFile(const std::string& rDirectory);
117 
118  friend class boost::serialization::access;
130  template<class Archive>
131  void serialize(Archive & archive, const unsigned int version)
132  {
133  archive & boost::serialization::base_object<AbstractOffLatticeCellPopulation<DIM> >(*this);
135  archive & mpVertexBasedDivisionRule;
136  archive & mRestrictVertexMovement;
137  }
138 
143  void Validate();
144 
145 public:
146 
160  std::vector<CellPtr>& rCells,
161  bool deleteMesh=false,
162  bool validate=true,
163  const std::vector<unsigned> locationIndices=std::vector<unsigned>());
164 
171 
175  virtual ~VertexBasedCellPopulation();
176 
183  double GetDampingConstant(unsigned nodeIndex);
184 
189 
193  const MutableVertexMesh<DIM, DIM>& rGetMesh() const;
194 
202  VertexElement<DIM, DIM>* GetElement(unsigned elementIndex);
203 
207  unsigned GetNumElements();
208 
214  unsigned GetNumNodes();
215 
227  c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
228 
236  Node<DIM>* GetNode(unsigned index);
237 
246  std::set<unsigned> GetNeighbouringLocationIndices(CellPtr pCell);
247 
256  unsigned AddNode(Node<DIM>* pNewNode);
257 
267  virtual void CheckForStepSizeException(unsigned nodeIndex, c_vector<double,DIM>& rDisplacement, double dt);
268 
277  void SetNode(unsigned index, ChastePoint<DIM>& rNewLocation);
278 
287 
297  CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr());
298 
308  unsigned RemoveDeadCells();
309 
316  bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
317 
326  void Update(bool hasHadBirthsOrDeaths=true);
327 
335  virtual void OpenWritersFiles(OutputFileHandler& rOutputFileHandler);
336 
343  virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
344 
351  virtual void AcceptPopulationCountWriter(boost::shared_ptr<AbstractCellPopulationCountWriter<DIM, DIM> > pPopulationCountWriter);
352 
360  virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
361 
370  unsigned GetRosetteRankOfCell(CellPtr pCell);
371 
378  double GetVolumeOfCell(CellPtr pCell);
379 
385  std::vector< c_vector< double, DIM > > GetLocationsOfT2Swaps();
386 
392  std::vector< unsigned > GetCellIdsOfT2Swaps();
393 
399  void AddLocationOfT2Swap(c_vector< double, DIM> locationOfT2Swap);
400 
406  void AddCellIdOfT2Swap(unsigned idOfT2Swap);
407 
412 
417 
423  void SetOutputCellRearrangementLocations(bool outputCellRearrangementLocations);
424 
430  void OutputCellPopulationParameters(out_stream& rParamsFile);
431 
441  double GetWidth(const unsigned& rDimension);
442 
449  std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
450 
461 
471  virtual bool IsPdeNodeAssociatedWithNonApoptoticCell(unsigned pdeNodeIndex);
472 
488  virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex,
489  std::string& rVariableName,
490  bool dirichletBoundaryConditionApplies=false,
491  double dirichletBoundaryValue=0.0);
492 
496  boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > GetVertexBasedDivisionRule();
497 
503  void SetVertexBasedDivisionRule(boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > pVertexBasedDivisionRule);
504 
515  virtual double GetDefaultTimeStep();
516 
524  virtual void WriteDataToVisualizerSetupFile(out_stream& pVizSetupFile);
525 
540 
547 
553  void SetRestrictVertexMovementBoolean(bool restrictVertexMovement);
554 };
555 
558 
559 namespace boost
560 {
561 namespace serialization
562 {
566 template<class Archive, unsigned DIM>
567 inline void save_construct_data(
568  Archive & ar, const VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
569 {
570  // Save data required to construct instance
571  const MutableVertexMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
572  ar & p_mesh;
573 }
574 
579 template<class Archive, unsigned DIM>
580 inline void load_construct_data(
581  Archive & ar, VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
582 {
583  // Retrieve data from archive required to construct new instance
585  ar >> p_mesh;
586 
587  // Invoke inplace constructor to initialise instance
588  ::new(t)VertexBasedCellPopulation<DIM>(*p_mesh);
589 }
590 }
591 } // namespace ...
592 
593 #endif /*VERTEXBASEDCELLPOPULATION_HPP_*/
594 
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)