VertexBasedCellPopulation.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 VERTEXBASEDCELLPOPULATION_HPP_
00037 #define VERTEXBASEDCELLPOPULATION_HPP_
00038 
00039 #include "AbstractOffLatticeCellPopulation.hpp"
00040 #include "MutableVertexMesh.hpp"
00041 #include "AbstractVertexBasedDivisionRule.hpp"
00042 
00043 #include "ChasteSerialization.hpp"
00044 #include <boost/serialization/base_object.hpp>
00045 #include <boost/serialization/set.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> class AbstractVertexBasedDivisionRule; // Circular definition thing.
00052 
00060 template<unsigned DIM>
00061 class VertexBasedCellPopulation : public AbstractOffLatticeCellPopulation<DIM>
00062 {
00063 private:
00064 
00068     friend class TestVertexBasedDivisionRules;
00069 
00074     bool mDeleteMesh;
00075 
00080     MutableVertexMesh<DIM, DIM>* mpMutableVertexMesh;
00081 
00083     bool mOutputCellRearrangementLocations;
00084 
00087     boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > mpVertexBasedDivisionRule;
00088 
00094     virtual void WriteVtkResultsToFile(const std::string& rDirectory);
00095 
00096     friend class boost::serialization::access;
00108     template<class Archive>
00109     void serialize(Archive & archive, const unsigned int version)
00110     {
00111         archive & boost::serialization::base_object<AbstractOffLatticeCellPopulation<DIM> >(*this);
00112         archive & mOutputCellRearrangementLocations;
00113         archive & mpVertexBasedDivisionRule;
00114     }
00115 
00120     void Validate();
00121 
00122 public:
00123 
00136     VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh,
00137                               std::vector<CellPtr>& rCells,
00138                               bool deleteMesh=false,
00139                               bool validate=true,
00140                               const std::vector<unsigned> locationIndices=std::vector<unsigned>());
00141 
00147     VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh);
00148 
00152     virtual ~VertexBasedCellPopulation();
00153 
00160     double GetDampingConstant(unsigned nodeIndex);
00161 
00165     MutableVertexMesh<DIM, DIM>& rGetMesh();
00166 
00170     const MutableVertexMesh<DIM, DIM>& rGetMesh() const;
00171 
00179     VertexElement<DIM, DIM>* GetElement(unsigned elementIndex);
00180 
00184     unsigned GetNumElements();
00185 
00191     unsigned GetNumNodes();
00192 
00204     c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
00205 
00213     Node<DIM>* GetNode(unsigned index);
00214 
00223     unsigned AddNode(Node<DIM>* pNewNode);
00224 
00230     void UpdateNodeLocations(double dt);
00231 
00240     void SetNode(unsigned index, ChastePoint<DIM>& rNewLocation);
00241 
00249     VertexElement<DIM, DIM>* GetElementCorrespondingToCell(CellPtr pCell);
00250 
00262     CellPtr AddCell(CellPtr pNewCell,
00263                     const c_vector<double,DIM>& rCellDivisionVector,
00264                     CellPtr pParentCell=CellPtr());
00265 
00275     unsigned RemoveDeadCells();
00276 
00283     bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
00284 
00293     void Update(bool hasHadBirthsOrDeaths=true);
00294 
00302     virtual void OpenWritersFiles(const std::string& rDirectory);
00303 
00310     virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
00311 
00319     virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
00320 
00327     double GetVolumeOfCell(CellPtr pCell);
00328 
00332     bool GetOutputCellRearrangementLocations();
00333 
00339     void SetOutputCellRearrangementLocations(bool outputCellRearrangementLocations);
00340 
00346     void OutputCellPopulationParameters(out_stream& rParamsFile);
00347 
00357     double GetWidth(const unsigned& rDimension);
00358 
00365     std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
00366 
00372     TetrahedralMesh<DIM, DIM>* GetTetrahedralMeshUsingVertexMesh();
00373 
00377     boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > GetVertexBasedDivisionRule();
00378 
00384     void SetVertexBasedDivisionRule(boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > pVertexBasedDivisionRule);
00385 };
00386 
00387 #include "SerializationExportWrapper.hpp"
00388 EXPORT_TEMPLATE_CLASS_SAME_DIMS(VertexBasedCellPopulation)
00389 
00390 namespace boost
00391 {
00392 namespace serialization
00393 {
00397 template<class Archive, unsigned DIM>
00398 inline void save_construct_data(
00399     Archive & ar, const VertexBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00400 {
00401     // Save data required to construct instance
00402     const MutableVertexMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
00403     ar & p_mesh;
00404 }
00405 
00410 template<class Archive, unsigned DIM>
00411 inline void load_construct_data(
00412     Archive & ar, VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
00413 {
00414     // Retrieve data from archive required to construct new instance
00415     MutableVertexMesh<DIM,DIM>* p_mesh;
00416     ar >> p_mesh;
00417 
00418     // Invoke inplace constructor to initialise instance
00419     ::new(t)VertexBasedCellPopulation<DIM>(*p_mesh);
00420 }
00421 }
00422 } // namespace ...
00423 
00424 #endif /*VERTEXBASEDCELLPOPULATION_HPP_*/
00425 

Generated by  doxygen 1.6.2