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.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.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 assert(pOldNode != pNewNode);
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
00087
00088
00089
00090
00091 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00092 c_vector<double, SPACE_DIM> AbstractElement<ELEMENT_DIM, SPACE_DIM>::GetNodeLocation(unsigned localIndex) const
00093 {
00094 assert((unsigned)localIndex < mNodes.size());
00095 return mNodes[localIndex]->rGetLocation();
00096 }
00097
00098 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00099 unsigned AbstractElement<ELEMENT_DIM, SPACE_DIM>::GetNodeGlobalIndex(unsigned localIndex) const
00100 {
00101 assert((unsigned)localIndex < mNodes.size());
00102 return mNodes[localIndex]->GetIndex();
00103 }
00104
00105 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00106 Node<SPACE_DIM>* AbstractElement<ELEMENT_DIM, SPACE_DIM>::GetNode(unsigned localIndex) const
00107 {
00108 assert((unsigned)localIndex < mNodes.size());
00109 return mNodes[localIndex];
00110 }
00111
00112 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00113 unsigned AbstractElement<ELEMENT_DIM, SPACE_DIM>::GetNumNodes() const
00114 {
00115 return mNodes.size();
00116 }
00117
00118 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00119 void AbstractElement<ELEMENT_DIM, SPACE_DIM>::AddNode(Node<SPACE_DIM>* pNode)
00120 {
00121 mNodes.push_back(pNode);
00122 }
00123
00124 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00125 bool AbstractElement<ELEMENT_DIM, SPACE_DIM>::IsDeleted() const
00126 {
00127 return mIsDeleted;
00128 }
00129
00130 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00131 unsigned AbstractElement<ELEMENT_DIM, SPACE_DIM>::GetIndex() const
00132 {
00133 return mIndex;
00134 }
00135
00136 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00137 void AbstractElement<ELEMENT_DIM, SPACE_DIM>::SetIndex(unsigned index)
00138 {
00139 mIndex = index;
00140 }
00141
00142 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00143 bool AbstractElement<ELEMENT_DIM, SPACE_DIM>::GetOwnership() const
00144 {
00145 return mOwnership;
00146 }
00147
00148 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00149 void AbstractElement<ELEMENT_DIM, SPACE_DIM>::SetOwnership(bool ownership)
00150 {
00151 mOwnership = ownership;
00152 }
00153
00154 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00155 void AbstractElement<ELEMENT_DIM, SPACE_DIM>::Flag()
00156 {
00157 mFlag = true;
00158 }
00159
00160 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00161 void AbstractElement<ELEMENT_DIM, SPACE_DIM>::Unflag()
00162 {
00163 mFlag = false;
00164 }
00165
00166 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00167 bool AbstractElement<ELEMENT_DIM, SPACE_DIM>::IsFlagged() const
00168 {
00169 return mFlag;
00170 }
00171
00172 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00173 void AbstractElement<ELEMENT_DIM, SPACE_DIM>::SetRegion(double region)
00174 {
00175 mRegion = region;
00176 }
00177
00178 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00179 double AbstractElement<ELEMENT_DIM, SPACE_DIM>::GetRegion()
00180 {
00181 return mRegion;
00182 }
00183
00184
00186
00188
00189 template class AbstractElement<0,1>;
00190 template class AbstractElement<1,1>;
00191 template class AbstractElement<0,2>;
00192 template class AbstractElement<1,2>;
00193 template class AbstractElement<2,2>;
00194 template class AbstractElement<0,3>;
00195 template class AbstractElement<1,3>;
00196 template class AbstractElement<2,3>;
00197 template class AbstractElement<3,3>;