MeshBasedCellPopulationWithGhostNodes.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
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 MESHBASEDCELLPOPULATIONWITHGHOSTNODES_HPP_
00029 #define MESHBASEDCELLPOPULATIONWITHGHOSTNODES_HPP_
00030 
00031 #include "MeshBasedCellPopulation.hpp"
00032 #include "TrianglesMeshReader.hpp"
00033 
00034 #include "ChasteSerialization.hpp"
00035 #include <boost/serialization/base_object.hpp>
00036 #include <boost/serialization/vector.hpp>
00037 
00048 template<unsigned DIM>
00049 class MeshBasedCellPopulationWithGhostNodes : public MeshBasedCellPopulation<DIM>
00050 {
00051 private:
00052 
00054     friend class TestMeshBasedCellPopulationWithGhostNodes;
00055 
00057     std::vector<bool> mIsGhostNode;
00058 
00062     double mGhostSpringStiffness;
00063 
00065     friend class boost::serialization::access;
00077     template<class Archive>
00078     void serialize(Archive & archive, const unsigned int version)
00079     {
00080         // This needs to be first so that MeshBasedCellPopulation::Validate() doesn't go mental.
00081         archive & mIsGhostNode;
00082         archive & mGhostSpringStiffness;
00083         archive & boost::serialization::base_object<MeshBasedCellPopulation<DIM> >(*this);
00084     }
00085 
00091     void SetGhostNodes(const std::set<unsigned>& rGhostNodeIndices);
00092 
00102     void Validate();
00103 
00104 public:
00105 
00115     MeshBasedCellPopulationWithGhostNodes(MutableMesh<DIM, DIM>& rMesh,
00116                                   std::vector<CellPtr>& rCells,
00117                                   const std::vector<unsigned> locationIndices=std::vector<unsigned>(),
00118                                   bool deleteMesh=false,
00119                                   double ghostSpringStiffness=15.0);
00120 
00127     MeshBasedCellPopulationWithGhostNodes(MutableMesh<DIM, DIM>& rMesh,
00128                                   double ghostSpringStiffness=15.0);
00129 
00140     void UpdateNodeLocations(const std::vector< c_vector<double, DIM> >& rNodeForces, double dt);
00141 
00145     std::vector<bool>& rGetGhostNodes();
00146 
00157     bool IsGhostNode(unsigned index);
00158 
00162     std::set<unsigned> GetGhostNodeIndices();
00163 
00170     void UpdateGhostPositions(double dt);
00171 
00177     void UpdateGhostNodesAfterReMesh(NodeMap& rMap);
00178 
00187     c_vector<double, DIM> CalculateForceBetweenGhostNodes(const unsigned& rNodeAGlobalIndex, const unsigned& rNodeBGlobalIndex);
00188 
00200     CellPtr AddCell(CellPtr pNewCell, const c_vector<double,DIM>& rCellDivisionVector, CellPtr pParentCell);
00201 
00205     void WriteVtkResultsToFile();
00206 
00215     void OutputCellPopulationParameters(out_stream& rParamsFile);
00216 };
00217 
00218 
00219 #include "SerializationExportWrapper.hpp"
00220 EXPORT_TEMPLATE_CLASS_SAME_DIMS(MeshBasedCellPopulationWithGhostNodes)
00221 
00222 namespace boost
00223 {
00224 namespace serialization
00225 {
00229 template<class Archive, unsigned DIM>
00230 inline void save_construct_data(
00231     Archive & ar, const MeshBasedCellPopulationWithGhostNodes<DIM> * t, const BOOST_PFTO unsigned int file_version)
00232 {
00233     // Save data required to construct instance
00234     const MutableMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
00235     ar & p_mesh;
00236 }
00237 
00242 template<class Archive, unsigned DIM>
00243 inline void load_construct_data(
00244     Archive & ar, MeshBasedCellPopulationWithGhostNodes<DIM> * t, const unsigned int file_version)
00245 {
00246     // Retrieve data from archive required to construct new instance
00247     MutableMesh<DIM,DIM>* p_mesh;
00248     ar >> p_mesh;
00249 
00250     // Invoke inplace constructor to initialise instance
00251     ::new(t)MeshBasedCellPopulationWithGhostNodes<DIM>(*p_mesh);
00252 
00253 }
00254 }
00255 } // namespace
00256 
00257 #endif /*MESHBASEDCELLPOPULATIONWITHGHOSTNODES_HPP_*/

Generated on Mon Apr 18 11:35:27 2011 for Chaste by  doxygen 1.5.5