Chaste Commit::1fd4e48e3990e67db148bc1bc4cf6991a0049d0c
NodeBasedCellPopulation.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 NODEBASEDCELLPOPULATION_HPP_
37#define NODEBASEDCELLPOPULATION_HPP_
38
40#include <boost/serialization/base_object.hpp>
41
42
43#include "ObjectCommunicator.hpp"
44#include "AbstractCentreBasedCellPopulation.hpp"
45#include "NodesOnlyMesh.hpp"
46
51template<unsigned DIM>
53{
54 friend class TestNodeBasedCellPopulation;
55 friend class TestNodeBasedCellPopulationParallelMethods;
56 friend class TestPeriodicNodeBasedCellPopulationParallelMethods;
57
58protected:
59
62
63private:
64
66 c_vector<double, DIM> mMinSpatialPositions;
67
69 c_vector<double, DIM> mMaxSpatialPositions;
70
72 std::vector< std::pair<Node<DIM>*, Node<DIM>* > > mNodePairs;
73
76
79
81 std::vector<std::pair<CellPtr, Node<DIM>* > > mCellsToSendRight;
82
84 std::vector<std::pair<CellPtr, Node<DIM>* > > mCellsToSendLeft;
85
87 boost::shared_ptr<std::vector<std::pair<CellPtr, Node<DIM>* > > > mpCellsRecvRight;
88
90 boost::shared_ptr<std::vector<std::pair<CellPtr, Node<DIM>* > > > mpCellsRecvLeft;
91
94
97
99 static const unsigned mCellCommunicationTag = 123;
100
102 std::vector<CellPtr> mHaloCells;
103
105 std::map<unsigned, CellPtr> mLocationHaloCellMap;
106
108 std::map<CellPtr, unsigned> mHaloCellLocationMap;
109
112
115
127 template<class Archive>
128 void serialize(Archive & archive, const unsigned int version)
129 {
130 archive & boost::serialization::base_object<AbstractCentreBasedCellPopulation<DIM> >(*this);
131 archive & mUseVariableRadii;
132
133 this->Validate();
134 }
135
144 unsigned AddNode(Node<DIM>* pNewNode);
145
151 void AddMovedCell(CellPtr pCell, boost::shared_ptr<Node<DIM> > pNode);
152
157 void DeleteMovedCell(unsigned index);
158
162 void RefreshHaloCells();
163
170 void AddNodeAndCellToSendRight(unsigned nodeIndex);
171
178 void AddNodeAndCellToSendLeft(unsigned nodeIndex);
179
184 void AddCellsToSendRight(std::vector<unsigned>& cellLocationIndices);
185
190 void AddCellsToSendLeft(std::vector<unsigned>& cellLocationIndices);
191
196
202 void AddHaloCell(CellPtr pCell, boost::shared_ptr<Node<DIM> > pNode);
203
210
211protected:
212
218 virtual void UpdateParticlesAfterReMesh(NodeMap& rMap);
219
223 virtual void Validate();
224
225private:
226
232 virtual void WriteVtkResultsToFile(const std::string& rDirectory);
233
243 unsigned CalculateMessageTag(unsigned senderI, unsigned receiverJ);
244
245public:
246
253 void SetNode(unsigned nodeIndex, ChastePoint<DIM>& rNewLocation);
254
267 std::vector<CellPtr>& rCells,
268 const std::vector<unsigned> locationIndices=std::vector<unsigned>(),
269 bool deleteMesh=false,
270 bool validate=true);
271
278
284 virtual ~NodeBasedCellPopulation();
285
290
294 const NodesOnlyMesh<DIM>& rGetMesh() const;
295
304
308 unsigned GetNumNodes();
309
317 virtual CellPtr GetCellUsingLocationIndex(unsigned index);
318
326 Node<DIM>* GetNode(unsigned index);
327
337 unsigned RemoveDeadCells();
338
342 void Clear();
343
349 void Update(bool hasHadBirthsOrDeaths=true);
350
356 std::vector< std::pair<Node<DIM>*, Node<DIM>* > >& rGetNodePairs();
357
366 void OutputCellPopulationParameters(out_stream& rParamsFile);
367
374 virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
375
382 virtual void AcceptPopulationCountWriter(boost::shared_ptr<AbstractCellPopulationCountWriter<DIM, DIM> > pPopulationCountWriter);
383
390 virtual void AcceptPopulationEventWriter(boost::shared_ptr<AbstractCellPopulationEventWriter<DIM, DIM> > pPopulationEventWriter);
391
399 virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
400
405
409 bool GetUseVariableRadii();
410
416 void SetUseVariableRadii(bool useVariableRadii=true);
417
422 void SetLoadBalanceMesh(bool loadBalanceMesh);
423
428 void SetLoadBalanceFrequency(unsigned loadBalanceFrequency);
429
439 double GetWidth(const unsigned& rDimension);
440
446 c_vector<double, DIM> GetSizeOfCellPopulation();
447
459 std::set<unsigned> GetNodesWithinNeighbourhoodRadius(unsigned index, double neighbourhoodRadius);
460
469 std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
470
482 virtual CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell);
483
490 double GetVolumeOfCell(CellPtr pCell);
491
493 // Parallel methods
495
502
510
515 void GetReceivedCells();
516
523 std::pair<CellPtr, Node<DIM>* > GetCellNodePair(unsigned nodeIndex);
524
528 void AddReceivedCells();
529
533 virtual void UpdateCellProcessLocation();
534};
535
538
539namespace boost
540{
541namespace serialization
542{
546template<class Archive, unsigned DIM>
547inline void save_construct_data(
548 Archive & ar, const NodeBasedCellPopulation<DIM> * t, const unsigned int file_version)
549{
550 // Save data required to construct instance
551 const NodesOnlyMesh<DIM>* p_mesh = &(t->rGetMesh());
552 ar & p_mesh;
553}
554
559template<class Archive, unsigned DIM>
560inline void load_construct_data(
561 Archive & ar, NodeBasedCellPopulation<DIM> * t, const unsigned int file_version)
562{
563 // Retrieve data from archive required to construct new instance
564 NodesOnlyMesh<DIM>* p_mesh;
565 ar >> p_mesh;
566
567 // Invoke inplace constructor to initialise instance
568 ::new(t)NodeBasedCellPopulation<DIM>(*p_mesh);
569}
570}
571} // namespace ...
572
573#endif /*NODEBASEDCELLPOPULATION_HPP_*/
gcov doesn't like this file...
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
boost::shared_ptr< std::vector< std::pair< CellPtr, Node< DIM > * > > > mpCellsRecvLeft
c_vector< double, DIM > GetSizeOfCellPopulation()
unsigned CalculateMessageTag(unsigned senderI, unsigned receiverJ)
c_vector< double, DIM > mMaxSpatialPositions
void SetNode(unsigned nodeIndex, ChastePoint< DIM > &rNewLocation)
ObjectCommunicator< std::vector< std::pair< CellPtr, Node< DIM > * > > > mLeftCommunicator
ObjectCommunicator< std::vector< std::pair< CellPtr, Node< DIM > * > > > mRightCommunicator
void AddCellsToSendRight(std::vector< unsigned > &cellLocationIndices)
std::vector< std::pair< Node< DIM > *, Node< DIM > * > > mNodePairs
void AddHaloCell(CellPtr pCell, boost::shared_ptr< Node< DIM > > pNode)
static const unsigned mCellCommunicationTag
Node< DIM > * GetNode(unsigned index)
virtual void AcceptPopulationCountWriter(boost::shared_ptr< AbstractCellPopulationCountWriter< DIM, DIM > > pPopulationCountWriter)
void OutputCellPopulationParameters(out_stream &rParamsFile)
void AddNodeAndCellToSendLeft(unsigned nodeIndex)
virtual CellPtr GetCellUsingLocationIndex(unsigned index)
NodesOnlyMesh< DIM > & rGetMesh()
void serialize(Archive &archive, const unsigned int version)
void SetUseVariableRadii(bool useVariableRadii=true)
std::vector< CellPtr > mHaloCells
std::pair< CellPtr, Node< DIM > * > GetCellNodePair(unsigned nodeIndex)
c_vector< double, DIM > mMinSpatialPositions
void SetLoadBalanceMesh(bool loadBalanceMesh)
virtual void WriteVtkResultsToFile(const std::string &rDirectory)
void AddCellsToSendLeft(std::vector< unsigned > &cellLocationIndices)
virtual void AcceptCellWriter(boost::shared_ptr< AbstractCellWriter< DIM, DIM > > pCellWriter, CellPtr pCell)
unsigned AddNode(Node< DIM > *pNewNode)
std::set< unsigned > GetNodesWithinNeighbourhoodRadius(unsigned index, double neighbourhoodRadius)
double GetWidth(const unsigned &rDimension)
virtual TetrahedralMesh< DIM, DIM > * GetTetrahedralMeshForPdeModifier()
NodesOnlyMesh< DIM > * mpNodesOnlyMesh
void SetLoadBalanceFrequency(unsigned loadBalanceFrequency)
std::map< CellPtr, unsigned > mHaloCellLocationMap
boost::shared_ptr< std::vector< std::pair< CellPtr, Node< DIM > * > > > mpCellsRecvRight
double GetVolumeOfCell(CellPtr pCell)
void Update(bool hasHadBirthsOrDeaths=true)
virtual CellPtr AddCell(CellPtr pNewCell, CellPtr pParentCell)
friend class boost::serialization::access
std::vector< std::pair< CellPtr, Node< DIM > * > > mCellsToSendLeft
void AddNodeAndCellToSendRight(unsigned nodeIndex)
std::map< unsigned, CellPtr > mLocationHaloCellMap
void AddMovedCell(CellPtr pCell, boost::shared_ptr< Node< DIM > > pNode)
std::set< unsigned > GetNeighbouringNodeIndices(unsigned index)
virtual void UpdateParticlesAfterReMesh(NodeMap &rMap)
virtual void AcceptPopulationEventWriter(boost::shared_ptr< AbstractCellPopulationEventWriter< DIM, DIM > > pPopulationEventWriter)
std::vector< std::pair< CellPtr, Node< DIM > * > > mCellsToSendRight
std::vector< std::pair< Node< DIM > *, Node< DIM > * > > & rGetNodePairs()
virtual void AcceptPopulationWriter(boost::shared_ptr< AbstractCellPopulationWriter< DIM, DIM > > pPopulationWriter)
Definition Node.hpp:59