Chaste Commit::baa90ac2819b962188b7562f2326be23c47859a7
CaBasedCellPopulation.hpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, 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
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34*/
35
36#ifndef CABASEDCELLPOPULATION_HPP_
37#define CABASEDCELLPOPULATION_HPP_
38
39#include "AbstractOnLatticeCellPopulation.hpp"
40#include "PottsMesh.hpp"
41#include "VertexMesh.hpp"
42#include "AbstractUpdateRule.hpp"
43#include "AbstractCaBasedDivisionRule.hpp"
44
46#include <boost/serialization/base_object.hpp>
47#include <boost/serialization/vector.hpp>
48
49template<unsigned DIM> class AbstractCaBasedDivisionRule; // Circular definition thing.
50
63template<unsigned DIM>
65{
66 friend class TestCaBasedCellPopulation;
67
68private:
69
72
77 std::vector<boost::shared_ptr<AbstractUpdateRule<DIM> > > mSwitchingUpdateRuleCollection;
78
80 std::vector<unsigned> mAvailableSpaces;
81
84 boost::shared_ptr<AbstractCaBasedDivisionRule<DIM> > mpCaBasedDivisionRule;
85
91 void SetEmptySites(const std::set<unsigned>& rEmptySiteIndices);
92
93 friend class boost::serialization::access;
105 template<class Archive>
106 void serialize(Archive & archive, const unsigned int version)
107 {
108 archive & boost::serialization::base_object<AbstractOnLatticeCellPopulation<DIM> >(*this);
110 archive & mLatticeCarryingCapacity;
111 archive & mAvailableSpaces;
112 archive & mpCaBasedDivisionRule;
113 }
114
120 void Validate();
121
129 virtual void WriteVtkResultsToFile(const std::string& rDirectory);
130
131public:
132
148 std::vector<CellPtr>& rCells,
149 const std::vector<unsigned> locationIndices,
150 unsigned latticeCarryingCapacity=1u,
151 bool deleteMesh=false,
152 bool validate=false);
153
160
164 virtual ~CaBasedCellPopulation();
165
169 std::vector<unsigned>& rGetAvailableSpaces();
170
181 virtual bool IsSiteAvailable(unsigned index, CellPtr pCell);
182
187
191 const PottsMesh<DIM>& rGetMesh() const;
192
201
209 Node<DIM>* GetNode(unsigned index);
210
216 unsigned GetNumNodes();
217
230 std::set<unsigned> GetNeighbouringLocationIndices(CellPtr pCell);
231
240 c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
241
249 void AddCellUsingLocationIndex(unsigned index, CellPtr pCell);
250
258 void RemoveCellUsingLocationIndex(unsigned index, CellPtr pCell);
259
268
278 CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr());
279
291 double virtual EvaluateDivisionPropensity(unsigned currentNodeIndex,
292 unsigned targetNodeIndex,
293 CellPtr pCell);
303 unsigned RemoveDeadCells();
304
312 virtual void OpenWritersFiles(OutputFileHandler& rOutputFileHandler);
313
319 void UpdateCellLocations(double dt);
320
327 bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
328
336 void Update(bool hasHadBirthsOrDeaths=true);
337
344 virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
345
352 virtual void AcceptPopulationCountWriter(boost::shared_ptr<AbstractCellPopulationCountWriter<DIM, DIM> > pPopulationCountWriter);
353
360 virtual void AcceptPopulationEventWriter(boost::shared_ptr<AbstractCellPopulationEventWriter<DIM, DIM> > pPopulationEventWriter);
361
369 virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
370
377 double GetVolumeOfCell(CellPtr pCell);
378
390 double GetWidth(const unsigned& rDimension);
391
399
408 void OutputCellPopulationParameters(out_stream& rParamsFile);
409
418 bool IsRoomToDivide(CellPtr pCell);
419
423 boost::shared_ptr<AbstractCaBasedDivisionRule<DIM> > GetCaBasedDivisionRule();
424
430 void SetCaBasedDivisionRule(boost::shared_ptr<AbstractCaBasedDivisionRule<DIM> > pCaBasedDivisionRule);
431
437 virtual void AddUpdateRule(boost::shared_ptr<AbstractUpdateRule<DIM> > pUpdateRule);
438
448 virtual const std::vector<boost::shared_ptr<AbstractUpdateRule<DIM> > > GetUpdateRuleCollection() const;
449
465 virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex,
466 std::string& rVariableName,
467 bool dirichletBoundaryConditionApplies=false,
468 double dirichletBoundaryValue=0.0);
469
479 virtual bool IsPdeNodeAssociatedWithNonApoptoticCell(unsigned pdeNodeIndex);
480};
481
484
485
486namespace boost
487{
488namespace serialization
489{
493template<class Archive, unsigned DIM>
494inline void save_construct_data(
495 Archive & ar, const CaBasedCellPopulation<DIM> * t, const unsigned int file_version)
496{
497 // Save data required to construct instance
498 const PottsMesh<DIM>* p_mesh = &(t->rGetMesh());
499 ar & p_mesh;
500}
501
506template<class Archive, unsigned DIM>
507inline void load_construct_data(
508 Archive & ar, CaBasedCellPopulation<DIM> * t, const unsigned int file_version)
509{
510 // Retrieve data from archive required to construct new instance
511 PottsMesh<DIM>* p_mesh;
512 ar >> p_mesh;
513
514 // Invoke inplace constructor to initialise instance
515 ::new(t)CaBasedCellPopulation<DIM>(*p_mesh);
516}
517}
518} // namespace ...
519
520
521#endif /*CABASEDCELLPOPULATION_HPP_*/
gcov doesn't like this file...
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
void SetCaBasedDivisionRule(boost::shared_ptr< AbstractCaBasedDivisionRule< DIM > > pCaBasedDivisionRule)
Node< DIM > * GetNode(unsigned index)
virtual void AddUpdateRule(boost::shared_ptr< AbstractUpdateRule< DIM > > pUpdateRule)
std::vector< boost::shared_ptr< AbstractUpdateRule< DIM > > > mSwitchingUpdateRuleCollection
std::vector< unsigned > mAvailableSpaces
boost::shared_ptr< AbstractCaBasedDivisionRule< DIM > > GetCaBasedDivisionRule()
virtual double EvaluateDivisionPropensity(unsigned currentNodeIndex, unsigned targetNodeIndex, CellPtr pCell)
void AddCellUsingLocationIndex(unsigned index, CellPtr pCell)
virtual const std::vector< boost::shared_ptr< AbstractUpdateRule< DIM > > > GetUpdateRuleCollection() const
CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr())
c_vector< double, DIM > GetLocationOfCellCentre(CellPtr pCell)
virtual void WriteVtkResultsToFile(const std::string &rDirectory)
double GetWidth(const unsigned &rDimension)
virtual void AcceptCellWriter(boost::shared_ptr< AbstractCellWriter< DIM, DIM > > pCellWriter, CellPtr pCell)
void serialize(Archive &archive, const unsigned int version)
std::set< unsigned > GetNeighbouringLocationIndices(CellPtr pCell)
void OutputCellPopulationParameters(out_stream &rParamsFile)
void SetEmptySites(const std::set< unsigned > &rEmptySiteIndices)
void RemoveCellUsingLocationIndex(unsigned index, CellPtr pCell)
virtual bool IsPdeNodeAssociatedWithNonApoptoticCell(unsigned pdeNodeIndex)
std::vector< unsigned > & rGetAvailableSpaces()
virtual void AcceptPopulationCountWriter(boost::shared_ptr< AbstractCellPopulationCountWriter< DIM, DIM > > pPopulationCountWriter)
boost::shared_ptr< AbstractCaBasedDivisionRule< DIM > > mpCaBasedDivisionRule
PottsMesh< DIM > & rGetMesh()
virtual void AcceptPopulationWriter(boost::shared_ptr< AbstractCellPopulationWriter< DIM, DIM > > pPopulationWriter)
void Update(bool hasHadBirthsOrDeaths=true)
virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex, std::string &rVariableName, bool dirichletBoundaryConditionApplies=false, double dirichletBoundaryValue=0.0)
bool IsCellAssociatedWithADeletedLocation(CellPtr pCell)
virtual void AcceptPopulationEventWriter(boost::shared_ptr< AbstractCellPopulationEventWriter< DIM, DIM > > pPopulationEventWriter)
Node< DIM > * GetNodeCorrespondingToCell(CellPtr pCell)
virtual TetrahedralMesh< DIM, DIM > * GetTetrahedralMeshForPdeModifier()
bool IsRoomToDivide(CellPtr pCell)
virtual void OpenWritersFiles(OutputFileHandler &rOutputFileHandler)
virtual bool IsSiteAvailable(unsigned index, CellPtr pCell)
double GetVolumeOfCell(CellPtr pCell)
Definition Node.hpp:59