NodeBasedTissue.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 #ifndef NODEBASEDTISSUE_HPP_
00029 #define NODEBASEDTISSUE_HPP_
00030
00031 #include "AbstractCellCentreBasedTissue.hpp"
00032 #include "AbstractTetrahedralMesh.hpp"
00033 #include "BoxCollection.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
00044 template<unsigned DIM>
00045 class NodeBasedTissue : public AbstractCellCentreBasedTissue<DIM>
00046 {
00047 friend class TestNodeBasedTissue;
00048 friend class TestBoxCollection;
00049
00050 protected:
00051
00053 std::vector<Node<DIM>* > mNodes;
00054
00056 std::vector<unsigned> mDeletedNodeIndices;
00057
00059 bool mAddedNodes;
00060
00061 private:
00062
00064 BoxCollection<DIM>* mpBoxCollection;
00065
00067 c_vector<double, DIM> mMinSpatialPositions;
00068
00070 c_vector<double, DIM> mMaxSpatialPositions;
00071
00073 std::set< std::pair<Node<DIM>*, Node<DIM>* > > mNodePairs;
00074
00078 bool mDeleteNodes;
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<AbstractCellCentreBasedTissue<DIM> >(*this);
00095
00096 Validate();
00097 }
00098
00107 unsigned AddNode(Node<DIM>* pNewNode);
00108
00115 void SetNode(unsigned nodeIndex, ChastePoint<DIM>& rNewLocation);
00116
00120 void Validate();
00121
00128 void SplitUpIntoBoxes(double cutOffLength, c_vector<double, 2*DIM> domainSize);
00129
00133 void FindMaxAndMin();
00134
00135 public:
00136
00147 NodeBasedTissue(const std::vector<Node<DIM>* > nodes,
00148 std::vector<TissueCell>& rCells,
00149 const std::vector<unsigned> locationIndices=std::vector<unsigned>(),
00150 bool deleteNodes=true);
00151
00161 NodeBasedTissue(const std::vector<Node<DIM>* > nodes, bool deleteNodes=true);
00162
00173 NodeBasedTissue(const AbstractMesh<DIM,DIM>& rMesh,
00174 std::vector<TissueCell>& rCells);
00175
00181 ~NodeBasedTissue();
00182
00186 unsigned GetNumNodes();
00187
00195 Node<DIM>* GetNode(unsigned index);
00196
00206 unsigned RemoveDeadCells();
00207
00212 void Clear();
00213
00219 void Update(bool hasHadBirthsOrDeaths=true);
00220
00226 std::vector<Node<DIM>* >& rGetNodes();
00227
00233 const std::vector<Node<DIM>* >& rGetNodes() const;
00234
00238 BoxCollection<DIM>* GetBoxCollection();
00239
00243 std::set< std::pair<Node<DIM>*, Node<DIM>* > >& rGetNodePairs();
00244 };
00245
00246
00247 #include "SerializationExportWrapper.hpp"
00248 EXPORT_TEMPLATE_CLASS_SAME_DIMS(NodeBasedTissue)
00249
00250 namespace boost {
00251 namespace serialization {
00252
00256 template<class Archive, unsigned SPACE_DIM>
00257 inline void save(
00258 Archive & ar,
00259 const Node<SPACE_DIM>& rNode,
00260 const unsigned int )
00261 {
00262
00263 const bool is_deleted = rNode.IsDeleted();
00264 ar << is_deleted;
00265 }
00266
00270 template<class Archive, unsigned SPACE_DIM>
00271 inline void load(
00272 Archive & ar,
00273 Node<SPACE_DIM>& rNode,
00274 const unsigned int )
00275 {
00276
00277 bool is_deleted;
00278 ar >> is_deleted;
00279 #define COVERAGE_IGNORE
00280 if (is_deleted)
00281 {
00282 rNode.MarkAsDeleted();
00283 }
00284 #undef COVERAGE_IGNORE
00285 }
00286
00287
00292 template<class Archive, unsigned SPACE_DIM>
00293 inline void serialize(
00294 Archive & ar,
00295 Node<SPACE_DIM>& rNode,
00296 const unsigned int file_version)
00297 {
00298 boost::serialization::split_free(ar, rNode, file_version);
00299 }
00300
00301
00305 template<class Archive, unsigned DIM>
00306 inline void save_construct_data(
00307 Archive & ar, const Node<DIM> * t, const BOOST_PFTO unsigned int file_version)
00308 {
00309
00310 const unsigned index = t->GetIndex();
00311 ar << index;
00312
00313
00314 const bool is_boundary = t->IsBoundaryNode();
00315 ar << is_boundary;
00316
00317
00318 const c_vector<double, DIM>& r_loc = t->rGetLocation();
00319 for (unsigned i=0; i<DIM; i++)
00320 {
00321 ar << r_loc[i];
00322 }
00323 }
00324
00328 template<class Archive, unsigned DIM>
00329 inline void load_construct_data(
00330 Archive & ar, Node<DIM> * t, const unsigned int file_version)
00331 {
00332
00333 unsigned index;
00334 ar >> index;
00335
00336
00337 bool is_boundary;
00338 ar >> is_boundary;
00339
00340
00341 c_vector<double, DIM> loc;
00342 for (unsigned i=0; i<DIM; i++)
00343 {
00344 ar >> loc[i];
00345 }
00346
00347
00348 ::new(t)Node<DIM>(index, loc, is_boundary);
00349 }
00350
00351
00355 template<class Archive, unsigned DIM>
00356 inline void save_construct_data(
00357 Archive & ar, const NodeBasedTissue<DIM> * t, const BOOST_PFTO unsigned int file_version)
00358 {
00359 ar & t->rGetNodes();
00360 }
00361
00365 template<class Archive, unsigned DIM>
00366 inline void load_construct_data(
00367 Archive & ar, NodeBasedTissue<DIM> * t, const unsigned int file_version)
00368 {
00369
00370 std::vector<Node<DIM>* > nodes;
00371 ar >> nodes;
00372
00373
00374 ::new(t)NodeBasedTissue<DIM>(nodes);
00375 }
00376
00377 }}
00378
00379
00380 #endif