NeoPZ
TPZRenumbering.cpp
Go to the documentation of this file.
1 
6 #include "TPZRenumbering.h"
7 #include "pzvec.h"
8 #include "pzerror.h"
9 #include "pzstack.h"
10 #include <map>
11 #include <set>
12 #include <algorithm>
13 #include "pzlog.h"
14 #include <algorithm>
15 
16 #include "TPZTimer.h"
17 #include "Hash/TPZHash.h"
18 #include "TPZStream.h"
19 #include "pzcmesh.h"
20 #include "pzcompel.h"
21 #include "TPZThreadPool.h"
22 
23 #ifdef LOG4CXX
24 static LoggerPtr logger(Logger::getLogger("pz.renumbering"));
25 #endif
26 
27 using namespace std;
28 
29 void TPZRenumbering::NodeToElGraph(TPZVec<int64_t> &elgraph, TPZVec<int64_t> &elgraphindex, TPZVec<int64_t> &nodtoelgraph, TPZVec<int64_t> &nodtoelgraphindex) {
30 
31  TPZVec<int64_t> nelcon(fNNodes+1,0);
32  int64_t nod,last = elgraphindex[fNElements];
33  for(nod = 0; nod<last; nod++) {
34  nelcon[elgraph[nod]]++;
35  }
36  nodtoelgraphindex = nelcon;
37 
38  for(nod=fNNodes; nod>0; nod--) nodtoelgraphindex[nod] = nodtoelgraphindex[nod-1];
39  nodtoelgraphindex[0] = 0;
40  for(nod=1;nod<=fNNodes;nod++) nodtoelgraphindex[nod] += nodtoelgraphindex[nod-1];
41 
42  nodtoelgraph.Resize(nodtoelgraphindex[fNNodes]);
43  nodtoelgraph.Fill (-1);
44 
45  TPZVec<int64_t> nodtoelgraphposition(nodtoelgraphindex);
46 
47  int64_t el;
48  for(el=0; el<fNElements; el++) {
49  int64_t firstnode = elgraphindex[el];
50  int64_t lastnode = elgraphindex[el+1];
51  for(nod=firstnode;nod<lastnode;nod++) {
52  int64_t gnod = elgraph[nod];
53  nodtoelgraph[nodtoelgraphposition[gnod]] = el;
54  nodtoelgraphposition[gnod]++;
55 #ifdef PZDEBUG
56  if (nodtoelgraphposition[gnod] > nodtoelgraphindex[gnod+1]) {
57  PZError << __PRETTY_FUNCTION__ << " wrong data structure\n";
58  }
59 #endif
60  /*
61  int firstel= nodtoelgraphindex[gnod];
62  int lastel = nodtoelgraphindex[gnod+1];
63  while(firstel<lastel && nodtoelgraph[firstel] != -1) firstel++;
64  if(firstel == lastel) {
65  PZError << "TPZCompMesh::ComputeConnecttoElGraph wrong data structure\n";
66  continue;
67  } else {
68  nodtoelgraph[firstel] = el;
69  }
70  */
71  }
72  }
73 }
74 
76  TPZTimer convert("Converting graph ");
77  convert.start();
78  int64_t nod, el;
79  TPZVec<int64_t> nodtoelgraphindex;
80  TPZVec<int64_t> nodtoelgraph;
81 
82  NodeToElGraph(elgraph, elgraphindex, nodtoelgraph, nodtoelgraphindex);
83 
84  nodegraphindex.Resize(fNNodes + 1);
85  nodegraphindex.Fill(0);
86 
87  int64_t nodegraphincrement = 100000;
88  nodegraph.Resize(nodegraphincrement);
89  int64_t nextfreeindex = 0;
90  for (nod = 0; nod < fNNodes; nod++) {
91  int64_t firstel = nodtoelgraphindex[nod];
92  int64_t lastel = nodtoelgraphindex[nod + 1];
93  std::set<int64_t> nodecon;
94  for (el = firstel; el < lastel; el++) {
95  int64_t gel = nodtoelgraph[el];
96  int64_t firstelnode = elgraphindex[gel];
97  int64_t lastelnode = elgraphindex[gel + 1];
98  nodecon.insert(&elgraph[firstelnode], &elgraph[(lastelnode - 1)] + 1);
99  }
100  nodecon.erase(nod);
101  while (nextfreeindex + nodecon.size() >= nodegraph.size()) nodegraph.Resize(nodegraph.NElements() + nodegraphincrement,0);
102  std::set<int64_t>::iterator it;
103  for (it = nodecon.begin(); it != nodecon.end(); it++) nodegraph[nextfreeindex++] = *it;
104 
105  nodegraphindex[nod + 1] = nextfreeindex;
106  }
107  convert.stop();
108  // std::cout << convert.processName().c_str() << convert << std::endl;
109 }
110 
111 TPZRenumbering::TPZRenumbering(int64_t NElements, int64_t NNodes){
112  fNElements = NElements;
113  fNNodes = NNodes;
114 }
115 
117  return Hash("TPZRenumbering");
118 }
119 
120 void TPZRenumbering::Read(TPZStream& buf, void* context) {
121  buf.Read(&fHDivPermute);
122  buf.Read(&fNElements);
123  buf.Read(&fNNodes);
124  buf.Read(fNodeWeights);
125  buf.Read(fElementGraph);
126  buf.Read(fElementGraphIndex);
127 }
128 
129 void TPZRenumbering::Write(TPZStream& buf, int withclassid) const {
130  buf.Write(&fHDivPermute);
131  buf.Write(&fNElements);
132  buf.Write(&fNNodes);
133  buf.Write(fNodeWeights);
134  buf.Write(fElementGraph);
135  buf.Write(fElementGraphIndex);
136 }
137 
138 int64_t TPZRenumbering::ColorNodes(TPZVec<int64_t> &nodegraph, TPZVec<int64_t> &nodegraphindex, TPZVec<int> &family, TPZVec<int> &colors) {
139  TPZStack<int> usedcolors;
140  TPZStack<int64_t> ncolorsbyfamily;
141  if (nodegraph.NElements() - 1 != family.NElements()) {
142  cout << "TPZRenumbering::ColorNodes inconsistent input parameters" << std::endl;
143  DebugStop();
144  }
145  int64_t nnodes = nodegraphindex.NElements() - 1;
146  colors.Resize(nnodes);
147  colors.Fill(-1);
148  int current_family = 0;
149  int64_t nodeshandled = 0;
150  int64_t ncolors = 0;
151  while (nodeshandled < nnodes) {
152  int64_t nod;
153  current_family = 0;
154  usedcolors.Resize(0);
155  for (nod = 0; nod < nnodes; nod++) {
156  int64_t firstnod = nodegraphindex[nod];
157  int64_t lastnod = nodegraphindex[nod + 1];
158  usedcolors.Fill(-1);
159  for (int64_t ind = firstnod; ind < lastnod; ind++) {
160  int64_t nodcon = nodegraph[ind];
161  if (family[nodcon] != current_family) continue;
162  if (colors[nodcon] != -1) usedcolors[colors[nodcon]] = 1;
163  }
164  int64_t ic;
165  for (ic = 0; ic < usedcolors.NElements(); ic++){
166  if (usedcolors[ic] != 1){
167  break;
168  }
169  }
170  if (ic == usedcolors.NElements()) {
171  usedcolors.Push(1);
172  }
173  colors[nod] = ic;
174  nodeshandled++;
175  }
176  ncolorsbyfamily.Push(usedcolors.NElements());
177  ncolors += usedcolors.NElements();
178  current_family++;
179  }
180  return ncolors;
181 }
182 
183 int64_t TPZRenumbering::ColorElements(const TPZCompMesh *cmesh, const TPZVec<int64_t> &elementIndices, TPZVec<int64_t> &elementColors) {
184  const int64_t n_connects = cmesh->NConnects();
185  const int64_t nel = cmesh->NElements();
186  const int64_t nel_to_be_colored = elementIndices.size();
187 
188  if (nel == 0 || nel_to_be_colored == 0) return 0;
189 
190  elementColors.Resize(nel_to_be_colored);
191  elementColors.Fill(-1);
192  int64_t n_colors = 0;
193  int64_t next_color_initial_index = 0;
194  std::function<void(int64_t,int64_t,TPZTaskGroup *)> color = [n_connects, nel_to_be_colored, &elementIndices, &elementColors, cmesh, &color, &n_colors, &next_color_initial_index](int64_t initial_index, int64_t currentColor, TPZTaskGroup *group) {
195  // determines whether each connect is in an element which has this color
196  TPZStack<int64_t> connects_this_color;
197  bool created_new_color = false; // flag: in the case we find an uncolored element
198  // that cannot be colored with this color, we should use another color,
199  // but just for the first element we find.
200  for (int64_t iel = initial_index; iel < nel_to_be_colored; ++iel) {
201  auto elindex = elementIndices[iel];
202  // if this element hasn't been computed in a previous pass
203  if (elementColors[iel] == -1) {
204  auto cel = cmesh->Element(elindex);
205  if (!cel) continue;
206  TPZStack<int64_t> connectlist;
207  cel->BuildConnectList(connectlist);
208  bool skip_element = false;
209  for (auto connect : connectlist) {
210  if (std::find(connects_this_color.begin(), connects_this_color.end(), connect) != connects_this_color.end()) {
211  skip_element = true;
212  break;
213  }
214  }
215  if (skip_element){
216  if (!created_new_color) {
217  if (group->Active() < TPZThreadPool::globalInstance().threadCount()){
218  TPZThreadPool::globalInstance().run(1, group, color, iel, n_colors++, group);
219  created_new_color = true;
220  } else {
221  if (next_color_initial_index == -1) {
222  next_color_initial_index = iel;
223  } else {
224  next_color_initial_index = std::min(next_color_initial_index, iel);
225  }
226  }
227  }
228  continue;
229  }
230  for (auto connect : connectlist) {
231  connects_this_color.push_back(connect);
232  }
233  elementColors[iel] = currentColor;
234  }
235  }
236  };
237  do {
238  int64_t initial_index = next_color_initial_index;
239  next_color_initial_index = -1;
240  TPZTaskGroup group;
241  TPZThreadPool::globalInstance().run(1, &group, color, initial_index, n_colors++, &group);
242  group.Wait();
243  } while (next_color_initial_index != -1);
244 #ifdef PZDEBUG
245 #define CHECK_COLORING
246 #ifdef CHECK_COLORING
247  for (unsigned int color = 0; color < n_colors; ++color) {
248  TPZManVector<bool> color_connect(n_connects, false);
249  for (int64_t iel = 0; iel < nel_to_be_colored; ++iel) {
250  auto elindex = elementIndices[iel];
251  if (elementColors[iel] == color) {
252  auto cel = cmesh->Element(elindex);
253  if (!cel) DebugStop(); //colored element is not in the mesh
254  TPZStack<int64_t> connectlist;
255  cel->BuildConnectList(connectlist);
256  for (auto connect : connectlist) {
257  if (color_connect[connect]) { //this connect is in another element of the same color
258  DebugStop();
259  }
260  }
261  for (auto connect : connectlist) {
262  color_connect[connect] = true;
263  }
264  } else if (elementColors[iel] == -1){
265  auto cel = cmesh->Element(elindex);
266  if (cel) DebugStop(); //uncolored element
267  }
268  }
269  }
270 #endif
271 #endif
272  return n_colors;
273 }
274 
275 void TPZRenumbering::Print(TPZVec<int64_t> &graph, TPZVec<int64_t> &graphindex, const char *name, std::ostream& out) {
276  out << "Graph: " << name << endl;
277  for (int64_t i = 0; i < graphindex.NElements() - 1; i++) {
278  out << "Graph item: " << i << "\t";
279  for (int64_t j = graphindex[i]; j < graphindex[i + 1]; j++) {
280  if (j >= graph.NElements()) {
281  out << "wrong graphindex graph.NElements = " << graph.NElements() << " i = " << i << "graphindex[i] = " << graphindex[i] << " " << graphindex[i + 1] << endl;
282  break;
283  } else {
284  out << graph[j] << "\t";
285  }
286  }
287  out << endl;
288  }
289 }
290 
291 #include "pzgeoel.h"
292 #include "pzgnode.h"
293 #include "pzcompel.h"
294 
295 static REAL XMin(TPZGeoEl *gel, const TPZVec<REAL> &normal) {
296 
297  int nnode = gel->NNodes();
298  REAL distmin = 1.e10;
299  if(!nnode) {
300  cout << "Geometric element without nodes??? \n";
301  gel->Print(cout);
302  return distmin;
303  }
304  TPZGeoNode *gn = gel->NodePtr(0);
305  distmin = gn->Coord(0)*normal[0]+ gn->Coord(1)*normal[1]+ gn->Coord(2)*normal[2];
306  int in;
307  for(in=0; in<nnode; in++) {
308  gn=gel->NodePtr(in);
309  REAL dist = gn->Coord(0)*normal[0]+ gn->Coord(1)*normal[1]+ gn->Coord(2)*normal[2];
310  distmin = distmin < dist ? distmin : dist;
311  }
312  return distmin;
313 
314 }
315 void ResequenceByGeometry(TPZCompMesh *cmesh, const TPZVec<REAL> &normal) {
316 
317  TPZCompEl *cel;
318  multimap<REAL, TPZCompEl *> elmap;
319  int64_t nelem = cmesh->ElementVec().NElements();
320  int64_t iel;
321  for(iel=0; iel<nelem; iel++) {
322  cel = cmesh->ElementVec()[iel];
323  if(!cel) continue;
324  TPZGeoEl *gel = cel->Reference();
325  if(!gel) continue;
326  REAL dist = XMin(gel,normal);
327  elmap.insert(pair<REAL,TPZCompEl *>(dist,cel));
328  }
329  TPZVec<int64_t> Permute(cmesh->NConnects(),-1);
330  multimap<REAL, TPZCompEl *>::iterator it;
331  it = elmap.begin();
332  int64_t iseq=0;
333  while(it != elmap.end()) {
334  cel = it->second;
335  int nc = cel->NConnects();
336  int ic;
337  for(ic=0; ic<nc; ic++) {
338  int64_t seqnum = cel->Connect(ic).SequenceNumber();
339  if(Permute[seqnum] == -1) Permute[seqnum] = iseq++;
340  }
341  it++;
342  }
343  cmesh->Permute(Permute);
344  cmesh->CleanUpUnconnectedNodes();
345 
346 }
347 
352  TPZVec<int64_t> &eltoelgraph, TPZVec<int> &eltoelweight, TPZVec<int64_t> &eltoelgraphindex)
353 {
354  TPZVec<int64_t> nodegraph;
355  TPZVec<int64_t> nodegraphindex;
356  LOGPZ_DEBUG(logger, "before NodeToElGraph")
357  NodeToElGraph(elgraph,elgraphindex,nodegraph,nodegraphindex);
358  LOGPZ_DEBUG(logger, "after NodeToElGraph")
359  int64_t nelements = elgraphindex.NElements()-1;
360  eltoelgraphindex.Resize(nelements+1);
361  eltoelgraphindex[0] = 0;
362  eltoelgraph.Resize(1000);
363  eltoelweight.Resize(1000);
364  int64_t iel;
365  for(iel=0; iel<nelements; iel++)
366  {
367  map<int64_t,int> elset;
368  int64_t firstnodeindex = elgraphindex[iel];
369  int64_t lastnodeindex = elgraphindex[iel+1];
370  int64_t nodeindex;
371  for(nodeindex = firstnodeindex; nodeindex< lastnodeindex; nodeindex++)
372  {
373  int64_t node = elgraph[nodeindex];
374  int64_t firstelindex = nodegraphindex[node];
375  int64_t lastelindex = nodegraphindex[node+1];
376  int64_t elindex;
377  for(elindex = firstelindex; elindex < lastelindex; elindex++)
378  {
379  int64_t element = nodegraph[elindex];
380  if(element != iel)
381  {
382  int nweight = 0;
383  if(node < fNodeWeights.NElements()) nweight = fNodeWeights[node];
384  elset[element] += nweight;
385  }
386  }
387  }
388  int64_t eltoelsize = eltoelgraph.NElements();
389  if(eltoelgraphindex[iel]+elset.size() >= eltoelsize)
390  {
391  eltoelgraph.Resize(eltoelsize+elset.size()+1000);
392  eltoelweight.Resize(eltoelgraph.NElements());
393  }
394  int64_t count = eltoelgraphindex[iel];
395  map<int64_t,int>::iterator it;
396  for(it=elset.begin(); it != elset.end(); it++,count++)
397  {
398  eltoelgraph[count] = it->first;
399  eltoelweight[count] = it->second;
400  }
401  eltoelgraphindex[iel+1] = count;
402  }
403  eltoelgraph.Resize(eltoelgraphindex[nelements]);
404  eltoelweight.Resize(eltoelgraph.NElements());
405 }
406 
408 #ifdef SLOANDEBUG
409  Print(elgraph, elgraphindex, "original element graph", cout);
410 #endif
411  fElementGraph = elgraph;
412  fElementGraphIndex = elgraphindex;
413 }
414 
416  fNodeWeights.Resize(0);
417  fElementGraph.Resize(0);
418  fElementGraphIndex.Resize(0);
419 }
420 
424 void TPZRenumbering::CornerEqs(unsigned int mincorners, int64_t nelconsider, std::set<int> &eligible, std::set<int> &cornernodes)
425 {
426 
427  TPZVec<int64_t> nodtoelgraphindex;
428  TPZVec<int64_t> nodtoelgraph;
429  int64_t sub = 0;
430 
431  NodeToElGraph(fElementGraph,fElementGraphIndex,nodtoelgraph,nodtoelgraphindex);
432 
433  int64_t nelem = fElementGraphIndex.NElements()-1;
434  if (nelconsider > nelem) {
435  DebugStop();
436  }
437  int64_t element;
438  for (element=0; element < nelconsider; element++)
439  {
440  int64_t firstindex = fElementGraphIndex[element];
441  int64_t lastindex = fElementGraphIndex[element+1];
442  if (firstindex == lastindex) {
443  continue;
444  }
445  TPZStack<int64_t> corners;
446  std::set<int64_t> elcornernodes;
447  // a vector of sets of element connections for each node
448  // first key : number elements connected to the node
449  // second key : pair of node and set of element indices
450  std::multimap<int64_t,std::pair<int64_t,std::set<int64_t> > > connectivities;
451  typedef std::multimap<int64_t,std::pair<int64_t,std::set<int64_t> > > map_type;
452  int64_t ind;
453  int64_t maxelcon = 0;
454  for (ind=firstindex; ind<lastindex; ind++) {
455  int64_t node = fElementGraph[ind];
456  int64_t firstelind = nodtoelgraphindex[node];
457  int64_t lastelind = nodtoelgraphindex[node+1];
458  std::set<int64_t> elcon;
459  elcon.insert(&nodtoelgraph[firstelind],(&nodtoelgraph[lastelind-1])+1);
460  maxelcon = maxelcon < elcon.size() ? elcon.size() : maxelcon;
461  connectivities.insert(map_type::value_type(elcon.size(), std::pair<int64_t, std::set<int64_t> >(node,elcon)));
462  }
463 
464  map_type::reverse_iterator it = connectivities.rbegin();
465  // put all nodes with maximum connectivities on the stack
466  int64_t maxconnect = it->first;
467  std::pair<map_type::const_iterator, map_type::const_iterator> p = connectivities.equal_range(it->first);
468  map_type::const_iterator ithead;
469  for (ithead = p.first; ithead != p.second; ithead++)
470  {
471  int64_t seqnum = ithead->second.first;
472  if (eligible.find(seqnum) != eligible.end()) {
473  corners.Push(seqnum);
474  cornernodes.insert(seqnum);
475  elcornernodes.insert(seqnum);
476  }
477  }
478 #ifdef LOG4CXX
479  {
480  std::stringstream sout;
481  sout << "Element " << element << " First stage corner nodes " << corners;
482  if (logger->isDebugEnabled())
483  {
484  LOGPZ_DEBUG(logger, sout.str())
485  }
486  }
487 #endif
488  // look the included sets
489  map_type::iterator itf = connectivities.begin();
490  for (itf=connectivities.begin(); itf != connectivities.end(); itf++)
491  {
492  map_type::reverse_iterator it = connectivities.rbegin();
493  while (it->first > itf->first && it!=connectivities.rend())
494  {
495  std::set<int64_t>::iterator smallsetbeg, smallsetend, largesetbeg, largesetend;
496  smallsetbeg = itf->second.second.begin();
497  smallsetend = itf->second.second.end();
498  largesetbeg = it->second.second.begin();
499  largesetend = it->second.second.end();
500 
501  if (includes(largesetbeg,largesetend,smallsetbeg,smallsetend)) {
502  break;
503  }
504  it++;
505  }
506  // the set is not included in any
507  // we allready put the maxconnect nodes on the stack
508  if (it->first == itf->first && it->first != maxconnect) {
509  int64_t seqnum = itf->second.first;
510  if (eligible.find(seqnum) != eligible.end())
511  {
512  corners.Push(seqnum);
513  cornernodes.insert(seqnum);
514  elcornernodes.insert(seqnum);
515  }
516  }
517  }
518 #ifdef LOG4CXX
519  {
520  std::stringstream sout;
521  sout << "Element " << element << " cornernodes.size " << elcornernodes.size() << " Second stage corner nodes " << corners;
522  if (logger->isDebugEnabled())
523  {
524  LOGPZ_DEBUG(logger, sout.str())
525  }
526  }
527 #endif
528  if (elcornernodes.size() < mincorners) {
529  it = connectivities.rbegin();
530  int64_t numelconnected = it->first-1;
531  int64_t ncorners = corners.NElements();
532  while (numelconnected > 1 && ncorners < mincorners) {
533  std::pair<map_type::const_iterator, map_type::const_iterator> p = connectivities.equal_range(numelconnected);
534  map_type::const_iterator ithead;
535  for (ithead = p.first; ithead != p.second; ithead++)
536  {
537  int64_t seqnum = ithead->second.first;
538  if (eligible.find(seqnum) != eligible.end())
539  {
540  corners.Push(seqnum);
541  cornernodes.insert(seqnum);
542  elcornernodes.insert(seqnum);
543  }
544  ncorners = elcornernodes.size();
545  }
546  numelconnected--;
547  }
548  }
549  int64_t ieq;
550  for (ieq=0; ieq<corners.NElements(); ieq++) {
551  if (cornernodes.find(corners[ieq]) == cornernodes.end()) {
552  DebugStop();
553  }
554  }
555 #ifdef LOG4CXX
556  {
557  std::stringstream sout;
558  sout << "Element " << element << " sub " << sub << " Final stage corner nodes " << corners;
559  if (logger->isDebugEnabled())
560  {
561  LOGPZ_DEBUG(logger, sout.str())
562  }
563  }
564 #endif
565 
566  sub++;
567  }
568 }
569 
570 template class TPZRestoreClass<TPZRenumbering>;
int64_t NElements() const
Number of computational elements allocated.
Definition: pzcmesh.h:169
The timer class. Utility.
Definition: TPZTimer.h:46
void SetElementGraph(TPZVec< int64_t > &elgraph, TPZVec< int64_t > &elgraphindex)
This method declares the element graph to the object.
TPZGeoNode * NodePtr(int i) const
Returns a pointer to the ith node of the element.
Definition: pzgeoel.cpp:2566
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.
Timing class. Absolutely copied from GNU time. Take a look at
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...
Contains declaration of TPZGeoNode class which defines a geometrical node.
REAL Coord(int i) const
Returns i-th coordinate of the current node.
Definition: pzgnode.h:99
Contains declaration of TPZCompEl class which defines the interface of a computational element...
Templated vector implementation.
int threadCount() const
Contains the TPZRenumbering class which defines the behavior to implementing node sequence numbering ...
Defines PZError.
static TPZThreadPool & globalInstance()
int64_t NElements() const
Access method to query the number of elements of the vector.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
Definition: pzmanvector.h:426
static TPZGraphNode gn
Definition: pzgraphmesh.cpp:76
int ClassId() const override
Define the class id associated with the class.
std::shared_future< void > run(const int priority, TPZAutoPointer< std::packaged_task< void(void) > > &task, TPZTaskGroup *taskGroup=NULL)
submits a task to be executed by TPZThreadPool
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
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...
Definition: pzvec.h:373
int64_t SequenceNumber() const
Returns the Sequence number of the connect object.
Definition: pzconnect.h:158
void Push(const T object)
Pushes a copy of the object on the stack.
Definition: pzstack.h:80
void start()
Turns the timer on.
Definition: TPZTimer.cpp:28
virtual void Write(const bool val)
Definition: TPZStream.cpp:8
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
void CornerEqs(unsigned int mincorners, int64_t nelconsider, std::set< int > &eligible, std::set< int > &cornernodes)
Analyzes the graph, finds the corner nodes Number of elements which should be considered for determi...
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
Definition: pzlog.h:87
void ConvertToElementoToElementGraph(TPZVec< int64_t > &elgraph, TPZVec< int64_t > &elgraphindex, TPZVec< int64_t > &eltotelgraph, TPZVec< int > &eltoelweight, TPZVec< int64_t > &eltoelgraphindex)
Convert a traditional elgraph to an element to element graph.
void Read(TPZStream &buf, void *context) override
read objects from the stream
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
int64_t NConnects() const
Number of connects allocated including free nodes.
Definition: pzcmesh.h:163
T * begin() const
Casting operator. Returns The fStore pointer.
Definition: pzvec.h:450
Contains declaration of TPZCompMesh class which is a repository for computational elements...
void Print(TPZVec< int64_t > &grapho, TPZVec< int64_t > &graphoindex, const char *name=0, std::ostream &out=std::cout)
Prints graph.
virtual TPZConnect & Connect(int i) const
Returns a pointer to the ith node.
Definition: pzcompel.cpp:298
A simple stack.
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
static int64_t ColorElements(const TPZCompMesh *cmesh, const TPZVec< int64_t > &elementIndices, TPZVec< int64_t > &elementColors)
Assigns a color to the elements in the elementIndices list such that two elements that share a connec...
virtual int NNodes() const =0
Returns the number of nodes of the element.
virtual int NConnects() const =0
Returns the number of nodes of the element.
virtual void ClearDataStructures()
This will reset all datastructures the object may contain.
virtual void CleanUpUnconnectedNodes()
Delete the nodes which have no elements connected to them.
Definition: pzcmesh.cpp:498
REAL dist(TPZVec< T1 > &vec1, TPZVec< T1 > &vec2)
Definition: pzvec_extras.h:124
TPZGeoEl * Reference() const
Return a pointer to the corresponding geometric element if such exists, return 0 otherwise.
Definition: pzcompel.cpp:1137
Implements a geometric node in the pz environment. Geometry.
Definition: pzgnode.h:31
void NodeToElGraph(TPZVec< int64_t > &elgraph, TPZVec< int64_t > &elgraphindex, TPZVec< int64_t > &nodetoelgraph, TPZVec< int64_t > &nodetoelgraphindex)
Stores the graph of nodes to elements.
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
TPZAdmChunkVector< TPZCompEl * > & ElementVec()
Returns a reference to the element pointers vector.
Definition: pzcmesh.h:183
void Fill(const T &copy, const int64_t from=0, const int64_t numelem=-1)
Will fill the elements of the vector with a copy object.
Definition: pzvec.h:460
Contains declaration of the abstract TPZStream class. TPZStream defines the interface for saving and ...
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
void stop()
Turns the timer off, and computes the elapsed time.
Definition: TPZTimer.cpp:36
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
static REAL XMin(TPZGeoEl *gel, const TPZVec< REAL > &normal)
virtual void Print(std::ostream &out=std::cout)
Print all relevant data of the element to cout.
Definition: pzgeoel.cpp:238
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
void push_back(const T object)
Definition: pzstack.h:48
int64_t ColorNodes(TPZVec< int64_t > &nodegraph, TPZVec< int64_t > &nodegraphindex, TPZVec< int > &family, TPZVec< int > &colors)
Will assign a color to the nodes in the graph such that no two connected nodes have the same color th...
void ResequenceByGeometry(TPZCompMesh *cmesh, const TPZVec< REAL > &normal)
Makes resequence to renumbering.
T * end() const
Returns a pointer to the last+1 element.
Definition: pzvec.h:455
Implements an interface to register a class id and a restore function. Persistence.
Definition: TPZSavable.h:150
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15
virtual void Read(bool &val)
Definition: TPZStream.cpp:91
void Permute(TPZVec< int64_t > &permute)
Permute the sequence number of the connect objects It is a permute gather operation.
Definition: pzcmesh.cpp:1321