VertexBasedCellPopulation.hpp

00001 /*
00002 
00003 Copyright (c) 2005-2015, 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 template<unsigned DIM> class AbstractVertexBasedDivisionRule; // Circular definition thing.
00049 
00057 template<unsigned DIM>
00058 class VertexBasedCellPopulation : public AbstractOffLatticeCellPopulation<DIM>
00059 {
00060 private:
00061 
00065     friend class TestVertexBasedDivisionRules;
00066 
00071     bool mDeleteMesh;
00072 
00077     MutableVertexMesh<DIM, DIM>* mpMutableVertexMesh;
00078 
00080     bool mOutputCellRearrangementLocations;
00081 
00084     boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > mpVertexBasedDivisionRule;
00085 
00090     std::vector< c_vector<double, DIM> > mLocationsOfT2Swaps;
00091 
00096     std::vector< unsigned > mCellIdsOfT2Swaps;
00097 
00103     virtual void WriteVtkResultsToFile(const std::string& rDirectory);
00104 
00105     friend class boost::serialization::access;
00117     template<class Archive>
00118     void serialize(Archive & archive, const unsigned int version)
00119     {
00120         archive & boost::serialization::base_object<AbstractOffLatticeCellPopulation<DIM> >(*this);
00121         archive & mOutputCellRearrangementLocations;
00122         archive & mpVertexBasedDivisionRule;
00123     }
00124 
00129     void Validate();
00130 
00131 public:
00132 
00145     VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh,
00146                               std::vector<CellPtr>& rCells,
00147                               bool deleteMesh=false,
00148                               bool validate=true,
00149                               const std::vector<unsigned> locationIndices=std::vector<unsigned>());
00150 
00156     VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh);
00157 
00161     virtual ~VertexBasedCellPopulation();
00162 
00169     double GetDampingConstant(unsigned nodeIndex);
00170 
00174     MutableVertexMesh<DIM, DIM>& rGetMesh();
00175 
00179     const MutableVertexMesh<DIM, DIM>& rGetMesh() const;
00180 
00188     VertexElement<DIM, DIM>* GetElement(unsigned elementIndex);
00189 
00193     unsigned GetNumElements();
00194 
00200     unsigned GetNumNodes();
00201 
00213     c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
00214 
00222     Node<DIM>* GetNode(unsigned index);
00223 
00232     std::set<unsigned> GetNeighbouringLocationIndices(CellPtr pCell);
00233 
00242     unsigned AddNode(Node<DIM>* pNewNode);
00243 
00249     void UpdateNodeLocations(double dt);
00250 
00259     void SetNode(unsigned index, ChastePoint<DIM>& rNewLocation);
00260 
00268     VertexElement<DIM, DIM>* GetElementCorrespondingToCell(CellPtr pCell);
00269 
00281     CellPtr AddCell(CellPtr pNewCell,
00282                     const c_vector<double,DIM>& rCellDivisionVector,
00283                     CellPtr pParentCell=CellPtr());
00284 
00294     unsigned RemoveDeadCells();
00295 
00302     bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
00303 
00312     void Update(bool hasHadBirthsOrDeaths=true);
00313 
00321     virtual void OpenWritersFiles(OutputFileHandler& rOutputFileHandler);
00322 
00329     virtual void AcceptPopulationWriter(boost::shared_ptr<AbstractCellPopulationWriter<DIM, DIM> > pPopulationWriter);
00330 
00337     virtual void AcceptPopulationCountWriter(boost::shared_ptr<AbstractCellPopulationCountWriter<DIM, DIM> > pPopulationCountWriter);
00338 
00346     virtual void AcceptCellWriter(boost::shared_ptr<AbstractCellWriter<DIM, DIM> > pCellWriter, CellPtr pCell);
00347 
00354     double GetVolumeOfCell(CellPtr pCell);
00355 
00361     std::vector< c_vector< double, DIM > > GetLocationsOfT2Swaps();
00362 
00368     std::vector< unsigned > GetCellIdsOfT2Swaps();
00369 
00375     void AddLocationOfT2Swap(c_vector< double, DIM> locationOfT2Swap);
00376 
00382     void AddCellIdOfT2Swap(unsigned idOfT2Swap);
00383 
00387     void ClearLocationsAndCellIdsOfT2Swaps();
00388 
00392     bool GetOutputCellRearrangementLocations();
00393 
00399     void SetOutputCellRearrangementLocations(bool outputCellRearrangementLocations);
00400 
00406     void OutputCellPopulationParameters(out_stream& rParamsFile);
00407 
00417     double GetWidth(const unsigned& rDimension);
00418 
00425     std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
00426 
00432     TetrahedralMesh<DIM, DIM>* GetTetrahedralMeshUsingVertexMesh();
00433 
00437     boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > GetVertexBasedDivisionRule();
00438 
00444     void SetVertexBasedDivisionRule(boost::shared_ptr<AbstractVertexBasedDivisionRule<DIM> > pVertexBasedDivisionRule);
00445 };
00446 
00447 #include "SerializationExportWrapper.hpp"
00448 EXPORT_TEMPLATE_CLASS_SAME_DIMS(VertexBasedCellPopulation)
00449 
00450 namespace boost
00451 {
00452 namespace serialization
00453 {
00457 template<class Archive, unsigned DIM>
00458 inline void save_construct_data(
00459     Archive & ar, const VertexBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00460 {
00461     // Save data required to construct instance
00462     const MutableVertexMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
00463     ar & p_mesh;
00464 }
00465 
00470 template<class Archive, unsigned DIM>
00471 inline void load_construct_data(
00472     Archive & ar, VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
00473 {
00474     // Retrieve data from archive required to construct new instance
00475     MutableVertexMesh<DIM,DIM>* p_mesh;
00476     ar >> p_mesh;
00477 
00478     // Invoke inplace constructor to initialise instance
00479     ::new(t)VertexBasedCellPopulation<DIM>(*p_mesh);
00480 }
00481 }
00482 } // namespace ...
00483 
00484 #endif /*VERTEXBASEDCELLPOPULATION_HPP_*/
00485 

Generated by  doxygen 1.6.2