CaBasedCellPopulation.hpp

00001 /*
00002 
00003 Copyright (c) 2005-2014, 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 CABASEDCELLPOPULATION_HPP_
00037 #define CABASEDCELLPOPULATION_HPP_
00038 
00039 #include "AbstractOnLatticeCellPopulation.hpp"
00040 #include "PottsMesh.hpp"
00041 #include "VertexMesh.hpp"
00042 #include "AbstractCaUpdateRule.hpp"
00043 
00044 #include "ChasteSerialization.hpp"
00045 #include <boost/serialization/base_object.hpp>
00046 #include <boost/serialization/vector.hpp>
00047 
00048 // Needed here to avoid serialization errors (on Boost<1.37)
00049 #include "WildTypeCellMutationState.hpp"
00050 
00051 template<unsigned DIM>
00052 class AbstractCaUpdateRule; // Circular definition
00053 
00067 template<unsigned DIM>
00068 class CaBasedCellPopulation : public AbstractOnLatticeCellPopulation<DIM>
00069 {
00070     friend class TestCaBasedCellPopulation;
00071 
00072 private:
00073 
00075     unsigned mLatticeCarryingCapacity;
00076 
00078     std::vector<boost::shared_ptr<AbstractCaUpdateRule<DIM> > > mUpdateRuleCollection;
00079 
00081     std::vector<unsigned> mAvailableSpaces;
00082 
00088     void SetEmptySites(const std::set<unsigned>& rEmptySiteIndices);
00089 
00090     friend class boost::serialization::access;
00102     template<class Archive>
00103     void serialize(Archive & archive, const unsigned int version)
00104     {
00105 #define COVERAGE_IGNORE
00106         archive & boost::serialization::base_object<AbstractOnLatticeCellPopulation<DIM> >(*this);
00107         archive & mLatticeCarryingCapacity;
00108         archive & mUpdateRuleCollection;
00109         archive & mAvailableSpaces;
00110 #undef COVERAGE_IGNORE
00111     }
00112 
00118     void Validate();
00119 
00120 
00128     virtual void WriteVtkResultsToFile(const std::string& rDirectory);
00129 
00130 public:
00131 
00146     CaBasedCellPopulation(PottsMesh<DIM>& rMesh,
00147                                   std::vector<CellPtr>& rCells,
00148                                   const std::vector<unsigned> locationIndices,
00149                                   unsigned latticeCarryingCapacity=1u,
00150                                   bool deleteMesh=false,
00151                                   bool validate=false);
00152 
00158     CaBasedCellPopulation(PottsMesh<DIM>& rMesh);
00159 
00163     virtual ~CaBasedCellPopulation();
00164 
00168     std::vector<unsigned>& rGetAvailableSpaces();
00169 
00178     virtual bool IsSiteAvailable(unsigned index, CellPtr pCell);
00179 
00183     PottsMesh<DIM>& rGetMesh();
00184 
00188     const PottsMesh<DIM>& rGetMesh() const;
00189 
00197     Node<DIM>* GetNode(unsigned index);
00198 
00204     unsigned GetNumNodes();
00205 
00214     c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
00215 
00223     void AddCellUsingLocationIndex(unsigned index, CellPtr pCell);
00224 
00232     void RemoveCellUsingLocationIndex(unsigned index, CellPtr pCell);
00233 
00241      Node<DIM>* GetNodeCorrespondingToCell(CellPtr pCell);
00242 
00253     CellPtr AddCell(CellPtr pNewCell, const c_vector<double,DIM>& rCellDivisionVector, CellPtr pParentCell=CellPtr());
00254 
00264      double virtual EvaluateDivisionPropensity(unsigned currentNodeIndex,
00265                                         unsigned targetNodeIndex,
00266                                         CellPtr pCell);
00276     unsigned RemoveDeadCells();
00277 
00285     virtual void OpenWritersFiles(const std::string& rDirectory);
00286 
00292     void UpdateCellLocations(double dt);
00293 
00300     bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
00301 
00309     void Update(bool hasHadBirthsOrDeaths=true);
00310 
00317     virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
00318 
00326     virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
00327 
00334     double GetVolumeOfCell(CellPtr pCell);
00335 
00347     double GetWidth(const unsigned& rDimension);
00348 
00354     void AddUpdateRule(boost::shared_ptr<AbstractCaUpdateRule<DIM> > pUpdateRule);
00355 
00359     void RemoveAllUpdateRules();
00360 
00366     const std::vector<boost::shared_ptr<AbstractCaUpdateRule<DIM> > >& rGetUpdateRuleCollection() const;
00367 
00376     void OutputCellPopulationParameters(out_stream& rParamsFile);
00377 
00386     bool IsRoomToDivide(CellPtr pCell);
00387 };
00388 
00389 #include "SerializationExportWrapper.hpp"
00390 EXPORT_TEMPLATE_CLASS_SAME_DIMS(CaBasedCellPopulation)
00391 
00392 // No archiving yet so untested
00393 #define COVERAGE_IGNORE
00394 namespace boost
00395 {
00396 namespace serialization
00397 {
00401 template<class Archive, unsigned DIM>
00402 inline void save_construct_data(
00403     Archive & ar, const CaBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00404 {
00405     // Save data required to construct instance
00406     const PottsMesh<DIM>* p_mesh = &(t->rGetMesh());
00407     ar & p_mesh;
00408 }
00409 
00414 template<class Archive, unsigned DIM>
00415 inline void load_construct_data(
00416     Archive & ar, CaBasedCellPopulation<DIM> * t, const unsigned int file_version)
00417 {
00418     // Retrieve data from archive required to construct new instance
00419     PottsMesh<DIM>* p_mesh;
00420     ar >> p_mesh;
00421 
00422     // Invoke inplace constructor to initialise instance
00423     ::new(t)CaBasedCellPopulation<DIM>(*p_mesh);
00424 }
00425 }
00426 } // namespace ...
00427 #undef COVERAGE_IGNORE
00428 
00429 #endif /*CABASEDCELLPOPULATION_HPP_*/

Generated by  doxygen 1.6.2