VertexBasedCellPopulation.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 #ifndef VERTEXBASEDCELLPOPULATION_HPP_
00030 #define VERTEXBASEDCELLPOPULATION_HPP_
00031 
00032 #include "AbstractOffLatticeCellPopulation.hpp"
00033 #include "MutableVertexMesh.hpp"
00034 
00035 #include "ChasteSerialization.hpp"
00036 #include <boost/serialization/base_object.hpp>
00037 #include <boost/serialization/set.hpp>
00038 #include <boost/serialization/vector.hpp>
00039 
00040 // Needed here to avoid serialization errors (on Boost<1.37)
00041 #include "WildTypeCellMutationState.hpp"
00042 
00050 template<unsigned DIM>
00051 class VertexBasedCellPopulation : public AbstractOffLatticeCellPopulation<DIM>
00052 {
00053 private:
00054 
00056     MutableVertexMesh<DIM, DIM>& mrMesh;
00057 
00062     bool mDeleteMesh;
00063 
00065     out_stream mpVizElementsFile;
00066 
00068     out_stream mpT1SwapLocationsFile;
00069 
00071     out_stream mpT3SwapLocationsFile;
00072 
00076     void WriteVtkResultsToFile();
00077 
00078     friend class boost::serialization::access;
00090     template<class Archive>
00091     void serialize(Archive & archive, const unsigned int version)
00092     {
00093         archive & boost::serialization::base_object<AbstractOffLatticeCellPopulation<DIM> >(*this);
00094     }
00095 
00100     void Validate();
00101 
00102 public:
00103 
00116     VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh,
00117                       std::vector<CellPtr>& rCells,
00118                       bool deleteMesh=false,
00119                       bool validate=true,
00120                       const std::vector<unsigned> locationIndices=std::vector<unsigned>());
00121 
00127     VertexBasedCellPopulation(MutableVertexMesh<DIM, DIM>& rMesh);
00128 
00132     virtual ~VertexBasedCellPopulation();
00133 
00140     double GetDampingConstant(unsigned nodeIndex);
00141 
00145     MutableVertexMesh<DIM, DIM>& rGetMesh();
00146 
00150     const MutableVertexMesh<DIM, DIM>& rGetMesh() const;
00151 
00159     VertexElement<DIM, DIM>* GetElement(unsigned elementIndex);
00160 
00164     unsigned GetNumElements();
00165 
00171     unsigned GetNumNodes();
00172 
00184     c_vector<double, DIM> GetLocationOfCellCentre(CellPtr pCell);
00185 
00193     Node<DIM>* GetNode(unsigned index);
00194 
00203     unsigned AddNode(Node<DIM>* pNewNode);
00204 
00211     void UpdateNodeLocations(const std::vector< c_vector<double, DIM> >& rNodeForces, double dt);
00212 
00221     void SetNode(unsigned index, ChastePoint<DIM>& rNewLocation);
00222 
00230     VertexElement<DIM, DIM>* GetElementCorrespondingToCell(CellPtr pCell);
00231 
00243     CellPtr AddCell(CellPtr pNewCell, const c_vector<double,DIM>& rCellDivisionVector, CellPtr pParentCell=CellPtr());
00244 
00254     unsigned RemoveDeadCells();
00255 
00262     bool IsCellAssociatedWithADeletedLocation(CellPtr pCell);
00263 
00272     void Update(bool hasHadBirthsOrDeaths=true);
00273 
00280     void CreateOutputFiles(const std::string& rDirectory, bool cleanOutputDirectory);
00284     void CloseOutputFiles();
00285 
00289     void WriteResultsToFiles();
00290 
00295     void WriteCellVolumeResultsToFile();
00296 
00300     virtual void GenerateCellResultsAndWriteToFiles();
00301 
00310     void OutputCellPopulationParameters(out_stream& rParamsFile);
00311 
00321     double GetWidth(const unsigned& rDimension);
00322 
00329     std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
00330 };
00331 
00332 #include "SerializationExportWrapper.hpp"
00333 EXPORT_TEMPLATE_CLASS_SAME_DIMS(VertexBasedCellPopulation)
00334 
00335 namespace boost
00336 {
00337 namespace serialization
00338 {
00342 template<class Archive, unsigned DIM>
00343 inline void save_construct_data(
00344     Archive & ar, const VertexBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00345 {
00346     // Save data required to construct instance
00347     const MutableVertexMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
00348     ar & p_mesh;
00349 }
00350 
00355 template<class Archive, unsigned DIM>
00356 inline void load_construct_data(
00357     Archive & ar, VertexBasedCellPopulation<DIM> * t, const unsigned int file_version)
00358 {
00359     // Retrieve data from archive required to construct new instance
00360     MutableVertexMesh<DIM,DIM>* p_mesh;
00361     ar >> p_mesh;
00362 
00363     // Invoke inplace constructor to initialise instance
00364     ::new(t)VertexBasedCellPopulation<DIM>(*p_mesh);
00365 }
00366 }
00367 } // namespace ...
00368 
00369 #endif /*VERTEXBASEDCELLPOPULATION_HPP_*/
00370 
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3