00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "AbstractElement.hpp"
00030
00031 #include "Exception.hpp"
00032
00033 #include <cassert>
00034
00036
00038
00039 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00040 AbstractElement<ELEMENT_DIM, SPACE_DIM>::AbstractElement(unsigned index, const std::vector<Node<SPACE_DIM>*>& rNodes)
00041 : mNodes(rNodes),
00042 mIndex(index),
00043 mRegion(0),
00044 mIsDeleted(false),
00045 mOwnership(true),
00046 mFlag(false)
00047 {
00048
00049 assert(ELEMENT_DIM <= SPACE_DIM);
00050
00051
00052 }
00053
00054 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00055 AbstractElement<ELEMENT_DIM, SPACE_DIM>::AbstractElement(unsigned index)
00056 : mIndex(index),
00057 mRegion(0),
00058 mIsDeleted(false),
00059 mOwnership(true),
00060 mFlag(false)
00061 {}
00062
00063 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00064 void AbstractElement<ELEMENT_DIM, SPACE_DIM>::ReplaceNode(Node<SPACE_DIM>* pOldNode, Node<SPACE_DIM>* pNewNode)
00065 {
00066
00067 for (unsigned i=0; i<this->mNodes.size(); i++)
00068 {
00069 if (this->mNodes[i] == pOldNode)
00070 {
00071 UpdateNode(i, pNewNode);
00072 return;
00073 }
00074 }
00075 EXCEPTION("You didn't have that node to start with.");
00076 }
00077
00078 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00079 double AbstractElement<ELEMENT_DIM, SPACE_DIM>::GetNodeLocation(unsigned localIndex, unsigned dimension) const
00080 {
00081 assert(dimension < SPACE_DIM);
00082 assert((unsigned)localIndex < mNodes.size());
00083 return mNodes[localIndex]->rGetLocation()[dimension];
00084 }
00085
00086 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00087 c_vector<double, SPACE_DIM> AbstractElement<ELEMENT_DIM, SPACE_DIM>::GetNodeLocation(unsigned localIndex) const
00088 {
00089 assert((unsigned)localIndex < mNodes.size());
00090 return mNodes[localIndex]->rGetLocation();
00091 }
00092
00093 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00094 unsigned AbstractElement<ELEMENT_DIM, SPACE_DIM>::GetNodeGlobalIndex(unsigned localIndex) const
00095 {
00096 assert((unsigned)localIndex < mNodes.size());
00097 return mNodes[localIndex]->GetIndex();
00098 }
00099
00100 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00101 Node<SPACE_DIM>* AbstractElement<ELEMENT_DIM, SPACE_DIM>::GetNode(unsigned localIndex) const
00102 {
00103 assert((unsigned)localIndex < mNodes.size());
00104 return mNodes[localIndex];
00105 }
00106
00107 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00108 unsigned AbstractElement<ELEMENT_DIM, SPACE_DIM>::GetNumNodes() const
00109 {
00110 return mNodes.size();
00111 }
00112
00113 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00114 void AbstractElement<ELEMENT_DIM, SPACE_DIM>::AddNode(Node<SPACE_DIM>* pNode)
00115 {
00116 mNodes.push_back(pNode);
00117 }
00118
00119 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00120 bool AbstractElement<ELEMENT_DIM, SPACE_DIM>::IsDeleted() const
00121 {
00122 return mIsDeleted;
00123 }
00124
00125 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00126 unsigned AbstractElement<ELEMENT_DIM, SPACE_DIM>::GetIndex() const
00127 {
00128 return mIndex;
00129 }
00130
00131 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00132 void AbstractElement<ELEMENT_DIM, SPACE_DIM>::SetIndex(unsigned index)
00133 {
00134 mIndex = index;
00135 }
00136
00137 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00138 bool AbstractElement<ELEMENT_DIM, SPACE_DIM>::GetOwnership() const
00139 {
00140 return mOwnership;
00141 }
00142
00143 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00144 void AbstractElement<ELEMENT_DIM, SPACE_DIM>::SetOwnership(bool ownership)
00145 {
00146 mOwnership = ownership;
00147 }
00148
00149 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00150 void AbstractElement<ELEMENT_DIM, SPACE_DIM>::Flag()
00151 {
00152 mFlag = true;
00153 }
00154
00155 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00156 void AbstractElement<ELEMENT_DIM, SPACE_DIM>::Unflag()
00157 {
00158 mFlag = false;
00159 }
00160
00161 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00162 bool AbstractElement<ELEMENT_DIM, SPACE_DIM>::IsFlagged() const
00163 {
00164 return mFlag;
00165 }
00166
00167 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00168 void AbstractElement<ELEMENT_DIM, SPACE_DIM>::SetRegion(unsigned region)
00169 {
00170 mRegion = region;
00171 }
00172
00173 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00174 unsigned AbstractElement<ELEMENT_DIM, SPACE_DIM>::GetRegion()
00175 {
00176 return mRegion;
00177 }
00178
00179
00181
00183
00184 template class AbstractElement<0,1>;
00185 template class AbstractElement<1,1>;
00186 template class AbstractElement<0,2>;
00187 template class AbstractElement<1,2>;
00188 template class AbstractElement<2,2>;
00189 template class AbstractElement<0,3>;
00190 template class AbstractElement<1,3>;
00191 template class AbstractElement<2,3>;
00192 template class AbstractElement<3,3>;