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 
00033 #include <boost/serialization/access.hpp>
00034 #include <boost/serialization/base_object.hpp>
00035 #include <boost/serialization/vector.hpp>
00036 
00043 template<unsigned DIM>
00044 class MeshBasedTissueWithGhostNodes : public MeshBasedTissue<DIM>
00045 {
00046 private:
00047 
00049     friend class TestMeshBasedTissueWithGhostNodes;
00050 
00052     std::vector<bool> mIsGhostNode;
00053 
00055     friend class boost::serialization::access;
00067     template<class Archive>
00068     void serialize(Archive & archive, const unsigned int version)
00069     {
00070         archive & boost::serialization::base_object<MeshBasedTissue<DIM> >(*this);
00071         archive & mIsGhostNode;
00072     }
00073 
00079     void SetGhostNodes(const std::set<unsigned>& ghostNodeIndices);
00080 
00090     void Validate();
00091 
00092 public:
00093 
00102     MeshBasedTissueWithGhostNodes(MutableMesh<DIM, DIM>& rMesh,
00103                                   const std::vector<TissueCell>& rCells,
00104                                   const std::vector<unsigned> locationIndices=std::vector<unsigned>(),
00105                                   bool deleteMesh=false);
00106 
00112     MeshBasedTissueWithGhostNodes(MutableMesh<DIM, DIM>& rMesh);
00113 
00124     void UpdateNodeLocations(const std::vector< c_vector<double, DIM> >& rNodeForces, double dt);
00125 
00129     std::vector<bool>& rGetGhostNodes();
00130 
00141     bool IsGhostNode(unsigned index);
00142 
00146     std::set<unsigned> GetGhostNodeIndices();
00147 
00154     void UpdateGhostPositions(double dt);
00155 
00161     void UpdateGhostNodesAfterReMesh(NodeMap& rMap);
00162 
00171     c_vector<double, DIM> CalculateForceBetweenNodes(const unsigned& rNodeAGlobalIndex, const unsigned& rNodeBGlobalIndex);
00172 
00183     TissueCell* AddCell(TissueCell& rNewCell, c_vector<double,DIM> newLocation, TissueCell* pParentCell=NULL);
00184 
00185 };
00186 
00187 
00188 #include "TemplatedExport.hpp"
00189 EXPORT_TEMPLATE_CLASS_SAME_DIMS(MeshBasedTissueWithGhostNodes)
00190 
00191 namespace boost
00192 {
00193 namespace serialization
00194 {
00198 template<class Archive, unsigned DIM>
00199 inline void save_construct_data(
00200     Archive & ar, const MeshBasedTissueWithGhostNodes<DIM> * t, const BOOST_PFTO unsigned int file_version)
00201 {
00202     // Save data required to construct instance
00203     const MutableMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
00204     ar & p_mesh;
00205 }
00206 
00211 template<class Archive, unsigned DIM>
00212 inline void load_construct_data(
00213     Archive & ar, MeshBasedTissueWithGhostNodes<DIM> * t, const unsigned int file_version)
00214 {
00215     // Retrieve data from archive required to construct new instance
00216     assert(MeshArchiveInfo::meshPathname.length() > 0);
00217     MutableMesh<DIM,DIM>* p_mesh;
00218     ar >> p_mesh;
00219 
00220     // Re-initialise the mesh
00221     p_mesh->Clear();
00222     TrianglesMeshReader<DIM,DIM> mesh_reader(MeshArchiveInfo::meshPathname);
00223     p_mesh->ConstructFromMeshReader(mesh_reader);
00224 
00225     // Needed for cylindrical meshes at present; should be safe in any case.
00226     NodeMap map(p_mesh->GetNumNodes());
00227     p_mesh->ReMesh(map);
00228 
00229     // Invoke inplace constructor to initialise instance
00230     ::new(t)MeshBasedTissueWithGhostNodes<DIM>(*p_mesh);
00231 
00232 }
00233 }
00234 } // namespace
00235 
00236 #endif /*MESHBASEDTISSUEWITHGHOSTNODES_HPP_*/

Generated on Wed Mar 18 12:51:50 2009 for Chaste by  doxygen 1.5.5