NeoPZ
TPZCompMeshTools.cpp
Go to the documentation of this file.
1 //
2 // TPZCompMeshTools.cpp
3 // PZ
4 //
5 // Created by Philippe Devloo on 6/4/15.
6 //
7 //
8 
9 #include "TPZCompMeshTools.h"
10 #include "pzelchdiv.h"
11 #include "pzshapepiram.h"
12 #include "TPZOneShapeRestraint.h"
13 #include "pzshapetriang.h"
14 #include "pzshapetetra.h"
15 #include "pzelementgroup.h"
16 #include "pzsubcmesh.h"
17 #include "pzcondensedcompel.h"
18 #include "pzmultiphysicselement.h"
19 #include "TPZMeshSolution.h"
20 
21 #include <algorithm>
22 
23 #include "pzmetis.h"
24 #include "pzsloan.h"
25 #include "TPZSloanRenumbering.h"
26 #include "TPZCutHillMcKee.h"
27 
28 #include "pzlog.h"
29 
30 #ifdef LOG4CXX
31 static LoggerPtr logger(Logger::getLogger("pz.analysis"));
32 #endif
33 
34 #ifdef USING_BOOST
35 #include "TPZBoostGraph.h"
40 #define RENUMBER TPZSloanRenumbering()
41 #else
42 
46 #define RENUMBER TPZSloanRenumbering()
47 //#define RENUMBER TPZCutHillMcKee()
48 #endif
49 
51 
52 using namespace pzshape;
53 
55 {
56  int64_t nel = cmesh->NElements();
57  for (int64_t el=0; el<nel; el++) {
58  TPZCompEl *cel = cmesh->Element(el);
60  if (!pyram) {
61  continue;
62  }
63 
64  if (cel->Type() != EPiramide)
65  {
66  DebugStop();
67  }
68  TPZGeoEl *gel = cel->Reference();
71  int is;
72  int numneigh = 0;
73  for (is=14; is<18; is++) {
74  TPZGeoElSide gelside(gel,is);
75  TPZCompElSide large = gelside.LowerLevelCompElementList2(1);
76  // if the side is constrained, it wont be used as a reference
77  if (large) {
78  numneigh++;
79  continue;
80  }
81  // if the side has smaller elements connected to it, discard the side
82  TPZStack<TPZCompElSide> celstack;
83  gelside.HigherLevelCompElementList2(celstack, 1, 0);
84  if (celstack.size()) {
85  numneigh++;
86  continue;
87  }
88  // see if there is a pyramid element neighbour of the pyramid
89  gelside.EqualLevelCompElementList(celstack, 1, 0);
90  int localel;
91  for (localel=0; localel<celstack.size(); localel++) {
92  if (celstack[localel].Reference().Element()->Type() == ETetraedro || celstack[localel].Reference().Element()->Type() == ETriangle) break;
93  }
94  if (celstack.size()) {
95  numneigh++;
96  }
99  if (localel < celstack.size()) {
100  // find out if the face is the restrained face
101 
102  pir = dynamic_cast<TPZCompElHDiv<pzshape::TPZShapeTetra> *>(celstack[localel].Element());
103  if (pir == NULL) {
104  break;
105  }
106  const int restrainedface = pir->RestrainedFace();
107  const int neighbourside = celstack[localel].Side();
108  if (restrainedface == neighbourside) {
109  continue;
110  }
111  break;
112  }
113  }
114  if (numneigh == 0) {
115  is = 17;
116  }
117  if (is == 18 || is == 13) {
118  cmesh->Print();
119  DebugStop();
120  }
122  pyram->AddShapeRestraint(rest);
124  TPZGeoElSide gelside(cel->Reference(),is);
125  TPZGeoElSide neighbour = gelside.Neighbour();
126  TPZCompElSide celneigh = neighbour.Reference();
127  TPZInterpolatedElement *interp = dynamic_cast<TPZInterpolatedElement *>(celneigh.Element());
128  interp->AddShapeRestraint(rest);
129  }
130 
131 
132  ExpandHDivPyramidRestraints(cmesh);
133 }
134 
135 static int idf[6] = {2,1,1,2,0,0};
136 
137 static int nextface(int side, int inc)
138 {
139  return ((side-14)+inc)%4+14;
140 }
141 
142 static void GetGeoNodeIds(TPZGeoEl *gel, int side, TPZVec<int64_t> &ids)
143 {
144  int nsidenodes = gel->NSideNodes(side);
145  if (nsidenodes != 3) {
146  DebugStop();
147  }
148  for (int i=0; i<3; i++) {
149  ids[i] = gel->SideNodePtr(side, i)->Id();
150  }
151 }
152 
153 static int SideIdf(TPZCompElHDiv<TPZShapePiram> *cel, int side)
154 {
156  GetGeoNodeIds(cel->Reference(),side,ids);
157  int transformid = TPZShapeTriang::GetTransformId2dT(ids);
158  return idf[transformid];
159 }
161 {
163  if (!pir) {
164  DebugStop();
165  }
166  TPZOneShapeRestraint result;
167  int mult = 1;
168  for (int fc=0; fc<4; fc++)
169  {
170  int face = nextface(side, fc);
171  int64_t nodeindex = pir->SideConnectIndex(0, face);
172  result.fFaces[fc] = std::make_pair(nodeindex, SideIdf(pir, face));
173  result.fOrient[fc] = mult*pir->SideOrient(face-13);
174  mult *= -1;
175  }
176  return result;
177 }
178 
180 {
182  std::map<int64_t, TPZOneShapeRestraint> AllRestraints;
183  typedef std::list<TPZOneShapeRestraint>::iterator itlist;
184  if (!cmesh) {
185  DebugStop();
186  }
187  int64_t nelem = cmesh->NElements();
188  for (int64_t iel=0; iel<nelem; iel++) {
189  TPZCompEl *cel = cmesh->Element(iel);
190  std::list<TPZOneShapeRestraint> ellist;
191  ellist = cel->GetShapeRestraints();
192  for (itlist it = ellist.begin(); it != ellist.end(); it++) {
193  int64_t elindex = it->fFaces[0].first;
194  AllRestraints[elindex] = *it;
195  }
196  }
198  for (int64_t iel=0; iel<nelem; iel++) {
199  TPZCompEl *cel = cmesh->Element(iel);
200  std::list<TPZOneShapeRestraint> ellist;
201  std::map<int64_t, TPZOneShapeRestraint> restraintmap;
202  std::set<int64_t> connectset;
203  ellist = cel->GetShapeRestraints();
204  // we will insert the restraints afterwards
205  cel->ResetShapeRestraints();
206  for (itlist it = ellist.begin(); it != ellist.end(); it++) {
207 // std::cout << "1 including connect index " << it->fFaces[0].first << " to restraint map\n";
208 // it->Print(std::cout);
209  restraintmap[it->fFaces[0].first] = *it;
210  for (int i=1; i<4; i++) {
211  connectset.insert(it->fFaces[i].first);
212  }
213  }
214  while (connectset.size()) {
215  int64_t cindex = *connectset.begin();
216  connectset.erase(cindex);
217  if (AllRestraints.find(cindex) != AllRestraints.end()) {
218  TPZOneShapeRestraint restloc = AllRestraints[cindex];
219 // std::cout << "2 including connect index " << cindex << " to restraint map\n";
220 // restloc.Print(std::cout);
221  restraintmap[cindex] = restloc;
222  for (int i=1; i<4; i++) {
223  int64_t locindex = restloc.fFaces[i].first;
224  std::cout << "3 verifying connect index " << locindex << "\n";
225  if (restraintmap.find(locindex) != restraintmap.end()) {
226  std::cout << "********************* CIRCULAR RESTRAINT\n";
227  }
228  else
229  {
230  connectset.insert(locindex);
231  }
232  }
233  }
234  }
235  for (std::map<int64_t,TPZOneShapeRestraint>::iterator it = restraintmap.begin(); it != restraintmap.end(); it++) {
236  cel->AddShapeRestraint(it->second);
237  }
238  }
239 
240 }
241 
243 {
244  int64_t nel = cpressure->NElements();
245  for (int64_t iel=0; iel<nel; iel++) {
246  TPZCompEl *cel = cpressure->Element(iel);
247  if (!cel) {
248  continue;
249  }
250  TPZGeoEl *gel = cel->Reference();
251  if (gel->Dimension() != 3) {
252  continue;
253  }
254  if (gel->Type() == EPiramide) {
255  TPZGeoNode *top = gel->NodePtr(4);
256  //TPZManVector<REAL,3> topco(3),valvec(1);AQUIFRAN
257  TPZManVector<REAL,3>topco(3);
258  TPZManVector<STATE,3>valvec(1);
259  top->GetCoordinates(topco);
260  Forcing.Execute(topco, valvec);
261  STATE topval = valvec[0];
262  TPZConnect &c = cel->Connect(0);
263  int64_t seqnum = c.SequenceNumber();
264  for (int i=0; i<4; i++) {
265  cpressure->Block()(seqnum,0,i,0) = topval;
266  }
267  for (int i=0; i<4; i++) {
268  TPZConnect &c = cel->Connect(i+1);
269  TPZGeoNode *no = gel->NodePtr(i);
270  no->GetCoordinates(topco);
271  Forcing.Execute(topco, valvec);
272  STATE nodeval = valvec[0];
273  seqnum = c.SequenceNumber();
274  cpressure->Block()(seqnum,0,0,0) = nodeval-topval;
275  }
276  }
277  else
278  {
279  int ncorner = gel->NCornerNodes();
280  for (int i=0; i<ncorner; i++) {
281  TPZConnect &c = cel->Connect(i);
282  TPZGeoNode *no = gel->NodePtr(i);
283  TPZManVector<REAL,3> topco(3);
284  no->GetCoordinates(topco);
285  TPZManVector<STATE,3> valvec(1);
286  Forcing.Execute(topco, valvec);
287  STATE nodeval = valvec[0];
288  int64_t seqnum = c.SequenceNumber();
289  cpressure->Block()(seqnum,0,0,0) = nodeval;
290  }
291  }
292  }
293 }
294 
295 void TPZCompMeshTools::GroupElements(TPZCompMesh *cmesh, std::set<int64_t> elbasis, std::set<int64_t> &grouped)
296 {
297  cmesh->Reference()->ResetReference();
298  cmesh->LoadReferences();
299  int dim = cmesh->Dimension();
300  int64_t nel = cmesh->NElements();
301  for (int64_t el=0; el<nel; el++) {
302  if (elbasis.find(el) == elbasis.end()) {
303  continue;
304  }
305  TPZCompEl *cel = cmesh->Element(el);
306  if (!cel) {
307  continue;
308  }
309  TPZGeoEl *gel = cel->Reference();
310  if (!gel || gel->Dimension() != dim) {
311  continue;
312  }
313  std::set<int64_t> elgroup;
314 
315  std::set<int64_t> connectlist;
316  cel->BuildConnectList(connectlist);
317  std::cout << "cel " << cel->Index() << " connects ";
318  for (std::set<int64_t>::iterator it=connectlist.begin(); it != connectlist.end(); it++) {
319  std::cout << *it << " ";
320  }
321  std::cout << std::endl;
322  int ns = gel->NSides();
323  for (int is=0; is<ns; is++) {
324  std::cout << "side " << is << std::endl;
325  TPZGeoElSide gelside(gel,is);
326  TPZStack<TPZCompElSide> celstack;
327  gelside.ConnectedCompElementList(celstack, 0, 0);
328  int64_t nelstack = celstack.size();
329  for (int64_t elst=0; elst<nelstack; elst++) {
330  TPZCompElSide celst=celstack[elst];
331 // TPZGeoElSide gelst =celst.Reference();
332  TPZCompEl *celsidelement = celst.Element();
333  if (elbasis.find(celsidelement->Index()) == elbasis.end()) {
334  continue;
335  }
336  std::set<int64_t> smallset;
337  celsidelement->BuildConnectList(smallset);
338  std::cout << "neigh " << celsidelement->Index() << " connects ";
339  for (std::set<int64_t>::iterator it=smallset.begin(); it != smallset.end(); it++) {
340  std::cout << *it << " ";
341  }
342  std::cout << std::endl;
343  if (std::includes(connectlist.begin(), connectlist.end(), smallset.begin(), smallset.end()))
344  {
345  std::cout << "Is included\n";
346  elgroup.insert(celsidelement->Index());
347  elbasis.erase(celsidelement->Index());
348  }
349  }
350  }
351  if (elgroup.size()) {
352  elgroup.insert(el);
353  int64_t grindex;
354  TPZElementGroup *elgr = new TPZElementGroup(*cmesh,grindex);
355  for (std::set<int64_t>::iterator it = elgroup.begin(); it != elgroup.end(); it++) {
356  elgr->AddElement(cmesh->Element(*it));
357  }
358  grouped.insert(grindex);
359  }
360  else
361  {
362  grouped.insert(el);
363  }
364  }
365 }
366 
368 {
369  cmesh->Reference()->ResetReference();
370  cmesh->LoadReferences();
371  int dim = cmesh->Dimension();
372  int64_t nel = cmesh->NElements();
373  // all elements that have been put in a group
374  std::set<int64_t> grouped;
375  for (int64_t el=0; el<nel; el++) {
376  if (grouped.find(el) != grouped.end()) {
377  continue;
378  }
379  TPZCompEl *cel = cmesh->Element(el);
380  if (!cel) {
381  continue;
382  }
383  TPZGeoEl *gel = cel->Reference();
384  if (!gel || gel->Dimension() != dim) {
385  continue;
386  }
387  std::set<int64_t> elgroup;
388 
389  std::set<int64_t> connectlist;
390  cel->BuildConnectList(connectlist);
391  int ns = gel->NSides();
392  for (int is=0; is<ns; is++) {
393  TPZGeoElSide gelside(gel,is);
394  TPZStack<TPZCompElSide> celstack;
395  gelside.ConnectedCompElementList(celstack, 0, 0);
396  int64_t nelstack = celstack.size();
397  for (int64_t elst=0; elst<nelstack; elst++) {
398  TPZCompElSide celst=celstack[elst];
399  TPZCompEl *celsidelement = celst.Element();
400  if (grouped.find(celsidelement->Index()) != grouped.end()) {
401  continue;
402  }
403  std::set<int64_t> smallset;
404  celsidelement->BuildConnectList(smallset);
405  if (std::includes(connectlist.begin(), connectlist.end(), smallset.begin(), smallset.end()))
406  {
407  elgroup.insert(celsidelement->Index());
408  }
409  }
410  }
411  if (elgroup.size()) {
412  elgroup.insert(el);
413  int64_t grindex;
414  TPZElementGroup *elgr = new TPZElementGroup(*cmesh,grindex);
415  for (std::set<int64_t>::iterator it = elgroup.begin(); it != elgroup.end(); it++) {
416  elgr->AddElement(cmesh->Element(*it));
417  grouped.insert(*it);
418  }
419  grouped.insert(grindex);
420  }
421  }
422  cmesh->ComputeNodElCon();
423 }
424 
427 
428  int64_t nelem = cmesh->NElements();
429 
430  //unwrapping element groups
431  for(int64_t i=0; i<nelem; i++){
432  TPZCompEl *el = cmesh->ElementVec()[i];
433  TPZElementGroup * group = dynamic_cast<TPZElementGroup*>(el);
434  if(group){
435  group->Unwrap();
436  }
437  }
438 
439 }
440 
443 
444  int64_t nelem = cmesh->NElements();
445 
446  //unwrapping condensed compel
447  for(int64_t i=0; i<nelem; i++){
448  TPZCompEl *el = cmesh->ElementVec()[i];
449  TPZCondensedCompEl * cond = dynamic_cast<TPZCondensedCompEl*>(el);
450  if(cond){
451  cond->Unwrap();
452  }
453  }
454 
455 }
456 
458 void TPZCompMeshTools::PutinSubmeshes(TPZCompMesh *cmesh, std::map<int64_t,std::set<int64_t> >&elindices, std::map<int64_t,int64_t> &indices, bool KeepOneLagrangian)
459 {
460  for (std::map<int64_t,std::set<int64_t> >::iterator it = elindices.begin(); it != elindices.end(); it++) {
461  int64_t index;
462  TPZSubCompMesh *subcmesh = new TPZSubCompMesh(*cmesh,index);
463  indices[it->first] = index;
464  for (std::set<int64_t>::iterator itloc = it->second.begin(); itloc != it->second.end(); itloc++) {
465  subcmesh->TransferElement(cmesh, *itloc);
466  }
467  }
468  cmesh->ComputeNodElCon();
469  for (std::map<int64_t,int64_t>::iterator it = indices.begin(); it != indices.end(); it++) {
470  TPZSubCompMesh *subcmesh = dynamic_cast<TPZSubCompMesh *>(cmesh->Element(it->second));
471  if (!subcmesh) {
472  DebugStop();
473  }
474  int count = 0;
475  if (KeepOneLagrangian)
476  {
477  int64_t nconnects = subcmesh->NConnects();
478  for (int64_t ic=0; ic<nconnects; ic++) {
479  TPZConnect &c = subcmesh->Connect(ic);
480  if (c.LagrangeMultiplier() > 0) {
482  count++;
483  if(count == 1 && c.NState() == 1)
484  {
485  break;
486  }
487  else if(count == 2 && c.NState() == 2)
488  {
489  break;
490  }
491  else if(count == 3 && c.NState() == 3)
492  {
493  break;
494  }
495  }
496  }
497  }
498  subcmesh->MakeAllInternal();
499  }
500 
501 
502 
503 }
504 
505 
506 
508 void TPZCompMeshTools::PutinSubmeshes(TPZCompMesh *cmesh, std::set<int64_t> &elindices, int64_t &index, bool KeepOneLagrangian)
509 {
510  TPZSubCompMesh *subcmesh = new TPZSubCompMesh(*cmesh,index);
511  for (std::set<int64_t>::iterator it = elindices.begin(); it != elindices.end(); it++) {
512  subcmesh->TransferElement(cmesh, *it);
513  }
514  cmesh->ComputeNodElCon();
515  if (KeepOneLagrangian)
516  {
517  int64_t nconnects = subcmesh->NConnects();
518  for (int64_t ic=0; ic<nconnects; ic++) {
519  TPZConnect &c = subcmesh->Connect(ic);
520  if (c.LagrangeMultiplier() > 0) {
522  break;
523  }
524  }
525  }
526  subcmesh->MakeAllInternal();
527 // int numthreads = 0;
528 // subcmesh->SetAnalysisSkyline(numthreads, 0, 0);
529 }
530 
531 
533 void TPZCompMeshTools::CreatedCondensedElements(TPZCompMesh *cmesh, bool KeepOneLagrangian, bool keepmatrix)
534 {
535 // cmesh->ComputeNodElCon();
536  int64_t nel = cmesh->NElements();
537  for (int64_t el=0; el<nel; el++) {
538  TPZCompEl *cel = cmesh->Element(el);
539  if (!cel) {
540  continue;
541  }
542  int nc = cel->NConnects();
543  if (KeepOneLagrangian) {
544  int count = 0;
545  for (int ic=0; ic<nc; ic++) {
546  TPZConnect &c = cel->Connect(ic);
547  if (c.LagrangeMultiplier() > 0) {
549  count++;
550  if(count == 1 && c.NState() == 1)
551  {
552  break;
553  } else if(count == 2 && c.NState() == 2)
554  {
555  break;
556  } else if(count == 3 && c.NState() == 3)
557  {
558  break;
559  }
560 
561  }
562  }
563  }
564  int ic;
565  for (ic=0; ic<nc; ic++) {
566  TPZConnect &c = cel->Connect(ic);
567  if (c.HasDependency() || c.NElConnected() > 1) {
568  continue;
569  }
570  break;
571  }
572  bool cancondense = (ic != nc);
573  if(cancondense)
574  {
575  TPZCondensedCompEl *cond = new TPZCondensedCompEl(cel, keepmatrix);
576  }
577 
578  }
579 
580  cmesh->CleanUpUnconnectedNodes();
581 
582 }
583 
584 static void ComputeError(TPZCompEl *cel, TPZFunction<STATE> &func, TPZCompMesh *mesh2, TPZVec<STATE> &square_errors);
585 
586 static void ComputeError(TPZCondensedCompEl *cel, TPZFunction<STATE> &func, TPZCompMesh *mesh2, TPZVec<STATE> &square_errors)
587 {
588  TPZCompEl *ref = cel->ReferenceCompEl();
589  ComputeError(ref, func, mesh2, square_errors);
590 }
591 
592 static void ComputeError(TPZMultiphysicsElement *cel, TPZFunction<STATE> &func, TPZCompMesh *mesh2, TPZVec<STATE> &square_errors)
593 {
594  TPZManVector<STATE,3> errors(3,0.);
595  bool store_error = false;
596  cel->EvaluateError(func, errors, store_error);
597  int64_t index = cel->Index();
598  TPZCompMesh *mesh = cel->Mesh();
599  for (int i=0; i<3; i++) {
600  mesh->ElementSolution()(index,i) = errors[i];
601  square_errors[i] += errors[i]*errors[i];
602  }
603 }
604 
605 static void ComputeError(TPZElementGroup *cel, TPZFunction<STATE> &func, TPZCompMesh *mesh2, TPZVec<STATE> &square_errors)
606 {
607  TPZStack<TPZCompEl *,5> celstack;
608  celstack = cel->GetElGroup();
609  int64_t nel = celstack.size();
610  for (int64_t el=0; el<nel; el++) {
611  TPZCompEl *subcel = celstack[el];
612  ComputeError(subcel, func, mesh2, square_errors);
613  }
614 }
615 
616 static void ComputeError(TPZInterpolationSpace *cel, TPZFunction<STATE> &func, TPZCompMesh *mesh2, TPZVec<STATE> &square_errors)
617 {
618  DebugStop();
619 }
620 
621 
622 static void ComputeError(TPZCompEl *cel, TPZFunction<STATE> &func, TPZCompMesh *mesh2, TPZVec<STATE> &square_errors)
623 {
624  TPZSubCompMesh *sub = dynamic_cast<TPZSubCompMesh *>(cel);
625  // acumulate the errors of the submeshes
626  if (sub) {
627  TPZCompMeshTools::ComputeDifferenceNorm(sub, mesh2, square_errors);
628  return;
629  }
630  TPZElementGroup *elgr = dynamic_cast<TPZElementGroup *>(cel);
631  if(elgr)
632  {
633  ComputeError(elgr, func, mesh2, square_errors);
634  return;
635  }
636  TPZCondensedCompEl *cond = dynamic_cast<TPZCondensedCompEl *>(cel);
637  if (cond) {
638  ComputeError(cond, func, mesh2, square_errors);
639  return;
640  }
641  TPZInterpolationSpace *intel = dynamic_cast<TPZInterpolationSpace *>(cel);
642  if (intel) {
643  ComputeError(intel, func, mesh2, square_errors);
644  return;
645  }
646  TPZMultiphysicsElement *mphys = dynamic_cast<TPZMultiphysicsElement *>(cel);
647  if(mphys)
648  {
649  ComputeError(mphys, func, mesh2, square_errors);
650  return;
651  }
652 
653 }
657 {
658  int64_t nel = mesh1->NElements();
659  int dim = mesh1->Dimension();
660  if(square_errors.size() != 3)
661  {
662  DebugStop();
663  }
664  mesh1->ElementSolution().Redim(mesh1->NElements(), 3);
665 
666  int materialid = 1;
667  TPZMeshSolution func(mesh2,materialid);
668 
669 // mesh2->Reference()->ResetReference();
670 // mesh2->LoadReferences();
671  if (nel >= 1000) {
672  std::cout << "ComputeDifferenceNorm nelem " << nel << std::endl;
673  }
674 
675  for (int64_t el=0; el<nel; el++) {
676  TPZCompEl *cel = mesh1->Element(el);
677  if (!cel) {
678  continue;
679  }
680  ComputeError(cel, func, mesh2, square_errors);
681 
682  if (nel >= 1000 && (el+1)%1000 == 0) {
683  std::cout << "*";
684  }
685  if(el%(20*1000) == 0)
686  {
687  std::cout << square_errors << std::endl;
688  }
689  }
690  if(nel >= 1000) std::cout << std::endl;
691 }
692 
695 {
696  int dim = fluxmesh->Dimension();
698  int64_t nel = fluxmesh->NElements();
699  for (int64_t el=0; el<nel; el++) {
700  TPZCompEl *cel = fluxmesh->Element(el);
701  TPZInterpolatedElement *intel = dynamic_cast<TPZInterpolatedElement *>(cel);
702  if (!intel) {
703  continue;
704  }
705  TPZGeoEl *gel = intel->Reference();
706  if (gel->Dimension() != dim) {
707  continue;
708  }
709  // compute the maxorder
710  int maxorder = -1;
711  int ncon = intel->NConnects();
712  for (int i=0; i<ncon-1; i++) {
713  int conorder = intel->Connect(i).Order();
714  maxorder = maxorder < conorder ? conorder : maxorder;
715  }
716  int nsides = gel->NSides();
717  int nconside = intel->NSideConnects(nsides-1);
718  // tive que tirar para rodar H1
719  // if (nconside != 1 || maxorder == -1) {
720  // DebugStop();
721  // }
722  int64_t cindex = intel->SideConnectIndex(nconside-1, nsides-1);
723  TPZConnect &c = fluxmesh->ConnectVec()[cindex];
724  if (c.NElConnected() != 1) {
725  DebugStop();
726  }
727  if (c.Order() != maxorder+hdivplusplus) {
728  // std::cout << "Changing the order of the central connect " << cindex << " from " << c.Order() << " to " << maxorder+hdivplusplus << std::endl;
729  // change the internal connect order to be equal do maxorder
730  intel->SetSideOrder(nsides-1, maxorder+hdivplusplus);
731  }
732  }
733  fluxmesh->ExpandSolution();
734 }
735 
738 {
739  // build a vector with the required order of each element in the pressuremesh
740  // if an element of the mesh dimension of the fluxmesh does not have a corresponding element in the pressuremesh DebugStop is called
741  int meshdim = fluxmesh->Dimension();
742  pressuremesh->Reference()->ResetReference();
743  pressuremesh->LoadReferences();
744  TPZManVector<int64_t> pressorder(pressuremesh->NElements(),-1);
745  int64_t nel = fluxmesh->NElements();
746  for (int64_t el=0; el<nel; el++) {
747  TPZCompEl *cel = fluxmesh->Element(el);
748  TPZInterpolatedElement *intel = dynamic_cast<TPZInterpolatedElement *>(cel);
749  if (!intel) {
750  continue;
751  }
752  TPZGeoEl *gel = intel->Reference();
753  if (gel->Dimension() != meshdim) {
754  continue;
755  }
756  int nsides = gel->NSides();
757  int64_t cindex = intel->SideConnectIndex(0, nsides-1);
758  TPZConnect &c = fluxmesh->ConnectVec()[cindex];
759  int order = c.Order();
760  TPZCompEl *pressureel = gel->Reference();
761  TPZInterpolatedElement *pintel = dynamic_cast<TPZInterpolatedElement *>(pressureel);
762  if (!pintel) {
763  DebugStop();
764  }
765  pressorder[pintel->Index()] = order;
766  }
767  pressuremesh->Reference()->ResetReference();
768  nel = pressorder.size();
769  for (int64_t el=0; el<nel; el++) {
770  TPZCompEl *cel = pressuremesh->Element(el);
771  TPZInterpolatedElement *pintel = dynamic_cast<TPZInterpolatedElement *>(cel);
772  if (!pintel) {
773  continue;
774  }
775  if (pressorder[el] == -1) {
776  continue;
777  }
778  pintel->PRefine(pressorder[el]);
779  }
780 
781  pressuremesh->ExpandSolution();
782 }
783 
int64_t NElements() const
Number of computational elements allocated.
Definition: pzcmesh.h:169
void HigherLevelCompElementList2(TPZStack< TPZCompElSide > &elsidevec, int onlyinterpolated, int removeduplicates)
Returns all connected computational elements which have level higher to the current element if onlyi...
TPZFMatrix< STATE > & ElementSolution()
Access method for the element solution vectors.
Definition: pzcmesh.h:225
TPZGeoMesh * Reference() const
Returns a pointer to the geometrical mesh associated.
Definition: pzcmesh.h:209
virtual void Execute(const TPZVec< REAL > &x, TPZVec< TVar > &f, TPZFMatrix< TVar > &df)
Performs function computation.
Definition: pzfunction.h:38
virtual void ResetShapeRestraints()
Return a list with the shape restraints.
Definition: pzcompel.h:439
static void GetGeoNodeIds(TPZGeoEl *gel, int side, TPZVec< int64_t > &ids)
Contains TPZShapeTetra class which implements the shape functions of a tetrahedral element...
static void CreatedCondensedElements(TPZCompMesh *cmesh, bool KeepOneLagrangian, bool keepmatrix=true)
created condensed elements for the elements that have internal nodes
TPZStack< TPZCompEl *, 5 > GetElGroup()
void IncrementElConnected()
Increment fNElConnected.
Definition: pzconnect.h:260
Implements computational element and a side. Computational Element.
Definition: pzcompel.h:632
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
Definition: pzconnect.h:30
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.
virtual MElementType Type()
Return the type of the element.
Definition: pzcompel.cpp:195
static void GroupElements(TPZCompMesh *cmesh, std::set< int64_t > elbasis, std::set< int64_t > &grouped)
group the elements joining boundary elements and their neighbours
void Unwrap()
put the elements in the element group back in the mesh and delete the element group ...
virtual void BuildConnectList(std::set< int64_t > &indepconnectlist, std::set< int64_t > &depconnectlist)
Builds the list of all connectivities related to the element including the connects pointed to by dep...
Definition: pzcompel.cpp:435
static TPZOneShapeRestraint SetupPyramidRestraint(TPZCompEl *cel, int side)
int RestrainedFace()
return the first one dof restraint
Definition: pzelchdiv.cpp:1751
TPZGeoElSide Reference() const
Reference to the geometric element.
Definition: pzcompel.cpp:748
Contains the declaration of the TPZElementGroup class, which implements an computational element whic...
groups all classes dedicated to the computation of shape functions
Definition: pzshapeextend.h:16
virtual int NCornerNodes() const =0
Returns the number of corner nodes of the element.
Definition of the retraint associated with the top of the pyramid.
TPZCompEl * ReferenceCompEl()
virtual TPZGeoNode * SideNodePtr(int side, int nodenum) const
Returns the pointer to the nodenum node of side.
Definition: pzgeoel.cpp:2578
Contains the declaration of the TPZMultiphysicsElement class. This class is abstract.
static void LoadSolution(TPZCompMesh *cpressure, TPZFunction< STATE > &Forcing)
TPZCompElSide LowerLevelCompElementList2(int onlyinterpolated)
return the element/side pair which contains this/side and has a computational element associated ...
static void AddHDivPyramidRestraints(TPZCompMesh *cmesh)
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Definition: pzgeoelside.h:83
Class which groups elements to characterize dense matrices.
static int SideIdf(TPZCompElHDiv< TPZShapePiram > *cel, int side)
Contains declaration of TPZCompElHDiv class which implements a generic computational element (HDiv sc...
TPZGeoElSide Neighbour() const
Definition: pzgeoel.h:754
virtual void EvaluateError(std::function< void(const TPZVec< REAL > &loc, TPZVec< STATE > &val, TPZFMatrix< STATE > &deriv)> func, TPZVec< REAL > &errors, bool store_error) override
Performs an error estimate on the elemen.
TPZManVector< std::pair< int64_t, int >, 4 > fFaces
Faces which are related. First item is the connect index, second item is the degree of freedom...
virtual int NSides() const =0
Returns the number of connectivities of the element.
void EqualLevelCompElementList(TPZStack< TPZCompElSide > &elsidevec, int onlyinterpolated, int removeduplicates)
Returns all connected computational elements which have equal level to the current element...
void LoadReferences()
Map this grid in the geometric grid.
Definition: pzcmesh.cpp:482
static void ComputeError(TPZCompEl *cel, TPZFunction< STATE > &func, TPZCompMesh *mesh2, TPZVec< STATE > &square_errors)
static void ExpandHDivPyramidRestraints(TPZCompMesh *cmesh)
unsigned char LagrangeMultiplier() const
Access method to return the indication whether the connect is associated with a pressure lagrange mul...
Definition: pzconnect.h:230
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
Contains the TPZBoostGraph class which implements an interface to the BGL for graph operations...
TPZCompEl * Element(int64_t iel)
Definition: pzcmesh.h:185
void Unwrap()
unwrap the condensed element from the computational element and delete the condensed element ...
unsigned char Order() const
Access function to return the order associated with the connect.
Definition: pzconnect.h:217
int64_t SequenceNumber() const
Returns the Sequence number of the connect object.
Definition: pzconnect.h:158
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
class which represents the solution and its derivative as a function
virtual void AddShapeRestraint(TPZOneShapeRestraint restraint) override
Add a shape restraint (meant to fit the pyramid to restraint.
Definition: pzintel.h:362
Implements a group of computational elements as a mesh and an element. Computational Mesh...
Definition: pzsubcmesh.h:36
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
virtual void ExpandSolution()
Adapt the solution vector to new block dimensions.
Definition: pzcmesh.cpp:396
static void UnCondensedElements(TPZCompMesh *cmesh)
uncondensed elements for the elements that have internal nodes
TPZCompMesh * Mesh() const
Return a pointer to the grid of the element.
Definition: pzcompel.cpp:288
int Dimension() const
Returns the dimension of the simulation.
Definition: pzcmesh.h:148
virtual void ComputeNodElCon()
Compute the number of elements connected to each connect object.
Definition: pzcmesh.cpp:668
virtual MElementType Type() const =0
Returns the element type acording to pzeltype.h.
static void PutinSubmeshes(TPZCompMesh *cmesh, std::set< int64_t > &elindices, int64_t &index, bool KeepOneLagrangian)
Put the element set into a subcompmesh and make the connects internal.
TPZCompEl * Reference() const
Return a pointer to the element referenced by the geometric element.
Definition: pzgeoel.h:750
static void SetPressureOrders(TPZCompMesh *fluxmesh, TPZCompMesh *pressuremesh)
set the pressure order acording to the order of internal connect of the elements of the fluxmesh ...
int HasDependency() const
Returns whether exist dependecy information.
Definition: pzconnect.h:292
TPZManVector< int, 4 > fOrient
Orientation of each face.
const TPZBlock< STATE > & Block() const
Access the block structure of the solution vector.
Definition: pzcmesh.h:213
virtual void AddShapeRestraint(TPZOneShapeRestraint restraint)
Add a shape restraint (meant to fit the pyramid to restraint.
Definition: pzcompel.h:426
TPZAdmChunkVector< TPZConnect > & ConnectVec()
Return a reference to the connect pointers vector.
Definition: pzcmesh.h:198
Class which implements an element which condenses the internal connects.
int64_t Index() const
Returns element index of the mesh fELementVec list.
Definition: pzcompel.h:821
virtual int NConnects() const override=0
Returns the number of connect objects of the element.
static int nextface(int side, int inc)
virtual void AddShapeRestraint(TPZOneShapeRestraint restraint) override
Add a shape restraint (meant to fit the pyramid to restraint.
Definition: pzelchdiv.h:120
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Definition: pzfmatrix.h:616
static int nsidenodes[27]
Vector with the number of vertices contained in the closure of the side.
Definition: tpzcube.cpp:103
static void ComputeDifferenceNorm(TPZCompMesh *mesh1, TPZCompMesh *mesh2, TPZVec< STATE > &square_errors)
virtual TPZConnect & Connect(int i) const
Returns a pointer to the ith node.
Definition: pzcompel.cpp:298
unsigned char NState() const
Number of state variables associated with the connect.
Definition: pzconnect.h:146
virtual int NSideNodes(int side) const =0
Returns the number of nodes for a particular side.
int SideOrient(int face)
the orientation of the face
Definition: pzelchdiv.h:189
void ConnectedCompElementList(TPZStack< TPZCompElSide > &elsidevec, int onlyinterpolated, int removeduplicates)
Returns all connected computational elements to the current element if onlyinterpolated == 1 only e...
static int GetTransformId2dT(TPZVec< int64_t > &id)
Method which identifies the triangular transformation based on the IDs of the corner nodes...
void Forcing(const TPZVec< REAL > &pt, TPZVec< STATE > &disp)
Definition: main.cpp:508
Implements the interfaces for TPZCompElDisc, TPZInterfaceElement and TPZInterpolatedElement. Computational element.
virtual int NConnects() const =0
Returns the number of nodes of the element.
static void UnGroupElements(TPZCompMesh *cmesh)
ungroup all embedded elements of the computational mesh
static void AdjustFluxPolynomialOrders(TPZCompMesh *fluxmesh, int hdivplusplus)
adjust the polynomial orders of the hdiv elements such that the internal order is higher than the sid...
Contains declaration of TPZSubCompMesh class which implements a group of computational elements as a ...
virtual std::list< TPZOneShapeRestraint > GetShapeRestraints() const
Return a list with the shape restraints.
Definition: pzcompel.h:432
static int idf[6]
virtual void CleanUpUnconnectedNodes()
Delete the nodes which have no elements connected to them.
Definition: pzcmesh.cpp:498
virtual int Dimension() const =0
Returns the dimension of the element.
TPZCompEl * Element() const
Gives a pointer to the reference computational element.
Definition: pzcompel.h:675
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
virtual int NSideConnects(int iside) const override=0
Returns the number of dof nodes along side iside.
int64_t SideConnectIndex(int icon, int is) const
Returns the index of the c th connect object along side is.
Definition: pzintel.cpp:101
virtual void MakeAllInternal() override
Makes all mesh connections internal mesh connections.
Definition: pzsubcmesh.cpp:602
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
TPZAdmChunkVector< TPZCompEl * > & ElementVec()
Returns a reference to the element pointers vector.
Definition: pzcmesh.h:183
virtual int64_t TransferElement(TPZCompMesh *mesh, int64_t elindex) override
Transfer the element elindex belonging to mesh to the current mesh and returns its index...
Definition: pzsubcmesh.cpp:987
void PRefine(int order) override
Changes the interpolation order of a side. Updates all constraints and block sizes ...
Definition: pzintel.cpp:1592
int NElConnected() const
Returns fNElConnected.
Definition: pzconnect.h:264
pthread_cond_t cond
Definition: numatst.cpp:318
Contains TPZShapePiram class which implements the shape functions of a pyramid element.
int Id() const
Returns the identity of the current node.
Definition: pzgnode.h:68
Contains the TPZSloan class.
void GetCoordinates(TPZVec< REAL > &co)
Fill the coordinates of the node.
Definition: pzgnode.cpp:83
void ResetReference()
Resets all load references in elements and nodes.
Definition: pzgmesh.cpp:197
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
Contains the declaration of the TPZCondensedCompEl class, which implements an computational element w...
virtual void AddElement(TPZCompEl *cel)
add an element to the element group
Contains TPZShapeTriang class which implements the shape functions of a triangular element...
Contains TPZMetis class which implements the renumbering for elements of a mesh to minimize the band...
virtual void SetSideOrder(int side, int order)=0
Sets the interpolation order of side to order.
Implements computational element based on an interpolation space. Computational Element.
Definition: pzintel.h:27
virtual void Print(std::ostream &out=std::cout) const
Prints mesh data.
Definition: pzcmesh.cpp:236
virtual int NConnects() const override
Returns the number of connections.
Definition: pzsubcmesh.cpp:342