Chaste Commit::f2ff7ee04e70ac9d06c57344df8d017dbb12b97b
MeshBasedCellPopulation.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 MESHBASEDCELLPOPULATION_HPP_
37#define MESHBASEDCELLPOPULATION_HPP_
38
39#include <map>
40#include "AbstractCentreBasedCellPopulation.hpp"
41#include "MutableMesh.hpp"
42#include "VertexMesh.hpp"
43#include "TrianglesMeshReader.hpp"
44
46#include <boost/serialization/base_object.hpp>
47#include <boost/serialization/set.hpp>
48#include <boost/serialization/vector.hpp>
49
59#ifdef DOXYGEN_CHASTE_ISSUE_199 // See https://github.com/Chaste/Chaste/issues/199
60template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
61#else
62template<unsigned ELEMENT_DIM, unsigned SPACE_DIM = ELEMENT_DIM>
63#endif
64class MeshBasedCellPopulation : public AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM>
65{
66 friend class TestMeshBasedCellPopulation;
67private:
81 template<class Archive>
82 void serialize(Archive & archive, const unsigned int version)
83 {
84 archive & boost::serialization::base_object<AbstractCentreBasedCellPopulation<ELEMENT_DIM, SPACE_DIM> >(*this);
85
86 /*
87 * In its current form the code does not allow the direct serialization
88 * of the VertexMesh class, so instead we delete mpVoronoiTessellation.
89 */
91 mpVoronoiTessellation = nullptr;
92
93 archive & mSpringRestLengths;
96 archive & mWriteVtkAsPoints;
98 archive & mHasVariableRestLength;
99
100 this->Validate();
101 }
102
103protected:
120
123
129
133 std::map<std::pair<unsigned,unsigned>, double> mSpringRestLengths;
134
137
140
143
146
149
151 std::vector< std::pair<Node<SPACE_DIM>*, Node<SPACE_DIM>* > > mNodePairs;
152
158 virtual void UpdateGhostNodesAfterReMesh(NodeMap& rMap);
159
164 virtual void Validate();
165
166public:
179 std::vector<CellPtr>& rCells,
180 const std::vector<unsigned> locationIndices = {},
181 bool deleteMesh = false,
182 bool validate = true);
183
190
194 virtual ~MeshBasedCellPopulation();
195
200
205
214
217
226 unsigned AddNode(Node<SPACE_DIM>* pNewNode);
227
236 void SetNode(unsigned nodeIndex, ChastePoint<SPACE_DIM>& rNewLocation);
237
245 double GetDampingConstant(unsigned nodeIndex);
246
252 void SetAreaBasedDampingConstant(bool useAreaBasedDampingConstant);
253
261 virtual void OpenWritersFiles(OutputFileHandler& rOutputFileHandler);
262
275 virtual unsigned RemoveDeadCells();
276
288 virtual CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell);
289
295 virtual void WriteResultsToFiles(const std::string& rDirectory);
296
303 virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<ELEMENT_DIM, SPACE_DIM> > pPopulationWriter);
304
311 virtual void AcceptPopulationCountWriter(boost::shared_ptr<AbstractCellPopulationCountWriter<ELEMENT_DIM, SPACE_DIM> > pPopulationCountWriter);
312
319 virtual void AcceptPopulationEventWriter(boost::shared_ptr<AbstractCellPopulationEventWriter<ELEMENT_DIM, SPACE_DIM> > pPopulationEventWriter);
320
328 virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<ELEMENT_DIM, SPACE_DIM> > pCellWriter, CellPtr pCell);
329
337 virtual void Update(bool hasHadBirthsOrDeaths=true);
338
345 void TessellateIfNeeded();
346
352 void DivideLongSprings(double springDivisionThreshold);
353
361 Node<SPACE_DIM>* GetNode(unsigned index);
362
368 unsigned GetNumNodes();
369
375 virtual void WriteVtkResultsToFile(const std::string& rDirectory);
376
383 double GetVolumeOfCell(CellPtr pCell);
384
389
394
407 double GetVolumeOfVoronoiElement(unsigned index);
408
419 double GetSurfaceAreaOfVoronoiElement(unsigned index);
420
432 double GetVoronoiEdgeLength(unsigned index1, unsigned index2);
433
443 double GetWidth(const unsigned& rDimension);
444
452 virtual void WriteDataToVisualizerSetupFile(out_stream& pVizSetupFile);
453
516
521
526
530 void CheckCellPointers();
531
536
542 void SetAreaBasedDampingConstantParameter(double areaBasedDampingConstantParameter);
543
549 std::vector< std::pair<Node<SPACE_DIM>*, Node<SPACE_DIM>* > >& rGetNodePairs();
550
556 void OutputCellPopulationParameters(out_stream& rParamsFile);
557
563 void SetWriteVtkAsPoints(bool writeVtkAsPoints);
564
568 bool GetWriteVtkAsPoints();
569
575 void SetBoundVoronoiTessellation(bool boundVoronoiTessellation);
576
581
588 std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
589
594
601 double GetRestLength(unsigned indexA, unsigned indexB);
602
610 void SetRestLength(unsigned indexA, unsigned indexB, double restLength);
611
612};
613
616
617namespace boost
618{
619namespace serialization
620{
624template<class Archive, unsigned ELEMENT_DIM, unsigned SPACE_DIM>
625inline void save_construct_data(
626 Archive & ar, const MeshBasedCellPopulation<ELEMENT_DIM, SPACE_DIM> * t, const unsigned int file_version)
627{
628 // Save data required to construct instance
629 const MutableMesh<ELEMENT_DIM, SPACE_DIM>* p_mesh = &(t->rGetMesh());
630 ar & p_mesh;
631}
632
637template<class Archive, unsigned ELEMENT_DIM, unsigned SPACE_DIM>
638inline void load_construct_data(
639 Archive & ar, MeshBasedCellPopulation<ELEMENT_DIM, SPACE_DIM> * t, const unsigned int file_version)
640{
641 // Retrieve data from archive required to construct new instance
643 ar >> p_mesh;
644
645 // Invoke inplace constructor to initialise instance
647}
648}
649} // namespace ...
650
651#endif /*MESHBASEDCELLPOPULATION_HPP_*/
gcov doesn't like this file...
#define EXPORT_TEMPLATE_CLASS_ALL_DIMS(CLASS)
MutableMesh< ELEMENT_DIM, SPACE_DIM >::EdgeIterator mEdgeIter
MeshBasedCellPopulation< ELEMENT_DIM, SPACE_DIM > & mrCellPopulation
bool operator!=(const typename MeshBasedCellPopulation< ELEMENT_DIM, SPACE_DIM >::SpringIterator &rOther)
std::set< std::set< unsigned > > mSpringsVisited
virtual void OpenWritersFiles(OutputFileHandler &rOutputFileHandler)
void serialize(Archive &archive, const unsigned int version)
std::vector< std::pair< Node< SPACE_DIM > *, Node< SPACE_DIM > * > > mNodePairs
std::vector< std::pair< Node< SPACE_DIM > *, Node< SPACE_DIM > * > > & rGetNodePairs()
std::map< std::pair< unsigned, unsigned >, double > mSpringRestLengths
void OutputCellPopulationParameters(out_stream &rParamsFile)
virtual void WriteResultsToFiles(const std::string &rDirectory)
virtual void Update(bool hasHadBirthsOrDeaths=true)
double GetVoronoiEdgeLength(unsigned index1, unsigned index2)
virtual void AcceptPopulationWriter(boost::shared_ptr< AbstractCellPopulationWriter< ELEMENT_DIM, SPACE_DIM > > pPopulationWriter)
double GetDampingConstant(unsigned nodeIndex)
virtual void AcceptCellWriter(boost::shared_ptr< AbstractCellWriter< ELEMENT_DIM, SPACE_DIM > > pCellWriter, CellPtr pCell)
void SetWriteVtkAsPoints(bool writeVtkAsPoints)
double GetWidth(const unsigned &rDimension)
void SetNode(unsigned nodeIndex, ChastePoint< SPACE_DIM > &rNewLocation)
virtual void AcceptPopulationEventWriter(boost::shared_ptr< AbstractCellPopulationEventWriter< ELEMENT_DIM, SPACE_DIM > > pPopulationEventWriter)
void SetAreaBasedDampingConstant(bool useAreaBasedDampingConstant)
virtual void WriteVtkResultsToFile(const std::string &rDirectory)
virtual TetrahedralMesh< ELEMENT_DIM, SPACE_DIM > * GetTetrahedralMeshForPdeModifier()
VertexMesh< ELEMENT_DIM, SPACE_DIM > * mpVoronoiTessellation
virtual CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell)
unsigned AddNode(Node< SPACE_DIM > *pNewNode)
double GetSurfaceAreaOfVoronoiElement(unsigned index)
std::set< unsigned > GetNeighbouringNodeIndices(unsigned index)
Node< SPACE_DIM > * GetNode(unsigned index)
virtual void UpdateGhostNodesAfterReMesh(NodeMap &rMap)
void SetBoundVoronoiTessellation(bool boundVoronoiTessellation)
virtual void AcceptPopulationCountWriter(boost::shared_ptr< AbstractCellPopulationCountWriter< ELEMENT_DIM, SPACE_DIM > > pPopulationCountWriter)
double GetVolumeOfVoronoiElement(unsigned index)
friend class boost::serialization::access
void SetRestLength(unsigned indexA, unsigned indexB, double restLength)
virtual void WriteDataToVisualizerSetupFile(out_stream &pVizSetupFile)
VertexMesh< ELEMENT_DIM, SPACE_DIM > * GetVoronoiTessellation()
MutableMesh< ELEMENT_DIM, SPACE_DIM > * mpMutableMesh
void SetAreaBasedDampingConstantParameter(double areaBasedDampingConstantParameter)
void DivideLongSprings(double springDivisionThreshold)
double GetRestLength(unsigned indexA, unsigned indexB)
double GetVolumeOfCell(CellPtr pCell)
MutableMesh< ELEMENT_DIM, SPACE_DIM > & rGetMesh()
Definition Node.hpp:59