DistanceMapCalculator.hpp
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 #ifndef DISTANCEMAPCALCULATOR_HPP_
00029 #define DISTANCEMAPCALCULATOR_HPP_
00030
00031 #include <vector>
00032 #include <queue>
00033
00034 #include "UblasIncludes.hpp"
00035 #include "AbstractTetrahedralMesh.hpp"
00036
00044 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00045 class DistanceMapCalculator
00046 {
00047 private:
00048 friend class TestDistanceMapCalculator;
00049
00051 AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>& mrMesh;
00053 unsigned mNumNodes;
00055 unsigned mLo;
00057 unsigned mHi;
00059 bool mWorkOnEntireMesh;
00061 unsigned *mNumHalosPerProcess;
00063 std::vector<unsigned> mHaloNodeIndices;
00065 unsigned mRoundCounter;
00067 unsigned mPopCounter;
00069 unsigned mTargetNodeIndex;
00071 bool mSingleTarget;
00073 c_vector<double, SPACE_DIM> mTargetNodePoint;
00074
00081 std::priority_queue<std::pair<double, unsigned> > mActivePriorityNodeIndexQueue;
00082
00091 bool WorkOnLocalQueue(std::vector<double>& rNodeDistances);
00092
00102 bool UpdateQueueFromRemote(std::vector<double>& rNodeDistances);
00103
00110 void PushLocal(double priority, unsigned nodeIndex)
00111 {
00112
00113 if (mLo<=nodeIndex && nodeIndex<mHi)
00114 {
00115
00116 mActivePriorityNodeIndexQueue.push(std::pair<double, unsigned>(-priority, nodeIndex));
00117 }
00118 }
00119
00120 public:
00121
00127 DistanceMapCalculator(AbstractTetrahedralMesh<ELEMENT_DIM, SPACE_DIM>& rMesh);
00131 ~DistanceMapCalculator()
00132 {
00133 delete [] mNumHalosPerProcess;
00134 }
00135
00145 void ComputeDistanceMap(const std::vector<unsigned>& rSourceNodeIndices,
00146 std::vector<double>& rNodeDistances);
00154 double SingleDistance(unsigned sourceNodeIndex, unsigned destinationNodeIndex);
00155
00156 };
00157
00158 #endif