AbstractElement.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 
00029 #ifndef ABSTRACTELEMENT_HPP_
00030 #define ABSTRACTELEMENT_HPP_
00031 
00032 #include <vector>
00033 
00034 #include "UblasVectorInclude.hpp"
00035 #include "Node.hpp"
00036 
00037 /*
00038  * When creating an element within a mesh one needs to specify its global index.
00039  * If the element is not used within a mesh the following constant is used instead.
00040  */
00041 const unsigned INDEX_IS_NOT_USED=0;
00042 
00046 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00047 class AbstractElement
00048 {
00049 protected:
00050 
00052     std::vector<Node<SPACE_DIM>*> mNodes;
00053 
00055     unsigned mIndex;
00056 
00058     unsigned mRegion;
00059 
00064     bool mIsDeleted;
00065 
00067     bool mOwnership;
00068 
00070     bool mFlag;
00071 
00072 public:
00073 
00080     AbstractElement(unsigned index, const std::vector<Node<SPACE_DIM>*>& rNodes);
00081 
00087     AbstractElement(unsigned index=INDEX_IS_NOT_USED);
00088 
00093     virtual ~AbstractElement()
00094     {}
00095 
00102     virtual void UpdateNode(const unsigned& rIndex, Node<SPACE_DIM>* pNode)=0;
00103 
00110     void ReplaceNode(Node<SPACE_DIM>* pOldNode, Node<SPACE_DIM>* pNewNode);
00111 
00116     virtual void MarkAsDeleted()=0;
00117 
00121     virtual void RegisterWithNodes()=0;
00122 
00131     double GetNodeLocation(unsigned localIndex, unsigned dimension) const;
00132 
00143     c_vector<double, SPACE_DIM> GetNodeLocation(unsigned localIndex) const;
00144 
00152     unsigned GetNodeGlobalIndex(unsigned localIndex) const;
00153 
00160     Node<SPACE_DIM>* GetNode(unsigned localIndex) const;
00161 
00165     unsigned GetNumNodes() const;
00166 
00172     void AddNode(Node<SPACE_DIM>* pNode);
00173 
00179     bool IsDeleted() const;
00180 
00184     unsigned GetIndex() const;
00185 
00191     void SetIndex(unsigned index);
00192 
00196     bool GetOwnership() const;
00197 
00203     void SetOwnership(bool ownership);
00204 
00208     void Flag();
00209 
00213     void Unflag();
00214 
00218     bool IsFlagged() const;
00219 
00225     void SetRegion(unsigned region);
00226 
00230     unsigned GetRegion();
00231 };
00232 
00233 #endif /*ABSTRACTELEMENT_HPP_*/

Generated on Tue Aug 4 16:10:22 2009 for Chaste by  doxygen 1.5.5