VertexElement.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 VERTEXELEMENT_HPP_
00029 #define VERTEXELEMENT_HPP_
00030 
00031 #include "AbstractElement.hpp"
00032 
00033 #include "ChasteSerialization.hpp"
00034 #include <boost/serialization/base_object.hpp>
00035 #include <boost/serialization/vector.hpp>
00036 
00043 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00044 class VertexElement : public AbstractElement<ELEMENT_DIM, SPACE_DIM>
00045 {
00046 private:
00047 
00051     std::vector<VertexElement<ELEMENT_DIM-1, SPACE_DIM>*> mFaces;
00052 
00063     std::vector<bool> mOrientations;
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 & mFaces;
00083         archive & mOrientations;
00084         archive & boost::serialization::base_object<AbstractElement<ELEMENT_DIM, SPACE_DIM> >(*this);
00085     }
00086 
00087 public:
00088 
00096     VertexElement(unsigned index,
00097                   const std::vector<VertexElement<ELEMENT_DIM-1, SPACE_DIM>*>& rFaces,
00098                   const std::vector<bool>& rOrientations);
00099 
00109     VertexElement(unsigned index);
00110 
00117     VertexElement(unsigned index,
00118                   const std::vector<Node<SPACE_DIM>*>& rNodes);
00119 
00130     VertexElement(unsigned index,
00131                   const std::vector<VertexElement<ELEMENT_DIM-1, SPACE_DIM>*>& rFaces,
00132                   const std::vector<bool>& rOrientations,
00133                   const std::vector<Node<SPACE_DIM>*>& rNodes);
00134 
00138     ~VertexElement();
00139 
00143     unsigned GetNumFaces() const;
00144 
00150     void RegisterWithNodes();
00151 
00158     void MarkAsDeleted();
00159 
00165     void ResetIndex(unsigned index);
00166 
00173     void UpdateNode(const unsigned& rIndex, Node<SPACE_DIM>* pNode);
00174 
00180     void DeleteNode(const unsigned& rIndex);
00181 
00188     void AddNode(const unsigned& rIndex, Node<SPACE_DIM>* pNode);
00189 
00195     void AddFace(VertexElement<ELEMENT_DIM-1, SPACE_DIM>* pFace);
00196 
00204     unsigned GetNodeLocalIndex(unsigned globalIndex) const;
00205 
00211     VertexElement<ELEMENT_DIM-1, SPACE_DIM>* GetFace(unsigned index) const;
00212 
00218     bool FaceIsOrientatedClockwise(unsigned index) const;
00219 
00225     bool IsElementOnBoundary() const;
00226 
00227 };
00228 
00229 
00231 //                  Specialization for 1d elements                  //
00232 //                                                                  //
00233 //                 1d elements are just edges (lines)               //
00235 
00240 template<unsigned SPACE_DIM>
00241 class VertexElement<1, SPACE_DIM> : public AbstractElement<1,SPACE_DIM>
00242 {
00243 public:
00244 
00251     VertexElement(unsigned index, const std::vector<Node<SPACE_DIM>*>& rNodes);
00252 
00256     virtual ~VertexElement();
00257 
00261     unsigned GetNumFaces() const;
00262 
00269     void UpdateNode(const unsigned& rIndex, Node<SPACE_DIM>* pNode);
00270 
00276     void RegisterWithNodes();
00277 
00284     void MarkAsDeleted();
00285 
00291     void ResetIndex(unsigned index);
00292 
00298     void DeleteNode(const unsigned& rIndex);
00299 
00306     void AddNode(const unsigned& rIndex, Node<SPACE_DIM>* pNode);
00307 
00315     unsigned GetNodeLocalIndex(unsigned globalIndex) const;
00316 
00322     VertexElement<0, SPACE_DIM>* GetFace(unsigned index) const;
00323 
00329     bool FaceIsOrientatedClockwise(unsigned index) const;
00330 
00336     bool IsElementOnBoundary() const;
00337 };
00338 
00339 #endif /*VERTEXELEMENT_HPP_*/

Generated on Tue May 31 14:31:48 2011 for Chaste by  doxygen 1.5.5