NodeBasedCellPopulation.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 NODEBASEDCELLPOPULATION_HPP_
00030 #define NODEBASEDCELLPOPULATION_HPP_
00031 
00032 #include "AbstractCentreBasedCellPopulation.hpp"
00033 #include "NodesOnlyMesh.hpp"
00034 #include "BoxCollection.hpp"
00035 
00036 #include "ChasteSerialization.hpp"
00037 #include <boost/serialization/base_object.hpp>
00038 
00043 template<unsigned DIM>
00044 class NodeBasedCellPopulation : public AbstractCentreBasedCellPopulation<DIM>
00045 {
00046     friend class TestNodeBasedCellPopulation;
00047     friend class TestBoxCollection;
00048 
00049 protected:
00050 
00052     NodesOnlyMesh<DIM>& mrMesh;
00053 
00054 private:
00055 
00057     BoxCollection<DIM>* mpBoxCollection;
00058 
00060     c_vector<double, DIM> mMinSpatialPositions;
00061 
00063     c_vector<double, DIM> mMaxSpatialPositions;
00064 
00066     std::set< std::pair<Node<DIM>*, Node<DIM>* > > mNodePairs;
00067 
00069     bool mDeleteMesh;
00070 
00075     double mMechanicsCutOffLength;
00076 
00078     friend class boost::serialization::access;
00088     template<class Archive>
00089     void serialize(Archive & archive, const unsigned int version)
00090     {
00091         archive & boost::serialization::base_object<AbstractCentreBasedCellPopulation<DIM> >(*this);
00092         archive & mMechanicsCutOffLength;
00093 
00094         this->Validate();
00095     }
00096 
00105     unsigned AddNode(Node<DIM>* pNewNode);
00106 
00107 
00108 protected:
00115     void SetNode(unsigned nodeIndex, ChastePoint<DIM>& rNewLocation);
00116 
00117 private:
00121     void Validate();
00122 
00129     void SplitUpIntoBoxes(double cutOffLength, c_vector<double, 2*DIM> domainSize);
00130 
00134     void FindMaxAndMin();
00135 
00139     void WriteCellVolumeResultsToFile();
00140 
00144     void WriteVtkResultsToFile();
00145 
00146 public:
00147 
00158     NodeBasedCellPopulation(NodesOnlyMesh<DIM>& rMesh,
00159                             std::vector<CellPtr>& rCells,
00160                             const std::vector<unsigned> locationIndices=std::vector<unsigned>(),
00161                             bool deleteMesh=false);
00162 
00168     NodeBasedCellPopulation(NodesOnlyMesh<DIM>& rMesh);
00169 
00175     ~NodeBasedCellPopulation();
00176 
00180     NodesOnlyMesh<DIM>& rGetMesh();
00181 
00185     const NodesOnlyMesh<DIM>& rGetMesh() const;
00186 
00190     unsigned GetNumNodes();
00191 
00199     Node<DIM>* GetNode(unsigned index);
00200 
00210     unsigned RemoveDeadCells();
00211 
00215     void Clear();
00216 
00222     void Update(bool hasHadBirthsOrDeaths=true);
00223 
00227     BoxCollection<DIM>* GetBoxCollection();
00228 
00232     std::set< std::pair<Node<DIM>*, Node<DIM>* > >& rGetNodePairs();
00233 
00242     void OutputCellPopulationParameters(out_stream& rParamsFile);
00243 
00247     double GetMechanicsCutOffLength();
00248 
00254     void SetMechanicsCutOffLength(double mechanicsCutOffLength);
00255 
00265     double GetWidth(const unsigned& rDimension);
00266 
00273     std::set<unsigned> GetNeighbouringNodeIndices(unsigned index);
00274 
00287     virtual CellPtr AddCell(CellPtr pNewCell, const c_vector<double,DIM>& rCellDivisionVector, CellPtr pParentCell=CellPtr());
00288 };
00289 
00290 #include "SerializationExportWrapper.hpp"
00291 EXPORT_TEMPLATE_CLASS_SAME_DIMS(NodeBasedCellPopulation)
00292 
00293 namespace boost
00294 {
00295 namespace serialization
00296 {
00300 template<class Archive, unsigned DIM>
00301 inline void save_construct_data(
00302     Archive & ar, const NodeBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00303 {
00304     // Save data required to construct instance
00305     const NodesOnlyMesh<DIM>* p_mesh = &(t->rGetMesh());
00306     ar & p_mesh;
00307 }
00308 
00313 template<class Archive, unsigned DIM>
00314 inline void load_construct_data(
00315     Archive & ar, NodeBasedCellPopulation<DIM> * t, const unsigned int file_version)
00316 {
00317     // Retrieve data from archive required to construct new instance
00318     NodesOnlyMesh<DIM>* p_mesh;
00319     ar >> p_mesh;
00320 
00321     // Invoke inplace constructor to initialise instance
00322     ::new(t)NodeBasedCellPopulation<DIM>(*p_mesh);
00323 }
00324 }
00325 } // namespace ...
00326 
00327 #endif /*NODEBASEDCELLPOPULATION_HPP_*/
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3