Chaste Commit::6e4f5fe395bca70eb7641cf6e0e87f450383ca5a
VertexBasedCellPopulation.hpp
1/*
2
3Copyright (c) 2005-2026, 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 VERTEXBASEDCELLPOPULATION_HPP_
37#define VERTEXBASEDCELLPOPULATION_HPP_
38
39#include "AbstractOffLatticeCellPopulation.hpp"
40#include "MutableVertexMesh.hpp"
41#include "TrapezoidEdgeVertexMeshWriter.hpp"
42#include "VertexBasedPopulationSrn.hpp"
43
45#include <boost/serialization/base_object.hpp>
46#include <boost/serialization/set.hpp>
47#include <boost/serialization/vector.hpp>
48
49template<unsigned DIM>
50class AbstractVertexBasedDivisionRule; // Forward declaration to prevent circular include chain
51template<unsigned DIM>
53
61template<unsigned DIM>
63{
64private:
65
70 friend class TestVertexBasedCellPopulation;
71 friend class TestMutableVertexMeshOperationsWithPopulationSrn;
72
78
84
87
90 boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > mpVertexBasedDivisionRule;
91
96 std::vector< c_vector<double, DIM> > mLocationsOfT2Swaps;
97
102 std::vector< unsigned > mCellIdsOfT2Swaps;
103
109
114
119
124
131 virtual void WriteVtkResultsToFile(const std::string& rDirectory);
132
137 virtual void WriteCellVtkResultsToFile(const std::string& rDirectory);
138
146 virtual void WriteCellEdgeVtkResultsToFile(const std::string& rDirectory);
147
148 friend class boost::serialization::access;
160 template<class Archive>
161 void serialize(Archive & archive, const unsigned int version)
162 {
163 archive & boost::serialization::base_object<AbstractOffLatticeCellPopulation<DIM> >(*this);
166 archive & mRestrictVertexMovement;
167 }
168
173 void Validate();
174
175public:
176
190 std::vector<CellPtr>& rCells,
191 bool deleteMesh=false,
192 bool validate=true,
193 const std::vector<unsigned> locationIndices=std::vector<unsigned>());
194
203
208
215 double GetDampingConstant(unsigned nodeIndex);
216
221
226
234 VertexElement<DIM, DIM>* GetElement(unsigned elementIndex);
235
239 unsigned GetNumElements();
240
246 unsigned GetNumNodes();
247
259 c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
260
268 Node<DIM>* GetNode(unsigned index);
269
279 std::set<unsigned> GetNeighbouringLocationIndices(CellPtr pCell);
280
291 std::set<std::pair<unsigned, unsigned>> GetNeighbouringEdgeIndices(CellPtr pCell, unsigned edgeLocalIndex);
292
301 unsigned AddNode(Node<DIM>* pNewNode);
302
312 virtual void CheckForStepSizeException(unsigned nodeIndex, c_vector<double,DIM>& rDisplacement, double dt);
313
322 void SetNode(unsigned index, ChastePoint<DIM>& rNewLocation);
323
332
342 CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr());
343
353 unsigned RemoveDeadCells();
354
361 bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
362
371 void Update(bool hasHadBirthsOrDeaths=true);
372
380 virtual void OpenWritersFiles(OutputFileHandler& rOutputFileHandler);
381
388 virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
389
396 virtual void AcceptPopulationCountWriter(boost::shared_ptr<AbstractCellPopulationCountWriter<DIM, DIM> > pPopulationCountWriter);
397
404 virtual void AcceptPopulationEventWriter(boost::shared_ptr<AbstractCellPopulationEventWriter<DIM, DIM> > pPopulationEventWriter);
405
413 virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
414
423 unsigned GetRosetteRankOfCell(CellPtr pCell);
424
431 double GetVolumeOfCell(CellPtr pCell);
432
438 std::vector< c_vector< double, DIM > > GetLocationsOfT2Swaps();
439
445 std::vector< unsigned > GetCellIdsOfT2Swaps();
446
452 void AddLocationOfT2Swap(c_vector< double, DIM> locationOfT2Swap);
453
459 void AddCellIdOfT2Swap(unsigned idOfT2Swap);
460
465
470
476 void SetOutputCellRearrangementLocations(bool outputCellRearrangementLocations);
477
483 void OutputCellPopulationParameters(out_stream& rParamsFile);
484
494 double GetWidth(const unsigned& rDimension);
495
502 std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
503
514
524 virtual bool IsPdeNodeAssociatedWithNonApoptoticCell(unsigned pdeNodeIndex);
525
541 virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex,
542 std::string& rVariableName,
543 bool dirichletBoundaryConditionApplies=false,
544 double dirichletBoundaryValue=0.0);
545
549 boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > GetVertexBasedDivisionRule();
550
556 void SetVertexBasedDivisionRule(boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > pVertexBasedDivisionRule);
557
568 virtual double GetDefaultTimeStep();
569
577 virtual void WriteDataToVisualizerSetupFile(out_stream& pVizSetupFile);
578
593
600
606 void SetRestrictVertexMovementBoolean(bool restrictVertexMovement);
607
613
618
623 void SetWriteCellVtkResults(const bool new_val);
624
629 void SetWriteEdgeVtkResults(const bool new_val);
630};
631
634
635namespace boost
636{
637namespace serialization
638{
642template<class Archive, unsigned DIM>
643inline void save_construct_data(
644 Archive & ar, const VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
645{
646 // Save data required to construct instance
647 const MutableVertexMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
648 ar & p_mesh;
649
650 const VertexBasedPopulationSrn<DIM>& pop_srn = t->rGetVertexBasedPopulationSrn();
651 ar & pop_srn;
652}
653
658template<class Archive, unsigned DIM>
659inline void load_construct_data(
660 Archive & ar, VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
661{
662 // Retrieve data from archive required to construct new instance
664 ar >> p_mesh;
665
667 ar & pop_srn;
668 // Invoke inplace constructor to initialise instance
669 ::new(t)VertexBasedCellPopulation<DIM>(*p_mesh, pop_srn);
670}
671}
672} // namespace ...
673
674#endif /*VERTEXBASEDCELLPOPULATION_HPP_*/
675
gcov doesn't like this file...
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
Definition Node.hpp:59
double GetDampingConstant(unsigned nodeIndex)
virtual void AcceptCellWriter(boost::shared_ptr< AbstractCellWriter< DIM, DIM > > pCellWriter, CellPtr pCell)
virtual void AcceptPopulationWriter(boost::shared_ptr< AbstractCellPopulationWriter< DIM, DIM > > pPopulationWriter)
void OutputCellPopulationParameters(out_stream &rParamsFile)
std::set< unsigned > GetNeighbouringNodeIndices(unsigned index)
c_vector< double, DIM > GetLocationOfCellCentre(CellPtr pCell)
std::vector< c_vector< double, DIM > > mLocationsOfT2Swaps
virtual void WriteCellVtkResultsToFile(const std::string &rDirectory)
void SetWriteCellVtkResults(const bool new_val)
boost::shared_ptr< AbstractVertexBasedDivisionRule< DIM > > GetVertexBasedDivisionRule()
virtual void WriteVtkResultsToFile(const std::string &rDirectory)
virtual void OpenWritersFiles(OutputFileHandler &rOutputFileHandler)
virtual void AcceptPopulationEventWriter(boost::shared_ptr< AbstractCellPopulationEventWriter< DIM, DIM > > pPopulationEventWriter)
VertexElement< DIM, DIM > * GetElementCorrespondingToCell(CellPtr pCell)
virtual void SimulationSetupHook(AbstractCellBasedSimulation< DIM, DIM > *pSimulation)
bool IsCellAssociatedWithADeletedLocation(CellPtr pCell)
unsigned AddNode(Node< DIM > *pNewNode)
CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr())
unsigned GetRosetteRankOfCell(CellPtr pCell)
VertexElement< DIM, DIM > * GetElement(unsigned elementIndex)
virtual bool IsPdeNodeAssociatedWithNonApoptoticCell(unsigned pdeNodeIndex)
std::vector< unsigned > mCellIdsOfT2Swaps
void AddLocationOfT2Swap(c_vector< double, DIM > locationOfT2Swap)
void serialize(Archive &archive, const unsigned int version)
void SetWriteEdgeVtkResults(const bool new_val)
virtual TetrahedralMesh< DIM, DIM > * GetTetrahedralMeshForPdeModifier()
VertexBasedPopulationSrn< DIM > & rGetVertexBasedPopulationSrn()
void SetOutputCellRearrangementLocations(bool outputCellRearrangementLocations)
MutableVertexMesh< DIM, DIM > & rGetMesh()
void SetVertexBasedDivisionRule(boost::shared_ptr< AbstractVertexBasedDivisionRule< DIM > > pVertexBasedDivisionRule)
MutableVertexMesh< DIM, DIM > * mpMutableVertexMesh
VertexBasedPopulationSrn< DIM > mPopulationSrn
virtual void WriteCellEdgeVtkResultsToFile(const std::string &rDirectory)
std::set< std::pair< unsigned, unsigned > > GetNeighbouringEdgeIndices(CellPtr pCell, unsigned edgeLocalIndex)
virtual void CheckForStepSizeException(unsigned nodeIndex, c_vector< double, DIM > &rDisplacement, double dt)
std::vector< c_vector< double, DIM > > GetLocationsOfT2Swaps()
void AddCellIdOfT2Swap(unsigned idOfT2Swap)
virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex, std::string &rVariableName, bool dirichletBoundaryConditionApplies=false, double dirichletBoundaryValue=0.0)
virtual void WriteDataToVisualizerSetupFile(out_stream &pVizSetupFile)
std::set< unsigned > GetNeighbouringLocationIndices(CellPtr pCell)
void Update(bool hasHadBirthsOrDeaths=true)
void SetRestrictVertexMovementBoolean(bool restrictVertexMovement)
boost::shared_ptr< AbstractVertexBasedDivisionRule< DIM > > mpVertexBasedDivisionRule
std::vector< unsigned > GetCellIdsOfT2Swaps()
void SetNode(unsigned index, ChastePoint< DIM > &rNewLocation)
virtual void AcceptPopulationCountWriter(boost::shared_ptr< AbstractCellPopulationCountWriter< DIM, DIM > > pPopulationCountWriter)
double GetWidth(const unsigned &rDimension)
Node< DIM > * GetNode(unsigned index)