NodeBasedCellPopulation.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
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
00318 NodesOnlyMesh<DIM>* p_mesh;
00319 ar >> p_mesh;
00320
00321
00322 ::new(t)NodeBasedCellPopulation<DIM>(*p_mesh);
00323 }
00324 }
00325 }
00326
00327 #endif