19 #ifdef PZDEBUG_SLOAN_RENUMBERING 21 std::ofstream myfile(
"c:\\Temp\\sloanrenumbering.txt");
25 #ifdef PZDEBUG_SLOAN_RENUMBERING 26 time_t StartTime = time(NULL);
36 #ifdef PZDEBUG_SLOAN_RENUMBERING 38 time_t finalTime = time(NULL);
39 const double elapsedtime = difftime(finalTime, StartTime);
40 myfile <<
"Tempo ConvertGraph = " << elapsedtime <<
"\n";
42 StartTime = time(NULL);
47 const int64_t nnodes = graph.
NNodes();
48 int64_t startNode = -1, endNode = -1;
55 int64_t nelslevel = LevelStructure.
NElements();
56 for(int64_t ilevel = 0; ilevel < nelslevel; ilevel++){
57 int64_t nelsilevel= LevelStructure[ ilevel ].
NElements();
58 for(int64_t iel = 0; iel < nelsilevel; iel++){
59 const int64_t node = LevelStructure[ ilevel ][ iel ];
60 DistanceToEndNode[ node ] = ilevel;
64 for(int64_t i = 0; i < DistanceToEndNode.
NElements(); i++){
65 if(DistanceToEndNode[i] == -1){
73 int64_t maxpriority = 0;
75 for(int64_t i = 0; i < nnodes; i++){
77 priority[i] = this->
W1()*DistanceToEndNode[i] - this->
W2()*(degree+1);
78 maxpriority =
MAX(maxpriority,priority[i]);
94 maxpriority =
MAX(maxpriority,priority[currnode]);
99 for(int64_t jadj = 0; jadj < nadjNodes; jadj++){
100 const int64_t adjNode = adjNodePtr[jadj];
101 priority[ adjNode ] += this->
W2();
104 maxpriority =
MAX(maxpriority,priority[adjNode]);
115 for(int64_t jadj = 0; jadj < nadjNodes; jadj++){
116 const int64_t adjNode = adjNodePtr[jadj];
119 priority[ adjNode ] += this->
W2();
120 maxpriority =
MAX(maxpriority,priority[adjNode]);
123 for(int64_t k = 0; k < nadjNodes2J; k++){
124 const int64_t knode = adjNode2JPtr[k];
126 int pr = priority[knode];
127 priority[knode] = pr+this->
W2();
128 maxpriority =
MAX(maxpriority,priority[knode]);
139 std::cout << R.
NElements() <<
"\tQ.size = " << Q.
fSize <<
", %done = " << 100.*R.
NElements()/nnodes <<
" maxpriority = " << maxpriority <<
"\n";
144 std::cout <<
"TPZSloanRenumbering::Resequence error! Not all nodes were processed.\n" 145 <<
"It may be an implementation bug or simply a graph with independent nodes\n" 146 <<
"as if the mesh has subdomains that are not connected.\n" 147 <<
"For the later, use CuttHillMcKee, which is prepared for this particular case\n";
153 std::set<int64_t> check;
154 for(int64_t i = 0; i < nnodes; i++) check.insert(R[i]);
155 if( ((int64_t)(check.size())) != nnodes)
DebugStop();
160 permGather.
Resize(nnodes);
161 for(int64_t i = 0; i < nnodes; i++) permGather[ permScatter[i] ] = i;
163 #ifdef PZDEBUG_SLOAN_RENUMBERING 165 time_t finalTime = time(NULL);
166 const double elapsedtime = difftime(finalTime, StartTime);
167 myfile <<
"Tempo restante = " << elapsedtime <<
"\n\n\n";
169 StartTime = time(NULL);
178 int64_t result = Q.
fList[0];
179 int64_t nodepriority = priority[result];
181 for(int64_t i = 1; i < Q.
fSize; i++){
182 const int64_t lcnode = Q.
fList[i];
183 if(priority[lcnode] > nodepriority){
185 nodepriority = priority[lcnode];
203 const int64_t nnodes = graph.
NNodes();
206 for (int64_t i=0; i<nnodes; i++) {
211 int64_t startNode = -1, endNode = -1;
218 for(int64_t ilevel = 0; ilevel < LevelStructure.
NElements(); ilevel++){
219 for(int64_t iel = 0; iel < LevelStructure[ ilevel ].
NElements(); iel++){
220 const int64_t node = LevelStructure[ ilevel ][ iel ];
221 DistanceToEndNode[ node ] = ilevel;
225 for(int64_t i = 0; i < DistanceToEndNode.
NElements(); i++){
226 if(DistanceToEndNode[i] == -1){
234 for(int64_t i = 0; i < nnodes; i++){
236 fAllNodes[i].fPriority = this->
W1()*DistanceToEndNode[i] - this->
W2()*(degree+1);
239 int64_t countnumbered = 0;
240 int64_t numactive = 1;
253 for(int64_t jadj = 0; jadj < nadjNodes; jadj++){
254 const int64_t adjNode = adjNodePtr[jadj];
263 int priority =
fAllNodes[adjNode].fPriority;
264 priority += this->
W2();
276 for(int64_t jadj = 0; jadj < nadjNodes; jadj++){
277 const int64_t adjNode = adjNodePtr[jadj];
280 int priority =
fAllNodes[adjNode].fPriority;
281 priority += this->
W2();
285 for(int64_t k = 0; k < nadjNodes2J; k++){
286 const int64_t knode = adjNode2JPtr[k];
288 int priority =
fAllNodes[knode].fPriority;
289 priority += this->
W2();
305 if(countnumbered % 1000000 == 0){
306 std::cout << countnumbered <<
"\tActive size = " << numactive <<
", %done = " << 100.*countnumbered/nnodes <<
"\n";
310 std::cout <<
"number of elements sequenced " << countnumbered << std::endl;
int64_t NElements() const
Number of computational elements allocated.
virtual ~TPZSloanRenumbering()
std::map< int, TNo * > fActive
int64_t FindHighestPriority(const SList &Q, const TPZVec< int64_t > &priority, int64_t &Qindex) const
TPZManVector< int64_t > fnodegraph
void ConvertGraph(TPZVec< int64_t > &elgraph, TPZVec< int64_t > &elgraphindex, TPZManVector< int64_t > &nodegraph, TPZManVector< int64_t > &nodegraphindex)
Will convert an element graph defined by elgraph and elgraphindex into a node graph defined by nodegr...
virtual void Resequence2(TPZVec< int64_t > &permGather, TPZVec< int64_t > &permScatter)
void degree(int root, int adj_num, int adj_row[], int adj[], int mask[], int deg[], int *iccsze, int ls[], int node_num)
int64_t Degree(int64_t node)
#define MAX(a, b)
Gets maxime value between a and b.
TNo * PopHighestPriorityNode()
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
void RootedLevelStructure(int64_t rootNode, TPZStack< TPZStack< int64_t > > &LevelStructure)
TPZVec< int64_t > fElementGraphIndex
Indicates for each element the index of the first entry with fElementGraph for that element The size ...
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
void Push(const T object)
Pushes a copy of the object on the stack.
This abstract class which defines the behavior which derived classes need to implement for implement...
#define DebugStop()
Returns a message to user put a breakpoint in.
void remove(int64_t index)
void TransferPriority(TNo *no, int newpriority)
void InsertNode(TNo *node)
virtual void Resequence(TPZVec< int64_t > &permGather, TPZVec< int64_t > &permScatter)
void Shrink()
It reallocates storage to fit the necessary storage exactly.
bool push_back(int64_t val)
TPZVec< int64_t > fElementGraph
Node number of each element.
TPZManVector< int64_t > fnodegraphindex
This class implements a stack object. Utility.
int64_t * AdjacentNodesPtr(int64_t parent, int64_t &n)
int64_t NElements() const
Returns the number of elements of the vector.
void PseudoPeripheralNodes(int64_t &startNode, int64_t &endNode)