AbstractCellBasedSimulation.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef ABSTRACTCELLBASEDSIMULATION_HPP_
00037 #define ABSTRACTCELLBASEDSIMULATION_HPP_
00038
00039 #include "ChasteSerialization.hpp"
00040 #include <boost/serialization/vector.hpp>
00041 #include <boost/serialization/string.hpp>
00042
00043 #include <vector>
00044
00045 #include "CellBasedPdeHandler.hpp"
00046 #include "AbstractCellKiller.hpp"
00047 #include "AbstractCellBasedSimulationModifier.hpp"
00048 #include "AbstractForce.hpp"
00049 #include "RandomNumberGenerator.hpp"
00050
00065 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM=ELEMENT_DIM>
00066 class AbstractCellBasedSimulation : public Identifiable
00067 {
00068
00069 friend class TestCryptSimulation2d;
00070 friend class TestOffLatticeSimulation3d;
00071 friend class TestOffLatticeSimulation;
00072
00073 private:
00074
00076 friend class boost::serialization::access;
00077
00084 template<class Archive>
00085 void serialize(Archive & archive, const unsigned int version)
00086 {
00087 SerializableSingleton<SimulationTime>* p_time_wrapper = SimulationTime::Instance()->GetSerializationWrapper();
00088 archive & p_time_wrapper;
00089
00090 SerializableSingleton<RandomNumberGenerator>* p_rng_wrapper = RandomNumberGenerator::Instance()->GetSerializationWrapper();
00091 archive & p_rng_wrapper;
00092
00093 archive & mDt;
00094 archive & mEndTime;
00095 archive & mNoBirth;
00096 archive & mUpdateCellPopulation;
00097 archive & mOutputDirectory;
00098 archive & mNumBirths;
00099 archive & mNumDeaths;
00100 archive & mOutputDivisionLocations;
00101 archive & mOutputCellVelocities;
00102 archive & mCellKillers;
00103 archive & mSimulationModifiers;
00104 archive & mSamplingTimestepMultiple;
00105 archive & mpCellBasedPdeHandler;
00106 }
00107
00108 protected:
00109
00111 double mDt;
00112
00114 double mEndTime;
00115
00117 AbstractCellPopulation<ELEMENT_DIM, SPACE_DIM>& mrCellPopulation;
00118
00120 bool mDeleteCellPopulationInDestructor;
00121
00123 bool mInitialiseCells;
00124
00126 bool mNoBirth;
00127
00129 bool mUpdateCellPopulation;
00130
00132 std::string mOutputDirectory;
00133
00135 std::string mSimulationOutputDirectory;
00136
00138 out_stream mpVizSetupFile;
00139
00141 unsigned mNumBirths;
00142
00144 unsigned mNumDeaths;
00145
00147 bool mOutputDivisionLocations;
00148
00150 out_stream mpDivisionLocationFile;
00151
00156 bool mOutputCellVelocities;
00157
00159 out_stream mpCellVelocitiesFile;
00160
00162 std::vector<boost::shared_ptr<AbstractCellKiller<SPACE_DIM> > > mCellKillers;
00163
00165 std::vector<boost::shared_ptr<AbstractCellBasedSimulationModifier<ELEMENT_DIM, SPACE_DIM> > > mSimulationModifiers;
00166
00171 unsigned mSamplingTimestepMultiple;
00172
00176 CellBasedPdeHandler<SPACE_DIM>* mpCellBasedPdeHandler;
00177
00181 virtual void WriteVisualizerSetupFile()
00182 {
00183 }
00184
00200 virtual unsigned DoCellBirth();
00201
00213 virtual c_vector<double, SPACE_DIM> CalculateCellDivisionVector(CellPtr pParentCell)=0;
00214
00223 unsigned DoCellRemoval();
00224
00228 virtual void SetupSolve()
00229 {
00230 }
00231
00238 virtual bool StoppingEventHasOccurred();
00239
00243 virtual void UpdateCellPopulation();
00244
00257 virtual void UpdateCellLocationsAndTopology()=0;
00258
00262 void OutputSimulationSetup();
00263
00270 virtual void OutputAdditionalSimulationSetup(out_stream& rParamsFile)
00271 {
00272 }
00273
00274 public:
00275
00284 AbstractCellBasedSimulation(AbstractCellPopulation<ELEMENT_DIM,SPACE_DIM>& rCellPopulation,
00285 bool deleteCellPopulationInDestructor=false,
00286 bool initialiseCells=true);
00287
00293 virtual ~AbstractCellBasedSimulation();
00294
00300 void SetCellBasedPdeHandler(CellBasedPdeHandler<SPACE_DIM>* pCellBasedPdeHandler);
00301
00305 CellBasedPdeHandler<SPACE_DIM>* GetCellBasedPdeHandler();
00306
00313 std::vector<double> GetNodeLocation(const unsigned& rNodeIndex);
00314
00318 double GetDt();
00319
00323 unsigned GetNumBirths();
00324
00328 unsigned GetNumDeaths();
00329
00333 std::string GetOutputDirectory();
00334
00340 void SetDt(double dt);
00341
00347 void SetEndTime(double endTime);
00348
00354 void SetOutputDirectory(std::string outputDirectory);
00355
00362 void SetSamplingTimestepMultiple(unsigned samplingTimestepMultiple);
00363
00369 void SetNoBirth(bool noBirth);
00370
00376 void SetUpdateCellPopulationRule(bool updateCellPopulation);
00377
00383 bool GetUpdateCellPopulationRule();
00384
00390 void AddCellKiller(boost::shared_ptr<AbstractCellKiller<SPACE_DIM> > pCellKiller);
00391
00395 void RemoveAllCellKillers();
00396
00402 void AddSimulationModifier(boost::shared_ptr<AbstractCellBasedSimulationModifier<ELEMENT_DIM,SPACE_DIM> > pSimulationModifier);
00403
00407 std::vector<boost::shared_ptr<AbstractCellBasedSimulationModifier<ELEMENT_DIM, SPACE_DIM> > >* GetSimulationModifiers();
00408
00463 void Solve();
00464
00468 AbstractCellPopulation<ELEMENT_DIM,SPACE_DIM>& rGetCellPopulation();
00469
00473 const AbstractCellPopulation<ELEMENT_DIM,SPACE_DIM>& rGetCellPopulation() const;
00474
00478 bool GetOutputDivisionLocations();
00479
00485 void SetOutputDivisionLocations(bool outputDivisionLocations);
00486
00490 bool GetOutputCellVelocities();
00491
00497 void SetOutputCellVelocities(bool outputCellVelocities);
00498
00507 virtual void OutputSimulationParameters(out_stream& rParamsFile)=0;
00508 };
00509
00510 #endif