Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
PottsBasedCellPopulation.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 POTTSBASEDCELLPOPULATION_HPP_
37#define POTTSBASEDCELLPOPULATION_HPP_
38
39#include "AbstractOnLatticeCellPopulation.hpp"
40#include "PottsMesh.hpp"
41#include "VertexMesh.hpp"
42#include "AbstractUpdateRule.hpp"
43#include "MutableMesh.hpp"
44
46#include <boost/serialization/base_object.hpp>
47#include <boost/serialization/vector.hpp>
48
59template<unsigned DIM>
61{
62 friend class TestPottsBasedCellPopulation;
63
64private:
65
72
78
84
87
93
94 friend class boost::serialization::access;
106 template<class Archive>
107 void serialize(Archive & archive, const unsigned int version)
108 {
109 archive & boost::serialization::base_object<AbstractOnLatticeCellPopulation<DIM> >(*this);
110
111 /*
112 * In its current form the code does not allow the direct serialization
113 * of the PottsMesh class, so instead we delete mpVoronoiTessellation.
114 */
116 mpElementTessellation = nullptr;
117
118 archive & mTemperature;
119 archive & mNumSweepsPerTimestep;
120 }
121
126 void Validate();
127
137 virtual void WriteVtkResultsToFile(const std::string& rDirectory);
138
139public:
140
155 std::vector<CellPtr>& rCells,
156 bool deleteMesh=false,
157 bool validate=true,
158 const std::vector<unsigned> locationIndices=std::vector<unsigned>());
159
166
171
176
180 const PottsMesh<DIM>& rGetMesh() const;
181
190
198 PottsElement<DIM>* GetElement(unsigned elementIndex);
199
203 unsigned GetNumElements();
204
212 Node<DIM>* GetNode(unsigned index);
213
219 unsigned GetNumNodes();
220
229 std::set<unsigned> GetNeighbouringLocationIndices(CellPtr pCell);
230
239 c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
240
249
259 CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr());
260
270 unsigned RemoveDeadCells();
271
277 void UpdateCellLocations(double dt);
278
285 bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
286
293 void Update(bool hasHadBirthsOrDeaths=true);
294
302 virtual void OpenWritersFiles(OutputFileHandler& rOutputFileHandler);
303
309 virtual void WriteResultsToFiles(const std::string& rDirectory);
310
317 virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
318
325 virtual void AcceptPopulationCountWriter(boost::shared_ptr<AbstractCellPopulationCountWriter<DIM, DIM> > pPopulationCountWriter);
326
333 virtual void AcceptPopulationEventWriter(boost::shared_ptr<AbstractCellPopulationEventWriter<DIM, DIM> > pPopulationEventWriter);
334
342 virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
343
350 double GetVolumeOfCell(CellPtr pCell);
351
361 double GetWidth(const unsigned& rDimension);
362
371 void OutputCellPopulationParameters(out_stream& rParamsFile);
372
378 void SetTemperature(double temperature);
379
383 double GetTemperature();
384
390 void SetNumSweepsPerTimestep(unsigned numSweepsPerTimestep);
391
395 unsigned GetNumSweepsPerTimestep();
396
401
406
410 void CreateMutableMesh();
411
416
422 virtual void AddUpdateRule(boost::shared_ptr<AbstractUpdateRule<DIM> > pUpdateRule);
423
439 virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex,
440 std::string& rVariableName,
441 bool dirichletBoundaryConditionApplies=false,
442 double dirichletBoundaryValue=0.0);
443};
444
447
448namespace boost
449{
450namespace serialization
451{
455template<class Archive, unsigned DIM>
456inline void save_construct_data(
457 Archive & ar, const PottsBasedCellPopulation<DIM> * t, const unsigned int file_version)
458{
459 // Save data required to construct instance
460 const PottsMesh<DIM>* p_mesh = &(t->rGetMesh());
461 ar & p_mesh;
462}
463
468template<class Archive, unsigned DIM>
469inline void load_construct_data(
470 Archive & ar, PottsBasedCellPopulation<DIM> * t, const unsigned int file_version)
471{
472 // Retrieve data from archive required to construct new instance
473 PottsMesh<DIM>* p_mesh;
474 ar >> p_mesh;
475
476 // Invoke inplace constructor to initialise instance
477 ::new(t)PottsBasedCellPopulation<DIM>(*p_mesh);
478}
479}
480} // namespace ...
481
482#endif /*POTTSBASEDCELLPOPULATION_HPP_*/
gcov doesn't like this file...
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
Definition Node.hpp:59
virtual void OpenWritersFiles(OutputFileHandler &rOutputFileHandler)
void Update(bool hasHadBirthsOrDeaths=true)
virtual void AcceptPopulationEventWriter(boost::shared_ptr< AbstractCellPopulationEventWriter< DIM, DIM > > pPopulationEventWriter)
VertexMesh< DIM, DIM > * GetElementTessellation()
virtual void WriteResultsToFiles(const std::string &rDirectory)
virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex, std::string &rVariableName, bool dirichletBoundaryConditionApplies=false, double dirichletBoundaryValue=0.0)
virtual void AcceptCellWriter(boost::shared_ptr< AbstractCellWriter< DIM, DIM > > pCellWriter, CellPtr pCell)
PottsElement< DIM > * GetElementCorrespondingToCell(CellPtr pCell)
virtual void AcceptPopulationWriter(boost::shared_ptr< AbstractCellPopulationWriter< DIM, DIM > > pPopulationWriter)
c_vector< double, DIM > GetLocationOfCellCentre(CellPtr pCell)
MutableMesh< DIM, DIM > * mpMutableMesh
std::set< unsigned > GetNeighbouringLocationIndices(CellPtr pCell)
PottsElement< DIM > * GetElement(unsigned elementIndex)
bool IsCellAssociatedWithADeletedLocation(CellPtr pCell)
VertexMesh< DIM, DIM > * mpElementTessellation
void SetNumSweepsPerTimestep(unsigned numSweepsPerTimestep)
CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr())
Node< DIM > * GetNode(unsigned index)
virtual void AcceptPopulationCountWriter(boost::shared_ptr< AbstractCellPopulationCountWriter< DIM, DIM > > pPopulationCountWriter)
virtual void WriteVtkResultsToFile(const std::string &rDirectory)
virtual TetrahedralMesh< DIM, DIM > * GetTetrahedralMeshForPdeModifier()
double GetWidth(const unsigned &rDimension)
MutableMesh< DIM, DIM > * GetMutableMesh()
virtual void AddUpdateRule(boost::shared_ptr< AbstractUpdateRule< DIM > > pUpdateRule)
void OutputCellPopulationParameters(out_stream &rParamsFile)
void serialize(Archive &archive, const unsigned int version)
void SetTemperature(double temperature)