AbstractElement.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 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 
00139     c_vector<double, SPACE_DIM> GetNodeLocation(unsigned localIndex) const;
00140 
00148     unsigned GetNodeGlobalIndex(unsigned localIndex) const;
00149 
00156     Node<SPACE_DIM>* GetNode(unsigned localIndex) const;
00157 
00161     unsigned GetNumNodes() const;
00162 
00168     void AddNode(Node<SPACE_DIM>* pNode);
00169 
00175     bool IsDeleted() const;
00176 
00180     unsigned GetIndex() const;
00181 
00187     void SetIndex(unsigned index);
00188 
00192     bool GetOwnership() const;
00193 
00199     void SetOwnership(bool ownership);
00200 
00204     void Flag();
00205 
00209     void Unflag();
00210 
00214     bool IsFlagged() const;
00215 
00221     void SetRegion(unsigned region);
00222 
00226     unsigned GetRegion();
00227 };
00228 
00229 #endif /*ABSTRACTELEMENT_HPP_*/

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