MutableMesh.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 MUTABLEMESH_HPP_
00030 #define MUTABLEMESH_HPP_
00031 
00032 #include "ChasteSerialization.hpp"
00033 #include <boost/serialization/base_object.hpp>
00034 
00035 #include "TetrahedralMesh.hpp"
00036 #include "NodeMap.hpp"
00037 
00041 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00042 class MutableMesh : public TetrahedralMesh<ELEMENT_DIM, SPACE_DIM>
00043 {
00045     friend class boost::serialization::access;
00046 
00057     template<class Archive>
00058     void serialize(Archive & archive, const unsigned int version)
00059     {
00060         archive & boost::serialization::base_object<TetrahedralMesh<ELEMENT_DIM, SPACE_DIM> >(*this);
00061 
00062         // Do a remesh after archiving has finished to get right number of boundary nodes etc.
00063         // (strictly only relevant for load - but doesn't take long in the scheme of things.)
00064         // NOTE - Subclasses must archive their member variables BEFORE calling this method.
00065         NodeMap map(this->GetNumNodes());
00066         this->ReMesh(map);
00067         assert(map.IsIdentityMap()); // Otherwise the mesh will get VERY confused.
00068     }
00069 
00070 protected:
00071 
00076     std::vector<unsigned> mDeletedElementIndices;
00077 
00082     std::vector<unsigned> mDeletedBoundaryElementIndices;
00083 
00088     std::vector<unsigned> mDeletedNodeIndices;
00089 
00091     bool mAddedNodes;
00092 
00093 private:
00094 
00095 #define COVERAGE_IGNORE
00096 
00103     bool CheckIsVoronoi(Element<ELEMENT_DIM, SPACE_DIM>* pElement, double maxPenetration);
00104 #undef COVERAGE_IGNORE
00105 
00106 public:
00107 
00111     MutableMesh();
00112 
00118     MutableMesh(std::vector<Node<SPACE_DIM> *> nodes);
00119 
00123     virtual ~MutableMesh();
00124 
00128     void Clear();
00129 
00133     unsigned GetNumNodes() const;
00134 
00138     unsigned GetNumElements() const;
00139 
00143     unsigned GetNumBoundaryElements() const;
00144 
00146 
00153     void RescaleMeshFromBoundaryNode(ChastePoint<1> updatedPoint, unsigned boundaryNodeIndex);
00154 
00162     virtual unsigned AddNode(Node<SPACE_DIM>* pNewNode);
00163 
00172     virtual void SetNode(unsigned index, ChastePoint<SPACE_DIM> point, bool concreteMove=true);
00173 
00183     void MoveMergeNode(unsigned index, unsigned targetIndex, bool concreteMove=true);
00184 
00185 #define COVERAGE_IGNORE
00186 
00192     virtual void DeleteNode(unsigned index);
00193 #undef COVERAGE_IGNORE
00194 
00195 #define COVERAGE_IGNORE
00196 
00204     void DeleteNodePriorToReMesh(unsigned index);
00205 #undef COVERAGE_IGNORE
00206 
00213     unsigned RefineElement(Element<ELEMENT_DIM,SPACE_DIM>* pElement, ChastePoint<SPACE_DIM> point);
00214 
00227     void DeleteBoundaryNodeAt(unsigned index);
00228 
00229 #define COVERAGE_IGNORE
00230 
00236     void ReIndex(NodeMap& map);
00237 #undef COVERAGE_IGNORE
00238 
00239 #define COVERAGE_IGNORE
00240 
00245     virtual void ReMesh(NodeMap& map);
00246 #undef COVERAGE_IGNORE
00247 
00248 
00249 #define COVERAGE_IGNORE
00250 
00254     void ReMesh();
00255 #undef COVERAGE_IGNORE
00256 
00257 #define COVERAGE_IGNORE
00258 
00266     bool CheckIsVoronoi(double maxPenetration=0.0);
00267 #undef COVERAGE_IGNORE
00268 };
00269 
00270 #include "SerializationExportWrapper.hpp"
00271 EXPORT_TEMPLATE_CLASS_ALL_DIMS(MutableMesh)
00272 
00273 #endif /*MUTABLEMESH_HPP_*/
Generated on Thu Dec 22 13:00:16 2011 for Chaste by  doxygen 1.6.3