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 <cassert>
00030
00031 #include "Node.hpp"
00032 #include "Exception.hpp"
00033
00035
00037
00038 template<unsigned SPACE_DIM>
00039 void Node<SPACE_DIM>::CommonConstructor(unsigned index, bool isBoundaryNode)
00040 {
00041 mIndex = index;
00042 mIsBoundaryNode = isBoundaryNode;
00043 mIsInternal = false;
00044 mIsDeleted = false;
00045 mRegion = 0;
00046 }
00047
00048 template<unsigned SPACE_DIM>
00049 Node<SPACE_DIM>::Node(unsigned index, ChastePoint<SPACE_DIM> point, bool isBoundaryNode)
00050 {
00051 mLocation = point.rGetLocation();
00052 CommonConstructor(index, isBoundaryNode);
00053 }
00054
00055 template<unsigned SPACE_DIM>
00056 Node<SPACE_DIM>::Node(unsigned index, std::vector<double> coords, bool isBoundaryNode)
00057 {
00058 for (unsigned i=0; i<SPACE_DIM; i++)
00059 {
00060 mLocation(i) = coords.at(i);
00061 }
00062 CommonConstructor(index, isBoundaryNode);
00063 }
00064
00065 template<unsigned SPACE_DIM>
00066 Node<SPACE_DIM>::Node(unsigned index, c_vector<double, SPACE_DIM> location, bool isBoundaryNode)
00067 {
00068 mLocation = location;
00069 CommonConstructor(index, isBoundaryNode);
00070 }
00071
00072 template<unsigned SPACE_DIM>
00073 Node<SPACE_DIM>::Node(unsigned index, bool isBoundaryNode, double v1, double v2, double v3)
00074 {
00075 mLocation[0] = v1;
00076 if (SPACE_DIM > 1)
00077 {
00078 mLocation[1] = v2;
00079 if (SPACE_DIM > 2)
00080 {
00081 mLocation[2] = v3;
00082 }
00083 }
00084 CommonConstructor(index, isBoundaryNode);
00085 }
00086 template<unsigned SPACE_DIM>
00087 Node<SPACE_DIM>::Node(unsigned index, double *location, bool isBoundaryNode)
00088 {
00089 for (unsigned i=0; i<SPACE_DIM; i++)
00090 {
00091 mLocation(i) = location[i];
00092 }
00093 CommonConstructor(index, isBoundaryNode);
00094
00095 }
00097
00099
00100 template<unsigned SPACE_DIM>
00101 void Node<SPACE_DIM>::SetPoint(ChastePoint<SPACE_DIM> point)
00102 {
00103 mLocation = point.rGetLocation();
00104 }
00105
00106 template<unsigned SPACE_DIM>
00107 void Node<SPACE_DIM>::SetIndex(unsigned index)
00108 {
00109 mIndex = index;
00110 }
00111
00112 template<unsigned SPACE_DIM>
00113 void Node<SPACE_DIM>::SetAsBoundaryNode(bool value)
00114 {
00115 mIsBoundaryNode = value;
00116 }
00117
00118
00119 template<unsigned SPACE_DIM>
00120 ChastePoint<SPACE_DIM> Node<SPACE_DIM>::GetPoint() const
00121 {
00122 return ChastePoint<SPACE_DIM>(mLocation);
00123 }
00124
00125 template<unsigned SPACE_DIM>
00126 const c_vector<double, SPACE_DIM>& Node<SPACE_DIM>::rGetLocation() const
00127 {
00128 assert(!mIsDeleted);
00129 return mLocation;
00130 }
00131
00132 template<unsigned SPACE_DIM>
00133 c_vector<double, SPACE_DIM>& Node<SPACE_DIM>::rGetModifiableLocation()
00134 {
00135 assert(!mIsDeleted);
00136 return mLocation;
00137 }
00138
00139 template<unsigned SPACE_DIM>
00140 unsigned Node<SPACE_DIM>::GetIndex() const
00141 {
00142 return mIndex;
00143 }
00144
00145 template<unsigned SPACE_DIM>
00146 bool Node<SPACE_DIM>::IsBoundaryNode() const
00147 {
00148 return mIsBoundaryNode;
00149 }
00150
00151
00152
00154
00156
00157 template<unsigned SPACE_DIM>
00158 void Node<SPACE_DIM>::AddElement(unsigned index)
00159 {
00160 mElementIndices.insert(index);
00161 }
00162
00163 template<unsigned SPACE_DIM>
00164 void Node<SPACE_DIM>::RemoveElement(unsigned index)
00165 {
00166 unsigned count = mElementIndices.erase(index);
00167 if (count == 0)
00168 {
00169 EXCEPTION("Tried to remove an index which was not in the set");
00170 }
00171 }
00172
00173 template<unsigned SPACE_DIM>
00174 void Node<SPACE_DIM>::RemoveBoundaryElement(unsigned index)
00175 {
00176 unsigned count = mBoundaryElementIndices.erase(index);
00177 if (count == 0)
00178 {
00179 EXCEPTION("Tried to remove an index which was not in the set");
00180 }
00181 }
00182
00183 template<unsigned SPACE_DIM>
00184 void Node<SPACE_DIM>::AddBoundaryElement(unsigned index)
00185 {
00186 mBoundaryElementIndices.insert(index);
00187 }
00188
00189 template<unsigned SPACE_DIM>
00190 std::set<unsigned>& Node<SPACE_DIM>::rGetContainingElementIndices()
00191 {
00192 return mElementIndices;
00193 }
00194
00195 template<unsigned SPACE_DIM>
00196 std::set<unsigned>& Node<SPACE_DIM>::rGetContainingBoundaryElementIndices()
00197 {
00198 return mBoundaryElementIndices;
00199 }
00200
00201 template<unsigned SPACE_DIM>
00202 unsigned Node<SPACE_DIM>::GetNumContainingElements() const
00203 {
00204 return mElementIndices.size();
00205 }
00206
00207 template<unsigned SPACE_DIM>
00208 unsigned Node<SPACE_DIM>::GetNumBoundaryElements() const
00209 {
00210 return mBoundaryElementIndices.size();
00211 }
00212
00214
00216
00217 template<unsigned SPACE_DIM>
00218 void Node<SPACE_DIM>::MarkAsDeleted()
00219 {
00220 mIsDeleted = true;
00221 }
00222
00223 template<unsigned SPACE_DIM>
00224 bool Node<SPACE_DIM>::IsDeleted() const
00225 {
00226 return mIsDeleted;
00227 }
00228
00229 template<unsigned SPACE_DIM>
00230 void Node<SPACE_DIM>::MarkAsInternal()
00231 {
00232 mIsInternal = true;
00233 }
00234
00235 template<unsigned SPACE_DIM>
00236 bool Node<SPACE_DIM>::IsInternal() const
00237 {
00238 return mIsInternal;
00239 }
00240
00241 template<unsigned SPACE_DIM>
00242 void Node<SPACE_DIM>::SetRegion(unsigned region)
00243 {
00244 mRegion = region;
00245 }
00246
00247 template<unsigned SPACE_DIM>
00248 unsigned Node<SPACE_DIM>::GetRegion() const
00249 {
00250 return mRegion;
00251 }
00252
00253
00255
00257
00258 template class Node<1>;
00259 template class Node<2>;
00260 template class Node<3>;