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 #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
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
00309 NodesOnlyMesh<DIM>* p_mesh;
00310 ar >> p_mesh;
00311
00312
00313 ::new(t)NodeBasedCellPopulation<DIM>(*p_mesh);
00314 }
00315 }
00316 }
00317
00318 #endif