NeoPZ
pzgradientreconstruction.cpp
Go to the documentation of this file.
1 //
2 // pzgradientreconstruction.cpp
3 // PZ
4 //
5 // Created by Agnaldo Farias on 4/10/13.
6 //
7 //
8 #ifndef STATE_COMPLEX //AQUIFRAN
10 #include "pzgradient.h"
11 #include "tpzintpoints.h"
12 #include "pzmultiphysicselement.h"
13 #include "TPZMaterial.h"
14 #include "pzskylstrmatrix.h"
15 #include "pzintel.h"
16 #include "pzgnode.h"
17 #include "pzstepsolver.h"
18 #include "pzbndcond.h"
19 #include <cmath>
20 
21 #include "pzlog.h"
22 #ifdef LOG4CXX
23 static LoggerPtr logger(Logger::getLogger("pz.pzgradientreconstruction"));
24 #endif
25 
26 
27 using namespace std;
28 
30 
31  if ((param != 1. && param !=2.) && distmesh) {
32  DebugStop();
33  }
34  fGradData = new TPZGradientData;
35  fDistortedMesh = distmesh;
36  fparam = param;
37 }
38 
40 
41 }
42 
44 
45  fGradData = cp.fGradData;
46  fDistortedMesh = cp.fDistortedMesh;
47  fparam = cp.fparam;
48 }
49 
51 
52  fGradData = copy.fGradData;
53  fDistortedMesh = copy.fDistortedMesh;
54  fparam = copy.fparam;
55  return *this;
56 }
57 
59 {
60  if (cmesh->Reference()->Reference() != cmesh) {
61  DebugStop();
62  }
63 
64  // Redimensionando a matriz dos dados da reconstruca de gradientes
65  int dim = cmesh->Dimension();
66  int nelem = cmesh->NElements();
67 
68  bool useweight;
69  REAL paramK;
70  GetDataDistortedMesh(useweight, paramK);
71 
72  //criar ponteiro para TPZFunction
73  TPZGradient *pGrad = new TPZGradient;
75 
76  //Criar matrix de rigidez e vetor de carga
77  int numloadcases=0;
78  std::map<int, TPZMaterial * >::const_iterator mit;
79  for(mit=cmesh->MaterialVec().begin(); mit!= cmesh->MaterialVec().end(); mit++) {
80  TPZMaterial *mat = mit->second;
81  if (!mat) {
82  DebugStop();
83  }
84  numloadcases = mat->NumLoadCases();
85  break;
86  }
87 
88  int neq = cmesh->NEquations();
90  rhs.Redim(neq,numloadcases);
91 
92  TPZSkylineStructMatrix stmatrix(cmesh);
93  TPZMatrix<STATE> *stiffmatrix = stmatrix.Create();
94 
95  int matid;
96  for(int i=0; i<nelem; i++)
97  {
98  TPZCompEl *cel = cmesh->ElementVec()[i];
99  if(!cel || cel->Dimension()!=dim) continue;
100 
103 
104  fGradData->SetCel(cel, useweight, paramK);
105 #ifdef LOG4CXX
106  {
107  std::stringstream sout;
108  fGradData->Print(sout);
109  LOGPZ_DEBUG(logger,sout.str())
110  }
111 #endif
112 
113  //set data of the gradient reconstructed
114  TPZManVector<REAL,3> centerPoint;
115  TPZManVector<STATE,3> gradient;
116  STATE cellAverage, slopeLimiter;
117  fGradData->GetData(centerPoint, gradient, cellAverage, slopeLimiter);
118  pGrad->SetData(centerPoint,gradient,cellAverage,slopeLimiter);
119 
120  //change material id current to material id of the L2Projection
121  matid = cel->Material()->Id();
122  ChangeMaterialIdIntoCompElement(cel, matid, matidl2proj);
123 
124  //set forcing function of l2 projection material
125  TPZMaterial *mat = cel->Material();
126  mat->SetForcingFunction(fp);
127 
128  //load the matrix ek and vector ef of the element
129  cel->CalcStiff(ek,ef);
130 //
131 // ek.fMat.Print("ek = ");
132 // ef.fMat.Print("ef = ");
133 //
134  //assemble pos l2 projection
135  AssembleGlobalMatrix(cel, ek, ef, *stiffmatrix, rhs);
136 
137 // stiffmatrix->Print("Matriz de Rigidez: ");
138 // rhs.Print("Right Handside: ");
139 
140  //Return for original material and current solution of the mesh
141  ChangeMaterialIdIntoCompElement(cel, matidl2proj, matid);
142  }
143 
144  //Solve linear system and transfer the solution to computational mesh
146  step.SetDirect(ELDLt);
147  step.SetMatrix(stiffmatrix);
148  TPZFMatrix<STATE> result;
149  step.Solve(rhs, result);
150 // cmesh->Solution().Zero();
151  cmesh->LoadSolution(result);
152 
153 // stiffmatrix->Print("MatKRG = ");
154 // rhs.Print("FComRG = ");
155 // result.Print("SolComRG = ");
156 }
157 
159 
160  // Changes material Id only elements with required id (matid)
161  if(cel->Material()->Id() != oldmatid) return;
162 
163  //mudar o material id
164  TPZGeoEl *gel;
165  gel = cel->Reference();
166  gel->SetMaterialId(newmatid);
167 }
168 
169 
171 
172  if(!el->HasDependency()) {
174 
175  stiffmatrix.AddKel(ek.fMat,ek.fSourceIndex,ek.fDestinationIndex);
177 
178  } else {
179  // the element has dependent nodes
180  ek.ApplyConstraints();
181  ef.ApplyConstraints();
183 
184  stiffmatrix.AddKel(ek.fConstrMat,ek.fSourceIndex,ek.fDestinationIndex);
186  }
187 }
188 
190 {
191  if(LxLyLz.size()==0 || MatIdBC.size()==0) {
192  PZError << "TPZGradientReconstruction: uninitialized data.\n";
193  DebugStop();
194  }
195 
196  if(coordmin.size()!=coordmax.size() || coordmin.size()!=MatIdBC.size()){
197  PZError << "TPZGradientReconstruction: Amount of coordinates may not be different from the number of indexes boundary condition.\n";
198  DebugStop();
199  }
200 
201  fGradData->UseGhostsNeighbors(LxLyLz, MatIdBC, coordmin, coordmax);
202 }
203 
204 
205 
207 {
208  fSolCellAndNeighbors.resize(0);
209  fCenterPointCellAndNeighbors.resize(0);
210  fCelAndNeighbors.resize(0);
211  fCenterPointInterface.resize(0);
212 
213  this->fForcingFunctionExact = NULL;
214  this->fUseForcinfFuncion = false;
215  fGhostNeighbor = false;
216 
217  fWeightsGrad.resize(0);
218  fGradient.resize(0);
219  fdim=0;
220  fSlopeLimiter=1.;
221  fUseWeight=false;
222  fparamK = 0;
223 
224  fLxLyLz.resize(0);
225  fMatIdBC.resize(0);
226  fcoordminBC.Resize(0);
227  fcoordmaxBC.Resize(0);
228 }
229 
231 {
232 
233 }
234 
235 
237 {
238  fdim = cp.fdim;
239  fCelAndNeighbors = cp.fCelAndNeighbors;
240  fWeightsGrad = cp.fWeightsGrad;
241  fUseWeight = cp.fUseWeight;
242  fparamK = cp.fparamK;
243 
244  fSolCellAndNeighbors = cp.fSolCellAndNeighbors;
245  fCenterPointCellAndNeighbors = cp.fCenterPointCellAndNeighbors;
246  fCenterPointInterface = cp.fCenterPointInterface;
247  fGradient = cp.fGradient;
248  fSlopeLimiter = cp.fSlopeLimiter;
249 
250  fForcingFunctionExact = cp.fForcingFunctionExact;
251  fUseForcinfFuncion = cp.fUseForcinfFuncion;
252 
253  fGhostNeighbor = cp.fGhostNeighbor;
254  fLxLyLz = cp.fLxLyLz;
255  fMatIdBC = cp.fMatIdBC;
256  fcoordminBC = cp.fcoordminBC;
257  fcoordmaxBC = cp.fcoordmaxBC;
258 }
259 
261 {
262  fdim = copy.fdim;
263  fCelAndNeighbors = copy.fCelAndNeighbors;
264  fWeightsGrad = copy.fWeightsGrad;
265  fUseWeight = copy.fUseWeight;
266  fparamK = copy.fparamK;
267 
268  fSolCellAndNeighbors = copy.fSolCellAndNeighbors;
269  fCenterPointCellAndNeighbors = copy.fCenterPointCellAndNeighbors;
270  fCenterPointInterface = copy.fCenterPointInterface;
271  fGradient = copy.fGradient;
272  fSlopeLimiter = copy.fSlopeLimiter;
273 
274  fForcingFunctionExact = copy.fForcingFunctionExact;
275  fUseForcinfFuncion = copy.fUseForcinfFuncion;
276 
277  fGhostNeighbor = copy.fGhostNeighbor;
278  fLxLyLz = copy.fLxLyLz;
279  fMatIdBC = copy.fMatIdBC;
280  fcoordminBC = copy.fcoordminBC;
281  fcoordmaxBC = copy.fcoordmaxBC;
282 
283  return *this;
284 }
285 
286 
287 void TPZGradientReconstruction::TPZGradientData::SetCel(TPZCompEl * cel, bool useweight, REAL paramK)
288 {
289  if(!cel || cel->Dimension()!=cel->Mesh()->Dimension())
290  {
291  std::cout << "\nError: Element does not exist or has dimension different to the geometric mesh\n";
292  DebugStop();
293  }
294 
295  fSolCellAndNeighbors.resize(0);
296  fCenterPointCellAndNeighbors.resize(0);
297  fCelAndNeighbors.resize(0);
298  fCenterPointInterface.resize(0);
299 
300  fdim = cel->Dimension();
301  fUseWeight = useweight;
302  fparamK = paramK;
303 
304  InitializeGradData(cel);
305 
306  if(fGhostNeighbor==true) CreateGhostsNeighbors(cel);
307 
308  ComputeGradient();
309 
310  ComputeSlopeLimiter3();
311 }
312 #ifdef linux
313 #pragma GCC diagnostic push
314 #pragma GCC diagnostic ignored "-Wformat"
315 #endif
316 #ifdef MACOSX
317 #pragma clang diagnostic push
318 #pragma clang diagnostic ignored "-Wformat"
319 #endif
320 
321 
323 {
324  const char *name1 = "Cell average";
325  const char *name2 = "Center Point";
326  const char *name3 = "Gradient";
327  const char *name4 = "Slope limiter";
328 
329  const char *name5 = "Cel";
330  const char *name6 = "Neigh";
331  const char *name7 = "Center Point Interface";
332 
333  char string[256];
334 
335  out<<"\n\n";
336  sprintf(string, "\t%s", name1);
337  out << string ;
338  sprintf(string, "\t%s", name2);
339  out << string ;
340  sprintf(string, "\t\t%s", name3);
341  out << string ;
342  sprintf(string, "\t\t%s", name4);
343  out << string ;
344  out<<"\n";
345 
346  sprintf(string, "%s", name5);
347  out << string ;
348 
349  out << "\t" ;
350  out << fSolCellAndNeighbors[0];
351 
352  int i, j;
353  out<<"\t(";
354  for(j=0; j<3; j++ ){
355  sprintf(string, "%f", fCenterPointCellAndNeighbors[0][j]);
356  out << string;
357  if (j<2) out<<",";
358  }
359  out <<")";
360 
361  out<<"\t(";
362  for(i=0; i<3; i++ ){
363  out << fGradient[i];
364  if (i<2) out<<",";
365  }
366  out <<")";
367 
368  out << "\t" << fSlopeLimiter << "\n";
369 
370 
371  for (i=1; i<fSolCellAndNeighbors.size(); i++)
372  {
373  out << name6 <<i;
374 
375  out << "\t" << fSolCellAndNeighbors[i];
376 
377  out<<"\t(";
378  for(j=0; j<3; j++ ){
379  out << fCenterPointCellAndNeighbors[i][j];
380  if (j<2) out<<",";
381  }
382  out <<")\n";
383  }
384  //Interface
385  out <<"\n\n" << name7 <<"\n";
386  for (i=0; i<fCenterPointInterface.size(); i++)
387  {
388  out<<"(";
389  for(j=0; j<3; j++ ){
390  sprintf(string, "%f", fCenterPointInterface[i][j]);
391  out << string;
392  if (j<2) out<<",";
393  }
394  out <<")\n";
395  }
396 
397 }
398 
399 #ifdef linux
400 #pragma GCC diagnostic pop
401 #endif
402 #ifdef MACOSX
403 #pragma clang diagnostic pop
404 #endif
405 
407 {
408  // ---------- calculating center point -----------
409  TPZGeoEl* gel = cel->Reference();
410  TPZManVector<REAL> centerpsi(3,0.0);
411  gel->CenterPoint(gel->NSides()-1,centerpsi);
412  xcenter.Fill(0.);
413  gel->X(centerpsi,xcenter);
414 
415  //-------- calculating cell averaged ------------
416  int intOrder = cel->GetgOrder();
418  if(!intel){
419  DebugStop();
420  }
421  TPZIntPoints *pointIntRule = intel->Reference()->CreateSideIntegrationRule((intel->Reference()->NSides())-1,intOrder);
422  int it, npoints = pointIntRule->NPoints();
423  REAL integral = 0.0;
424  TPZManVector<REAL> point(3,0.);
425  TPZManVector<REAL> xpoint(3,0.);
426  REAL weight;
427  REAL Area = gel->RefElVolume();
428 
429  for(it=0;it<npoints;it++)
430  {
431  pointIntRule->Point(it,point,weight);
432  weight /= Area;
433  cel->Reference()->X(point,xpoint);
434 
435  TPZVec<STATE> sol;
436  if (this->HasForcingFunctionExact()){
437  sol.Resize(1, 0.);
438  this->fForcingFunctionExact->Execute(xpoint, sol);
439  }
440  else{
441  cel->Solution(xpoint, 1, sol);
442  }
443  if(sol.size()!=1) {
444  PZError << "TPZGradientReconstruction::TPZDataGradient: The number of solutions variable can not be other than 1.\n";
445  DebugStop();
446  }
447 #ifdef STATE_COMPLEX
448  integral += weight*sol[0].real();
449 #else
450  integral += weight*sol[0];
451 #endif
452  }
453 
454  solcel = integral;
455 }
456 
458 {
459  if(!cel){
460  std::cout << "\nError: Element does not exist\n";
461  DebugStop();
462  }
463 
464  fCelAndNeighbors.Push(cel);
465 
466  TPZManVector<REAL,3> xcenter(3);
467  STATE cellaveraged;
468 
469  //------ Solution and center point of the cel -----------------
470  GetCenterPointAndCellAveraged(cel,xcenter,cellaveraged);
471  fCenterPointCellAndNeighbors.Push(xcenter);
472  fSolCellAndNeighbors.Push(cellaveraged);
473 
474 
475  //-------- Solution and center point of the neighbors, and center point of the interfaces ---------
476  TPZStack<TPZCompElSide> neighequal,neighsmaller;
477  TPZCompElSide neighbigger;
478  int nneighs=0;
479  TPZManVector<REAL,3> point(3,0.);
480  TPZManVector<REAL,3> xpoint(3,0.);
481 
482  int oldneighs=0;
483  int newneighs=0;
484 
485  std::set<TPZCompEl *> interfaces;
486  for(int side = cel->Reference()->NSides()-2; side > cel->Reference()->NCornerNodes()-1; side--)
487  {
488  neighequal.Resize(0);
489  neighsmaller.Resize(0);
490 
491  TPZCompElSide celside(cel,side);
492  celside.EqualLevelElementList(neighequal, 0, 0);//(neighs,0,0);
493  neighbigger = celside.LowerLevelElementList(0);
494 
495  if(neighbigger){
496  neighequal.Push(neighbigger);
497  }
498 
499  celside.HigherLevelElementList(neighsmaller, 1, 1);
500 
501  nneighs = neighequal.NElements();
502  int nneighsmaller = neighsmaller.size();
503  if(nneighs && nneighsmaller)
504  {
505  DebugStop();
506  }
507 
508  if(nneighs != 0)
509  {
510  //Loop on neighboring elements greater or equal level
511  for(int i =0; i<nneighs; i++)
512  {
513  TPZInterpolationSpace * InterpEl = dynamic_cast<TPZInterpolationSpace *>(neighequal[i].Element());
514  if(!InterpEl) continue;
515 
516  //Do not assume neighbors by node
517  if(neighequal[i].Side() <neighequal[i].Reference().Element()->NCornerNodes()) continue;
518 
519  //verificando se eh elemento de contorno
520  if(neighequal[i].Element()->Dimension() == fdim-1)
521  {
522  TPZGeoElSide gelside = celside.Reference();
523  gelside.CenterPoint(point);
524  gelside.X(point,xpoint);
525  fCenterPointInterface.Push(xpoint);
526  continue;
527  }
528 
529  oldneighs = interfaces.size();
530  interfaces.insert(neighequal[i].Element());
531  newneighs = interfaces.size();
532 
533  if(newneighs > oldneighs)
534  {
535  fCelAndNeighbors.Push(neighequal[i].Element());
536 
537  GetCenterPointAndCellAveraged(neighequal[i].Element(),xcenter,cellaveraged);
538  fCenterPointCellAndNeighbors.Push(xcenter);
539  fSolCellAndNeighbors.Push(cellaveraged);
540 
541  TPZGeoElSide gelside = celside.Reference();
542  gelside.CenterPoint(point);
543  gelside.X(point,xpoint);
544  fCenterPointInterface.Push(xpoint);
545  }
546  }
547 
548  }
549 
550  //Loop on neighboring lower level elements
551  if(nneighsmaller != 0)
552  {
553 
554  for(int i =0; i<nneighsmaller; i++)
555  {
556 
557  TPZInterpolationSpace * InterpEl = dynamic_cast<TPZInterpolationSpace *>(neighsmaller[i].Element());
558  if(!InterpEl) continue;
559 
560  //Do not assume neighbors by node
561  if(neighsmaller[i].Side() <neighsmaller[i].Reference().Element()->NCornerNodes()) continue;
562 
563  //verificando se eh elemento de contorno
564  if(neighequal[i].Element()->Dimension() == fdim-1)
565  {
566  TPZGeoElSide gelside = neighsmaller[i].Reference();
567  gelside.CenterPoint(point);
568  gelside.X(point,xpoint);
569  fCenterPointInterface.Push(xpoint);
570  continue;
571  }
572 
573  oldneighs = interfaces.size();
574  interfaces.insert(neighsmaller[i].Element());
575  newneighs = interfaces.size();
576 
577  if(newneighs > oldneighs)
578  {
579  fCelAndNeighbors.Push(neighsmaller[i].Element());
580 
581  GetCenterPointAndCellAveraged(neighsmaller[i].Element(),xcenter,cellaveraged);
582  fCenterPointCellAndNeighbors.Push(xcenter);
583  fSolCellAndNeighbors.Push(cellaveraged);
584 
585  TPZGeoElSide gelside = neighsmaller[i].Reference();
586  gelside.CenterPoint(point);
587  gelside.X(point,xpoint);
588  fCenterPointInterface.Push(xpoint);
589  }
590  }
591  }
592  }
593 
594  int ncorn = cel->Reference()->NCornerNodes();
595  for(int side = 0; side < ncorn; side++)
596  {
597  TPZCompElSide celside(cel,side);
598  TPZGeoElSide gelside = celside.Reference();
599  gelside.CenterPoint(point);
600  gelside.X(point,xpoint);
601  fCenterPointInterface.Push(xpoint);
602  }
603 }
604 
605 
606 #include <stdio.h>
607 #ifdef USING_LAPACK
608 #include "TPZLapack.h"
609 #endif
610 
611 #ifdef USING_BLAS
612 #ifdef USING_MKL
613 #include <mkl.h>
614 #elif MACOSX
615 #include <Accelerate/Accelerate.h>
616 #else
617 #include <cblas.h>
618 #endif
619 #endif
620 
622 {
623  if (fCenterPointInterface.size()<1 || fSolCellAndNeighbors.size()<1)
624  {
625  DebugStop();
626  }
627 
628  int i, j;
629  fGradient.Resize(3, 0.);
630 
631  //matrices to apply the method of least squares
632  TPZFMatrix<REAL> DeltaXcenter;//xcenter cell menos xcenter neigh
633  TPZFMatrix<REAL> DeltaXcenterTranspose;
634  TPZFMatrix<REAL> DifSol;//sol cell menos sol neigh
635 
636  int nneighs = fCenterPointCellAndNeighbors.size()-1;
637 
638  DeltaXcenter.Redim(nneighs,fdim);
639  DeltaXcenterTranspose.Redim(fdim,nneighs);
640  DifSol.Redim(nneighs,1);
641 
642  for(i = 0; i < nneighs; i++)
643  {
644  for(j=0; j<fdim; j++)
645  {
646  DeltaXcenter(i,j) = fCenterPointCellAndNeighbors[i+1][j] - fCenterPointCellAndNeighbors[0][j];
647  }
648  DifSol(i,0) = fSolCellAndNeighbors[i+1] - fSolCellAndNeighbors[0];
649  }
650 
651  //insert weight
652  if(fUseWeight==true)
653  {
654  ComputeWeights(fparamK);
655  InsertWeights(DeltaXcenter, DifSol);
656  }
657 
658  TPZFMatrix<REAL> grad;
659  grad.Redim(fdim, 1);
660 
661 
662  if(nneighs==fdim-1)
663  {
664  grad(0,0) = DifSol(0,0)/DeltaXcenter(0,0);
665  //grad(1,0) = -DifSol(0,0)/DeltaXcenter(1,0);
666 
667 // TPZFMatrix<REAL> A(fdim,fdim);
668 // DeltaXcenter.Transpose(&DeltaXcenterTranspose);
669 // A = DeltaXcenterTranspose*DeltaXcenter;
670 // grad = DeltaXcenterTranspose*DifSol;
671 // A.SolveDirect(grad,ELU);
672  }
673  else if(nneighs==fdim)
674  {
675  TPZVec<int> index;
676  DeltaXcenter.Decompose_LU(index);
677  DeltaXcenter.Substitution(&DifSol, index);
678  grad = DifSol;
679  }
680  else
681  {
682 #ifdef USING_LAPACK
683  //QR factorization
684  QRFactorization(DeltaXcenter,DifSol);
685  TPZVec<int> index;
686  DeltaXcenter.Decompose_LU(index);
687  DeltaXcenter.Substitution(&DifSol, index);
688  grad= DifSol;
689 #else
690 
691  // Solving the system by least squares: DeltaXcenter_T * DifSol = DeltaXcenter_T * DeltaXcenter*Grad(u)
692  TPZFMatrix<REAL> A(fdim,fdim);
693  DeltaXcenter.Transpose(&DeltaXcenterTranspose);
694  A = DeltaXcenterTranspose*DeltaXcenter;
695  grad = DeltaXcenterTranspose*DifSol;
696  A.SolveDirect(grad,ELU);
697 #endif
698  }
699 
700  for (i = 0; i<grad.Rows(); i++)
701  {
702  fGradient[i] = grad(i,0);
703  }
704 }
705 
707 {
708  //-------- Compute a QR factorization of a real M-by-N matrix A = QR ---------
709  //On exit, the elements on and above the diagonal of the array
710  //contain the min(M,N)-by-N upper trapezoidal matrix R (R is
711  //upper triangular if m >= n); the elements below the diagonal,
712  //with the array TAU, represent the orthogonal matrix Q as a
713  //product of min(m,n) elementary reflectors
714 
715 #ifdef USING_LAPACK
716 
717  int m = matA.Rows();
718  int n = matA.Cols();
719 
720  int lda = m; //the leading dimension of the matA
721  double *tau = new double[n];//The scalar factors of the elementary reflectors
722  int lwork = n;
723  double *work = new double[n];
724  int info;
725 
726  double *A = new double[m*n];
727  for(int j = 0; j<n; j++){
728  for(int i=0; i<m; i++){
729  A[i+m*j] = matA(i,j);
730  }
731  }
732 
733  dgeqrf_(&m, &n, A, &lda,tau,work,&lwork,&info);
734 
735  //matrix R: upper triangular
736  matA.Redim(n, n);
737  for(int j = 0; j<n; j++)
738  {
739  for(int i=0; i<n; i++)
740  {
741  if(i<=j) matA(i,j)=A[i+m*j];
742  }
743  }
744  //matA.Print("\n\n \tmtR = ");
745 
746  //metodo que retorna a matrix Q
747  int kk=n;
748  double *Q = new double[m*n];
749  Q=A;
750 
751  dorgqr_(&m, &n, &kk, Q, &lda,tau,work,&lwork,&info);
752 
753  TPZFMatrix<REAL> matQ;
754  matQ.Redim(m, n);
755  for(int j = 0; j<n; j++){
756  for(int i=0; i<m; i++){
757  matQ(i,j) = Q[i+m*j];
758  }
759  }
760  //matQ.Print("\n\n \tmQ = ");
761  TPZFMatrix<REAL> matQt;
762  matQ.Transpose(&matQt);
764 
765  matQt.Multiply(vecb, res);
766  vecb.Redim(res.Rows(), res.Cols());
767  vecb = res;
768 
769 #else
770  DebugStop();
771 #endif
772 
773  //------- Product of the transpose of matrix Q by b: Qˆt*vecb -------
774  /*
775  char side = 'L';
776  char Trans = 'T';
777  int nb = vecb.Cols();
778  int k = n;
779 
780  int ldc = m;
781  double work2[nb];
782  int lwork2 =nb;
783 
784  double *b = new double[m];
785  for (int i = 0; i<m; i++) {
786  b[i]=vecb(i,0);
787  }
788 
789  //o metodo nao explicita a matriz Q. Retorna Qˆt*b diretamente;
790  dormqr_(&side, &Trans, &m, &nb, &k, A, &lda, tau, b, &ldc, work2, &lwork2, &info);
791 
792  vecb.Redim(n, 1);
793  for(int j = 0; j<n; j++){
794  vecb(j,0)=b[j];
795  }
796  vecb.Print("\n\n \tmQˆt*b = ");
797  */
798 }
799 
800 //Finite volume methods:foundation and analysis (chapter 3.3),Timothy Barth and Mario Ohlberge-2004
802 {
803  if(fGradient.size()==0 || fSolCellAndNeighbors.size()==0 || fCenterPointInterface.size()==0){
804  PZError << "TPZGradientReconstruction::TPZDataGradient: gradient has size equal zero.\n";
805  DebugStop();
806  }
807 
808  int nneigh = fSolCellAndNeighbors.size()-1;
809  if(nneigh==0) DebugStop();
810  int i, j;
811 
812  //-------- getting min and max solution of neighbors ----
813  STATE solKmax, solKmin;
814  solKmin = fSolCellAndNeighbors[1];
815  solKmax = fSolCellAndNeighbors[1];
816 
817  for(i = 2; i<= nneigh; i++)
818  {
819  if(solKmin > fSolCellAndNeighbors[i])
820  {
821  solKmin = fSolCellAndNeighbors[i];
822  continue;
823  }
824 
825  if(solKmax < fSolCellAndNeighbors[i])
826  {
827  solKmax = fSolCellAndNeighbors[i];
828  }
829  }
830 
831  if(solKmax < solKmin) DebugStop();
832 
833  // ----------- Calculating slope limiter --------------
834  int ninterf = fCenterPointInterface.size();
835  STATE solKside;
836  STATE temp;
837  TPZStack<STATE> alphavec;
838  STATE solcel = fSolCellAndNeighbors[0];
839 
840  for (i = 0; i<ninterf; i++)
841  {
842  solKside = solcel;
843  for(j=0; j<fdim; j++)
844  {
845  solKside += (STATE)(fCenterPointInterface[i][j] - fCenterPointCellAndNeighbors[0][j])*fGradient[j];
846  }
847 
848 
849  if(IsZero(solKside - solKmax) || IsZero(solKside - solKmin)) {
850  temp = 1.;
851  }
852  else if((solKside - solKmax) > 1.e-12)
853  {
854  temp = (solKmax - solcel)/(solKside-solcel);
855  if(temp<0.) temp = fabs(temp);
856  if(temp>1.) temp = 1.;
857  }
858  else if((solKside - solKmin) < 1.e-12)
859  {
860  temp = (solKmin - solcel)/(solKside-solcel);
861  if(temp<0.) temp = fabs(temp);
862  if(temp>1.) temp = 1.;
863  }
864  else temp = 1.;
865 
866  if(temp < 0. || temp > 1.) DebugStop();
867  alphavec.Push(temp);
868  }
869 
870  //getting min slope limiter
871  STATE alphaK = alphavec[0];
872  for (int64_t j=1; j<alphavec.size(); j++)
873  {
874  if(alphaK > alphavec[j])
875  {
876  alphaK = alphavec[j];
877  }
878  }
879  fSlopeLimiter = alphaK;
880 
881  if(alphaK<0. || alphaK>1.) {
882  DebugStop();
883  }
884 }
885 
886 //Paper: Development of a cell centred upwind finite volume algorithm for a new conservation law formulation in structural dynamics
888 {
889  if(fGradient.size()==0 || fSolCellAndNeighbors.size()==0 || fCenterPointInterface.size()==0){
890  PZError << "TPZGradientReconstruction::TPZDataGradient: gradient has size equal zero.\n";
891  DebugStop();
892  }
893 
894  int nneigh = fSolCellAndNeighbors.size()-1;
895  if(nneigh==0) DebugStop();
896  int i, j;
897 
898  //-------- getting min and max solution of neighbors ----
899  STATE solKmax, solKmin;
900  solKmin = fSolCellAndNeighbors[0];
901  solKmax = fSolCellAndNeighbors[0];
902 
903  for(i = 1; i<= nneigh; i++)
904  {
905  if(solKmin > fSolCellAndNeighbors[i])
906  {
907  solKmin = fSolCellAndNeighbors[i];
908  continue;
909  }
910 
911  if(solKmax < fSolCellAndNeighbors[i])
912  {
913  solKmax = fSolCellAndNeighbors[i];
914  }
915  }
916 
917  if(solKmax < solKmin) DebugStop();
918 
919  // ----------- Calculating slope limiter --------------
920  int ninterf = fCenterPointInterface.size();
921  STATE solKside;
922  STATE temp;
923  TPZStack<STATE> alphavec;
924  STATE solcel = fSolCellAndNeighbors[0];
925 
926  for (i = 0; i<ninterf; i++)
927  {
928  solKside = solcel;
929  for(j=0; j<fdim; j++)
930  {
931  solKside += (STATE)(fCenterPointInterface[i][j] - fCenterPointCellAndNeighbors[0][j])*fGradient[j];
932  }
933 
934 
935  if(IsZero(solKside - solcel)) {
936  temp = 1.;
937  }
938  else if((solKside - solcel) > 1.e-12)
939  {
940  temp = (solKmax - solcel)/(solKside-solcel);
941  if(temp>1.) temp = 1.;
942  }
943  else if(solKside - solcel < 1.e-12)
944  {
945  temp = (solKmin-solcel)/(solKside-solcel);
946  if(temp<0.) temp = fabs(temp);
947  if(temp>1.) temp = 1.;
948  }
949  else temp =1.;
950 
951  if(temp < 0. || temp > 1.) DebugStop();
952  alphavec.Push(temp);
953  }
954 
955  //getting min slope limiter
956  STATE alphaK = alphavec[0];
957  for (int64_t j=1; j<alphavec.size(); j++)
958  {
959  if(alphaK > alphavec[j])
960  {
961  alphaK = alphavec[j];
962  }
963  }
964  fSlopeLimiter = alphaK;
965 
966  if(alphaK<0. || alphaK>1.) {
967  DebugStop();
968  }
969 }
970 
971 //Venkatakrishnan V (1993). On the accuracy of limiters and convergence to steady state solutions
972 //Christopher Michalak, Carl Ollivier-Gooch (2009)-Accuracy preserving limiter for the high-order accurate solution of the Euler equations
974 {
975  if(fGradient.size()==0 || fSolCellAndNeighbors.size()==0 || fCenterPointInterface.size()==0){
976  PZError << "TPZGradientReconstruction::TPZDataGradient: gradient has size equal zero.\n";
977  DebugStop();
978  }
979 
980  int nneigh = fSolCellAndNeighbors.size()-1;
981  if(nneigh==0) DebugStop();
982  int i, j;
983 
984  //-------- getting min and max solution of neighbors ----
985  STATE solKmax, solKmin;
986  solKmin = fSolCellAndNeighbors[0];
987  solKmax = fSolCellAndNeighbors[0];
988 
989  for(i = 1; i<= nneigh; i++)
990  {
991  if(solKmin > fSolCellAndNeighbors[i])
992  {
993  solKmin = fSolCellAndNeighbors[i];
994  continue;
995  }
996 
997  if(solKmax < fSolCellAndNeighbors[i])
998  {
999  solKmax = fSolCellAndNeighbors[i];
1000  }
1001  }
1002 
1003  if(solKmax < solKmin) DebugStop();
1004 
1005  // ----------- Calculating slope limiter --------------
1006  int ninterf = fCenterPointInterface.size();
1007  STATE solKside;
1008  STATE temp;
1009  TPZStack<STATE> alphavec;
1010  STATE solcel = fSolCellAndNeighbors[0];
1011 
1012  for (i = 0; i<ninterf; i++)
1013  {
1014  solKside = solcel;
1015  for(j=0; j<fdim; j++)
1016  {
1017  solKside += (STATE)(fCenterPointInterface[i][j] - fCenterPointCellAndNeighbors[0][j])*fGradient[j];
1018  }
1019 
1020 
1021  if(IsZero(solKside - solcel)) {
1022  temp = 1.;
1023  }
1024  else if((solKside - solcel) > 1.e-12)
1025  {
1026  temp = (solKmax - solcel)/(solKside-solcel);
1027  temp = (temp*temp + 2.*temp)/(temp*temp + temp + 2.);
1028 
1029  }
1030  else if(solKside - solcel < 1.e-12)
1031  {
1032  temp = (solKmin-solcel)/(solKside-solcel);
1033  temp = (temp*temp + 2.*temp)/(temp*temp + temp + 2.);
1034  }
1035  else temp =1.;
1036 
1037  if(temp < 0.) DebugStop();
1038  alphavec.Push(temp);
1039  }
1040 
1041  //getting min slope limiter
1042  STATE alphaK = alphavec[0];
1043  for (int64_t j=1; j<alphavec.size(); j++)
1044  {
1045  if(alphaK > alphavec[j])
1046  {
1047  alphaK = alphavec[j];
1048  }
1049  }
1050  fSlopeLimiter = alphaK;
1051 }
1052 
1054 {
1055 
1056  if(paramk<1 || paramk>2) DebugStop();
1057 
1058  TPZManVector<REAL,3> nodecelX;
1059 
1060  //Node more closer of the cel barycenter
1061  NodeCloserCenterX(nodecelX);
1062 
1063  int64_t nneighs = fCelAndNeighbors.size()-1;
1064  TPZManVector<REAL,30> dist(nneighs,0.);
1065  TPZManVector<REAL,3> centerneigh(3,0.0);
1066 
1067  REAL sum=0.;
1068  for(int in = 0; in < nneighs; in++)
1069  {
1070  TPZGeoEl * gel = fCelAndNeighbors[in+1]->Reference();
1071  if(!gel) DebugStop();
1072 
1073  for(int k=0; k<fdim; k++) centerneigh[k]=fCenterPointCellAndNeighbors[in+1][k];
1074 
1075  dist[in]=gel->Distance(centerneigh, nodecelX);
1076 
1077  sum += 1./pow((REAL)dist[in],paramk);
1078  }
1079 
1080  fWeightsGrad.Resize(dist.size(), 0.);
1081  REAL temp;
1082 
1083  for (int id = 0; id<dist.size(); id++)
1084  {
1085  temp = 1./pow((REAL)dist[id],paramk);
1086  fWeightsGrad[id] = temp/sum;
1087  if(fWeightsGrad[id]<0 || fWeightsGrad[id]>1) DebugStop();
1088  }
1089 }
1090 
1092 {
1093  TPZGeoEl* gel = fCelAndNeighbors[0]->Reference();
1094  if(!gel) DebugStop();
1095 
1096  TPZManVector<REAL,3> centercelX(3,0.);
1097  TPZManVector<REAL,3> coordX(3,0.);
1098  nodecelX.Resize(3, 0.);
1099 
1100  for(int k=0; k<fdim; k++) centercelX[k]=fCenterPointCellAndNeighbors[0][k];
1101 
1102  int nnodes = gel->NCornerNodes();
1103  TPZManVector<REAL,8> dist(nnodes,0.);
1104 
1105 
1106  for (int in = 0; in<nnodes; in++)
1107  {
1108  TPZGeoNode geonode = gel->Node(in);
1109  geonode.GetCoordinates(coordX);
1110 
1111  dist[in]=gel->Distance(centercelX, coordX);
1112  }
1113 
1114  int id = 0;
1115  for(int j=1; j<dist.size(); j++){
1116 
1117  if(dist[id] > dist[j]){
1118  id = j;
1119  }
1120  }
1121 
1122  gel->Node(id).GetCoordinates(nodecelX);
1123 }
1124 
1126 
1127  if(fWeightsGrad[0]==0) DebugStop();
1128  if(DeltaH.Rows()!=fWeightsGrad.size()) DebugStop();
1129  if(DifSol.Rows()!=fWeightsGrad.size()) DebugStop();
1130 
1131  int64_t ncH = DeltaH.Cols();
1132  int64_t ncD = DifSol.Cols();
1133  for (int64_t i = 0; i<fWeightsGrad.size(); i++) {
1134 
1135  for (int64_t j = 0; j<ncH; j++){
1136  DeltaH(i,j) = fWeightsGrad[i]*DeltaH(i,j);
1137  }
1138 
1139  for (int64_t k = 0; k<ncD; k++){
1140  DifSol(i,k) = fWeightsGrad[i]*DifSol(i,k);
1141  }
1142  }
1143 }
1144 
1146 {
1147  int nbc = fMatIdBC.size();
1148  int i, j;
1149 
1150  int in, nneighs;
1151  int is, nside = cel->Reference()->NSides();
1152  int ncorn = cel->Reference()->NCornerNodes();
1153 
1154  TPZStack<TPZCompElSide> neighequal;
1155  TPZManVector<REAL,3> xcent(3,0.);
1156 
1157  for(is = ncorn; is < nside; is++)
1158  {
1159  neighequal.Resize(0);
1160  TPZCompElSide celside(cel,is);
1161  celside.EqualLevelElementList(neighequal, 0, 0);
1162  nneighs = neighequal.NElements();
1163 
1164  for(in =0; in<nneighs; in++)
1165  {
1166  TPZInterpolationSpace * InterpEl = dynamic_cast<TPZInterpolationSpace *>(neighequal[in].Element());
1167  if(!InterpEl) continue;
1168 
1169  //Do not assume neighbors by node
1170  if(neighequal[in].Side() <neighequal[in].Reference().Element()->NCornerNodes()) continue;
1171 
1172  if(neighequal[in].Element()->Dimension() == fdim) continue;
1173 
1174  //verificando se eh elemento de contorno
1175  if(neighequal[in].Element()->Dimension() == fdim-1){
1176 
1177  TPZCompEl *bccel = neighequal[in].Element();
1178  TPZMaterial *mymat = bccel->Material();
1179  TPZBndCond *bcmat = dynamic_cast< TPZBndCond *> (mymat);
1180 
1181  for(i=0; i<nbc; i++){
1182  j=0;
1183  if(mymat->Id() == fMatIdBC[i])
1184  {
1185  //Neumann condition (is not inflow or outflow)
1186  if(bcmat->Type() != 1){
1187  PZError << "TPZGradientReconstruction::TPZDataGradient: boundary conditions is not of the type Neumann.\n";
1188  DebugStop();
1189 
1190  }
1191 
1192  while (fcoordminBC[i][j] != fcoordmaxBC[i][j]){
1193  j++;
1194  }
1195 
1196  fCelAndNeighbors.Push(cel);
1197  fSolCellAndNeighbors.Push(fSolCellAndNeighbors[0]);
1198  xcent = fCenterPointCellAndNeighbors[0];
1199 
1200  if(xcent[j]>fLxLyLz[j]/2.){
1201  xcent[j] = fLxLyLz[j] + (fLxLyLz[j]- xcent[j]);
1202  }else xcent[j] = fcoordminBC[i][j]- xcent[j];
1203 
1204  fCenterPointCellAndNeighbors.Push(xcent);
1205  }
1206  }
1207  }
1208  }
1209  }
1210 }
1211 
1212 
1213 #endif
int64_t NElements() const
Number of computational elements allocated.
Definition: pzcmesh.h:169
TPZGeoMesh * Reference() const
Returns a pointer to the geometrical mesh associated.
Definition: pzcmesh.h:209
void ProjectionL2GradientReconstructed(TPZCompMesh *cmesh, int matidl2proj)
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
Definition: tfadfunc.h:140
TPZCompMesh * Reference() const
Returns the currently loaded computational grid.
Definition: pzgmesh.h:167
virtual int NPoints() const =0
Returns number of points for the cubature rule related.
TPZCompElSide LowerLevelElementList(int onlyinterpolated)
Returns all connected elements which have level lower to the current element.
Definition: pzcompel.cpp:824
Implements computational element and a side. Computational Element.
Definition: pzcompel.h:632
TPZStack< TPZManVector< REAL, 3 > > fCenterPointCellAndNeighbors
Definition: pzmatrix.h:52
bool IsZero(long double a)
Returns if the value a is close Zero as the allowable tolerance.
Definition: pzreal.h:668
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.
Contains the TPZGradient class which implements the methods to reconstruction gradient.
virtual int Decompose_LU(std::list< int64_t > &singular) override
LU Decomposition. Stores L and U matrices at the storage of the same matrix.
Definition: pzfmatrix.cpp:1246
void GetCenterPointAndCellAveraged(TPZCompEl *cel, TPZManVector< REAL, 3 > &xcenter, STATE &solcel)
Contains declaration of TPZGeoNode class which defines a geometrical node.
void CreateGhostsNeighbors(TPZCompEl *cel)
Method to create ghosts neighbors of the element cel. This method is used only for regular domain...
int64_t NEquations()
This computes the number of equations associated with non-restrained nodes.
Definition: pzcmesh.cpp:721
void AddFel(TPZFMatrix< TVar > &rhs, TPZVec< int64_t > &destination)
Performs a right hand side assemblage.
Definition: pzfmatrix.cpp:209
int Type()
Definition: pzbndcond.h:249
TPZGeoElSide Reference() const
Reference to the geometric element.
Definition: pzcompel.cpp:748
TPZFNMatrix< 1000, STATE > fMat
Pointer to a blocked matrix object.
Definition: pzelmat.h:41
static REAL Distance(TPZVec< REAL > &centel, TPZVec< REAL > &centface)
Definition: pzgeoel.cpp:936
void NodeCloserCenterX(TPZManVector< REAL, 3 > &nodecelX)
Method to choose the node of the cell closer of your center point.
TPZAutoPointer< TPZFunction< STATE > > fForcingFunctionExact
Pointer to exact solution function, needed to calculate exact error.
Defines step solvers class. Solver.
Definition: pzmganalysis.h:17
virtual int Dimension() const =0
Dimension of the element.
virtual int NCornerNodes() const =0
Returns the number of corner nodes of the element.
virtual void CalcStiff(TPZElementMatrix &ek, TPZElementMatrix &ef)
Computes the element stifness matrix and right hand side.
Definition: pzcompel.h:794
TPZGradientReconstruction & operator=(const TPZGradientReconstruction &copy)
void ComputeSlopeLimiter()
Methods to calculate the slope limiter (alphaK)
void QRFactorization(TPZFMatrix< REAL > &matA, TPZFMatrix< REAL > &vecb)
Contains the declaration of the TPZMultiphysicsElement class. This class is abstract.
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Definition: pzgeoelside.h:83
void ChangeMaterialIdIntoCompElement(TPZCompEl *cel, int oldmatid, int newmatid)
virtual int NSides() const =0
Returns the number of connectivities of the element.
void CenterPoint(TPZVec< REAL > &center) const
return the coordinates of the center in master element space (associated with the side) ...
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
Definition: pzmanvector.h:426
TPZManVector< int64_t > fDestinationIndex
Definition: pzelmat.h:53
void ComputeDestinationIndices()
Definition: pzelmat.cpp:126
Abstract class defining integration rules. Numerical Integration.
Definition: tpzintpoints.h:19
Implements SkyLine Structural Matrices. Structural Matrix.
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
virtual void CenterPoint(int side, TPZVec< REAL > &masscent) const =0
It returns the coordinates from the center of the side of the element in the element coordinate space...
virtual TPZIntPoints * CreateSideIntegrationRule(int side, int order)=0
Creates an integration rule for the topology of the corresponding side and able to integrate a polyno...
Contains the TPZBndCond class which implements a boundary condition for TPZMaterial objects...
virtual TPZMaterial * Material() const
Identify the material object associated with the element.
Definition: pzcompel.cpp:959
void HigherLevelElementList(TPZStack< TPZCompElSide > &elsidevec, int onlyinterpolated, int removeduplicates)
Returns all connected elements which have level higher to the current element.
Definition: pzcompel.cpp:761
TPZGradientData & operator=(const TPZGradientData &copy)
void Print(std::ostream &out)
Definition: pzelmat.cpp:47
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
void LoadSolution(const TPZFMatrix< STATE > &sol)
Given the solution of the global system of equations, computes and stores the solution for the restri...
Definition: pzcmesh.cpp:441
virtual TPZMatrix< STATE > * Create()
void Push(const T object)
Pushes a copy of the object on the stack.
Definition: pzstack.h:80
void EqualLevelElementList(TPZStack< TPZCompElSide > &elsidevec, int onlyinterpolated, int removeduplicates)
Returns all connected elements which have equal level to the current element This method will not put...
Definition: pzcompel.cpp:771
void ComputeWeights(REAL paramk)
Method to calculate the weights that we will use in distorted meshes.
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
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
Definition: pzlog.h:87
void X(TPZVec< REAL > &loc, TPZVec< REAL > &result) const
X coordinate of a point loc of the side.
This class defines the boundary condition for TPZMaterial objects.
Definition: pzbndcond.h:29
TPZCompMesh * Mesh() const
Return a pointer to the grid of the element.
Definition: pzcompel.cpp:288
Contains the TPZSkylineStructMatrix class which implements SkyLine Structural Matrices.
Definition: pzmatrix.h:52
int Dimension() const
Returns the dimension of the simulation.
Definition: pzcmesh.h:148
void SetData(TPZManVector< REAL, 3 > &center, TPZManVector< STATE, 3 > &grad, STATE u0, STATE alphak)
Definition: pzgradient.h:51
virtual void SetMatrix(TPZAutoPointer< TPZMatrix< TVar > > Refmat)
Sets a matrix to the current object.
Definition: pzsolve.h:115
TPZCompEl * Reference() const
Return a pointer to the element referenced by the geometric element.
Definition: pzgeoel.h:750
void InsertWeights(TPZFMatrix< REAL > &DeltaH, TPZFMatrix< REAL > &DifSol)
Method to insert the weights in the matrices of the system by least squares.
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
virtual void AddKel(TPZFMatrix< TVar > &elmat, TPZVec< int64_t > &destinationindex)
Add a contribution of a stiffness matrix.
Definition: pzmatrix.cpp:506
string res
Definition: test.py:151
static int GetgOrder()
Set the default value of the interpolation order.
Definition: pzcompel.h:830
static int Substitution(const TVar *ptr, int64_t rows, TPZFMatrix< TVar > *B)
Definition: pzfmatrix.cpp:1323
TPZManVector< int64_t > fSourceIndex
Definition: pzelmat.h:53
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Definition: pzfmatrix.h:616
TPZGeoNode & Node(int i) const
Returns the ith node of the element.
Definition: pzgeoel.cpp:2570
void Solve(const TPZFMatrix< TVar > &F, TPZFMatrix< TVar > &result, TPZFMatrix< TVar > *residual=0) override
Solves the system of linear equations.
std::map< int,TPZMaterial *> & MaterialVec()
Returns a reference to the material pointers vector.
Definition: pzcmesh.h:203
This class associates an element matrix with the coeficients of its contribution in the global stiffn...
Definition: pzelmat.h:30
TPZFNMatrix< 1000, STATE > fConstrMat
Pointer to the constrained matrix object.
Definition: pzelmat.h:48
Implements the interfaces for TPZCompElDisc, TPZInterfaceElement and TPZInterpolatedElement. Computational element.
void ApplyConstraints()
Apply the constraints applied to the nodes by transforming the tangent matrix and right hand side...
Definition: pzelmat.cpp:186
TPZFlopCounter pow(const TPZFlopCounter &orig, const TPZFlopCounter &xp)
Returns the power and increments the counter of the power.
Definition: pzreal.h:487
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
virtual void X(TPZVec< REAL > &qsi, TPZVec< REAL > &result) const =0
Return the coordinate in real space of the point coordinate in the master element space...
virtual REAL RefElVolume()=0
Volume of the master element.
void SetForcingFunction(TPZAutoPointer< TPZFunction< STATE > > fp)
Sets a procedure as source function for the material.
Definition: TPZMaterial.h:368
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
virtual void Multiply(const TPZFMatrix< TVar > &A, TPZFMatrix< TVar > &res, int opt=0) const
It mutiplies itself by TPZMatrix<TVar>A putting the result in res.
Definition: pzmatrix.cpp:1916
TPZAdmChunkVector< TPZCompEl * > & ElementVec()
Returns a reference to the element pointers vector.
Definition: pzcmesh.h:183
void SetCel(TPZCompEl *cel, bool useweight, REAL paramK)
virtual void Solution(TPZVec< REAL > &qsi, int var, TPZVec< STATE > &sol)
Calculates the solution - sol - for the variable var at point qsi, where qsi is expressed in terms of...
Definition: pzcompel.cpp:421
Contains declaration of TPZInterpolatedElement class which implements computational element of the in...
int NumLoadCases()
returns the number of load cases for this material object
Definition: TPZMaterial.h:186
void SetMaterialId(int id)
Sets the material index of the element.
Definition: pzgeoel.h:395
int Id() const
Definition: TPZMaterial.h:170
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 TPZStepSolver class which defines step solvers class.
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
void SetDataGhostsNeighbors(TPZVec< REAL > LxLyLz, TPZVec< int > MatIdBC, TPZManVector< TPZVec< REAL > > coordmin, TPZManVector< TPZVec< REAL > > coordmax)
Contains the TPZIntPoints class which defines integration rules.
TPZStack< TPZManVector< REAL, 3 > > fCenterPointInterface
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
void AssembleGlobalMatrix(TPZCompEl *el, TPZElementMatrix &ek, TPZElementMatrix &ef, TPZMatrix< STATE > &stiffmatrix, TPZFMatrix< STATE > &rhs)
void SetDirect(const DecomposeType decomp)
clarg::argString m("-m", "input matrix file name (text format)", "matrix.txt")
void GetCoordinates(TPZVec< REAL > &co)
Fill the coordinates of the node.
Definition: pzgnode.cpp:83
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
TPZGradientReconstruction(bool distmesh, REAL paramK)
virtual int HasDependency()
Returns 1 if the element has at least one dependent node. Returns 0 otherwise.
Definition: pzcompel.cpp:565
void Transpose(TPZMatrix< TVar > *const T) const override
It makes *T the transpose of current matrix.
Definition: pzfmatrix.cpp:1073
Implements computational element based on an interpolation space. Computational Element.
Definition: pzintel.h:27
virtual int SolveDirect(TPZFMatrix< TVar > &F, const DecomposeType dt, std::list< int64_t > &singular)
Solves the linear system using Direct methods.
Definition: pzmatrix.cpp:710
virtual void Point(int i, TPZVec< REAL > &pos, REAL &w) const =0
Returns i-th point at master element and related weight.
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15
This class implements a reference counter mechanism to administer a dynamically allocated object...