Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
VertexBasedCellPopulation.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 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
116
121
126
131
138 virtual void WriteVtkResultsToFile(const std::string& rDirectory);
139
144 virtual void WriteCellVtkResultsToFile(const std::string& rDirectory);
145
153 virtual void WriteCellEdgeVtkResultsToFile(const std::string& rDirectory);
154
155 friend class boost::serialization::access;
167 template<class Archive>
168 void serialize(Archive & archive, const unsigned int version)
169 {
170 archive & boost::serialization::base_object<AbstractOffLatticeCellPopulation<DIM> >(*this);
173 archive & mRestrictVertexMovement;
174 }
175
180 void Validate();
181
182public:
183
197 std::vector<CellPtr>& rCells,
198 bool deleteMesh=false,
199 bool validate=true,
200 const std::vector<unsigned> locationIndices=std::vector<unsigned>());
201
210
215
222 double GetDampingConstant(unsigned nodeIndex);
223
228
233
241 VertexElement<DIM, DIM>* GetElement(unsigned elementIndex);
242
246 unsigned GetNumElements();
247
253 unsigned GetNumNodes();
254
266 c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
267
275 Node<DIM>* GetNode(unsigned index);
276
286 std::set<unsigned> GetNeighbouringLocationIndices(CellPtr pCell);
287
298 std::set<std::pair<unsigned, unsigned>> GetNeighbouringEdgeIndices(CellPtr pCell, unsigned edgeLocalIndex);
299
308 unsigned AddNode(Node<DIM>* pNewNode);
309
319 virtual void CheckForStepSizeException(unsigned nodeIndex, c_vector<double,DIM>& rDisplacement, double dt);
320
329 void SetNode(unsigned index, ChastePoint<DIM>& rNewLocation);
330
339
349 CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr());
350
360 unsigned RemoveDeadCells();
361
368 bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
369
378 void Update(bool hasHadBirthsOrDeaths=true);
379
387 virtual void OpenWritersFiles(OutputFileHandler& rOutputFileHandler);
388
395 virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
396
403 virtual void AcceptPopulationCountWriter(boost::shared_ptr<AbstractCellPopulationCountWriter<DIM, DIM> > pPopulationCountWriter);
404
411 virtual void AcceptPopulationEventWriter(boost::shared_ptr<AbstractCellPopulationEventWriter<DIM, DIM> > pPopulationEventWriter);
412
420 virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
421
430 unsigned GetRosetteRankOfCell(CellPtr pCell);
431
438 double GetVolumeOfCell(CellPtr pCell);
439
445 std::vector< c_vector< double, DIM > > GetLocationsOfT2Swaps();
446
452 std::vector< unsigned > GetCellIdsOfT2Swaps();
453
459 void AddLocationOfT2Swap(c_vector< double, DIM> locationOfT2Swap);
460
466 void AddCellIdOfT2Swap(unsigned idOfT2Swap);
467
472
477
483 void SetOutputCellRearrangementLocations(bool outputCellRearrangementLocations);
484
490 void OutputCellPopulationParameters(out_stream& rParamsFile);
491
501 double GetWidth(const unsigned& rDimension);
502
509 std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
510
521
531 virtual bool IsPdeNodeAssociatedWithNonApoptoticCell(unsigned pdeNodeIndex);
532
548 virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex,
549 std::string& rVariableName,
550 bool dirichletBoundaryConditionApplies=false,
551 double dirichletBoundaryValue=0.0);
552
556 boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > GetVertexBasedDivisionRule();
557
563 void SetVertexBasedDivisionRule(boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > pVertexBasedDivisionRule);
564
575 virtual double GetDefaultTimeStep();
576
584 virtual void WriteDataToVisualizerSetupFile(out_stream& pVizSetupFile);
585
600
607
613 void SetRestrictVertexMovementBoolean(bool restrictVertexMovement);
614
620
625
630 void SetWriteCellVtkResults(const bool new_val);
631
636 void SetWriteEdgeVtkResults(const bool new_val);
637};
638
641
642namespace boost
643{
644namespace serialization
645{
649template<class Archive, unsigned DIM>
650inline void save_construct_data(
651 Archive & ar, const VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
652{
653 // Save data required to construct instance
654 const MutableVertexMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
655 ar & p_mesh;
656
657 const VertexBasedPopulationSrn<DIM>& pop_srn = t->rGetVertexBasedPopulationSrn();
658 ar & pop_srn;
659}
660
665template<class Archive, unsigned DIM>
666inline void load_construct_data(
667 Archive & ar, VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
668{
669 // Retrieve data from archive required to construct new instance
671 ar >> p_mesh;
672
674 ar & pop_srn;
675 // Invoke inplace constructor to initialise instance
676 ::new(t)VertexBasedCellPopulation<DIM>(*p_mesh, pop_srn);
677}
678}
679} // namespace ...
680
681#endif /*VERTEXBASEDCELLPOPULATION_HPP_*/
682
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)