Chaste Commit::675f9facbe008c5eacb9006feaeb6423206579ea
MeshBasedCellPopulation.hpp
1/*
2
3Copyright (c) 2005-2025, 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;
100 archive & mOffsetNewBoundaryNodes;
101 archive & mHasVariableRestLength;
102 this->Validate();
103 this->UpdateNodePairs();
104 }
105
106protected:
123
126
132
136 std::map<std::pair<unsigned,unsigned>, double> mSpringRestLengths;
137
140
143
146
149
152
155
158
161
163 virtual void UpdateNodePairs();
164
170 virtual void UpdateGhostNodesAfterReMesh(NodeMap& rMap);
171
176 virtual void Validate();
177
178public:
191 std::vector<CellPtr>& rCells,
192 const std::vector<unsigned> locationIndices = {},
193 bool deleteMesh = false,
194 bool validate = true);
195
202
206 virtual ~MeshBasedCellPopulation();
207
212
217
226
229
238 unsigned AddNode(Node<SPACE_DIM>* pNewNode);
239
248 void SetNode(unsigned nodeIndex, ChastePoint<SPACE_DIM>& rNewLocation);
249
257 double GetDampingConstant(unsigned nodeIndex);
258
264 void SetAreaBasedDampingConstant(bool useAreaBasedDampingConstant);
265
273 virtual void OpenWritersFiles(OutputFileHandler& rOutputFileHandler);
274
287 virtual unsigned RemoveDeadCells();
288
300 virtual CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell);
301
307 virtual void WriteResultsToFiles(const std::string& rDirectory);
308
315 virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<ELEMENT_DIM, SPACE_DIM> > pPopulationWriter);
316
323 virtual void AcceptPopulationCountWriter(boost::shared_ptr<AbstractCellPopulationCountWriter<ELEMENT_DIM, SPACE_DIM> > pPopulationCountWriter);
324
331 virtual void AcceptPopulationEventWriter(boost::shared_ptr<AbstractCellPopulationEventWriter<ELEMENT_DIM, SPACE_DIM> > pPopulationEventWriter);
332
340 virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<ELEMENT_DIM, SPACE_DIM> > pCellWriter, CellPtr pCell);
341
349 virtual void Update(bool hasHadBirthsOrDeaths=true);
350
357 void TessellateIfNeeded();
358
364 void DivideLongSprings(double springDivisionThreshold);
365
373 Node<SPACE_DIM>* GetNode(unsigned index);
374
380 unsigned GetNumNodes();
381
387 virtual void WriteVtkResultsToFile(const std::string& rDirectory);
388
395 double GetVolumeOfCell(CellPtr pCell);
396
401
406
419 double GetVolumeOfVoronoiElement(unsigned index);
420
431 double GetSurfaceAreaOfVoronoiElement(unsigned index);
432
444 double GetVoronoiEdgeLength(unsigned index1, unsigned index2);
445
455 double GetWidth(const unsigned& rDimension);
456
464 virtual void WriteDataToVisualizerSetupFile(out_stream& pVizSetupFile);
465
528
533
538
542 void CheckCellPointers();
543
548
554 void SetAreaBasedDampingConstantParameter(double areaBasedDampingConstantParameter);
555
561 void OutputCellPopulationParameters(out_stream& rParamsFile);
562
568 void SetWriteVtkAsPoints(bool writeVtkAsPoints);
569
573 bool GetWriteVtkAsPoints();
574
580 void SetBoundVoronoiTessellation(bool boundVoronoiTessellation);
581
586
592 void SetScaleBoundByEdgeLength(bool scaleBoundByEdgeLength);
593
598
604 void SetBoundedVoroniTesselationLengthCutoff(double boundedVoroniTesselationLengthCutoff);
605
610
616 void SetOffsetNewBoundaryNodes(bool offsetNewBoundaryNodes);
617
622
629 std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
630
635
642 double GetRestLength(unsigned indexA, unsigned indexB);
643
651 void SetRestLength(unsigned indexA, unsigned indexB, double restLength);
652
653};
654
657
658namespace boost
659{
660namespace serialization
661{
665template<class Archive, unsigned ELEMENT_DIM, unsigned SPACE_DIM>
666inline void save_construct_data(
667 Archive & ar, const MeshBasedCellPopulation<ELEMENT_DIM, SPACE_DIM> * t, const unsigned int file_version)
668{
669 // Save data required to construct instance
670 const MutableMesh<ELEMENT_DIM, SPACE_DIM>* p_mesh = &(t->rGetMesh());
671 ar & p_mesh;
672}
673
678template<class Archive, unsigned ELEMENT_DIM, unsigned SPACE_DIM>
679inline void load_construct_data(
680 Archive & ar, MeshBasedCellPopulation<ELEMENT_DIM, SPACE_DIM> * t, const unsigned int file_version)
681{
682 // Retrieve data from archive required to construct new instance
684 ar >> p_mesh;
685
686 // Invoke inplace constructor to initialise instance
688}
689}
690} // namespace ...
691
692#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::map< std::pair< unsigned, unsigned >, double > mSpringRestLengths
void SetBoundedVoroniTesselationLengthCutoff(double boundedVoroniTesselationLengthCutoff)
void OutputCellPopulationParameters(out_stream &rParamsFile)
virtual void WriteResultsToFiles(const std::string &rDirectory)
virtual void Update(bool hasHadBirthsOrDeaths=true)
double GetVoronoiEdgeLength(unsigned index1, unsigned index2)
void SetScaleBoundByEdgeLength(bool scaleBoundByEdgeLength)
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)
void SetOffsetNewBoundaryNodes(bool offsetNewBoundaryNodes)
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