Chaste Commit::333233612e3dcc941d260418acd7b5ccdc30390e
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 & mScaleBoundByEdgeLength;
100 archive & mOffsetNewBoundaryNodes;
101 archive & mHasVariableRestLength;
102 this->Validate();
103 }
104
105protected:
122
125
131
135 std::map<std::pair<unsigned,unsigned>, double> mSpringRestLengths;
136
139
142
145
148
151
154
157
160
162 std::vector< std::pair<Node<SPACE_DIM>*, Node<SPACE_DIM>* > > mNodePairs;
163
169 virtual void UpdateGhostNodesAfterReMesh(NodeMap& rMap);
170
175 virtual void Validate();
176
177public:
190 std::vector<CellPtr>& rCells,
191 const std::vector<unsigned> locationIndices = {},
192 bool deleteMesh = false,
193 bool validate = true);
194
201
205 virtual ~MeshBasedCellPopulation();
206
211
216
225
228
237 unsigned AddNode(Node<SPACE_DIM>* pNewNode);
238
247 void SetNode(unsigned nodeIndex, ChastePoint<SPACE_DIM>& rNewLocation);
248
256 double GetDampingConstant(unsigned nodeIndex);
257
263 void SetAreaBasedDampingConstant(bool useAreaBasedDampingConstant);
264
272 virtual void OpenWritersFiles(OutputFileHandler& rOutputFileHandler);
273
286 virtual unsigned RemoveDeadCells();
287
299 virtual CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell);
300
306 virtual void WriteResultsToFiles(const std::string& rDirectory);
307
314 virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<ELEMENT_DIM, SPACE_DIM> > pPopulationWriter);
315
322 virtual void AcceptPopulationCountWriter(boost::shared_ptr<AbstractCellPopulationCountWriter<ELEMENT_DIM, SPACE_DIM> > pPopulationCountWriter);
323
330 virtual void AcceptPopulationEventWriter(boost::shared_ptr<AbstractCellPopulationEventWriter<ELEMENT_DIM, SPACE_DIM> > pPopulationEventWriter);
331
339 virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<ELEMENT_DIM, SPACE_DIM> > pCellWriter, CellPtr pCell);
340
348 virtual void Update(bool hasHadBirthsOrDeaths=true);
349
356 void TessellateIfNeeded();
357
363 void DivideLongSprings(double springDivisionThreshold);
364
372 Node<SPACE_DIM>* GetNode(unsigned index);
373
379 unsigned GetNumNodes();
380
386 virtual void WriteVtkResultsToFile(const std::string& rDirectory);
387
394 double GetVolumeOfCell(CellPtr pCell);
395
400
405
418 double GetVolumeOfVoronoiElement(unsigned index);
419
430 double GetSurfaceAreaOfVoronoiElement(unsigned index);
431
443 double GetVoronoiEdgeLength(unsigned index1, unsigned index2);
444
454 double GetWidth(const unsigned& rDimension);
455
463 virtual void WriteDataToVisualizerSetupFile(out_stream& pVizSetupFile);
464
527
532
537
541 void CheckCellPointers();
542
547
553 void SetAreaBasedDampingConstantParameter(double areaBasedDampingConstantParameter);
554
560 std::vector< std::pair<Node<SPACE_DIM>*, Node<SPACE_DIM>* > >& rGetNodePairs();
561
567 void OutputCellPopulationParameters(out_stream& rParamsFile);
568
574 void SetWriteVtkAsPoints(bool writeVtkAsPoints);
575
579 bool GetWriteVtkAsPoints();
580
586 void SetBoundVoronoiTessellation(bool boundVoronoiTessellation);
587
592
598 void SetScaleBoundByEdgeLength(bool scaleBoundByEdgeLength);
599
604
610 void SetBoundedVoroniTesselationLengthCutoff(double boundedVoroniTesselationLengthCutoff);
611
616
622 void SetOffsetNewBoundaryNodes(bool offsetNewBoundaryNodes);
623
628
635 std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
636
641
648 double GetRestLength(unsigned indexA, unsigned indexB);
649
657 void SetRestLength(unsigned indexA, unsigned indexB, double restLength);
658
659};
660
663
664namespace boost
665{
666namespace serialization
667{
671template<class Archive, unsigned ELEMENT_DIM, unsigned SPACE_DIM>
672inline void save_construct_data(
673 Archive & ar, const MeshBasedCellPopulation<ELEMENT_DIM, SPACE_DIM> * t, const unsigned int file_version)
674{
675 // Save data required to construct instance
676 const MutableMesh<ELEMENT_DIM, SPACE_DIM>* p_mesh = &(t->rGetMesh());
677 ar & p_mesh;
678}
679
684template<class Archive, unsigned ELEMENT_DIM, unsigned SPACE_DIM>
685inline void load_construct_data(
686 Archive & ar, MeshBasedCellPopulation<ELEMENT_DIM, SPACE_DIM> * t, const unsigned int file_version)
687{
688 // Retrieve data from archive required to construct new instance
690 ar >> p_mesh;
691
692 // Invoke inplace constructor to initialise instance
694}
695}
696} // namespace ...
697
698#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 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