Chaste Release::3.1
|
00001 /* 00002 00003 Copyright (c) 2005-2012, University of Oxford. 00004 All rights reserved. 00005 00006 University of Oxford means the Chancellor, Masters and Scholars of the 00007 University of Oxford, having an administrative office at Wellington 00008 Square, Oxford OX1 2JD, UK. 00009 00010 This file is part of Chaste. 00011 00012 Redistribution and use in source and binary forms, with or without 00013 modification, are permitted provided that the following conditions are met: 00014 * Redistributions of source code must retain the above copyright notice, 00015 this list of conditions and the following disclaimer. 00016 * Redistributions in binary form must reproduce the above copyright notice, 00017 this list of conditions and the following disclaimer in the documentation 00018 and/or other materials provided with the distribution. 00019 * Neither the name of the University of Oxford nor the names of its 00020 contributors may be used to endorse or promote products derived from this 00021 software without specific prior written permission. 00022 00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 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 "RandomNumberGenerator.hpp" 00048 00063 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM=ELEMENT_DIM> 00064 class AbstractCellBasedSimulation : public Identifiable 00065 { 00066 // Allow tests to access private members, in order to test computation of private functions e.g. DoCellBirth() 00067 friend class TestCryptSimulation2d; 00068 friend class TestOffLatticeSimulation3d; 00069 friend class TestOffLatticeSimulation; 00070 00071 private: 00072 00074 friend class boost::serialization::access; 00075 00082 template<class Archive> 00083 void serialize(Archive & archive, const unsigned int version) 00084 { 00085 SerializableSingleton<SimulationTime>* p_time_wrapper = SimulationTime::Instance()->GetSerializationWrapper(); 00086 archive & p_time_wrapper; 00087 00088 SerializableSingleton<RandomNumberGenerator>* p_rng_wrapper = RandomNumberGenerator::Instance()->GetSerializationWrapper(); 00089 archive & p_rng_wrapper; 00090 00091 archive & mDt; 00092 archive & mEndTime; 00093 archive & mNoBirth; 00094 archive & mUpdateCellPopulation; 00095 archive & mOutputDirectory; 00096 archive & mNumBirths; 00097 archive & mNumDeaths; 00098 archive & mCellKillers; 00099 archive & mSamplingTimestepMultiple; 00100 archive & mpCellBasedPdeHandler; 00101 } 00102 00103 protected: 00104 00106 double mDt; 00107 00109 double mEndTime; 00110 00112 AbstractCellPopulation<ELEMENT_DIM, SPACE_DIM>& mrCellPopulation; 00113 00115 bool mDeleteCellPopulationInDestructor; 00116 00118 bool mInitialiseCells; 00119 00121 bool mNoBirth; 00122 00124 bool mUpdateCellPopulation; 00125 00127 std::string mOutputDirectory; 00128 00130 std::string mSimulationOutputDirectory; 00131 00133 out_stream mpVizSetupFile; 00134 00136 unsigned mNumBirths; 00137 00139 unsigned mNumDeaths; 00140 00142 bool mOutputDivisionLocations; 00143 00145 out_stream mpDivisionLocationFile; 00146 00148 std::vector<boost::shared_ptr<AbstractCellKiller<SPACE_DIM> > > mCellKillers; 00149 00154 unsigned mSamplingTimestepMultiple; 00155 00159 CellBasedPdeHandler<SPACE_DIM>* mpCellBasedPdeHandler; 00160 00164 virtual void WriteVisualizerSetupFile() 00165 { 00166 } 00167 00175 virtual unsigned DoCellBirth(); 00176 00188 virtual c_vector<double, SPACE_DIM> CalculateCellDivisionVector(CellPtr pParentCell)=0; 00189 00198 unsigned DoCellRemoval(); 00199 00203 virtual void UpdateAtEndOfTimeStep() 00204 { 00205 } 00206 00210 virtual void SetupSolve() 00211 { 00212 } 00213 00218 virtual void UpdateAtEndOfSolve() 00219 { 00220 } 00221 00227 virtual bool StoppingEventHasOccurred(); 00228 00232 virtual void UpdateCellPopulation(); 00233 00239 virtual void UpdateCellLocationsAndTopology()=0; 00240 00244 void OutputSimulationSetup(); 00245 00252 virtual void OutputAdditionalSimulationSetup(out_stream& rParamsFile) 00253 { 00254 } 00255 00256 public: 00257 00266 AbstractCellBasedSimulation(AbstractCellPopulation<ELEMENT_DIM,SPACE_DIM>& rCellPopulation, 00267 bool deleteCellPopulationInDestructor=false, 00268 bool initialiseCells=true); 00269 00275 virtual ~AbstractCellBasedSimulation(); 00276 00282 void SetCellBasedPdeHandler(CellBasedPdeHandler<SPACE_DIM>* pCellBasedPdeHandler); 00283 00287 CellBasedPdeHandler<SPACE_DIM>* GetCellBasedPdeHandler(); 00288 00295 std::vector<double> GetNodeLocation(const unsigned& rNodeIndex); 00296 00300 double GetDt(); 00301 00305 unsigned GetNumBirths(); 00306 00310 unsigned GetNumDeaths(); 00311 00315 std::string GetOutputDirectory(); 00316 00322 void SetDt(double dt); 00323 00329 void SetEndTime(double endTime); 00330 00336 void SetOutputDirectory(std::string outputDirectory); 00337 00344 void SetSamplingTimestepMultiple(unsigned samplingTimestepMultiple); 00345 00351 void SetNoBirth(bool noBirth); 00352 00358 void SetUpdateCellPopulationRule(bool updateCellPopulation); 00359 00365 void AddCellKiller(boost::shared_ptr<AbstractCellKiller<SPACE_DIM> > pCellKiller); 00366 00370 void RemoveAllCellKillers(); 00371 00382 void Solve(); 00383 00387 AbstractCellPopulation<ELEMENT_DIM,SPACE_DIM>& rGetCellPopulation(); 00388 00392 const AbstractCellPopulation<ELEMENT_DIM,SPACE_DIM>& rGetCellPopulation() const; 00393 00397 bool GetOutputDivisionLocations(); 00398 00404 void SetOutputDivisionLocations(bool outputDivisionLocations); 00405 00414 virtual void OutputSimulationParameters(out_stream& rParamsFile)=0; 00415 }; 00416 00417 #endif /*ABSTRACTCELLBASEDSIMULATION_HPP_*/