MeshBasedTissueWithGhostNodes.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
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 MESHBASEDTISSUEWITHGHOSTNODES_HPP_
00029 #define MESHBASEDTISSUEWITHGHOSTNODES_HPP_
00030 
00031 #include "MeshBasedTissue.hpp"
00032 #include "TrianglesMeshReader.hpp"
00033 
00034 #include <boost/serialization/access.hpp>
00035 #include <boost/serialization/base_object.hpp>
00036 #include <boost/serialization/vector.hpp>
00037 
00048 template<unsigned DIM>
00049 class MeshBasedTissueWithGhostNodes : public MeshBasedTissue<DIM>
00050 {
00051 private:
00053     friend class TestMeshBasedTissueWithGhostNodes;
00054 
00056     std::vector<bool> mIsGhostNode;
00057 
00059     friend class boost::serialization::access;
00071     template<class Archive>
00072     void serialize(Archive & archive, const unsigned int version)
00073     {
00074         // This needs to be first so that MeshBasedTissue::Validate() doesn't go mental.
00075         archive & mIsGhostNode;
00076         archive & boost::serialization::base_object<MeshBasedTissue<DIM> >(*this);
00077     }
00078 
00084     void SetGhostNodes(const std::set<unsigned>& rGhostNodeIndices);
00085 
00095     void Validate();
00096 
00097 public:
00098 
00107     MeshBasedTissueWithGhostNodes(MutableMesh<DIM, DIM>& rMesh,
00108                                   const std::vector<TissueCell>& rCells,
00109                                   const std::vector<unsigned> locationIndices=std::vector<unsigned>(),
00110                                   bool deleteMesh=false);
00111 
00117     MeshBasedTissueWithGhostNodes(MutableMesh<DIM, DIM>& rMesh);
00118 
00129     void UpdateNodeLocations(const std::vector< c_vector<double, DIM> >& rNodeForces, double dt);
00130 
00134     std::vector<bool>& rGetGhostNodes();
00135 
00146     bool IsGhostNode(unsigned index);
00147 
00151     std::set<unsigned> GetGhostNodeIndices();
00152 
00159     void UpdateGhostPositions(double dt);
00160 
00166     void UpdateGhostNodesAfterReMesh(NodeMap& rMap);
00167 
00176     c_vector<double, DIM> CalculateForceBetweenNodes(const unsigned& rNodeAGlobalIndex, const unsigned& rNodeBGlobalIndex);
00177 
00188     TissueCell* AddCell(TissueCell& rNewCell, c_vector<double,DIM> newLocation, TissueCell* pParentCell=NULL);
00189 
00200     virtual void GenerateCellResultsAndWriteToFiles(std::vector<unsigned>& rCellTypeCounter,
00201                                                     std::vector<unsigned>& rCellMutationStateCounter,
00202                                                     std::vector<unsigned>& rCellCyclePhaseCounter);
00203 };
00204 
00205 
00206 #include "TemplatedExport.hpp"
00207 EXPORT_TEMPLATE_CLASS_SAME_DIMS(MeshBasedTissueWithGhostNodes)
00208 
00209 namespace boost
00210 {
00211 namespace serialization
00212 {
00216 template<class Archive, unsigned DIM>
00217 inline void save_construct_data(
00218     Archive & ar, const MeshBasedTissueWithGhostNodes<DIM> * t, const BOOST_PFTO unsigned int file_version)
00219 {
00220     // Save data required to construct instance
00221     const MutableMesh<DIM,DIM> *p_mesh = &(t->rGetMesh());
00222     ar & p_mesh;
00223 }
00224 
00229 template<class Archive, unsigned DIM>
00230 inline void load_construct_data(
00231     Archive & ar, MeshBasedTissueWithGhostNodes<DIM> * t, const unsigned int file_version)
00232 {
00233     // Retrieve data from archive required to construct new instance
00234     MutableMesh<DIM,DIM> *p_mesh;
00235     ar >> p_mesh;
00236 
00237     // Invoke inplace constructor to initialise instance
00238     ::new(t)MeshBasedTissueWithGhostNodes<DIM>(*p_mesh);
00239 
00240 }
00241 }
00242 } // namespace
00243 
00244 #endif /*MESHBASEDTISSUEWITHGHOSTNODES_HPP_*/

Generated on Tue Aug 4 16:10:21 2009 for Chaste by  doxygen 1.5.5