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 
00029 #ifndef MESHBASEDCELLPOPULATIONWITHGHOSTNODES_HPP_
00030 #define MESHBASEDCELLPOPULATIONWITHGHOSTNODES_HPP_
00031 
00032 #include "MeshBasedCellPopulation.hpp"
00033 #include "TrianglesMeshReader.hpp"
00034 
00035 #include "ChasteSerialization.hpp"
00036 #include <boost/serialization/base_object.hpp>
00037 #include <boost/serialization/vector.hpp>
00038 
00049 template<unsigned DIM>
00050 class MeshBasedCellPopulationWithGhostNodes : public MeshBasedCellPopulation<DIM>
00051 {
00052 private:
00053 
00055     friend class TestMeshBasedCellPopulationWithGhostNodes;
00056 
00058     std::vector<bool> mIsGhostNode;
00059 
00063     double mGhostSpringStiffness;
00064 
00066     friend class boost::serialization::access;
00078     template<class Archive>
00079     void serialize(Archive & archive, const unsigned int version)
00080     {
00081         // This needs to be first so that MeshBasedCellPopulation::Validate() doesn't go mental.
00082         archive & mIsGhostNode;
00083         archive & mGhostSpringStiffness;
00084         archive & boost::serialization::base_object<MeshBasedCellPopulation<DIM> >(*this);
00085     }
00086 
00092     void SetGhostNodes(const std::set<unsigned>& rGhostNodeIndices);
00093 
00103     void Validate();
00104 
00105 public:
00106 
00116     MeshBasedCellPopulationWithGhostNodes(MutableMesh<DIM, DIM>& rMesh,
00117                                   std::vector<CellPtr>& rCells,
00118                                   const std::vector<unsigned> locationIndices=std::vector<unsigned>(),
00119                                   bool deleteMesh=false,
00120                                   double ghostSpringStiffness=15.0);
00121 
00128     MeshBasedCellPopulationWithGhostNodes(MutableMesh<DIM, DIM>& rMesh,
00129                                   double ghostSpringStiffness=15.0);
00130 
00141     void UpdateNodeLocations(const std::vector< c_vector<double, DIM> >& rNodeForces, double dt);
00142 
00146     std::vector<bool>& rGetGhostNodes();
00147 
00158     bool IsGhostNode(unsigned index);
00159 
00163     std::set<unsigned> GetGhostNodeIndices();
00164 
00171     void UpdateGhostPositions(double dt);
00172 
00178     void UpdateGhostNodesAfterReMesh(NodeMap& rMap);
00179 
00188     c_vector<double, DIM> CalculateForceBetweenGhostNodes(const unsigned& rNodeAGlobalIndex, const unsigned& rNodeBGlobalIndex);
00189 
00201     CellPtr AddCell(CellPtr pNewCell, const c_vector<double,DIM>& rCellDivisionVector, CellPtr pParentCell);
00202 
00206     void WriteVtkResultsToFile();
00207 
00216     void OutputCellPopulationParameters(out_stream& rParamsFile);
00217 };
00218 
00219 
00220 #include "SerializationExportWrapper.hpp"
00221 EXPORT_TEMPLATE_CLASS_SAME_DIMS(MeshBasedCellPopulationWithGhostNodes)
00222 
00223 namespace boost
00224 {
00225 namespace serialization
00226 {
00230 template<class Archive, unsigned DIM>
00231 inline void save_construct_data(
00232     Archive & ar, const MeshBasedCellPopulationWithGhostNodes<DIM> * t, const BOOST_PFTO unsigned int file_version)
00233 {
00234     // Save data required to construct instance
00235     const MutableMesh<DIM,DIM>* p_mesh = &(t->rGetMesh());
00236     ar & p_mesh;
00237 }
00238 
00243 template<class Archive, unsigned DIM>
00244 inline void load_construct_data(
00245     Archive & ar, MeshBasedCellPopulationWithGhostNodes<DIM> * t, const unsigned int file_version)
00246 {
00247     // Retrieve data from archive required to construct new instance
00248     MutableMesh<DIM,DIM>* p_mesh;
00249     ar >> p_mesh;
00250 
00251     // Invoke inplace constructor to initialise instance
00252     ::new(t)MeshBasedCellPopulationWithGhostNodes<DIM>(*p_mesh);
00253 
00254 }
00255 }
00256 } // namespace
00257 
00258 #endif /*MESHBASEDCELLPOPULATIONWITHGHOSTNODES_HPP_*/
Generated on Thu Dec 22 13:00:05 2011 for Chaste by  doxygen 1.6.3