Chaste Release::3.1
|
00001 /* 00002 00003 Copyright (c) 2005-2012, University of Oxford. 00004 All rights reserved. 00005 00006 University of Oxford means the Chancellor, Masters and Scholars of the 00007 University of Oxford, having an administrative office at Wellington 00008 Square, Oxford OX1 2JD, UK. 00009 00010 This file is part of Chaste. 00011 00012 Redistribution and use in source and binary forms, with or without 00013 modification, are permitted provided that the following conditions are met: 00014 * Redistributions of source code must retain the above copyright notice, 00015 this list of conditions and the following disclaimer. 00016 * Redistributions in binary form must reproduce the above copyright notice, 00017 this list of conditions and the following disclaimer in the documentation 00018 and/or other materials provided with the distribution. 00019 * Neither the name of the University of Oxford nor the names of its 00020 contributors may be used to endorse or promote products derived from this 00021 software without specific prior written permission. 00022 00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 00034 */ 00035 00036 #ifndef NODEBASEDCELLPOPULATION_HPP_ 00037 #define NODEBASEDCELLPOPULATION_HPP_ 00038 00039 #include "AbstractCentreBasedCellPopulation.hpp" 00040 #include "NodesOnlyMesh.hpp" 00041 #include "BoxCollection.hpp" 00042 00043 #include "ChasteSerialization.hpp" 00044 #include <boost/serialization/base_object.hpp> 00045 00050 template<unsigned DIM> 00051 class NodeBasedCellPopulation : public AbstractCentreBasedCellPopulation<DIM> 00052 { 00053 friend class TestNodeBasedCellPopulation; 00054 friend class TestBoxCollection; 00055 00056 private: 00057 00059 NodesOnlyMesh<DIM>* mpNodesOnlyMesh; 00060 00062 c_vector<double, DIM> mMinSpatialPositions; 00063 00065 c_vector<double, DIM> mMaxSpatialPositions; 00066 00068 std::set< std::pair<Node<DIM>*, Node<DIM>* > > mNodePairs; 00069 00071 std::map<unsigned, std::set<unsigned> > mNodeNeighbours; 00072 00074 bool mDeleteMesh; 00075 00080 double mMechanicsCutOffLength; 00081 00085 bool mUseVariableRadii; 00086 00088 friend class boost::serialization::access; 00098 template<class Archive> 00099 void serialize(Archive & archive, const unsigned int version) 00100 { 00101 archive & boost::serialization::base_object<AbstractCentreBasedCellPopulation<DIM> >(*this); 00102 archive & mMechanicsCutOffLength; 00103 archive & mUseVariableRadii; 00104 00105 this->Validate(); 00106 } 00107 00116 unsigned AddNode(Node<DIM>* pNewNode); 00117 00118 00119 protected: 00120 00121 #undef COVERAGE_IGNORE // Avoid prototypes being treated as code by gcov 00122 00127 virtual void UpdateParticlesAfterReMesh(NodeMap& rMap); 00128 00132 virtual void Validate(); 00133 00134 private: 00135 00142 void SplitUpIntoBoxes(double cutOffLength, c_vector<double, 2*DIM> domainSize); 00143 00147 void FindMaxAndMin(); 00148 00152 void WriteCellVolumeResultsToFile(); 00153 00157 void WriteVtkResultsToFile(); 00158 00159 public: 00160 00167 void SetNode(unsigned nodeIndex, ChastePoint<DIM>& rNewLocation); 00168 00180 NodeBasedCellPopulation(NodesOnlyMesh<DIM>& rMesh, 00181 std::vector<CellPtr>& rCells, 00182 const std::vector<unsigned> locationIndices=std::vector<unsigned>(), 00183 bool deleteMesh=false, 00184 bool validate=true); 00185 00191 NodeBasedCellPopulation(NodesOnlyMesh<DIM>& rMesh); 00192 00198 virtual ~NodeBasedCellPopulation(); 00199 00203 NodesOnlyMesh<DIM>& rGetMesh(); 00204 00208 const NodesOnlyMesh<DIM>& rGetMesh() const; 00209 00213 unsigned GetNumNodes(); 00214 00222 Node<DIM>* GetNode(unsigned index); 00223 00233 unsigned RemoveDeadCells(); 00234 00238 void Clear(); 00239 00245 void Update(bool hasHadBirthsOrDeaths=true); 00246 00250 BoxCollection<DIM>* GetBoxCollection(); 00251 00257 std::set< std::pair<Node<DIM>*, Node<DIM>* > >& rGetNodePairs(); 00258 00267 void OutputCellPopulationParameters(out_stream& rParamsFile); 00268 00272 double GetMechanicsCutOffLength(); 00273 00279 void SetMechanicsCutOffLength(double mechanicsCutOffLength); 00280 00284 bool GetUseVariableRadii(); 00285 00291 void SetUseVariableRadii(bool useVariableRadii=true); 00292 00302 double GetWidth(const unsigned& rDimension); 00303 00312 std::set<unsigned> GetNeighbouringNodeIndices(unsigned index); 00313 00326 virtual CellPtr AddCell(CellPtr pNewCell, const c_vector<double,DIM>& rCellDivisionVector, CellPtr pParentCell); 00327 00333 double GetVolumeOfCell(CellPtr pCell); 00334 }; 00335 00336 #include "SerializationExportWrapper.hpp" 00337 EXPORT_TEMPLATE_CLASS_SAME_DIMS(NodeBasedCellPopulation) 00338 00339 namespace boost 00340 { 00341 namespace serialization 00342 { 00346 template<class Archive, unsigned DIM> 00347 inline void save_construct_data( 00348 Archive & ar, const NodeBasedCellPopulation<DIM> * t, const BOOST_PFTO unsigned int file_version) 00349 { 00350 // Save data required to construct instance 00351 const NodesOnlyMesh<DIM>* p_mesh = &(t->rGetMesh()); 00352 ar & p_mesh; 00353 } 00354 00359 template<class Archive, unsigned DIM> 00360 inline void load_construct_data( 00361 Archive & ar, NodeBasedCellPopulation<DIM> * t, const unsigned int file_version) 00362 { 00363 // Retrieve data from archive required to construct new instance 00364 NodesOnlyMesh<DIM>* p_mesh; 00365 ar >> p_mesh; 00366 00367 // Invoke inplace constructor to initialise instance 00368 ::new(t)NodeBasedCellPopulation<DIM>(*p_mesh); 00369 } 00370 } 00371 } // namespace ... 00372 00373 #endif /*NODEBASEDCELLPOPULATION_HPP_*/