Chaste Commit::f2ff7ee04e70ac9d06c57344df8d017dbb12b97b
AbstractCellBasedSimulation.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 ABSTRACTCELLBASEDSIMULATION_HPP_
37#define ABSTRACTCELLBASEDSIMULATION_HPP_
38
40#include <boost/serialization/vector.hpp>
41#include <boost/serialization/string.hpp>
42
43#include <vector>
44
45#include "AbstractCellKiller.hpp"
46#include "AbstractCellBasedSimulationModifier.hpp"
47#include "AbstractForce.hpp"
48#include "RandomNumberGenerator.hpp"
49
50// Forward declaration prevents circular include chain
51template<unsigned ELEMENT_DIM, unsigned SPACE_DIM> class AbstractCellPopulation;
52
67template<unsigned ELEMENT_DIM, unsigned SPACE_DIM=ELEMENT_DIM>
69{
70 // Allow tests to access private members, in order to test computation of private functions e.g. DoCellBirth()
71 friend class TestCryptSimulation2d;
72 friend class TestOffLatticeSimulation3d;
73 friend class TestOffLatticeSimulation;
74
75private:
76
79
86 template<class Archive>
87 void serialize(Archive & archive, const unsigned int version)
88 {
90 archive & p_time_wrapper;
91
93 archive & p_rng_wrapper;
94
95 archive & mDt;
96 archive & mEndTime;
97 archive & mNoBirth;
98 archive & mUpdateCellPopulation;
99 archive & mOutputDirectory;
100 archive & mNumBirths;
101 archive & mNumDeaths;
102 archive & mOutputDivisionLocations;
103 archive & mOutputCellVelocities;
104 archive & mCellKillers;
105 archive & mSimulationModifiers;
109 }
110
111protected:
112
114 double mDt;
115
117 double mEndTime;
118
121
124
127
130
133
135 std::string mOutputDirectory;
136
139
141 out_stream mpVizSetupFile;
142
144 unsigned mNumBirths;
145
147 unsigned mNumDeaths;
148
151
154
160
163
165 std::vector<boost::shared_ptr<AbstractCellKiller<SPACE_DIM> > > mCellKillers;
166
168 std::vector<boost::shared_ptr<AbstractCellBasedSimulationModifier<ELEMENT_DIM, SPACE_DIM> > > mSimulationModifiers;
169
173 std::vector<boost::shared_ptr<AbstractCellBasedSimulationModifier<ELEMENT_DIM, SPACE_DIM> > > mTopologyUpdateSimulationModifiers;
174
180
186
191 {
192 }
193
209 virtual unsigned DoCellBirth();
210
219 unsigned DoCellRemoval();
220
224 virtual void SetupSolve()
225 {
226 }
227
234 virtual bool StoppingEventHasOccurred();
235
239 virtual void UpdateCellPopulation();
240
255
260
270 virtual void OutputAdditionalSimulationSetup(out_stream& rParamsFile)=0;
271
272public:
273
283 bool deleteCellPopulationInDestructor=false,
284 bool initialiseCells=true);
285
292
299 std::vector<double> GetNodeLocation(const unsigned& rNodeIndex);
300
304 double GetDt();
305
309 unsigned GetNumBirths();
310
314 unsigned GetNumDeaths();
315
319 std::string GetOutputDirectory();
320
326 void SetDt(double dt);
327
333 void SetEndTime(double endTime);
334
340 void SetOutputDirectory(std::string outputDirectory);
341
348 void SetSamplingTimestepMultiple(unsigned samplingTimestepMultiple);
349
356 void SetUpdatingTimestepMultiple(unsigned updatingTimestepMultiple);
357
363 void SetNoBirth(bool noBirth);
364
370 void SetUpdateCellPopulationRule(bool updateCellPopulation);
371
378
384 void AddCellKiller(boost::shared_ptr<AbstractCellKiller<SPACE_DIM> > pCellKiller);
385
390
396 void AddSimulationModifier(boost::shared_ptr<AbstractCellBasedSimulationModifier<ELEMENT_DIM,SPACE_DIM> > pSimulationModifier);
397
401 std::vector<boost::shared_ptr<AbstractCellBasedSimulationModifier<ELEMENT_DIM, SPACE_DIM> > >* GetSimulationModifiers();
402
410
414 std::vector<boost::shared_ptr<AbstractCellBasedSimulationModifier<ELEMENT_DIM, SPACE_DIM> > >* GetTopologyUpdateSimulationModifiers();
415
470 void Solve();
471
476
481
486
492 void SetOutputDivisionLocations(bool outputDivisionLocations);
493
498
504 void SetOutputCellVelocities(bool outputCellVelocities);
505
514 virtual void OutputSimulationParameters(out_stream& rParamsFile)=0;
515};
516
517#endif /*ABSTRACTCELLBASEDSIMULATION_HPP_*/
std::vector< boost::shared_ptr< AbstractCellBasedSimulationModifier< ELEMENT_DIM, SPACE_DIM > > > mSimulationModifiers
AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM > & mrCellPopulation
void SetUpdateCellPopulationRule(bool updateCellPopulation)
virtual void UpdateCellLocationsAndTopology()=0
std::vector< boost::shared_ptr< AbstractCellKiller< SPACE_DIM > > > mCellKillers
void SetOutputCellVelocities(bool outputCellVelocities)
void SetUpdatingTimestepMultiple(unsigned updatingTimestepMultiple)
AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM > & rGetCellPopulation()
std::vector< boost::shared_ptr< AbstractCellBasedSimulationModifier< ELEMENT_DIM, SPACE_DIM > > > * GetSimulationModifiers()
std::vector< boost::shared_ptr< AbstractCellBasedSimulationModifier< ELEMENT_DIM, SPACE_DIM > > > mTopologyUpdateSimulationModifiers
void AddSimulationModifier(boost::shared_ptr< AbstractCellBasedSimulationModifier< ELEMENT_DIM, SPACE_DIM > > pSimulationModifier)
void serialize(Archive &archive, const unsigned int version)
void AddTopologyUpdateSimulationModifier(boost::shared_ptr< AbstractCellBasedSimulationModifier< ELEMENT_DIM, SPACE_DIM > > pSimulationModifier)
virtual void OutputSimulationParameters(out_stream &rParamsFile)=0
virtual void OutputAdditionalSimulationSetup(out_stream &rParamsFile)=0
void SetOutputDirectory(std::string outputDirectory)
void AddCellKiller(boost::shared_ptr< AbstractCellKiller< SPACE_DIM > > pCellKiller)
std::vector< boost::shared_ptr< AbstractCellBasedSimulationModifier< ELEMENT_DIM, SPACE_DIM > > > * GetTopologyUpdateSimulationModifiers()
std::vector< double > GetNodeLocation(const unsigned &rNodeIndex)
friend class boost::serialization::access
void SetSamplingTimestepMultiple(unsigned samplingTimestepMultiple)
void SetOutputDivisionLocations(bool outputDivisionLocations)
static RandomNumberGenerator * Instance()
SerializableSingleton< SINGLETON_CLASS > * GetSerializationWrapper() const
static SimulationTime * Instance()