27 static LoggerPtr logger(Logger::getLogger(
"pz.mesh.nodesetcompute"));
60 for(in=0; in<nnodes; in++)
69 std::cout << std::endl;
80 if(! nodeset[node].size())
83 nodeset[node].insert(node);
86 std::set<int64_t>::iterator it;
88 for(it = nodeset[node].begin(); it != nodeset[node].end(); it++)
90 int64_t othernode = *it;
91 if(othernode == node)
continue;
93 if(! nodeset[othernode].size())
96 nodeset[othernode].insert(othernode);
99 bool inc = includes(nodeset[node].begin(),nodeset[node].end(),nodeset[othernode].begin(),nodeset[othernode].end());
101 bool diff = nodeset[node] != nodeset[othernode];
108 minlevel = minlevel <
fLevel[othernode]+1 ?
fLevel[othernode]+1 : minlevel;
110 if(
fLevel[othernode] >= 0)
112 std::stringstream sout;
113 sout <<
"The level of " << node <<
" is increased because of " << othernode <<
" ";
114 sout <<
"Level of othernode " <<
fLevel[othernode] <<
" Seqnumber othernode " <<
fSeqNumber[othernode];
126 equalnodes.
Push(othernode);
129 if(inc && diff &&
fSeqNumber[othernode] != -1)
132 minlevel = minlevel <
fLevel[othernode]+1 ?
fLevel[othernode]+1 : minlevel;
133 }
else if(!diff &&
fSeqNumber[othernode] != -1)
136 minlevel = minlevel <
fLevel[othernode] ?
fLevel[othernode] : minlevel;
146 std::stringstream sout;
147 sout <<
"Assigning Seq Number " <<
fMaxSeqNum <<
" and level " << minlevel <<
" to nodes " << node <<
" " << equalnodes;
156 nodeset[node].erase(node);
159 for(it = nodeset[node].begin(); it != nodeset[node].end(); it++)
161 int64_t othernode = *it;
162 int level =
fLevel[othernode];
164 if(seq != -1 && level <= minlevel)
166 nodeset[othernode].
clear();
167 if(othernode == node)
175 nodeset[node].clear();
179 for(ieq=0; ieq<neq; ieq++)
182 fLevel[equalnodes[ieq]] = minlevel;
184 nodeset[equalnodes[ieq]].
clear();
194 blockgraph.
Resize(nnodes);
196 blockgraphindex[0] = 0;
197 blockgraphindex[1] = 0;
200 blockgraphindex[seq] = blockgraphindex[seq-1]+
fSeqCard[seq-2];
203 for(in = 0; in< nnodes; in++)
206 blockgraph[blockgraphindex[seqn+1]] = in;
207 blockgraphindex[seqn+1]++;
213 std::map<int64_t,int64_t> vertices;
216 for(in=0; in<nnodes; in++)
220 int64_t nvert = vertices.size();
221 blockgraphindex.
Resize(nvert+1);
222 blockgraphindex[0] = 0;
224 std::map<int64_t,int64_t>::iterator it;
225 for(it=vertices.begin(); it != vertices.end(); it++)
227 int node = (*it).second;
228 blockgraph.
Push(node);
229 std::set<int64_t> vertexset;
230 std::set<int> included;
231 std::set<int> notincluded;
234 included.insert((*it).first);
235 std::set<int64_t>::iterator versetit;
236 for(versetit = vertexset.begin(); versetit != vertexset.end(); versetit++)
238 int64_t linkednode = *versetit;
239 if(linkednode == node)
continue;
244 if(included.count(seq))
246 blockgraph.
Push(linkednode);
250 else if(notincluded.count(seq))
257 std::set<int64_t> locset;
260 if(includes(vertexset.begin(),vertexset.end(),locset.begin(),locset.end()))
262 included.insert(seq);
263 blockgraph.
Push(linkednode);
268 notincluded.insert(seq);
272 blockgraphindex[iv] = blockgraph.
NElements();
281 nodeset.insert(node);
291 if(!vertices.size())
return;
292 std::set<int64_t> elem;
293 std::set<int64_t>::iterator intit,diffit;
295 std::stringstream sout;
296 sout << __PRETTY_FUNCTION__ <<
" Original set of nodes ";
297 Print(sout,vertices,0);
300 for(intit = vertices.begin(); intit != vertices.end(); intit++)
302 std::set<int64_t> locset,diffset,interset,unionset,loclocset;
306 if(*locset.begin() < *vertices.begin())
continue;
308 set_difference(vertices.begin(),vertices.end(),locset.begin(),locset.end(),inserter(diffset,diffset.begin()));
314 std::stringstream sout;
315 sout <<
"Difference after taking the intersection with " << *intit;
316 Print(sout,diffset,
" Difference set");
321 for(diffit=diffset.begin(); diffit!= diffset.end(); diffit++)
327 if(*loclocset.begin() < *vertices.begin())
continue;
328 unionset.insert(loclocset.begin(),loclocset.end());
333 set_intersection(unionset.begin(),unionset.end(),vertices.begin(),vertices.end(),inserter(diffset,diffset.begin()));
336 std::stringstream sout;
337 Print(sout,diffset,
"First set to be reanalised");
341 set_intersection(vertices.begin(),vertices.end(),locset.begin(),locset.end(),inserter(interset,interset.begin()));
344 std::stringstream sout;
345 Print(sout,interset,
"Second set to be reanalised");
355 intit = vertices.begin();
360 for(;intit != vertices.end(); intit++)
362 std::set<int64_t> locset,interset;
364 set_intersection(elem.begin(),elem.end(),locset.begin(),locset.end(),inserter(interset,interset.begin()));
371 std::stringstream sout;
372 sout <<
"Discarding a vertex set as incomplete";
373 Print(sout,vertices,0);
382 std::stringstream sout;
383 Print(sout,elem,
"Inserted element");
387 elements.insert(elem);
395 std::stringstream sout;
396 sout << __PRETTY_FUNCTION__ <<
" entering build element graph\n";
401 blockgraphindex.
Resize(1);
402 blockgraphindex[0] = 0;
405 std::set<int64_t> nodeset;
406 for(in=0; in<nnodes; in++)
408 std::set< std::set<int64_t> > elements;
412 std::stringstream sout;
413 sout <<
"Nodeset for " << in <<
' ';
414 Print(sout,nodeset,
"Nodeset");
421 std::stringstream sout;
422 Print(sout,nodeset,
"LowerNodes result");
427 std::set< std::set<int64_t> >::iterator itel;
428 for(itel = elements.begin(); itel != elements.end(); itel++)
430 std::set<int64_t>::const_iterator it;
431 for(it = (*itel).begin(); it!= (*itel).end(); it++)
433 blockgraph.
Push(*it);
442 std::set<int64_t> lownode,lownodeset,unionset;
443 std::set<int64_t>::iterator it;
446 std::stringstream sout;
447 sout << __PRETTY_FUNCTION__;
448 Print(sout,nodeset,
" Incoming nodeset");
452 for(it=nodeset.begin(); it != nodeset.end() && *it < node; it++)
455 unionset.insert(lownodeset.begin(),lownodeset.end());
458 set_difference(nodeset.begin(),nodeset.end(),unionset.begin(),unionset.end(),
459 inserter(lownode,lownode.begin()));
462 std::stringstream sout;
463 Print(sout,lownode,
" What is left after substracting the influence of lower numbered nodes ");
468 for(it=lownode.begin(); it!=lownode.end(); it++)
471 unionset.insert(lownodeset.begin(),lownodeset.end());
475 set_intersection(unionset.begin(),unionset.end(),nodeset.begin(),nodeset.end(),
476 inserter(lownode,lownode.begin()));
479 std::stringstream sout;
480 Print(sout,lownode,
" Resulting lower nodeset");
489 file <<
"TPZNodesetCompute\n";
490 file <<
"Node graph\n";
492 file <<
"Node sequence number and level\n";
495 for(in=0; in<nnode; in++) file << in <<
"/" <<
fSeqNumber[in] <<
"/" <<
fLevel[in] <<
" ";
501 int64_t nnode = graphindex.
NElements()-1;
503 for(in =0; in<nnode; in++)
505 file <<
"Node Number " << in;
506 int64_t
first = graphindex[in];
507 int64_t last = graphindex[in+1];
509 for(jn = first; jn< last; jn++) file <<
" " << graph[jn];
516 if(text) file << text;
517 std::set<int64_t>::const_iterator it;
518 for(it=nodeset.begin(); it!=nodeset.end(); it++) file << *it <<
' ';
528 int64_t expgraphsize = 0;
532 for(ibl=0; ibl<nbl; ibl++)
534 expgraphsize += block.
Size(graph[ibl]);
536 expgraph.
Resize(expgraphsize);
538 int64_t numblocks = graphindex.
NElements()-1;
539 expgraphindex[0] = counter;
540 int64_t blcounter = 0;
541 for(ibl=0; ibl < numblocks; ibl++)
543 int64_t
first = graphindex[ibl];
544 int64_t last = graphindex[ibl+1];
546 for(ieq = first; ieq<last; ieq++)
548 int64_t blsize = block.
Size(graph[ieq]);
549 int64_t pos = block.
Position(graph[ieq]);
551 for(b=0; b<blsize; b++)
553 expgraph[counter++] = pos+b;
556 if(expgraphindex[blcounter] != counter) expgraphindex[++blcounter] = counter;
558 expgraphindex.
Resize(blcounter+1);
569 bool hasuncolored =
true;
570 int64_t nblocks = graphindex.
NElements()-1;
575 hasuncolored =
false;
578 for(ibl=0; ibl<nblocks; ibl++)
580 if(colors[ibl] != -1)
continue;
581 int64_t
first = graphindex[ibl];
582 int64_t last = graphindex[ibl+1];
584 for(ieq=first; ieq<last; ieq++)
586 if(eqcolor[graph[ieq]] == color)
break;
595 for(ieq=first; ieq<last; ieq++)
597 eqcolor[graph[ieq]] = color;
void AnalyseNode(int64_t node, TPZVec< std::set< int64_t > > &nodeset)
This method will analyse the set inclusion of the current node, calling the method recursively if an...
void AnalyseGraph()
Group the node graph as passed by the parameters.
int Position(const int block_diagonal) const
Returns the position of first element block dependent on matrix diagonal.
void Print(std::ostream &file) const
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
TPZManVector< int64_t > fNodegraphindex
This class implements a simple vector storage scheme for a templated class T. Utility.
static int ColorGraph(TPZVec< int64_t > &graph, TPZVec< int64_t > &graphindex, int64_t neq, TPZVec< int > &colors)
Color the graph into mutually independent blocks.
TPZVec< int > fLevel
Inclusion relation ship between nodes.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
void BuildNodeGraph(TPZVec< int64_t > &blockgraph, TPZVec< int64_t > &blockgraphindex)
Build the graph which groups the equations of each node.
void BuildNodeSet(int64_t node, std::set< int64_t > &nodeset)
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...
TPZStack< int64_t > fSeqCard
Number of nodes associated with each sequence number.
TPZManVector< int64_t > fNodegraph
The node graph as passed on by the finite element mesh His node graph is organized by sequence numbe...
void Push(const T object)
Pushes a copy of the object on the stack.
#define DebugStop()
Returns a message to user put a breakpoint in.
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
virtual void clear()
Empty the vector, make its size zero.
#define LOGPZ_ERROR(A, B)
Define log for errors (cout)
void BuildVertexGraph(TPZStack< int64_t > &blockgraph, TPZVec< int64_t > &blockgraphindex)
build the graph which builds the equations linked to vertices
int64_t fMaxSeqNum
Counter for the condensed node graph.
TPZVec< int64_t > fSeqNumber
Sequence number associated with each node after condensing.
void BuildElementGraph(TPZStack< int64_t > &blockgraph, TPZStack< int64_t > &blockgraphindex)
Build the graph which groups the equations grouped by elements.
TPZVec< int > fIsIncluded
Vector indicating whether a node connectivity is included in another one.
void AnalyseForElements(std::set< int64_t > &vertices, std::set< std::set< int64_t > > &elements)
Look for elements formed by vertices, intersecting with the intersectvertices, one by one...
void SubstractLowerNodes(int64_t node, std::set< int64_t > &nodeset)
working a set of vertex nodes with nodes which have to be intersected (tested)
static void ExpandGraph(TPZVec< int64_t > &graph, TPZVec< int64_t > &graphindex, TPZBlock< STATE > &block, TPZVec< int64_t > &expgraph, TPZVec< int64_t > &expgraphindex)
Expand the graph acording to the block structure.
int Size(const int block_diagonal) const
Returns block dimension.
void Fill(const T ©, const int64_t from=0, const int64_t numelem=-1)
Will fill the elements of the vector with a copy object.
int64_t NElements() const
Returns the number of elements of the vector.
Contains the TPZNodesetCompute class which computes the cardinality of a nodegraph.