NeoPZ
pzmatmixedpoisson3d.cpp
Go to the documentation of this file.
1 //
2 // pzmatmixedpoisson3d.cpp
3 // PZ
4 //
5 // Created by Agnaldo Farias on 03/11/14.
6 //
7 //
8 
9 #include "pzmatmixedpoisson3d.h"
10 #include "pzlog.h"
11 #include "pzfmatrix.h"
12 #include "pzmaterialdata.h"
13 #include "pzbndcond.h"
14 #include "pzaxestools.h"
15 #include "pzlog.h"
16 
17 #include <iostream>
18 
19 #ifdef LOG4CXX
20 static LoggerPtr logdata(Logger::getLogger("pz.TPZMatMixedPoisson3D.data"));
21 #endif
22 
23 using namespace std;
24 
28 TPZMaterial(){
29 
31  fF = 0.; //fF
32 
34  fDim = 2;
35 
37  fMatId = -1;
38 
39  falpha = 0.;
40  fvisc = 1.;
41  fInvK.Resize(1, 1);
42  fTensorK.Resize(1, 1);
44  fInvK.Identity();
45  fPermeabilityFunction = NULL;
46  fReactionTermFunction = NULL;
48  fSecondIntegration = false;
49  fReactionTerm = false;
50 
51 }
52 
55 TPZMaterial(matid){
56 
57 
59  fF = 0.; //fF
60 
62  fDim = dim;
63 
65  fMatId = matid;
66 
67  fvisc = 1.;
68  falpha = 0.;
69  fInvK.Redim(dim, dim);
70  fTensorK.Resize(dim, dim);
71  fInvK.Identity();
73  fPermeabilityFunction = NULL;
74  fReactionTermFunction = NULL;
76  fSecondIntegration = false;
77  fReactionTerm = false;
78 }
79 
81 }
82 
84 TPZMaterial(copy){
85 
86  this->operator=(copy);
87  this->fF = copy.fF;
88  this->falpha = copy.falpha;
89  this->fDim = copy.fDim;
90  this->fMatId = copy.fMatId;
91  this->fmatLagr = copy.fmatLagr;
92  this->fTensorK = copy.fTensorK;
93  this->fInvK = copy.fInvK;
95  this->fReactionTerm = copy.fReactionTerm;
96 }
97 
99 
101  this->fF = copy.fF;
102  this->falpha = copy.falpha;
103  this->fDim = copy.fDim;
104  this->fMatId = copy.fMatId;
105  this->fmatLagr = copy.fmatLagr;
106  this->fTensorK = copy.fTensorK;
107  this->fInvK = copy.fInvK;
109  this->fReactionTerm = copy.fReactionTerm;
110 
111  return *this;
112 }
113 
115  return 1;
116 }
117 
118 void TPZMatMixedPoisson3D::Print(std::ostream &out) {
119  out << "name of material : " << Name() << "\n";
120  out << "Dimesion of problem " << fDim << endl;
121  out << "Material ID "<< fMatId << endl;
122  out << "Forcing function "<< fF << endl;
123  out << "Base Class properties :";
124  TPZMaterial::Print(out);
125  out << "\n";
126 }
127 
128 
129 // Contribute methods
130 // esse metodo esta ok
131 //This method use normalized piola contravariant mapping for nonlinear mappings. With second integration by parts
133 {
134  int phrq = datavec[0].fVecShapeIndex.NElements();
135 
136  if(!fSecondIntegration){
137 
138  if(/*HDivPiola==0 ||*/ phrq == 0){
139  std::cout << "\n Error.\n";
140  std::cout << "If you want to use the variational formulation with second integration by parts, you need to set fSecondIntegration==true\n";
141  DebugStop();
142  }
143 
144  ContributeWithoutSecondIntegration(datavec,weight,ek,ef);
145  return;
146  }
147 
148 #ifdef PZDEBUG
149  int nref = datavec.size();
150  if (nref != 2 ) {
151  std::cout << " Erro. The size of the datavec is different from 2 \n";
152  DebugStop();
153  }
154 #endif
155  REAL force = fF;
156  if(fForcingFunction) {
158  fForcingFunction->Execute(datavec[1].x,res);
159  force = res[0];
160  }
161 
162  // Setting the phis
163  TPZFMatrix<REAL> &phiQ = datavec[0].phi;
164  TPZFMatrix<REAL> &phip = datavec[1].phi;
165  TPZFMatrix<REAL> &dphipLoc = datavec[1].dphix;
166 
167  TPZFNMatrix<660> GradofPhiL2;
168  TPZAxesTools<REAL>::Axes2XYZ(datavec[1].dphix, GradofPhiL2, datavec[1].axes);
169 
170 
171  int phrp = phip.Rows();
172 
173  //Matrix B: the contribution of skeletal elements is done by TPZLagrangeMultiplier material
174  if(phrq==0) {
175  int nr = phiQ.Rows();
176  if(nr<1) DebugStop();
177  REAL multiplier = -1.;
178  fmatLagr->SetMultiplier(multiplier);
179  fmatLagr->Contribute(datavec, weight, ek, ef);
180  return;
181  }
182 
183  //Calculate the matrix contribution for flux. Matrix A
184  // A matriz de rigidez é tal que A{ij}=\int_\Omega K^{-1} \varphi_j\cdot\varphi_i d\Omega
185  // K, futuramente sera uma matriz ou funcao, deve-se ter cuidado com essa parte da inversao de K
186 
187  TPZFNMatrix<3,REAL> PermTensor = fTensorK;
188  TPZFNMatrix<3,REAL> InvPermTensor = fInvK;
189 
191 // PermTensor.Redim(fDim,fDim);
192 // InvPermTensor.Redim(fDim,fDim);
193  TPZFNMatrix<3,STATE> resultMat;
195  fPermeabilityFunction->Execute(datavec[0].x,res,resultMat);
196 
197  for(int id=0; id<fDim; id++){
198  for(int jd=0; jd<fDim; jd++){
199 
200  PermTensor(id,jd) = resultMat(id,jd);
201  InvPermTensor(id,jd) = resultMat(id+fDim,jd);
202  }
203  }
204  }
205 
206 
207  //REAL InvK = 1./fK;
208  for (int iq = 0; iq<phrq; iq++)
209  {
210  int ivecind = datavec[0].fVecShapeIndex[iq].first;
211  int ishapeind = datavec[0].fVecShapeIndex[iq].second;
212  TPZFNMatrix<3> ivec(3,1);
213  ivec(0,0) = datavec[0].fNormalVec(0,ivecind);
214  ivec(1,0) = datavec[0].fNormalVec(1,ivecind);
215  ivec(2,0) = datavec[0].fNormalVec(2,ivecind);
216 
217  TPZFNMatrix<3,REAL> jvecZ(3,1,0.);
218 
219  for (int jq=0; jq<phrq; jq++)
220  {
221  TPZFNMatrix<3> jvec(3,1);
222  int jvecind = datavec[0].fVecShapeIndex[jq].first;
223  int jshapeind = datavec[0].fVecShapeIndex[jq].second;
224  jvec(0,0) = datavec[0].fNormalVec(0,jvecind);
225  jvec(1,0) = datavec[0].fNormalVec(1,jvecind);
226  jvec(2,0) = datavec[0].fNormalVec(2,jvecind);
227 
228 
229  //dot product between Kinv[u]v
230  jvecZ.Zero();
231  for(int id=0; id<3; id++){
232  for(int jd=0; jd<3; jd++){
233  jvecZ(id,0) += InvPermTensor(id,jd)*jvec(jd,0);
234  }
235  }
236  REAL prod = 0.;
237  for(int id=0; id < 3;id++) prod += ivec(id,0)*jvecZ(id,0);
238  ek(iq,jq) += fvisc*weight*phiQ(ishapeind,0)*phiQ(jshapeind,0)*prod;
239 
240  }
241  }
242 
243  // Coupling terms between flux and pressure inside the element. Matrix B
244  // A matriz de rigidez é tal que B{ij}=\int_\Omega \nabla\phi_j\cdot\varphi_i d\Omega
245 
246  TPZFNMatrix<200,REAL> dphip(3,datavec[1].dphix.Cols(),0.0);
247  for (int ip = 0; ip<dphip.Cols(); ip++) {
248  for (int d = 0; d<dphipLoc.Rows(); d++) {
249  for (int j=0; j< 3; j++) {
250  dphip(j,ip)+=datavec[1].axes(d,j)*dphipLoc(d,ip);
251  }
252  }
253  }
254 
255  for(int iq=0; iq<phrq; iq++)
256  {
257  int ivecind = datavec[0].fVecShapeIndex[iq].first;
258  int ishapeind = datavec[0].fVecShapeIndex[iq].second;
259  TPZFNMatrix<3> ivec(3,1);
260  ivec(0,0) = datavec[0].fNormalVec(0,ivecind);
261  ivec(1,0) = datavec[0].fNormalVec(1,ivecind);
262  ivec(2,0) = datavec[0].fNormalVec(2,ivecind);
263 
264  for (int jp=0; jp<phrp; jp++)
265  {
266  //dot product between varphi and grad phi
267  REAL prod = 0.;
268  for(int iloc=0; iloc<3; iloc++)
269  {
270  prod += (ivec(iloc,0)*phiQ(ishapeind,0))*GradofPhiL2(iloc,jp);
271  }
272 
273  REAL fact = weight*prod;
274  // Matrix B
275  ek(iq, phrq+jp) += fact;
276 
277  // Matrix B^T
278  ek(phrq+jp,iq) += fact;
279 
280  }
281  }
282 
283  if(fReactionTerm)
284  {
285  REAL alpha = falpha;
286 
288  {
289  TPZFNMatrix<3,STATE> resultMat;
291  fReactionTermFunction->Execute(datavec[1].x,res,resultMat);
292 
293  alpha = res[0];
294  }
295 
296  for(int ip=0; ip<phrp; ip++)
297  {
298  for (int jp=0; jp<phrp; jp++)
299  {
300  REAL fact = (-1.)*weight*phip(ip,0)*phip(jp,0);
301  // Matrix C
302  ek(phrq+ip, phrq+jp) += alpha*fact;
303  }
304  }
305  }
306 
307 
308  //termo fonte referente a equacao da pressao
309  for(int ip=0; ip<phrp; ip++){
310  ef(phrq+ip,0) += (-1.)*weight*force*phip(ip,0);
311  }
312 }
313 
314 
317 #ifdef PZDEBUG
318  int nref = datavec.size();
319  if (nref != 2 ) {
320  std::cout << " Erro. The size of the datavec is different from 2 \n";
321  DebugStop();
322  }
323 #endif
324 
325  STATE force = fF;
326  if(fForcingFunction) {
328  fForcingFunction->Execute(datavec[1].x,res);
329  force = res[0];
330  }
331 
332  TPZFNMatrix<9,REAL> PermTensor = fTensorK;
333  TPZFNMatrix<9,REAL> InvPermTensor = fInvK;
334  //int rtens = 2*fDim;
336  {
337 
338  TPZFNMatrix<3,STATE> resultMat;
340  fPermeabilityFunction->Execute(datavec[0].x,res,resultMat);
341 
342  for(int id=0; id<fDim; id++){
343  for(int jd=0; jd<fDim; jd++){
344 
345  PermTensor(id,jd) = resultMat(id,jd);
346  InvPermTensor(id,jd) = resultMat(id+fDim,jd);
347  }
348  }
349  }
350 
351  // Setting the phis
352  TPZFMatrix<REAL> &phiQ = datavec[0].phi;
353  TPZFMatrix<REAL> &phip = datavec[1].phi;
354  TPZFMatrix<REAL> &dphiQ = datavec[0].dphix;
355  TPZFNMatrix<40, REAL> divphi = datavec[0].divphi;
356 
357 
358  int phrq, phrp;
359  phrp = phip.Rows();
360  phrq = datavec[0].fVecShapeIndex.NElements();
361 
362  //Calculate the matrix contribution for flux. Matrix A
363  for(int iq=0; iq<phrq; iq++)
364  {
365  int ivecind = datavec[0].fVecShapeIndex[iq].first;
366  int ishapeind = datavec[0].fVecShapeIndex[iq].second;
367  TPZFNMatrix<3,REAL> ivec(3,1,0.);
368  for(int id=0; id<fDim; id++){
369  ivec(id,0) = datavec[0].fNormalVec(id,ivecind);
370  }
371 
372  TPZFNMatrix<3,REAL> ivecZ(3,1,0.);
373  TPZFNMatrix<3,REAL> jvecZ(3,1,0.);
374  for (int jq=0; jq<phrq; jq++)
375  {
376  TPZFNMatrix<3,REAL> jvec(3,1,0.);
377  int jvecind = datavec[0].fVecShapeIndex[jq].first;
378  int jshapeind = datavec[0].fVecShapeIndex[jq].second;
379 
380  for(int id=0; id<fDim; id++){
381  jvec(id,0) = datavec[0].fNormalVec(id,jvecind);
382  }
383 
384  //dot product between Kinv[u]v
385  jvecZ.Zero();
386  for(int id=0; id<fDim; id++){
387  for(int jd=0; jd<fDim; jd++){
388  jvecZ(id,0) += InvPermTensor(id,jd)*jvec(jd,0);
389  }
390  }
391 
392  REAL prod1 = ivec(0,0)*jvecZ(0,0) + ivec(1,0)*jvecZ(1,0) + ivec(2,0)*jvecZ(2,0);
393  ek(iq,jq) += fvisc*weight*phiQ(ishapeind,0)*phiQ(jshapeind,0)*prod1;
394  }
395  }
396 
397  // Coupling terms between flux and pressure. Matrix B
398  for(int iq=0; iq<phrq; iq++)
399  {
400 
401  REAL divwq = divphi(iq,0)/datavec[0].detjac;
402 
403  for (int jp=0; jp<phrp; jp++) {
404 
405  REAL fact = (-1.)*weight*phip(jp,0)*divwq;
406  // Matrix B
407  ek(iq, phrq+jp) += fact;
408 
409  // Matrix B^T
410  ek(phrq+jp,iq) += fact;
411  }
412  }
413 
414  //Calculate the matrix contribution for pressure. Matrix C: term: alpha*p
415  if(fReactionTerm)
416  {
417  REAL alpha = falpha;
419  {
420  TPZFNMatrix<3,STATE> resultMat;
422  fReactionTermFunction->Execute(datavec[1].x,res,resultMat);
423 
424  alpha = res[0];
425  }
426 
427  for(int ip=0; ip<phrp; ip++)
428  {
429  for (int jp=0; jp<phrp; jp++)
430  {
431 
432  REAL fact = (-1.)*weight*phip(ip,0)*phip(jp,0);
433  // Matrix C
434  ek(phrq+ip, phrq+jp) += alpha*fact;
435  }
436  }
437  }
438 
439 
440  //termo fonte referente a equacao da pressao
441  for(int ip=0; ip<phrp; ip++){
442  ef(phrq+ip,0) += (-1.)*weight*force*phip(ip,0);
443  }
444 
445  //
446  //#ifdef LOG4CXX
447  // if(logdata->isDebugEnabled())
448  // {
449  // std::stringstream sout;
450  // sout<<"\n\n Matriz ek e vetor fk \n ";
451  // ek.Print("ekmph = ",sout,EMathematicaInput);
452  // ef.Print("efmph = ",sout,EMathematicaInput);
453  // LOGPZ_DEBUG(logdata,sout.str());
454  // }
455  //#endif
456 
457 }
458 
460 
461 #ifdef PZDEBUG
462  int nref = datavec.size();
463  if (nref != 2 ) {
464  std::cout << " Erro.!! datavec tem que ser de tamanho 2 \n";
465  DebugStop();
466  }
467  // if (!bc.Type() ) {
468  // std::cout << " Erro.!!\n";
469  // DebugStop();
470  // }
471 #endif
472 
473 
474  TPZFMatrix<REAL> &phiQ = datavec[0].phi;
475  int phrq = phiQ.Rows();
476 
477  REAL v2;
478  if(bc.HasForcingFunction())
479  {
481  bc.ForcingFunction()->Execute(datavec[0].x,res);
482  v2 = res[0];
483  }else
484  {
485  v2 = bc.Val2()(0,0);
486  }
487 
488 
489 
490  switch (bc.Type()) {
491  case 0 : // Dirichlet condition
492  //primeira equacao
493  for(int iq=0; iq<phrq; iq++)
494  {
495  //the contribution of the Dirichlet boundary condition appears in the flow equation
496  ef(iq,0) += (-1.)*v2*phiQ(iq,0)*weight;
497  }
498  break;
499 
500  case 1 : // Neumann condition
501  //primeira equacao
502  for(int iq=0; iq<phrq; iq++)
503  {
504  ef(iq,0)+= gBigNumber*v2*phiQ(iq,0)*weight;
505  for (int jq=0; jq<phrq; jq++) {
506 
507  ek(iq,jq)+= gBigNumber*phiQ(iq,0)*phiQ(jq,0)*weight;
508  }
509  }
510  break;
511 
512  case 2 : // mixed condition
513  for(int iq = 0; iq < phrq; iq++) {
514 
515  ef(iq,0) += v2*phiQ(iq,0)*weight;
516  for (int jq = 0; jq < phrq; jq++) {
517  ek(iq,jq) += weight*bc.Val1()(0,0)*phiQ(iq,0)*phiQ(jq,0);
518  }
519  }
520 
521  break;
522 
523  // case 3 : //Contribution of skeletal elements.
524  // {
525  // REAL multiplier = -1.;
526  // fmatLagr->SetMultiplier(multiplier);
527  // fmatLagr->Contribute(datavec, weight, ek, ef);
528  // break;
529  // }
530  default:
531  {
532  std::cout << "Boundary condition not found!";
533  DebugStop();
534  break;
535  }
536 
537 
538  }
539 
540 }
541 
543 {
544  int nref = datavec.size();
545  for(int i = 0; i<nref; i++)
546  {
547  datavec[i].fNeedsSol = false;
548  datavec[i].fNeedsNormal = false;
549  }
550 }
551 
553 int TPZMatMixedPoisson3D::VariableIndex(const std::string &name){
554  if(!strcmp("Flux",name.c_str())) return 1;
555  if(!strcmp("Pressure",name.c_str())) return 2;
556  if(!strcmp("GradFluxX",name.c_str())) return 3;
557  if(!strcmp("GradFluxY",name.c_str())) return 4;
558  if(!strcmp("GradFluxZ",name.c_str())) return 5;
559  if(!strcmp("ExactPressure",name.c_str())) return 6;
560  if(!strcmp("ExactFlux",name.c_str())) return 7;
561  if(!strcmp("Rhs",name.c_str())) return 8;
562  if(!strcmp("GradP",name.c_str())) return 9;
563  if(!strcmp("Divergence",name.c_str())) return 10;
564  if(!strcmp("ExactDiv",name.c_str())) return 11;
565  if(!strcmp("POrder",name.c_str())) return 12;
566 
567  return TPZMaterial::VariableIndex(name);
568 }
569 
571  if(var == 1) return fDim;
572  if(var == 2 || var == 12) return 1;
573  if(var == 3) return 3;
574  if(var == 4) return 3;
575  if(var == 5) return 3;
576  if(var == 6) return 1;
577  if(var == 7) return fDim;
578  if(var == 8 || var == 10 || var == 11) return 1;
579  if(var == 9) return fDim;
581 }
582 
583 // metodo para gerar vtk
585 
586  Solout.Resize( this->NSolutionVariables(var));
587 
588  TPZVec<STATE> SolP, SolQ;
589 
590  // SolQ = datavec[0].sol[0];
591  SolP = datavec[1].sol[0];
592 
593 
594  if(var == 1){ //function (state variable Q)
595  for (int ip = 0; ip<fDim; ip++)
596  {
597  Solout[ip] = datavec[0].sol[0][ip];
598  }
599  return;
600  }
601 
602  if(var == 2){
603  Solout[0] = SolP[0];//function (state variable p)
604  return;
605  }
606 
607  if(var==3){
608  for (int ip = 0; ip<Dimension(); ip++)
609  {
610  Solout[ip] = datavec[0].dsol[0](ip,0);
611  }
612  return;
613  }
614 
615  if(var==4){
616  for (int ip = 0; ip<Dimension(); ip++)
617  {
618  Solout[ip] = datavec[0].dsol[0](ip,1);
619  }
620  return;
621  }
622 
623  if(var==5){
624  for (int ip = 0; ip<Dimension(); ip++)
625  {
626  Solout[ip] = datavec[0].dsol[0](ip,2);
627  }
628  return;
629  }
630 
631  TPZVec<REAL> ptx(3);
632  TPZVec<STATE> solExata(1);
633  TPZFMatrix<STATE> flux(3,1);
634 
635  //Exact soluion
636  if(var == 6){
637  fForcingFunctionExact->Execute(datavec[1].x, solExata,flux);
638  Solout[0] = solExata[0];
639  return;
640  }//var6
641 
642  if(var == 7){
643  fForcingFunctionExact->Execute(datavec[0].x, solExata,flux);
644  for (int ip = 0; ip<fDim; ip++)
645  {
646  Solout[ip] = flux(ip,0);
647  }
648  return;
649  }//var7
650 
651  if(var == 8){
652  REAL force = fF;
653  if(fForcingFunction) {
655  fForcingFunction->Execute(datavec[1].x,res);
656  force = res[0];
657  }
658  Solout[0] = force;
659 
660  return;
661  }//var8
662 
663  if(var==9){
664 
665  TPZFNMatrix<660,STATE> GradofP;
666  TPZAxesTools<STATE>::Axes2XYZ(datavec[1].dsol[0], GradofP, datavec[1].axes);
667  // int nc = GradofP.Cols();
668  // int nl = GradofP.Rows();
669 
670  for (int ip = 0; ip<fDim; ip++)
671  {
672  Solout[ip] = -1.0*GradofP(ip,0);
673  }
674  return;
675  }
676 
677  if(var==10){
678  REAL val = 0.;
679  for(int i=0; i<fDim; i++){
680  val += datavec[0].dsol[0](i,i);
681  }
682  Solout[0] = val;
683  return;
684  }
685 
686  if(var==11){
687  fForcingFunctionExact->Execute(datavec[0].x,solExata,flux);
688  Solout[0]=flux(fDim,0);
689  return;
690  }
691 
692  if(var==12){
693  Solout[0] = datavec[1].p;
694  return;
695  }
696 }
697 
698 // metodo para computar erros
700 
701  Solout.Resize( 3 /*this->NSolutionVariables(var)*/);
702  // AQUI!!! //redefinicao feita acima, antigamente mudava para 2, por exemplo, e nao ficava compativel com o resto que era 3
703 
704  if(var == 1){ //function (state variable Q)
705  for (int ip = 0; ip<3; ip++)
706  {
707  Solout[ip] = data.sol[0][ip];
708  }
709 
710  return;
711  }
712 
713  if(var == 2){ //function (state variable p)
714 
715  TPZVec<STATE> SolP;
716  SolP = data.sol[0];
717 
718  Solout[0] = SolP[0];
719  return;
720  }
721 
722 
723 }
724 
725 #include "pzaxestools.h"
727 
728 #ifndef STATE_COMPLEX
729  Solout.Resize( this->NSolutionVariables( var ) );
730 
731  if(var == 1){
732  int id;
733  for(id=0 ; id<fDim; id++) {
734  TPZFNMatrix<9,STATE> dsoldx;
735  TPZAxesTools<STATE>::Axes2XYZ(DSol, dsoldx, axes);
736  Solout[id] = dsoldx(id,0);//derivate
737  }
738  return;
739  }
740  if(var == 2) {
741  Solout[0] = Sol[0];//function
742  return;
743  }//var == 2
744 
745 #endif
746  TPZMaterial::Solution(Sol, DSol, axes, var, Solout);
747 
748 }//method
749 
751 {
752  int nref = datavec.size();
753  for(int i = 0; i<nref; i++)
754  {
755  datavec[i].SetAllRequirements(false);
756  datavec[i].fNeedsSol = false;
757  datavec[i].fNeedsNeighborSol = false;
758  datavec[i].fNeedsNeighborCenter = false;
759  datavec[i].fNeedsNormal = false;
760  }
761 }
762 
764 
765  values.Fill(0.0);
766  TPZVec<STATE> primal(1),dual(3),div(1);
767  Solution(data,1,dual);//fluxo
768  //Solution(data,14,div);//divergente
769 
770  for(int id=0; id<3; id++) {
771  REAL diffFlux = abs(dual[id] - du_exact(id,0));
772 
773  values[1] += diffFlux*diffFlux;
774  }
775 
776 }
777 
778 
779 
781  TPZFMatrix<STATE> &dudx, TPZFMatrix<REAL> &axes, TPZVec<STATE> &/*flux*/,
782  TPZVec<STATE> &u_exact,TPZFMatrix<STATE> &du_exact,TPZVec<REAL> &values) {
783 
784  values.Resize(NEvalErrors());
785  values.Fill(0.0);
786 
787  TPZManVector<STATE> sol(1),dsol(3,0.);
788  Solution(u,dudx,axes,2,sol);
789  Solution(u,dudx,axes,1,dsol);
790  int id;
791  //values[1] : eror em norma L2
792  REAL diff = fabs(sol[0] - u_exact[0]);
793  values[1] = diff*diff;
794  //values[2] : erro em semi norma H1
795  values[2] = 0.;
796  for(id=0; id<fDim; id++) {
797  DebugStop();
798 // diff = fabs(dsol[id] - du_exact(id,0));
799 // values[2] += abs(fK)*diff*diff;
800  }
801  //values[0] : erro em norma H1 <=> norma Energia
802  values[0] = values[1]+values[2];
803 }
804 
806  return Hash("TPZMatMixedPoisson3D") ^ TPZMaterial::ClassId() << 1;
807 }
808 
809 
void Print(std::ostream &out) override
Prints out the data associated with the material.
virtual void Solution(TPZMaterialData &data, int var, TPZVec< STATE > &Solout)
Returns the solution associated with the var index based on the finite element approximation.
virtual void Execute(const TPZVec< REAL > &x, TPZVec< TVar > &f, TPZFMatrix< TVar > &df)
Performs function computation.
Definition: pzfunction.h:38
virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
It computes a contribution to the stiffness matrix and load vector at one integration point...
TPZMatMixedPoisson3D & operator=(const TPZMatMixedPoisson3D &copy)
Material which implements a Lagrange Multiplier.
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
void ContributeWithoutSecondIntegration(TPZVec< TPZMaterialData > &datavec, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef)
This method use piola contravariant mapping for nonlinear mappings.
TPZFMatrix< REAL > fTensorK
permeability tensor. Coeficient which multiplies the gradient operator
virtual void ContributeBC(TPZVec< TPZMaterialData > &datavec, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
It computes a contribution to the stiffness matrix and load vector at one BC integration point...
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.
Implements a vector class which allows to use external storage provided by the user. Utility.
Definition: pzquad.h:16
clarg::argBool bc("-bc", "binary checkpoints", false)
static void Axes2XYZ(const TPZFMatrix< TVar > &dudaxes, TPZFMatrix< TVar > &dudx, const TPZFMatrix< REAL > &axesv, bool colMajor=true)
Makes the basis transformation from axes basis to euclidian basis.
Definition: pzaxestools.h:61
int Type()
Definition: pzbndcond.h:249
TPZMaterial & operator=(const TPZMaterial &copy)
operator =
Definition: TPZMaterial.cpp:62
virtual void Identity()
Converts the matrix in an identity matrix.
Definition: pzmatrix.cpp:199
virtual int VariableIndex(const std::string &name)
Returns the variable index associated with the name.
TPZFMatrix< REAL > fInvK
inverse of the permeability tensor.
virtual void FillBoundaryConditionDataRequirement(int type, TPZVec< TPZMaterialData > &datavec) override
This method defines which parameters need to be initialized in order to compute the contribution of t...
bool fSecondIntegration
Parameter to choose the second integration by parts in the variational formulation.
TinyFad< 8, T > abs(const TinyFad< 8, T > &in)
Definition: tinyfadeight.h:846
This class implements a simple vector storage scheme for a templated class T. Utility.
Definition: pzgeopoint.h:19
REAL val(STATE &number)
Returns value of the variable.
Definition: pzartdiff.h:23
virtual int ClassId() const override
Define the class id associated with the class.
TPZFMatrix< STATE > & Val2(int loadcase=0)
Definition: pzbndcond.h:255
virtual void Print(std::ostream &out=std::cout)
Prints out the data associated with the material.
virtual void Contribute(TPZVec< TPZMaterialData > &datavec, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
It computes a contribution to the stiffness matrix and load vector at one integration point...
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
Contains the TPZBndCond class which implements a boundary condition for TPZMaterial objects...
TPZAutoPointer< TPZFunction< STATE > > & ForcingFunction()
Returns a procedure as source function for the material.
Definition: TPZMaterial.h:397
int Zero() override
Makes Zero all the elements.
Definition: pzfmatrix.h:651
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
virtual int NEvalErrors()
Returns the number of norm errors. Default is 3: energy, L2 and H1.
Definition: TPZMaterial.h:524
virtual int NStateVariables() const override
Returns the number of state variables associated with the material.
virtual void FillDataRequirements(TPZVec< TPZMaterialData > &datavec) override
It computes a contribution to stiffness matrix and load vector at one BC integration point...
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
TPZAutoPointer< TPZFunction< STATE > > fForcingFunctionExact
Pointer to exact solution function, needed to calculate exact error.
Definition: TPZMaterial.h:50
This class defines the boundary condition for TPZMaterial objects.
Definition: pzbndcond.h:29
void ErrorsHdiv(TPZMaterialData &data, TPZVec< STATE > &u_exact, TPZFMatrix< STATE > &du_exact, TPZVec< REAL > &values) override
virtual std::string Name() override
Returns the name of the material.
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
int Dimension() const override
Returns the integrable dimension of the material.
string res
Definition: test.py:151
TPZFMatrix< STATE > & Val1()
Definition: pzbndcond.h:253
Contains the TPZMaterialData class which implements an interface between TPZCompEl::CalcStiff and TPZ...
virtual int HasForcingFunction()
Directive that gives true if the material has a forcing function.
Definition: TPZMaterial.h:472
TPZAutoPointer< TPZFunction< STATE > > fPermeabilityFunction
Pointer to forcing function, it is the Permeability and its inverse.
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Definition: pzfmatrix.h:616
static REAL gBigNumber
Big number to penalization method, used for Dirichlet conditions.
Definition: TPZMaterial.h:83
TPZLagrangeMultiplier * fmatLagr
virtual void SetMultiplier(STATE mult)
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
int ClassId() const override
Unique identifier for serialization purposes.
int VariableIndex(const std::string &name) override
virtual int NSolutionVariables(int var)
Returns the number of variables associated with the variable indexed by var.
void Errors(TPZVec< REAL > &x, TPZVec< STATE > &u, TPZFMatrix< STATE > &dudx, TPZFMatrix< REAL > &axes, TPZVec< STATE > &, TPZVec< STATE > &u_exact, TPZFMatrix< STATE > &du_exact, TPZVec< REAL > &values) override
Computes the error due to the difference between the interpolated flux and the flux computed based o...
TPZAutoPointer< TPZFunction< STATE > > fForcingFunction
Pointer to forcing function, it is the right member at differential equation.
Definition: TPZMaterial.h:47
REAL fvisc
fluid viscosity
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 TPZAxesTools class which implements verifications over axes...
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
int Resize(const int64_t newRows, const int64_t wCols) override
Redimension a matrix, but maintain your elements.
Definition: pzfmatrix.cpp:1016
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
def values
Definition: rdt.py:119
void Solution(TPZVec< TPZMaterialData > &datavec, int var, TPZVec< STATE > &Solout) override
Returns the solution associated with the var index based on the finite element approximation.
Material to solve a mixed poisson problem 3D by multiphysics simulation.
TPZSolVec sol
vector of the solutions at the integration point
TPZAutoPointer< TPZFunction< STATE > > fReactionTermFunction
Pointer to forcing function, it is the reaction term.
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
Definition: pzfmatrix.h:716
int NSolutionVariables(int var) override
Returns the number of variables associated with the variable indexed by var.