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 #ifndef _NODE_HPP_
00030 #define _NODE_HPP_
00031
00032 #include "UblasVectorInclude.hpp"
00033
00034 #include <set>
00035 #include <vector>
00036
00037 #include "ChastePoint.hpp"
00038
00039 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00040 class AbstractTetrahedralMesh;
00041
00045 template<unsigned SPACE_DIM>
00046 class Node
00047 {
00048 private:
00049
00051 unsigned mIndex;
00052
00054 unsigned mRegion;
00055
00057 c_vector<double, SPACE_DIM> mLocation;
00058
00060 bool mIsBoundaryNode;
00061
00063 bool mIsInternal;
00064
00069 bool mIsDeleted;
00070
00072 std::set<unsigned> mElementIndices;
00073
00075 std::set<unsigned> mBoundaryElementIndices;
00076
00083 void CommonConstructor(unsigned index, bool isBoundaryNode);
00084
00085 public:
00086
00099 Node(unsigned index, ChastePoint<SPACE_DIM> point, bool isBoundaryNode=false);
00100
00108 Node(unsigned index, std::vector<double> coords, bool isBoundaryNode=false);
00109
00117 Node(unsigned index, c_vector<double, SPACE_DIM> location, bool isBoundaryNode=false);
00118
00128 Node(unsigned index, bool isBoundaryNode=false, double v1=0, double v2=0, double v3=0);
00129
00138 Node(unsigned index, double *location, bool isBoundaryNode=false);
00139
00148 void SetPoint(ChastePoint<SPACE_DIM> point);
00149
00155 void SetIndex(unsigned index);
00156
00162 void SetAsBoundaryNode(bool value=true);
00163
00167 ChastePoint<SPACE_DIM> GetPoint() const;
00168
00175 const c_vector<double, SPACE_DIM>& rGetLocation() const;
00176
00185 c_vector<double, SPACE_DIM>& rGetModifiableLocation();
00186
00190 unsigned GetIndex() const;
00191
00195 bool IsBoundaryNode() const;
00196
00202 void AddElement(unsigned index);
00203
00209 void RemoveElement(unsigned index);
00210
00216 void RemoveBoundaryElement(unsigned index);
00217
00223 void AddBoundaryElement(unsigned index);
00224
00228 std::set<unsigned>& rGetContainingElementIndices();
00229
00233 std::set<unsigned>& rGetContainingBoundaryElementIndices();
00234
00238 unsigned GetNumContainingElements() const;
00239
00243 unsigned GetNumBoundaryElements() const;
00244
00248 void MarkAsDeleted();
00249
00253 bool IsDeleted() const;
00254
00258 void MarkAsInternal();
00259
00263 bool IsInternal() const;
00264
00270 template <unsigned ELEMENT_DIM>
00271 bool IsFlagged(AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>& rMesh)
00272 {
00273 bool in_flagged_element = false;
00274 for (ContainingElementIterator it = ContainingElementsBegin();
00275 it != ContainingElementsEnd();
00276 ++it)
00277 {
00278 if (rMesh.GetElement(*it)->IsFlagged())
00279 {
00280 in_flagged_element = true;
00281 break;
00282 }
00283 }
00284 return in_flagged_element;
00285 }
00286
00292 void SetRegion(unsigned region);
00293
00297 unsigned GetRegion() const;
00298
00302 class ContainingElementIterator
00303 {
00304 public:
00310 ContainingElementIterator(std::set<unsigned>::const_iterator indexIterator)
00311 : mIndexIterator(indexIterator)
00312 {}
00316 const unsigned& operator*() const
00317 {
00318 return *mIndexIterator;
00319 }
00325 bool operator!=(const ContainingElementIterator& rOther) const
00326 {
00327 return mIndexIterator != rOther.mIndexIterator;
00328 }
00334 bool operator==(const ContainingElementIterator& rOther) const
00335 {
00336 return !operator!=(rOther);
00337 }
00341 ContainingElementIterator& operator++()
00342 {
00343 ++mIndexIterator;
00344 return *this;
00345 }
00346 private:
00347 std::set<unsigned>::const_iterator mIndexIterator;
00348 };
00349
00353 ContainingElementIterator ContainingElementsBegin() const
00354 {
00355 return ContainingElementIterator(mElementIndices.begin());
00356 }
00357
00361 ContainingElementIterator ContainingElementsEnd() const
00362 {
00363 return ContainingElementIterator(mElementIndices.end());
00364 }
00365
00369 class ContainingBoundaryElementIterator
00370 {
00371 public:
00377 ContainingBoundaryElementIterator(std::set<unsigned>::const_iterator indexIterator)
00378 : mIndexIterator(indexIterator)
00379 {}
00383 const unsigned& operator*() const
00384 {
00385 return *mIndexIterator;
00386 }
00392 bool operator!=(const ContainingBoundaryElementIterator& rOther) const
00393 {
00394 return mIndexIterator != rOther.mIndexIterator;
00395 }
00401 bool operator==(const ContainingBoundaryElementIterator& rOther) const
00402 {
00403 return !operator!=(rOther);
00404 }
00408 ContainingBoundaryElementIterator& operator++()
00409 {
00410 ++mIndexIterator;
00411 return *this;
00412 }
00413 private:
00414 std::set<unsigned>::const_iterator mIndexIterator;
00415 };
00416
00420 ContainingBoundaryElementIterator ContainingBoundaryElementsBegin() const
00421 {
00422 return ContainingBoundaryElementIterator(mBoundaryElementIndices.begin());
00423 }
00424
00428 ContainingBoundaryElementIterator ContainingBoundaryElementsEnd() const
00429 {
00430 return ContainingBoundaryElementIterator(mBoundaryElementIndices.end());
00431 }
00432 };
00433
00434
00435 #endif //_NODE_HPP_