Chaste  Release::2017.1
PottsBasedCellPopulation.hpp
1 /*
2 
3 Copyright (c) 2005-2017, 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 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 
45 #include "ChasteSerialization.hpp"
46 #include <boost/serialization/base_object.hpp>
47 #include <boost/serialization/vector.hpp>
48 
59 template<unsigned DIM>
61 {
62  friend class TestPottsBasedCellPopulation;
63 
64 private:
65 
72 
78 
84 
86  double mTemperature;
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  */
115  delete mpElementTessellation;
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 
139 public:
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 
170  virtual ~PottsBasedCellPopulation();
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 
334  virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
335 
342  double GetVolumeOfCell(CellPtr pCell);
343 
353  double GetWidth(const unsigned& rDimension);
354 
363  void OutputCellPopulationParameters(out_stream& rParamsFile);
364 
370  void SetTemperature(double temperature);
371 
375  double GetTemperature();
376 
382  void SetNumSweepsPerTimestep(unsigned numSweepsPerTimestep);
383 
387  unsigned GetNumSweepsPerTimestep();
388 
393 
398 
402  void CreateMutableMesh();
403 
408 
414  virtual void AddUpdateRule(boost::shared_ptr<AbstractUpdateRule<DIM> > pUpdateRule);
415 
431  virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex,
432  std::string& rVariableName,
433  bool dirichletBoundaryConditionApplies=false,
434  double dirichletBoundaryValue=0.0);
435 };
436 
439 
440 namespace boost
441 {
442 namespace serialization
443 {
447 template<class Archive, unsigned DIM>
448 inline void save_construct_data(
449  Archive & ar, const PottsBasedCellPopulation<DIM> * t, const unsigned int file_version)
450 {
451  // Save data required to construct instance
452  const PottsMesh<DIM>* p_mesh = &(t->rGetMesh());
453  ar & p_mesh;
454 }
455 
460 template<class Archive, unsigned DIM>
461 inline void load_construct_data(
462  Archive & ar, PottsBasedCellPopulation<DIM> * t, const unsigned int file_version)
463 {
464  // Retrieve data from archive required to construct new instance
465  PottsMesh<DIM>* p_mesh;
466  ar >> p_mesh;
467 
468  // Invoke inplace constructor to initialise instance
469  ::new(t)PottsBasedCellPopulation<DIM>(*p_mesh);
470 }
471 }
472 } // namespace ...
473 
474 #endif /*POTTSBASEDCELLPOPULATION_HPP_*/
Definition: Node.hpp:58
Node< DIM > * GetNode(unsigned index)
MutableMesh< DIM, DIM > * mpMutableMesh
VertexMesh< DIM, DIM > * GetElementTessellation()
std::set< unsigned > GetNeighbouringLocationIndices(CellPtr pCell)
PottsElement< DIM > * GetElementCorrespondingToCell(CellPtr pCell)
virtual void AcceptPopulationCountWriter(boost::shared_ptr< AbstractCellPopulationCountWriter< DIM, DIM > > pPopulationCountWriter)
virtual double GetCellDataItemAtPdeNode(unsigned pdeNodeIndex, std::string &rVariableName, bool dirichletBoundaryConditionApplies=false, double dirichletBoundaryValue=0.0)
c_vector< double, DIM > GetLocationOfCellCentre(CellPtr pCell)
virtual void AcceptCellWriter(boost::shared_ptr< AbstractCellWriter< DIM, DIM > > pCellWriter, CellPtr pCell)
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
void OutputCellPopulationParameters(out_stream &rParamsFile)
void SetTemperature(double temperature)
virtual void WriteVtkResultsToFile(const std::string &rDirectory)
virtual void AcceptPopulationWriter(boost::shared_ptr< AbstractCellPopulationWriter< DIM, DIM > > pPopulationWriter)
void Update(bool hasHadBirthsOrDeaths=true)
virtual void AddUpdateRule(boost::shared_ptr< AbstractUpdateRule< DIM > > pUpdateRule)
double GetVolumeOfCell(CellPtr pCell)
void serialize(Archive &archive, const unsigned int version)
virtual void WriteResultsToFiles(const std::string &rDirectory)
CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell=CellPtr())
virtual TetrahedralMesh< DIM, DIM > * GetTetrahedralMeshForPdeModifier()
MutableMesh< DIM, DIM > * GetMutableMesh()
PottsElement< DIM > * GetElement(unsigned elementIndex)
double GetWidth(const unsigned &rDimension)
virtual void OpenWritersFiles(OutputFileHandler &rOutputFileHandler)
gcov doesn&#39;t like this file...
void SetNumSweepsPerTimestep(unsigned numSweepsPerTimestep)
VertexMesh< DIM, DIM > * mpElementTessellation
PottsBasedCellPopulation(PottsMesh< DIM > &rMesh, std::vector< CellPtr > &rCells, bool deleteMesh=false, bool validate=true, const std::vector< unsigned > locationIndices=std::vector< unsigned >())
bool IsCellAssociatedWithADeletedLocation(CellPtr pCell)