NeoPZ
TPZMultiphysicsInterfaceEl.cpp
Go to the documentation of this file.
1 
9 #include "pzelmat.h"
10 #include "pzinterpolationspace.h"
11 #include "TPZMaterial.h"
12 #include "pzmultiphysicselement.h"
13 #include "tpzintpoints.h"
14 #include "pzdiscgal.h"
15 #include "pzmultiphysicscompel.h"
16 #include "pzgeoel.h"
17 
18 #include "pzgraphel.h"
19 #include "pzgraphelq2dd.h"
20 #include "pzgraphelq3dd.h"
21 #include "pzgraphel1d.h"
22 #include "pzgraphel1dd.h"
23 #include "pztrigraphd.h"
24 #include "pztrigraph.h"
25 #include "tpzgraphelt2dmapped.h"
26 #include "tpzgraphelprismmapped.h"
28 #include "tpzgraphelt3d.h"
29 #include "pzgraphel.h"
30 #include "pzgraphmesh.h"
32 
33 
35 TPZCompEl(),fLeftElSide(0), fRightElSide(0)
36 {
37 }
38 
40  TPZCompElSide leftside, TPZCompElSide rightside) :
42 {
43 
44  ref->SetReference(this);
45 #ifdef PZDEBUG
46  TPZMaterial *mat = mesh.FindMaterial(ref->MaterialId());
47  if (!mat) {
48  DebugStop();
49  }
50 #endif
52 
53  TPZMultiphysicsElement * mp_left = dynamic_cast<TPZMultiphysicsElement * >(leftside.Element());
54  TPZMultiphysicsElement * mp_right = dynamic_cast<TPZMultiphysicsElement * >(rightside.Element());
55 
56 #ifdef PZDEBUG
57  if (!mp_left || !mp_right) {
58  DebugStop();
59  }
60 #endif
61 
62  int left_n_meshes = mp_left->NMeshes();
63  int right_n_meshes = mp_right->NMeshes();
64 
65  fLeftElIndices.Resize(left_n_meshes);
66  fRightElIndices.Resize(right_n_meshes);
67 
68  for (int iref = 0; iref < left_n_meshes; iref++) {
69  fLeftElIndices[iref] = iref;
70  }
71 
72  for (int iref = 0; iref < right_n_meshes; iref++) {
73  fRightElIndices[iref] = iref;
74  }
75 
76  this->SetLeftRightElement(leftside, rightside);
77  this->IncrementElConnected();
78  this->CreateIntegrationRule();
79 }
80 
82  const int ncon = this->NConnects();
83  for(int i = 0; i < ncon; i++){
84  int64_t index = this->ConnectIndex(i);
85  fMesh->ConnectVec()[index].IncrementElConnected();
86  }
87 }
88 
92 {
93  TPZCompElSide left = copy.Left();
94  TPZCompElSide right = copy.Right();
95  if (!left || !right ) {
96  DebugStop();
97  }
98  int leftside = left.Side();
99  int rightside = right.Side();
100  int64_t leftindex = left.Element()->Index();
101  int64_t rightindex = right.Element()->Index();
102  TPZCompEl *leftel = mesh.ElementVec()[leftindex];
103  TPZCompEl *rightel = mesh.ElementVec()[rightindex];
104  if (!leftel || !rightel) {
105  DebugStop();
106  }
107  fLeftElSide = TPZCompElSide(leftel,leftside);
108  fRightElSide = TPZCompElSide(rightel,rightside);
110 }
111 
114  std::map<int64_t,int64_t> & gl2lcElMap) :
116 {
118  DebugStop();
119  TPZCompElSide left = copy.Left();
120  TPZCompElSide right = copy.Right();
121  if (!left || !right ) {
122  DebugStop();
123  }
124  int leftside = left.Side();
125  int rightside = right.Side();
126  int64_t leftindex = left.Element()->Index();
127  int64_t rightindex = right.Element()->Index();
128  if (gl2lcElMap.find(leftindex) == gl2lcElMap.end() || gl2lcElMap.find(rightindex) == gl2lcElMap.end()) {
129  DebugStop();
130  }
131  TPZCompEl *leftel = mesh.ElementVec()[gl2lcElMap[leftindex]];
132  TPZCompEl *rightel = mesh.ElementVec()[gl2lcElMap[rightindex]];
133  if (!leftel || !rightel) {
134  DebugStop();
135  }
136  SetLeftRightElement(TPZCompElSide(leftel,leftside), TPZCompElSide(rightel,rightside));
137 
138 }
139 
140 
141 
142 
144  if (Reference()) {
146  }
147 }
148 
150 {
151  TPZGeoEl *gel = Reference();
152  int side = gel->NSides()-1;
153  TPZGeoElSide thisside(gel,side);
154  int64_t numneigh = Neighbor.size();
155  for (int64_t in=0; in<numneigh; in++) {
156  TPZGeoElSide gelside = Neighbor[in].Reference();
157  if(! thisside.NeighbourExists(gelside))
158  {
159  DebugStop();
160  }
161  TPZTransform<> tr(thisside.Dimension());
162  thisside.SideTransform3(gelside, tr);
163  transf[in] = tr;
164  }
165 }//ComputeSideTransform
166 
171 {
172  fLeftElSide = leftel;
173  fRightElSide = rightel;
175 }
176 
181 {
182  if(! fLeftElSide || ! fRightElSide){
183  DebugStop();
184  };
185 
186  fLeftElIndices=leftindices;
187  fRightElIndices=rightindices;
190 
191  int64_t nleftmeshes = LeftEl->NMeshes();
192  int64_t nrightmeshes = RightEl->NMeshes();
193 
194  int64_t nleftindices = leftindices.size();
195  int64_t nrightindices = rightindices.size();
196 
197  //Number of connects in each element
198  TPZManVector<int64_t,5> nclvec(nleftmeshes,0);
199  TPZManVector<int64_t,5> ncrvec(nrightmeshes,0);
200  TPZManVector<int64_t,5> first_left_c_index(nleftmeshes + 1,0);
201  TPZManVector<int64_t,5> first_right_c_index(nrightmeshes + 1,0);
202 
203  int64_t ncl=0, ncr=0;
204 
205  //left side
206  for (int64_t iref = 0; iref<nleftmeshes; iref++) {
207  TPZCompEl *Left = LeftEl->Element(iref);
208  if(Left){
209  nclvec[iref] = Left->NConnects();
210  bool is_active = LeftEl->IsActiveApproxSpaces(iref);
211  if (is_active) {
212  first_left_c_index[iref+1] = first_left_c_index[iref] + nclvec[iref];
213  }
214  }
215  }
216 
217  //right side
218  for (int64_t iref = 0; iref<nrightmeshes; iref++) {
219  TPZCompEl *Right = RightEl->Element(iref);
220  if(Right){
221  ncrvec[iref] = Right->NConnects();
222  bool is_active = RightEl->IsActiveApproxSpaces(iref);
223  if (is_active) {
224  first_right_c_index[iref+1] = first_right_c_index[iref] + ncrvec[iref];
225  }
226  }
227  }
228 
229  //left side
230  for(int64_t i = 0; i < nleftindices; i++){
231  int iref = leftindices[i];
232  TPZCompEl *Left = LeftEl->Element(iref);
233  if(Left){
234  if (LeftEl->IsActiveApproxSpaces(iref)) {
235  ncl += nclvec[iref];
236  }
237  }
238  }
239 
240  //right side
241  for(int64_t i = 0; i < nrightindices; i++){
242  int iref = rightindices[i];
243  TPZCompEl *Right = RightEl->Element(iref);
244  if(Right){
245  if (RightEl->IsActiveApproxSpaces(iref)) {
246  ncr += ncrvec[iref];
247  }
248  }
249  }
250 
252  fConnectIndexes.Resize(ncl+ncr);
253  int64_t count = 0;
254  for(int64_t i = 0; i < nleftindices; i++){
255  int iref = leftindices[i];
256  bool is_active = LeftEl->IsActiveApproxSpaces(iref);
257  if (is_active) {
258  for (int ic=0; ic < nclvec[iref]; ic++) {
259  fConnectIndexes[count++] = LeftEl->ConnectIndex(first_left_c_index[iref]+ic);
260  }
261  }
262  }
263 
264  for(int64_t i = 0; i < nrightindices; i++){
265  int iref = rightindices[i];
266  bool is_active = RightEl->IsActiveApproxSpaces(iref);
267  if (is_active) {
268  for (int ic=0; ic < ncrvec[iref]; ic++) {
269  fConnectIndexes[count++] = RightEl->ConnectIndex(first_right_c_index[iref]+ic);
270  }
271  }
272  }
273 
274  if (count != fConnectIndexes.size() ) {
275  DebugStop();
276  }
277 }
278 
279 
280 
285 {
286  leftel = fLeftElSide;
287  rightel = fRightElSide;
288 }
289 
292 {
293  return fConnectIndexes.size();
294 }
295 
301 {
302 
303 #ifdef PZDEBUG
304  if (i < 0 || i >= fConnectIndexes.size()) {
305  DebugStop();
306  }
307 #endif
308  return fConnectIndexes[i];
309 }
310 
311 
312 #include "pzmultiphysicscompel.h"
314 {
315 
316  TPZDiscontinuousGalerkin * material = dynamic_cast<TPZDiscontinuousGalerkin *> (this->Material());
317  if(!material){
318  PZError << "Error at " << __PRETTY_FUNCTION__ << " this->Material() == NULL\n";
319  ek.Reset();
320  ef.Reset();
321  return;
322  }
323 
324 
326 
327  if (this->NConnects() == 0) return;//boundary discontinuous elements have this characteristic
330  TPZGeoEl *leftgel = leftel->Reference();
331  TPZGeoEl *rightgel = rightel->Reference();
332 #ifdef PZDEBUG
333  if (!leftel || !rightel) {
334  DebugStop();
335  }
336 #endif
337 
338  TPZManVector<TPZMaterialData,6> datavecleft,datavecright;
339  TPZMaterialData data;
340  InitMaterialData(data, datavecleft, datavecright);
341 
342  TPZManVector<TPZTransform<REAL>,6> leftcomptr, rightcomptr;
343  leftel->AffineTransform(leftcomptr);
344  rightel->AffineTransform(rightcomptr);
345 
346  int nmesh =datavecleft.size();
347  for(int id = 0; id<nmesh; id++){
348  datavecleft[id].p = 0;
349  TPZInterpolationSpace *msp = dynamic_cast <TPZInterpolationSpace *>(leftel->Element(id));
350  if (msp)
351  {
352  datavecleft[id].p =msp->MaxOrder();
353  }
354  }
355 
356  TPZManVector<int> intleftorder;
357  leftel->PolynomialOrder(intleftorder);
358  TPZManVector<int> intrightorder;
359  rightel->PolynomialOrder(intrightorder);
360  int integrationorder = material->GetIntegrationOrder(intleftorder, intrightorder);
361  TPZGeoEl *gel = Reference();
362  int dimension = gel->Dimension();
363  int thisside = gel->NSides()-1;
364  TPZFNMatrix<9,REAL> jac(dimension,dimension),axes(dimension,3), jacInv(dimension,dimension);
365 
366  TPZAutoPointer<TPZIntPoints> intrule = gel->CreateSideIntegrationRule(thisside, integrationorder);
367  TPZManVector<REAL,3> Point(dimension), leftPoint(leftel->Dimension()), rightPoint(rightel->Dimension());
368  TPZGeoElSide neighleft(fLeftElSide.Reference()), neighright(fRightElSide.Reference());
369  TPZTransform<> trleft(dimension),trright(dimension);
370  TPZGeoElSide gelside(this->Reference(),thisside);
371  // compute the transformation between neighbours
372  gelside.SideTransform3(neighleft, trleft);
373  gelside.SideTransform3(neighright, trright);
374 
375  TPZTransform<> leftloctr = leftgel->SideToSideTransform(neighleft.Side(), leftgel->NSides()-1);
376  TPZTransform<> rightloctr = rightgel->SideToSideTransform(neighright.Side(), rightgel->NSides()-1);
377  // transform from the element to the interior of the neighbours
378  trleft = leftloctr.Multiply(trleft);
379  trright = rightloctr.Multiply(trright);
380 
381 
382  int nintpoints = intrule->NPoints();
383  for (int ip =0; ip<nintpoints; ip++) {
384  REAL weight;
385  data.intLocPtIndex = ip;
386  intrule->Point(ip, Point, weight);
387  ComputeRequiredData(data, Point);
388  weight *= fabs(data.detjac);
389  trleft.Apply(Point, leftPoint);
390  leftel->ComputeRequiredData(leftPoint, leftcomptr, datavecleft, fLeftElIndices);
391  trright.Apply(Point, rightPoint);
392  rightel->ComputeRequiredData(rightPoint, rightcomptr, datavecright, fRightElIndices);
393 
394  data.x = datavecleft[0].x;
395  material->ContributeInterface(data, datavecleft, datavecright, weight, ek.fMat, ef.fMat);
396  }
397 
398 }//CalcStiff
399 
401 {
402  TPZDiscontinuousGalerkin * material = dynamic_cast<TPZDiscontinuousGalerkin *> (this->Material());
403  if(!material){
404  PZError << "Error at " << __PRETTY_FUNCTION__ << " this->Material() == NULL\n";
405  ef.Reset();
406  return;
407  }
408 
410 
411  if (this->NConnects() == 0) return;//boundary discontinuous elements have this characteristic
414  TPZGeoEl *leftgel = leftel->Reference();
415  TPZGeoEl *rightgel = rightel->Reference();
416 #ifdef PZDEBUG
417  if (!leftel || !rightel) {
418  DebugStop();
419  }
420 #endif
421 
422  TPZManVector<TPZMaterialData,6> datavecleft,datavecright;
423  TPZMaterialData data;
424  InitMaterialData(data, datavecleft, datavecright);
425 
426  TPZManVector<TPZTransform<> > leftcomptr, rightcomptr;
427  leftel->AffineTransform(leftcomptr);
428  rightel->AffineTransform(rightcomptr);
429 
430  InitMaterialData(data);
431  int nmesh =datavecleft.size();
432  for(int id = 0; id<nmesh; id++){
433  datavecleft[id].fNeedsNormal=true;
434  TPZInterpolationSpace *msp = dynamic_cast <TPZInterpolationSpace *>(leftel->Element(id));
435  datavecleft[id].p =msp->MaxOrder();
436  }
437  data.fNeedsHSize=true;
438 
439  TPZManVector<int> intleftorder;
440  leftel->PolynomialOrder(intleftorder);
441  TPZManVector<int> intrightorder;
442  rightel->PolynomialOrder(intrightorder);
443  int integrationorder = material->GetIntegrationOrder(intleftorder, intrightorder);
444  TPZGeoEl *gel = Reference();
445  int dimension = gel->Dimension();
446  int thisside = gel->NSides()-1;
447  TPZFNMatrix<9,REAL> jac(dimension,dimension),axes(dimension,3), jacInv(dimension,dimension);
448 
449  TPZAutoPointer<TPZIntPoints> intrule = gel->CreateSideIntegrationRule(thisside, integrationorder);
450  TPZManVector<REAL,3> Point(dimension), leftPoint(leftel->Dimension()), rightPoint(rightel->Dimension());
451  TPZGeoElSide neighleft(fLeftElSide.Reference()), neighright(fRightElSide.Reference());
452  TPZTransform<> trleft(dimension),trright(dimension);
453  TPZGeoElSide gelside(this->Reference(),thisside);
454  // compute the transformation between neighbours
455  gelside.SideTransform3(neighleft, trleft);
456  gelside.SideTransform3(neighright, trright);
457 
458  TPZTransform<> leftloctr = leftgel->SideToSideTransform(neighleft.Side(), leftgel->NSides()-1);
459  TPZTransform<> rightloctr = rightgel->SideToSideTransform(neighright.Side(), rightgel->NSides()-1);
460  // transform from the element to the interior of the neighbours
461  trleft = leftloctr.Multiply(trleft);
462  trright = rightloctr.Multiply(trright);
463 
464 
465  int nintpoints = intrule->NPoints();
466  for (int ip =0; ip<nintpoints; ip++) {
467  REAL weight;
468  data.intLocPtIndex = ip;
469  intrule->Point(ip, Point, weight);
470  ComputeRequiredData(data, Point);
471  weight *= fabs(data.detjac);
472  trleft.Apply(Point, leftPoint);
473  leftel->ComputeRequiredData(leftPoint, leftcomptr, datavecleft, fLeftElIndices);
474  trright.Apply(Point, rightPoint);
475  rightel->ComputeRequiredData(rightPoint, rightcomptr, datavecright, fRightElIndices);
476 
477  data.x = datavecleft[0].x;
478  material->ContributeInterface(data, datavecleft, datavecright, weight, ef.fMat);
479  }
480 
481 }//CalcStiff
482 
484 {
485  if (!fIntegrationRule) {
486  DebugStop();
487  }
488  return *fIntegrationRule;
489 }
490 
491 
493 
496  if (!left || !right) return -1;
497 
498  int left_order = left->ComputeIntegrationOrder();
499  int right_order = right->ComputeIntegrationOrder();
500  int int_order = MAX(left_order, right_order);
501 
502  return int_order;
503 }
504 
505 
507 {
508  if (fIntegrationRule) {
509  delete fIntegrationRule;
510  }
511 
512  TPZDiscontinuousGalerkin * material = dynamic_cast<TPZDiscontinuousGalerkin *> (this->Material());
513  if(!material){
514  PZError << "Error at " << __PRETTY_FUNCTION__ << " this->Material() == NULL\n";
515  DebugStop();
516  }
517 
518 
521 
522 #ifdef PZDEBUG
523  if (!leftel || !rightel) {
524  DebugStop();
525  }
526 #endif
527 
528  TPZManVector<int> intleftorder;
529  leftel->PolynomialOrder(intleftorder);
530  TPZManVector<int> intrightorder;
531  rightel->PolynomialOrder(intrightorder);
532  int integrationorder = material->GetIntegrationOrder(intleftorder, intrightorder);
533  TPZGeoEl *gel = Reference();
534  int thisside = gel->NSides()-1;
535 
536  fIntegrationRule = gel->CreateSideIntegrationRule(thisside, integrationorder);
537 }
538 
540 {
541  DebugStop();
542 }//ComputeRequiredData
543 
545 {
546  ek.fMesh = Mesh();
547  ef.fMesh = ek.fMesh;
550  const int ncon = this->NConnects();
551  int64_t numeq = 0;
552  int ic;
553 
554  for(ic=0; ic<ncon; ic++)
555  {
556  TPZConnect &c = Connect(ic);
557  numeq += c.NShape()*c.NState();
558  }
559 
560  TPZMultiphysicsElement *mfcel_left = dynamic_cast<TPZMultiphysicsElement *>(fLeftElSide.Element());
561  TPZMultiphysicsElement *mfcel_right = dynamic_cast<TPZMultiphysicsElement *>(fRightElSide.Element());
562  if (! mfcel_left || !mfcel_right) {
563  DebugStop();
564  }
565  //nstate=1;
566  int numloadcases = 1;
568  if (!msp) {
569  DebugStop();
570  }
571  TPZMaterial *mat = msp->Material();
572  int nstate = mat->NStateVariables();
573  numloadcases = mat->NumLoadCases();
574 
575  ek.fMat.Redim(numeq,numeq);
576  ef.fMat.Redim(numeq,numloadcases);
577  ek.fBlock.SetNBlocks(ncon);
578  ef.fBlock.SetNBlocks(ncon);
579 
580  int i;
581  for(i=0; i<ncon; i++)
582  {
583  TPZConnect &c = Connect(i);
584  int ndof = Connect(i).NShape()*c.NState();
585 #ifdef PZDEBUG
586  if (c.NDof(*Mesh()) != ndof) {
587  DebugStop();
588  }
589 #endif
590  ek.fBlock.Set(i,ndof);
591  ef.fBlock.Set(i,ndof);
592  }
593  ek.fConnect.Resize(ncon);
594  ef.fConnect.Resize(ncon);
595  for(i=0; i<ncon; i++){
596  (ek.fConnect)[i] = ConnectIndex(i);
597  (ef.fConnect)[i] = ConnectIndex(i);
598  }
599 
600 }//void
601 
603 {
604 
605  ef.fMesh = Mesh();
607  const int ncon = this->NConnects();
608  int64_t numeq = 0;
609  int ic;
610 
611  for(ic=0; ic<ncon; ic++)
612  {
613  TPZConnect &c = Connect(ic);
614  numeq += c.NShape()*c.NState();
615  }
616 
617  TPZMultiphysicsElement *mfcel_left = dynamic_cast<TPZMultiphysicsElement *>(fLeftElSide.Element());
618  TPZMultiphysicsElement *mfcel_right = dynamic_cast<TPZMultiphysicsElement *>(fRightElSide.Element());
619  if (! mfcel_left || !mfcel_right) {
620  DebugStop();
621  }
622  //nstate=1;
623  int numloadcases = 1;
625  if (!msp) {
626  DebugStop();
627  }
628  TPZMaterial *mat = msp->Material();
629  int nstate = mat->NStateVariables();
630  numloadcases = mat->NumLoadCases();
631 
632  ef.fMat.Redim(numeq,numloadcases);
633  ef.fBlock.SetNBlocks(ncon);
634 
635  int i;
636  for(i=0; i<ncon; i++)
637  {
638  TPZConnect &c = Connect(i);
639  int ndof = Connect(i).NShape()*c.NState();
640 #ifdef PZDEBUG
641  if (c.NDof(*Mesh()) != ndof) {
642  DebugStop();
643  }
644 #endif
645  ef.fBlock.Set(i,ndof);
646  }
647  ef.fConnect.Resize(ncon);
648  for(i=0; i<ncon; i++){
649  (ef.fConnect)[i] = ConnectIndex(i);
650  }
651 
652 }//void
653 
655 
656  TPZGeoEl *gel = Reference();
657  int dim = gel->Dimension();
658  int nsides = gel->NSides();
659  TPZManVector<REAL> center(dim);
660  gel->CenterPoint(nsides-1 , center);
661  TPZGeoElSide gelside(gel,nsides-1);
662  gelside.Normal(center, fLeftElSide.Element()->Reference(), fRightElSide.Element()->Reference(), normal);
663 }
664 
665 void TPZMultiphysicsInterfaceElement::Print(std::ostream &out) const {
666 
667  TPZCompEl::Print(out);
668  out << "\nInterface element : \n";
669  if(!LeftElement() || !LeftElement()->Reference()) out << "\tNULL LeftElement - this is inconsistent\n";
670  else{
671  out << "\tLeft Computational Index: " << LeftElement()->Index() << std::endl;
672  out << "\tLeft Geometric Index: " << LeftElement()->Reference()->Index() << std::endl;
673  out << "\tLeft Geometric Id: " << LeftElement()->Reference()->Id() << std::endl;
674  out << "\tElement Dimension " << LeftElement()->Reference()->Dimension() << std::endl;
675  }
676 
677  if(!RightElement() || !RightElement()->Reference()) out << "\tNULL RightElement - this is inconsistent";
678  else{
679  out << "\tRight Computational Index: " << RightElement()->Index() << std::endl;
680  out << "\tRight Geometric Index: " << RightElement()->Reference()->Index() << std::endl;
681  out << "\tRight Geometric Id: " << RightElement()->Reference()->Id() << std::endl;
682  out << "\tElement Dimension " << RightElement()->Reference()->Dimension() << std::endl;
683  }
684 
685  out << "\tMaterial id : " << Reference()->MaterialId() << std::endl;
686 
687  TPZMaterial *mat = Material();
688  TPZMaterialData data;
689  mat->FillDataRequirements(data);
690  if (mat && data.fNeedsNormal)
691  {
692  TPZVec<REAL> center_normal;
693  ComputeCenterNormal(center_normal);
694  out << "\tNormal vector (at center point): ";
695  out << "(" << center_normal[0] << "," << center_normal[1] << "," << center_normal[2] << ")\n";
696 
697  }
698 }
699 
701 //void TPZMultiphysicsInterfaceElement::InitMaterialData(TPZVec<TPZMaterialData> &data, TPZMultiphysicsElement *mfcel,TPZVec<int64_t> *indices)
702 //{
703 // data.resize(mfcel->NMeshes());
704 // mfcel->InitMaterialData(data,indices);
705 //}
706 
709 
712  // TPZMultiphysicsCompMesh * mp_cmesh = dynamic_cast<TPZMultiphysicsCompMesh * >(Mesh());
713  int n_meshes = leftel->NMeshes();
714  data_left.resize(n_meshes);
715  data_right.resize(n_meshes);
716 
717  TPZVec<int64_t> *leftindices(0), *rightindices(0);
718  if (fLeftElIndices.size()) {
719  leftindices = &fLeftElIndices;
720  }
721  if (fRightElIndices.size()) {
722  rightindices = &fRightElIndices;
723  }
724 
725  leftel->InitMaterialData(data_left,leftindices);
726  rightel->InitMaterialData(data_right,rightindices);
727 
728  TPZMaterial * mat = this->Material();
729  mat->FillDataRequirementsInterface(center_data, data_left, data_right);
730 
731 
732 }
733 
736 {
737  TPZGeoEl *gel = Reference();
738  int dim = gel->Dimension();
739  int nsides = gel->NSides();
740  TPZManVector<REAL> center(dim);
741  gel->CenterPoint(nsides-1 , center);
742  TPZGeoElSide gelside(gel,nsides-1);
743  TPZMaterial *mat = Material();
744  if (mat) {
745  mat->FillDataRequirements(data);
746  }
747  if (data.fNeedsNormal)
748  {
749  gelside.Normal(center, fLeftElSide.Element()->Reference(), fRightElSide.Element()->Reference(), data.normal);
750  }
751  data.axes.Redim(dim,3);
752  data.jacobian.Redim(dim,dim);
753  data.jacinv.Redim(dim,dim);
754  data.x.Resize(3);
755 }
756 
759 {
760  data.intGlobPtIndex = -1;
761  TPZGeoEl *gel = Reference();
762  TPZGeoElSide gelside(gel,gel->NSides()-1);
763  gel->Jacobian(point, data.jacobian, data.axes, data.detjac, data.jacinv);
764 
765  TPZMaterial *mat = Material();
766  if (mat) {
768  }
769 
770  if (data.fNeedsNormal)
771  {
772 
773  if (gelside.Dimension() == gelside.Element()->Dimension()-1) {
774  gelside.Normal(point, data.normal);
775  }else{
776  gelside.Normal(point, fLeftElSide.Element()->Reference(), fRightElSide.Element()->Reference(), data.normal);
777  }
778  }
779 
780  if (data.fNeedsHSize){
781  const int dim = this->Dimension();
782  REAL faceSize;
783  if (dim == 0){//it means I am a point
784 // DebugStop();
785  faceSize = 0.;
786  }
787  else{
788  faceSize = 2.*this->Reference()->ElementRadius();//Igor Mozolevski's suggestion. It works well for elements with small aspect ratio
789  }
790  data.HSize = faceSize;
791  }
792 
793 }
794 
796 {
797  TPZGeoEl *ref = Reference();
798  if (ref->Dimension() != dimension) {
799  return;
800  }
801 
802  TPZMaterial * material = Material();
803 
804  TPZManVector<std::string,4> scalarnames, vecnames;
805  scalarnames = grmesh.ScalarNames();
806  vecnames = grmesh.VecNames();
807  for (int i=0; i<scalarnames.size(); i++) {
808  if (material->VariableIndex(scalarnames[i]) == -1) {
809  return;
810  }
811  }
812  for (int i=0; i<vecnames.size(); i++) {
813  if (material->VariableIndex(vecnames[i]) == -1) {
814  return;
815  }
816  }
817  int matid = material->Id();
818  int nsides = ref->NSides();
819  bool to_postpro = grmesh.Material_Is_PostProcessed(matid);
820 
821  if(dimension == 2 && to_postpro){
822  if(nsides == 9){
823  new TPZGraphElQ2dd(this,&grmesh);
824  return;
825  }
826  if(nsides == 7){
827  new TPZGraphElT2dMapped(this,&grmesh);
828  return;
829  }
830  }//2d
831 
832  if(dimension == 3 && to_postpro){
833  if(nsides == 27){
834  new TPZGraphElQ3dd(this,&grmesh);
835  return;
836  }//cube
837  if(nsides == 21){
838  new TPZGraphElPrismMapped(this,&grmesh);
839  return;
840  }//prism
841  if(nsides == 15){
842  new TPZGraphElT3d(this,&grmesh);
843  return;
844  }//tetra
845  if(nsides == 19){
846  new TPZGraphElPyramidMapped(this,&grmesh);
847  return;
848  }//pyram
849  }//3d
850 
851  if(dimension == 1 && to_postpro){
852  new TPZGraphEl1dd(this,&grmesh);
853  }//1d
854 
855 }
856 
858 {
859 
860  if(var >= 100) {
861  TPZCompEl::Solution(qsi,var,sol);
862  return;
863  }
864 
865  TPZMaterial * material = this->Material();
866  if(!material){
867  sol.Resize(0);
868  return;
869  }
870 
871  if (this->NConnects() == 0) return;//boundary discontinuous elements have this characteristic
872 
873  TPZCompElSide LeftSide;
874  TPZCompElSide RightSide;
875  this->GetLeftRightElement(LeftSide, RightSide);
876 
877  TPZMultiphysicsElement *leftel = dynamic_cast<TPZMultiphysicsElement *> (LeftSide.Element());
878  TPZMultiphysicsElement *rightel = dynamic_cast<TPZMultiphysicsElement *>(RightSide.Element());
879 
880  TPZManVector<TPZMaterialData,6> datavecleft,datavecright;
881  TPZMaterialData data;
882  InitMaterialData(data, datavecleft, datavecright);
883 
884  TPZManVector<TPZTransform<> > leftcomptr, rightcomptr;
885  leftel->AffineTransform(leftcomptr);
886  rightel->AffineTransform(rightcomptr);
887  InitMaterialData(data);
888  TPZTransform<> lefttr;
889  TPZTransform<> righttr;
890 
891  // Integration points in left and right elements: making transformations to neighbour elements
892  this->ComputeSideTransform(LeftSide, lefttr);
893  this->ComputeSideTransform(RightSide, righttr);
894 
895  TPZVec<REAL> myqsi;
896  myqsi.resize(qsi.size());
897  lefttr.Apply(qsi, myqsi);
898  lefttr.Apply(qsi, myqsi);
899 
900  leftel->ComputeRequiredData(myqsi, leftcomptr, datavecleft,fLeftElIndices);
901  rightel->ComputeRequiredData(myqsi, rightcomptr, datavecright,fRightElIndices);
902 
903  material->Solution(data,datavecleft,datavecright,var, sol,LeftSide.Element(),RightSide.Element());
904 }
905 
907  TPZGeoEl * neighel = Neighbor.Element()->Reference();
908  const int dim = this->Dimension();
909  TPZTransform<> LocalTransf(dim);
910  TPZGeoElSide thisgeoside(this->Reference(), this->Reference()->NSides()-1);
911  TPZGeoElSide neighgeoside(neighel, Neighbor.Side());
912  thisgeoside.SideTransform3(neighgeoside, LocalTransf);
913 
914  TPZGeoElSide highdim(neighel, neighel->NSides()-1);
915  transf = neighgeoside.SideToSideTransform(highdim).Multiply(LocalTransf);
916 }//ComputeSideTransform
917 
918 
920  return Hash("TPZMultiphysicsInterfaceElement") ^ TPZCompEl::ClassId() << 1;
921 }
Defines the interface which material objects need to implement for discontinuous Galerkin formulation...
Definition: pzdiscgal.h:20
bool Material_Is_PostProcessed(int matid)
Return a directive if the material id is being postprocessed.
virtual void Solution(TPZMaterialData &data, int var, TPZVec< STATE > &Solout)
Returns the solution associated with the var index based on the finite element approximation.
Represents a graphical mesh used for post processing purposes. Post processing.
Definition: pzgraphmesh.h:34
void CalcStiff(TPZElementMatrix &ek, TPZElementMatrix &ef) override
virtual void ComputeRequiredData(TPZVec< REAL > &point, TPZVec< TPZTransform<> > &trvec, TPZVec< TPZMaterialData > &datavec, TPZVec< int64_t > indices)
virtual int Dimension() const override
Dimension of the element.
Contains the TPZGraphElTd class which implements the graphical discontinuous triangular element...
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 IncrementElConnected()
Informs the connect that this element is connected to it.
virtual int NConnects() const override
Returns the number of nodes of the element.
virtual void InitMaterialData(TPZVec< TPZMaterialData > &dataVec, TPZVec< int64_t > *indices=0)=0
TPZManVector< REAL, 3 > normal
normal to the element at the integration point
virtual int NPoints() const =0
Returns number of points for the cubature rule related.
Implements computational element and a side. Computational Element.
Definition: pzcompel.h:632
int Set(const int index, const int dim, const int pos=-1)
Modifies existing block dimensions or creates a new block with given index.
Definition: pzblock.cpp:104
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
Definition: pzconnect.h:30
TPZCompEl * LeftElement() const
Returns the left element from the element interface.
TPZManVector< REAL, 3 > x
value of the coordinate at the integration point
To export a graphical one dimensional discontinuous element. Post processing.
Definition: pzgraphel1dd.h:22
Implements a vector class which allows to use external storage provided by the user. Utility.
Definition: pzquad.h:16
virtual void Solution(TPZVec< REAL > &qsi, int var, TPZVec< STATE > &sol) override
Calculates the solution - sol - for the variable var at point qsi, where qsi is expressed in terms of...
virtual int64_t ConnectIndex(int i) const override
Returns the index of the ith connectivity of the element.
int MaterialId() const
Returns the material index of the element.
Definition: pzgeoel.h:250
virtual void resize(const int64_t newsize)
Definition: pzvec.h:213
TPZCompElSide Left() const
access function to the left element
virtual TPZCompEl * Element(int64_t elindex)=0
clarg::argInt dimension("-d", "Matrices dimension M x M", 1000)
TPZStack< int64_t > fConnect
Vector of pointers to TPZConnect objects.
Definition: pzelmat.h:39
const TPZIntPoints & GetIntegrationRule() const override
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
TPZManVector< int64_t, 3 > fRightElIndices
indices of the Right Element Vector
TPZManVector< int64_t, 20 > fConnectIndexes
indexes of the connects
virtual int ComputeIntegrationOrder() const override
TPZVec< std::string > VecNames()
Return vectorial variable names.
Definition: pzgraphmesh.h:146
To export a graphical two-dimensional discontinuous element. Post processing.
Definition: pzgraphelq2dd.h:16
To export a graphical three dimensional discontinuous element. Post processing.
Definition: pzgraphelq3dd.h:20
virtual int Dimension() const =0
Dimension of the element.
virtual int VariableIndex(const std::string &name)
Returns the variable index associated with the name.
virtual int64_t NMeshes()=0
Contains declaration of TPZInterpolationSpace class which implements the interface for interpolated c...
virtual void Print(std::ostream &out=std::cout) const override
Prints element data.
Contains the TPZGraphEl class which implements the graphical one-, two- and three-dimensional element...
virtual int NStateVariables() const =0
Returns the number of state variables associated with the material.
Contains the declaration of the TPZMultiphysicsElement class. This class is abstract.
TPZFNMatrix< 9, REAL > jacinv
value of the inverse of the jacobian at the integration point
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Definition: pzgeoelside.h:83
Implements the graphical element for a pyramid using a map to the cube element. Post processing...
int NDof(TPZCompMesh &mesh)
Number of degrees of freedom associated with the object.
Definition: pzconnect.cpp:317
#define MAX(a, b)
Gets maxime value between a and b.
Definition: pzreal.h:81
virtual int NSides() const =0
Returns the number of connectivities of the element.
virtual void ComputeRequiredData(TPZVec< REAL > &intpointtemp, TPZVec< TPZTransform<> > &trvec, TPZVec< TPZMaterialData > &datavec)
Compute and fill data with requested attributes for each of the compels in fElementVec.
TPZBlock< STATE > fBlock
Block structure associated with fMat.
Definition: pzelmat.h:43
Contains the TPZGraphEl1d class which implements the graphical one dimensional element.
void SideTransform3(TPZGeoElSide neighbour, TPZTransform<> &t)
Accumulates the transformations from the current element/side to the neighbour/side.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
Definition: pzmanvector.h:426
TPZFNMatrix< 9, REAL > jacobian
value of the jacobian at the integration point
It has the declaration of the TPZMultiphysicsCompEl class.
virtual int ClassId() const override
Define the class id associated with the class.
Definition: pzcompel.cpp:1129
Abstract class defining integration rules. Numerical Integration.
Definition: tpzintpoints.h:19
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
Contains declaration of TPZElementMatrix struct which associates an element matrix with the coeficien...
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...
virtual TPZMaterial * Material() const
Identify the material object associated with the element.
Definition: pzcompel.cpp:959
Implements a graphical element for a triangle mapped into de quadrilateral element. Post processing.
virtual void AffineTransform(TPZVec< TPZTransform<> > &trVec) const =0
virtual void CreateGraphicalElement(TPZGraphMesh &grmesh, int dimension) override
Creates corresponding graphical element(s) if the dimension matches graphical elements are used to ge...
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 GetIntegrationOrder(TPZVec< int > &porder_left, TPZVec< int > &porder_right) const
return the integration order as a function of interpolation orders of the left and right elements ...
Definition: pzdiscgal.cpp:123
Contains the TPZGraphElT3d class which implements the graphical representation of a tetrahedra elemen...
Implements the graphical element for a prism using a degenerated cube element. Post processing...
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
Contains the TPZGraphElQ2dd class which implements the graphical two-dimensional discontinuous elemen...
Implements the graphical representation of a tetrahedra element. Post processing. ...
Definition: tpzgraphelt3d.h:16
int64_t Index() const
Returns the index of the element within the element vector of the mesh.
Definition: pzgeoel.h:730
virtual void FillDataRequirements(TPZMaterialData &data)
Fill material data parameter with necessary requirements for the.
Definition: TPZMaterial.cpp:81
void GetLeftRightElement(TPZCompElSide &leftel, TPZCompElSide &rightel)
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
Contains the TPZGraphElPrismMapped class which implements the graphical element for a prism using a d...
TPZCompMesh * Mesh() const
Return a pointer to the grid of the element.
Definition: pzcompel.cpp:288
virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef)
It computes a contribution to stiffness matrix and load vector at one integration point...
Definition: pzdiscgal.cpp:30
Contains the declaration of multiphysic interface class.
void Jacobian(TPZVec< REAL > &qsi, TPZFMatrix< REAL > &jac, TPZFMatrix< REAL > &axes, REAL &detjac, TPZFMatrix< REAL > &jacinv) const
Compute a decomposition of the gradient of the mapping function, as a rotation matrix (Jacobian) and ...
Definition: pzgeoel.cpp:1144
TPZMaterial * FindMaterial(int id)
Find the material with identity id.
Definition: pzcmesh.cpp:297
unsigned int NShape() const
Definition: pzconnect.h:151
virtual int ComputeIntegrationOrder() const override
void SetLeftRightElement(const TPZCompElSide &leftel, const TPZCompElSide &rightel)
Contains the TPZGraphElT class which implements the graphical triangular element. ...
TPZFNMatrix< 9, REAL > axes
axes indicating the directions of the derivatives of the shapefunctions
void SetLeftRightElementIndices(const TPZVec< int64_t > &lefindices, const TPZVec< int64_t > &rightindices)
TPZCompMesh * fMesh
Definition: pzelmat.h:36
Contains the TPZGraphMesh class which represents a graphical mesh used for post processing purposes...
Contains the TPZGraphElPyramidMapped class which implements the graphical element for a pyramid using...
TPZIntPoints * fIntegrationRule
Integration rule established by the user.
Definition: pzcompel.h:590
TPZAdmChunkVector< TPZConnect > & ConnectVec()
Return a reference to the connect pointers vector.
Definition: pzcmesh.h:198
int64_t Index() const
Returns element index of the mesh fELementVec list.
Definition: pzcompel.h:821
REAL HSize
measure of the size of the element
int intGlobPtIndex
global point index
int SetNBlocks(const int num_of_blocks)
Sets number of blocks on diagonal matrix.
Definition: pzblock.cpp:91
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Definition: pzfmatrix.h:616
virtual TPZConnect & Connect(int i) const
Returns a pointer to the ith node.
Definition: pzcompel.cpp:298
int intLocPtIndex
Index of the current integration point being evaluated.
unsigned char NState() const
Number of state variables associated with the connect.
Definition: pzconnect.h:146
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
virtual int64_t ConnectIndex(int i) const =0
Returns the index of the ith connectivity of the element.
TPZTransform< T > Multiply(TPZTransform< T > &right)
Multiply the transformation object (to the right) with right (Multiplying matrices) ...
Definition: pztrnsform.cpp:112
void InitMaterialData(TPZMaterialData &center_data, TPZVec< TPZMaterialData > &data_left, TPZVec< TPZMaterialData > &data_right)
Initialize the material data structures.
This class associates an element matrix with the coeficients of its contribution in the global stiffn...
Definition: pzelmat.h:30
Implements the interfaces for TPZCompElDisc, TPZInterfaceElement and TPZInterpolatedElement. Computational element.
virtual int NConnects() const =0
Returns the number of nodes of the element.
void Normal(TPZVec< REAL > &point, TPZGeoEl *left, TPZGeoEl *right, TPZVec< REAL > &normal) const
compute the normal to the point from left to right neighbour
void ComputeSideTransform(TPZManVector< TPZCompElSide > &Neighbor, TPZManVector< TPZTransform<> > &transf)
Compute the transform of a paramenter point in the multiphysic interface element to a parameter point...
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
virtual TPZTransform< REAL > SideToSideTransform(int sidefrom, int sideto)=0
Compute the transformation between the master element space of one side of an element to the master e...
int64_t Id() const
Returns the Id of the element.
Definition: pzgeoel.h:223
TPZManVector< int64_t, 3 > fLeftElIndices
indices of the Left Element Vector
TPZGeoEl * Reference() const
Return a pointer to the corresponding geometric element if such exists, return 0 otherwise.
Definition: pzcompel.cpp:1137
void ComputeCenterNormal(TPZVec< REAL > &normal) const
TPZVec< std::string > ScalarNames()
Return scalar variable names.
Definition: pzgraphmesh.h:140
int Dimension() const
the dimension associated with the element/side
void ResetReference()
Reset the element referenced by the geometric element to NULL.
Definition: pzgeoel.h:431
Computes the contribution over an interface between two discontinuous elements. Computational Element...
void Reset(TPZCompMesh *mesh=NULL, MType type=Unknown)
Reset the data structure.
Definition: pzelmat.h:59
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
TPZCompElSide fRightElSide
Element vector the right of the normal a interface.
TPZAdmChunkVector< TPZCompEl * > & ElementVec()
Returns a reference to the element pointers vector.
Definition: pzcmesh.h:183
virtual void FillDataRequirementsInterface(TPZMaterialData &data)
This method defines which parameters need to be initialized in order to compute the contribution of i...
Definition: TPZMaterial.h:143
virtual void Print(std::ostream &out=std::cout) const
Prints element data.
Definition: pzcompel.cpp:322
TPZCompEl * RightElement() const
Returns the right element from the element interface.
void InitializeElementMatrix(TPZElementMatrix &ek, TPZElementMatrix &ef)
Initialize the structure of the stiffness matrix.
TPZMultiphysicsInterfaceElement()
Default constructor.
virtual void PolynomialOrder(TPZVec< int > &order) const =0
void SetReference(TPZCompEl *elp)
Make the current element reference to the computational element.
Definition: pzgeoel.h:746
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 the TPZGraphElT2dMapped class which implements a graphical element for a triangle mapped int...
int NumLoadCases()
returns the number of load cases for this material object
Definition: TPZMaterial.h:186
int Id() const
Definition: TPZMaterial.h:170
int Side() const
Returns the side index.
Definition: pzcompel.h:688
virtual int MaxOrder()
Returns the max order of interpolation.
Contains the TPZIntPoints class which defines integration rules.
int NeighbourExists(const TPZGeoElSide &neighbour) const
Returns 1 if neighbour is a neighbour of the element along side.
Contains the TPZGraphEl1dd class which implements the graphical one dimensional discontinuous element...
Implements an affine transformation between points in parameter space. Topology Utility.
Definition: pzmganalysis.h:14
TPZCompElSide Right() const
Access function to the right element.
virtual ~TPZMultiphysicsInterfaceElement()
Default destructor.
virtual REAL ElementRadius()
Definition: pzgeoel.cpp:949
virtual bool IsActiveApproxSpaces(int space_index)
Contains the TPZDiscontinuousGalerkin class which implements the interface for discontinuous Galerkin...
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
int IncrementNumInterfaces()
Increments number of TPZInterfaceElement pointing to this.
Definition: pzgeoel.h:99
Contains the TPZGraphElQ3dd class which implements the graphical three dimensional discontinuous elem...
REAL detjac
determinant of the jacobian
virtual int ClassId() const override
Define the class id associated with the class.
void Apply(TPZVec< T > &vectorin, TPZVec< T > &vectorout)
Transforms the vector.
Definition: pztrnsform.cpp:121
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
TPZCompMesh * fMesh
Computational mesh to which the element belongs.
Definition: pzcompel.h:64
TPZCompElSide fLeftElSide
Element vector the left of the normal a interface.