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 #ifndef NODEBASEDCELLPOPULATION_HPP_
00029 #define NODEBASEDCELLPOPULATION_HPP_
00030 
00031 #include "AbstractCentreBasedCellPopulation.hpp"
00032 #include "NodesOnlyMesh.hpp"
00033 #include "BoxCollection.hpp"
00034 
00035 #include "ArchiveLocationInfo.hpp"
00036 
00037 #include "ChasteSerialization.hpp"
00038 #include <boost/serialization/base_object.hpp>
00039 #include <boost/serialization/set.hpp>
00040 #include <boost/serialization/vector.hpp>
00041 
00046 template<unsigned DIM>
00047 class NodeBasedCellPopulation : public AbstractCentreBasedCellPopulation<DIM>
00048 {
00049     friend class TestNodeBasedCellPopulation;
00050     friend class TestBoxCollection;
00051 
00052 protected:
00053 
00055     NodesOnlyMesh<DIM>& mrMesh;
00056 
00057 private:
00058 
00060     BoxCollection<DIM>* mpBoxCollection;
00061 
00063     c_vector<double, DIM> mMinSpatialPositions;
00064 
00066     c_vector<double, DIM> mMaxSpatialPositions;
00067 
00069     std::set< std::pair<Node<DIM>*, Node<DIM>* > > mNodePairs;
00070 
00072     bool mDeleteMesh;
00073 
00078     double mMechanicsCutOffLength;
00079 
00081     friend class boost::serialization::access;
00091     template<class Archive>
00092     void serialize(Archive & archive, const unsigned int version)
00093     {
00094         archive & boost::serialization::base_object<AbstractCentreBasedCellPopulation<DIM> >(*this);
00095         archive & mMechanicsCutOffLength;
00096 
00097         this->Validate();
00098     }
00099 
00108     unsigned AddNode(Node<DIM>* pNewNode);
00109 
00116     void SetNode(unsigned nodeIndex, ChastePoint<DIM>& rNewLocation);
00117 
00121     void Validate();
00122 
00129     void SplitUpIntoBoxes(double cutOffLength, c_vector<double, 2*DIM> domainSize);
00130 
00134     void FindMaxAndMin();
00135 
00139     void WriteVtkResultsToFile();
00140 
00141 public:
00142 
00153     NodeBasedCellPopulation(NodesOnlyMesh<DIM>& rMesh,
00154                             std::vector<CellPtr>& rCells,
00155                             const std::vector<unsigned> locationIndices=std::vector<unsigned>(),
00156                             bool deleteMesh=false);
00157 
00163     NodeBasedCellPopulation(NodesOnlyMesh<DIM>& rMesh);
00164 
00170     ~NodeBasedCellPopulation();
00171 
00175     NodesOnlyMesh<DIM>& rGetMesh();
00176 
00180     const NodesOnlyMesh<DIM>& rGetMesh() const;
00181 
00185     unsigned GetNumNodes();
00186 
00194     Node<DIM>* GetNode(unsigned index);
00195 
00205     unsigned RemoveDeadCells();
00206 
00210     void Clear();
00211 
00217     void Update(bool hasHadBirthsOrDeaths=true);
00218 
00224     std::vector<Node<DIM>*>& rGetNodes();
00225 
00229     BoxCollection<DIM>* GetBoxCollection();
00230 
00234     std::set< std::pair<Node<DIM>*, Node<DIM>* > >& rGetNodePairs();
00235 
00244     void OutputCellPopulationParameters(out_stream& rParamsFile);
00245 
00249     double GetMechanicsCutOffLength();
00250 
00256     void SetMechanicsCutOffLength(double mechanicsCutOffLength);
00257 
00267     double GetWidth(const unsigned& rDimension);
00268 
00278     void SetOutputCellVolumes(bool outputCellVolumes);
00279 };
00280 
00281 #include "SerializationExportWrapper.hpp"
00282 EXPORT_TEMPLATE_CLASS_SAME_DIMS(NodeBasedCellPopulation)
00283 
00284 namespace boost
00285 {
00286 namespace serialization
00287 {
00291 template<class Archive, unsigned DIM>
00292 inline void save_construct_data(
00293     Archive & ar, const NodeBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version)
00294 {
00295     // Save data required to construct instance
00296     const NodesOnlyMesh<DIM>* p_mesh = &(t->rGetMesh());
00297     ar & p_mesh;
00298 }
00299 
00304 template<class Archive, unsigned DIM>
00305 inline void load_construct_data(
00306     Archive & ar, NodeBasedCellPopulation<DIM> * t, const unsigned int file_version)
00307 {
00308     // Retrieve data from archive required to construct new instance
00309     NodesOnlyMesh<DIM>* p_mesh;
00310     ar >> p_mesh;
00311 
00312     // Invoke inplace constructor to initialise instance
00313     ::new(t)NodeBasedCellPopulation<DIM>(*p_mesh);
00314 }
00315 }
00316 } // namespace ...
00317 
00318 #endif /*NODEBASEDCELLPOPULATION_HPP_*/

Generated on Tue May 31 14:31:41 2011 for Chaste by  doxygen 1.5.5