NeoPZ
pzintel.cpp
Go to the documentation of this file.
1 
6 #include "pzintel.h"
7 #include "pzcmesh.h"
8 #include "pzgeoel.h"
9 #include "TPZMaterial.h"
10 #include "pztrnsform.h"
11 #include "pztransfer.h"
12 #include "pzbndcond.h"
13 #include "pzsolve.h"
14 #include "pzstepsolver.h"
15 #include "pzquad.h"
16 #include "pzelmat.h"
17 #include "pzmat1dlin.h"
18 #include "time.h"
19 #include "pzmanvector.h"
20 #include "pzblockdiag.h"
21 #include "pzcheckrestraint.h"
22 
23 #include "pzcheckmesh.h"
24 #include "TPZCompElDisc.h"
25 #include "pzmaterialdata.h"
26 
27 #include "pzlog.h"
28 
29 #ifdef LOG4CXX
30 static LoggerPtr logger(Logger::getLogger("pz.mesh.tpzinterpolatedelement"));
31 static LoggerPtr loggerdiv(Logger::getLogger("pz.mesh.tpzinterpolatedelement.divide"));
32 #endif
33 
34 
35 #ifdef _AUTODIFF
36 #include "fadType.h"
37 #endif
38 
39 #include <sstream>
40 using namespace std;
41 
43 TPZInterpolationSpace(mesh, reference, index) {
44 }
45 
47 TPZInterpolationSpace(mesh, copy) {
48 }
49 
51  const TPZInterpolatedElement &copy,
52  std::map<int64_t, int64_t> & gl2lcElMap) :
53 TPZInterpolationSpace(mesh, copy, gl2lcElMap) {
54 }
55 
58 }
59 
61 }
62 
64  int nn = NConnects();
65  int in, res = 0;
66  for (in = 0; in < nn; in++) {
67  TPZConnect &c = Connect(in);
68  res += NConnectShapeF(in, c.Order());
69  }
70  return res;
71 }
72 
74  int ns = NSideConnects(side);
75  int in, res = 0;
76  for (in = 0; in < ns; in++) {
77  TPZConnect &c = Connect(SideConnectLocId(in, side));
78  res += NConnectShapeF(SideConnectLocId(in, side), c.Order());
79  }
80  return res;
81 }
82 
84  int il = 1;
85  if (NSideConnects(side) == 0) return -1;
86  int nodloc = SideConnectLocId(NSideConnects(side) - il, side);
87  return nodloc;
88 }
89 
95  if (NSideConnects(is) == 0) {
96  DebugStop();
97  }
98  return Connect(MidSideConnectLocId(is));
99 }
100 
101 int64_t TPZInterpolatedElement::SideConnectIndex(int connect, int side) const {
102  return ConnectIndex(SideConnectLocId(connect, side));
103 }
104 
106  if (side < 0 || connect < 0 || side > Reference()->NSides()) {
107  LOGPZ_ERROR(logger, "Exiting SideConnect - has bad first or second parameter.");
108  static TPZConnect con;
109  return con;
110  }
111  return (fMesh->ConnectVec()[SideConnectIndex(connect, side)]);
112 }
113 
114 void TPZInterpolatedElement::ForceSideOrder(int side, int order) {
115  if ((side < Reference()->NCornerNodes() && order != 0) || side >= Reference()->NSides()) {
116  std::stringstream sout;
117  sout << __PRETTY_FUNCTION__ << " setting an order for a corner side " << side << " order " << order;
118  LOGPZ_ERROR(logger, sout.str())
119  DebugStop();
120  }
121  TPZCompElSide thisside(this, side);
122  TPZCompElSide large = thisside.LowerLevelElementList(1);
123  if (large.Exists()) {
124  LOGPZ_INFO(logger, "Exiting ForceSideOrder - large exists.");
125  return;
126  }
127  TPZConnect &c = MidSideConnect(side);
128  int sideorder = c.Order();
129  int neworder = order;
130  int orderchanged = (sideorder != neworder);
131  if (!orderchanged) return;
133  thisside.EqualLevelElementList(elvec, 1, 0);
134  elvec.Push(thisside);
135  int64_t cap, il;
136  TPZInterpolatedElement *equal;
137  int equalside;
138  if (orderchanged == 1) {
139  // elvec.Push(thisside);
140  cap = elvec.NElements();
141  for (il = 0; il < cap; il++) {
142  equal = dynamic_cast<TPZInterpolatedElement *> (elvec[il].Element());
143  if (!equal) continue;
144  equalside = elvec[il].Side();
145  int cindex = equal->MidSideConnectLocId(equalside);
146  if (equal->ConnectIndex(cindex) != -1) {
147  equal->SetSideOrder(equalside, neworder);
148  }
149  }
150  // Put the accumulated higher dimension sides in highdim (neighbours will not be included because of the third parameter)
151  // The higher dimension sides are only analysed for one dimensional sides
152  TPZStack<TPZCompElSide> highdim;
153  if (thisside.Reference().Dimension() == 1) {
154  for (il = 0; il < cap; il++) {
155  elvec[il].HigherDimensionElementList(highdim, 1, 1);
156  }
157  }
158 
159  // reuse elvec to put the smaller elements (element/sides restrained by the current element side
160 
161  elvec.Resize(0);
162  // Adapt the restraints of all smaller elements connected to the current side
163  thisside.HigherLevelElementList(elvec, 1, 1);
164 
165  // analyse their side order because they are restrained by me
166  cap = elvec.NElements();
167  TPZInterpolatedElement *smalll;
168  int smallside;
169  int dimension;
170  for (dimension = 0; dimension < 4; dimension++) {
171  for (il = 0; il < cap; il++) {
172  if (elvec[il].Reference().Dimension() != dimension) continue;
173  smalll = dynamic_cast<TPZInterpolatedElement *> (elvec[il].Element());
174  if (!smalll) continue;
175  smallside = elvec[il].Side();
176  // Identify Side Order is used because it will call itself recursively
177  // for its smaller elements too.
178  smalll->IdentifySideOrder(smallside);
179  }
180  }
181 
182  // Loop over all higher dimension sides
183  cap = highdim.NElements();
184  for (il = 0; il < cap; il++) {
185  // verify if the higher dimension element/side is restrained.
186  // if it is restrained then its order will not have changed
187  TPZCompElSide highlarge = highdim[il].LowerLevelElementList(1);
188  if (highlarge.Exists()) continue;
189 
190  // verify if the order of the higher dimension side has changed
192  int highside;
193  el = dynamic_cast<TPZInterpolatedElement *> (highdim[il].Element());
194  if (!el) continue;
195  highside = highdim[il].Side();
196  int order, comporder;
197  TPZStack<TPZCompElSide> equallist;
198  highdim[il].EqualLevelElementList(equallist, 1, 0);
199  equallist.Push(highdim[il]);
200  // when the element highdim is restricted by the same element as the original side, do nothing
201  // the restriction will be taken care of in the future
202  // verify if the order of the higher dimension side changed due to the change in order of the side being studied
203  order = el->MidSideConnect(highside).Order();
204  comporder = el->ComputeSideOrder(equallist);
205  if (order != comporder) {
206  // the order has changed
207  el->IdentifySideOrder(highside);
208  } else {
209  // the order hasnt changed
210  el->RecomputeRestraints(highside);
211  }
212  }
213  }
214 }
215 
217  if (MidSideConnectLocId(side) == -1) {
218  // there is no connect to adjust the order for
219  return;
220  }
221  TPZCompElSide thisside(this, side);
222  TPZCompElSide large = thisside.LowerLevelElementList(1);
223  // int sideorder = MidSideConnect(side).Order();
224  int dimension = Reference()->SideDimension(side);
225 
226  int neworder;
227  int orderchanged = 0;
228  TPZStack<TPZCompElSide> elvecall, elvecequal;
229  elvecall.Push(thisside);
230  thisside.EqualLevelElementList(elvecall, 1, 0);
231  int index = MidSideConnectLocId(side);
232  int64_t sideconnectindex = ConnectIndex(index);
233  int i;
234  for (i = 0; i < elvecall.NElements(); i++) {
235  int64_t elvecconnectindex = elvecall[i].ConnectIndex();
236  // skip the element/sides which have a different connect than my own
237  if (sideconnectindex != -1 && sideconnectindex != elvecconnectindex) {
238  continue;
239  }
240  if (elvecall[i].ConnectIndex() != -1) elvecequal.Push(elvecall[i]);
241  }
242 
243  TPZInterpolatedElement *equal;
244  int equalside;
245  if (large.Exists()) {
246  // There is a larger element
247  // identify the order of the larger element and set the interpolation order
248  // of the current element and all its neighbours of equal level to this order
249  TPZInterpolatedElement *largel = dynamic_cast<TPZInterpolatedElement *> (large.Element());
250  neworder = largel->EffectiveSideOrder(large.Side());
251  // improve the check on the connect dependencies
252  // We assume the datastructure of the elements is consistent in the sense
253  // that if the current element has the same side order than the large
254  // element, then all its neighbours will also have the same order
255  if (largel->MidSideConnectLocId(large.Side()) != -1 && VerifyConstraintConsistency(side, large) == false) {
256  orderchanged = 1;
258  SetSideOrder(side, neworder);
259  RestrainSide(side, largel, large.Side());
260  int64_t cap = elvecequal.NElements();
261  for (int64_t il = 0; il < cap; il++) {
262  equal = dynamic_cast<TPZInterpolatedElement *> (elvecequal[il].Element());
263  if (!equal) continue;
264  equalside = elvecequal[il].Side();
265  //if(equal->ConnectIndex(equalside) != -1)
266  if (equal->MidSideConnectLocId(equalside) != -1) {
267  equal->SetSideOrder(equalside, neworder);
268  }
269  }
270 #ifdef PZDEBUG
271  if (VerifyConstraintConsistency(side, large) == false) {
272  std::cout << "I don't understand\n";
273  VerifyConstraintConsistency(side, large);
274  }
275 #endif
276  }
277  } else {
278  // There is no larger element connected to the side
279  // identify the new side order by comparing the orders of the equal level elements
280  if (MidSideConnect(side).HasDependency()) {
281  TPZConnect &c = MidSideConnect(side);
282  c.Print(*Mesh());
283  LOGPZ_WARN(logger, "TPZInterpolatedElement SetSideOrder fodeu");
284  DebugStop();
285  large = thisside.LowerLevelElementList(1);
286  }
288  neworder = ComputeSideOrder(elvecequal);
289  // Verify is the side order of all elements is equal to neworder
290  int64_t connectindex = ConnectIndex(MidSideConnectLocId(side));
291  int connectorder = MidSideConnect(side).Order();
292  if (neworder != connectorder) {
293  orderchanged = 1;
294  SetSideOrder(side, neworder);
295  }
296 #ifdef PZDEBUG
297  int64_t cap = elvecequal.NElements();
298  int64_t il = 0;
299  while (il < cap) {//SideOrder(int side)
300  equal = dynamic_cast<TPZInterpolatedElement *> (elvecequal[il].Element());
301  equalside = elvecequal[il].Side();
302  TPZConnect connect = equal->Connect(equal->MidSideConnectLocId(equalside));
303 
304  int64_t equalindex = equal->ConnectIndex(equal->MidSideConnectLocId(equalside));
305  if (equalindex != connectindex) {
306 
307  if (connect.LagrangeMultiplier() == 1) {
308  il++;
309  continue;
310  }
311 
312  DebugStop();
313  }
314  il++;
315  }
316 #endif
317 
318  }
320  if (dimension == 0) {
321  return;
322  }
323 
324  // reuse elvec to put the smaller elements (element/sides restrained by the current element side
325  int sideorder = EffectiveSideOrder(side);
326  TPZStack<TPZCompElSide> elvechighlevel;
327  // Adapt the restraints of all smaller elements connected to the current side
328  thisside.HigherLevelElementList(elvechighlevel, 1, 1);
329  for (int dim = 0; dim < 4; dim++) {
330  for (int64_t il = 0; il < elvechighlevel.size(); il++) {
331  TPZInterpolatedElement *intel = dynamic_cast<TPZInterpolatedElement*> (elvechighlevel[il].Element());
332  TPZGeoEl *ref = intel->Reference();
333  if (ref->SideDimension(elvechighlevel[il].Side()) != dim) {
334  continue;
335  }
336  if (intel->VerifyConstraintConsistency(elvechighlevel[il].Side(), thisside) == false) {
337  orderchanged = 1;
338  intel->RemoveSideRestraintWithRespectTo(elvechighlevel[il].Side(), thisside);
339  intel->SetSideOrder(elvechighlevel[il].Side(), sideorder);
340  intel->RestrainSide(elvechighlevel[il].Side(), this, side);
341  intel->IdentifySideOrder(elvechighlevel[il].Side());
342 #ifdef PZDEBUG
343  if (intel->VerifyConstraintConsistency(elvechighlevel[il].Side(), thisside) == false) {
344  std::cout << "Verify\n";
345  intel->VerifyConstraintConsistency(elvechighlevel[il].Side(),thisside);
346  }
347 #endif
348  }
349  }
350  }
352  if (orderchanged == 1) {//Cedric : || neworder != computorder
353  // The order of the current element changed
354  // Therefore the constraints of all smaller elements connected to the current
355  // element will need to be adapted
356  // The following loop will happen twice, but doesn't affect anything
357 
358  // elvec.Resize(0);
359  // thisside.EqualLevelElementList(elvec,1,0);
360  // Put the accumulated higher dimension sides in highdim (neighbours will not be included because of the third parameter)
361  // The higher dimension sides are only analysed for one dimensional sides
362  TPZStack<TPZCompElSide> highdim;
363  {
364  int64_t cap = elvecequal.size();
365  if (thisside.Reference().Dimension() == 1) {
366  for (int64_t il = 0; il < cap; il++) {
367  elvecequal[il].HigherDimensionElementList(highdim, 1, 1);
368  }
369  }
370  }
371 
372  for (int64_t il = 0; il < highdim.size(); il++) {
373 
374  // verify if the higher dimension element/side is restrained.
375  // if it is restrained then its order will not have changed
376  TPZInterpolatedElement *intel = dynamic_cast<TPZInterpolatedElement *> (highdim[il].Element());
377  if (!intel || intel->ConnectIndex(intel->MidSideConnectLocId(highdim[il].Side())) == -1) {
378  continue;
379  }
380  TPZCompElSide highlarge = highdim[il].LowerLevelElementList(1);
381  if (highlarge.Exists()) {
382  TPZInterpolatedElement *highlargel = dynamic_cast<TPZInterpolatedElement *> (highlarge.Element());
383  if (!highlargel) {
384  DebugStop();
385  }
386  int sideorder = highlargel->EffectiveSideOrder(highlarge.Side());
387  if (intel->VerifyConstraintConsistency(highdim[il].Side(), highlarge) == false) {
388  intel->RemoveSideRestraintWithRespectTo(highdim[il].Side(), highlarge);
389  intel->SetSideOrder(highdim[il].Side(), sideorder);
390  intel->RestrainSide(highdim[il].Side(), highlargel, highlarge.Side());
391  intel->IdentifySideOrder(highdim[il].Side());
392  if (intel->VerifyConstraintConsistency(highdim[il].Side(), highlarge) == false) {
393  std::cout << "Verify\n";
394  intel->VerifyConstraintConsistency(highdim[il].Side(), highlarge);
395  }
396  }
397  } else {
398  intel->IdentifySideOrder(highdim[il].Side());
399  }
400  }
401  }
402 }
403 
406  elvec.Resize(0);
407  TPZCompElSide thisside(this, side);
408  //Adapt the restraints of all smaller elements connected to the current side
409  thisside.HigherLevelElementList(elvec, 1, 1);
410  //thisside.ExpandConnected(elvec,1);
411  int64_t cap, il;
412  cap = elvec.NElements();
413  TPZInterpolatedElement *smalll;
414  int order = EffectiveSideOrder(side);
415  int smallside;
416  int dimension;
417  for (dimension = 0; dimension < 4; dimension++) {
418  for (il = 0; il < cap; il++) {
419  if (elvec[il].Reference().Dimension() != dimension) continue;
420  smalll = dynamic_cast<TPZInterpolatedElement *> (elvec[il].Element());
421  if (!smalll) continue;
422  smallside = elvec[il].Side();
423  // Identify Side Order is used because it will call itself recursively
424  // for its smaller elements too.
425  smalll->RemoveSideRestraintWithRespectTo(smallside, thisside);
426  smalll->SetSideOrder(smallside, order);
427  smalll->RestrainSide(smallside, this, side);
428  }
429  }
430 }
431 
433  int orside = MidSideConnect(side).Order();
434  int neighbourside;
435  TPZInterpolatedElement *neighbour;
436  int64_t il;
437  int64_t cap = elvec.NElements();
438  for (il = 0; il < cap; il++) {
439  neighbour = dynamic_cast<TPZInterpolatedElement *> (elvec[il].Element());
440  if (!neighbour) continue;
441  neighbourside = elvec[il].Side();
442  int neighord = neighbour->MidSideConnect(neighbourside).Order();
443  if (orside != neighord) neighbour->IdentifySideOrder(neighbourside);
444  }
445 }
446 
448  // accumulates the transfer coefficients between the current element and the
449  // coarse element into the transfer matrix, using the transformation t
450  TPZGeoEl *ref = Reference();
451  int locnod = NConnects();
452  int cornod = coarsel.NConnects();
453  int locmatsize = NShapeF();
454  int cormatsize = coarsel.NShapeF();
455 
456  // compare interpolation orders
457  // the minimum interpolation order of this needs to be larger than the maximum interpolation order of coarse
458 
459  int myminorder = MidSideConnect(locnod - 1).Order();
460  int ncorners = NCornerConnects();
461  int ic;
462  for (ic = ncorners; ic < locnod; ic++) {
463  if (MidSideConnect(ic).Order() < myminorder) myminorder = MidSideConnect(ic).Order();
464  }
465  ncorners = coarsel.NCornerConnects();
466  int coarsemaxorder = 0;
467  for (ic = ncorners; ic < cornod; ic++) {
468  if (coarsel.MidSideConnect(ic).Order() > coarsemaxorder) coarsemaxorder = coarsel.MidSideConnect(ic).Order();
469  }
470  if (coarsemaxorder > myminorder) {
471  stringstream sout;
472  sout << "Exiting BuildTransferMatrix - compute the transfer matrix coarse "
473  << coarsemaxorder << " me " << myminorder << endl;
474  LOGPZ_ERROR(logger, sout.str());
475  return;
476  }
477  TPZStack<int64_t> connectlistcoarse;
478  TPZStack<int> dependencyordercoarse, corblocksize;
479  connectlistcoarse.Resize(0);
480  dependencyordercoarse.Resize(0);
481  corblocksize.Resize(0);
482  for (ic = 0; ic < cornod; ic++) connectlistcoarse.Push(coarsel.ConnectIndex(ic));
483  coarsel.BuildConnectList(connectlistcoarse);
484  TPZConnect::BuildDependencyOrder(connectlistcoarse, dependencyordercoarse, *coarsel.Mesh());
485 
486  // cornod = number of connects associated with the coarse element
487  cornod = connectlistcoarse.NElements();
488  int nvar = coarsel.Material()->NStateVariables();
489 
490  // number of blocks is cornod
491  TPZBlock<REAL> corblock(0, cornod);
492  int in;
493  // corblock and corblocksize have the same function
494  for (in = 0; in < NConnects(); in++) {
495  TPZConnect &c = Connect(in);
496  int blsize = c.NShape();
497  corblock.Set(in, blsize);
498  corblocksize.Push(blsize);
499  }
500 
501  // cormatsize is , so far, the number of shape functions of the coarse element
502  int c;
503  for (; in < cornod; in++) {
504  c = connectlistcoarse[in];
505  int nshape = coarsel.Mesh()->ConnectVec()[c].NShape();
506  int blsize = coarsel.Mesh()->ConnectVec()[c].NDof(*(coarsel.Mesh())) / nvar;
507  if (nshape != blsize) {
508  DebugStop();
509  }
510  corblock.Set(in, blsize);
511  corblocksize.Push(blsize);
512  cormatsize += blsize;
513  }
514  corblock.Resequence();
515 
516  // REAL loclocmatstore[500] = {0.};
517  // loclocmat is the inner product of the shape functions of the local element
518  // loccormat is the inner product of the shape functions with the shape functions
519  // of the coarse element, both dependent and independent
520  TPZFNMatrix<500, STATE> loclocmat(locmatsize, locmatsize);
521  TPZFNMatrix<500, STATE> loccormat(locmatsize, cormatsize);
522  loclocmat.Zero();
523  loccormat.Zero();
524 
526  int dimension = Dimension();
527 
528  TPZManVector<int> prevorder(dimension), order(dimension);
529  intrule->GetOrder(prevorder);
530 
531  TPZManVector<int> interpolation(dimension);
532  GetInterpolationOrder(interpolation);
533 
534  // compute the interpolation order of the shapefunctions squared
535  int dim;
536  int maxorder = interpolation[0];
537  for (dim = 0; dim < interpolation.NElements(); dim++) {
538  maxorder = interpolation[dim] < maxorder ? maxorder : interpolation[dim];
539  }
540  for (dim = 0; dim < dimension; dim++) {
541  order[dim] = maxorder * 2 + 2;
542  }
543  intrule->SetOrder(order);
544 
545  TPZBlock<REAL> locblock(0, locnod);
546 
547  for (in = 0; in < locnod; in++) {
548  TPZConnect &c = Connect(in);
549  locblock.Set(in, c.NShape());
550  }
551  locblock.Resequence();
552 
553  REAL locphistore[50] = {0.}, locdphistore[150] = {0.};
554  TPZFMatrix<REAL> locphi(locmatsize, 1, locphistore, 50);
555  TPZFMatrix<REAL> locdphi(dimension, locmatsize, locdphistore, 150);
556  locphi.Zero();
557  locdphi.Zero();
558  // derivative of the shape function
559  // in the master domain
560 
561  TPZFMatrix<REAL> corphi(cormatsize, 1);
562  TPZFMatrix<REAL> cordphi(dimension, cormatsize);
563  // derivative of the shape function
564  // in the master domain
565 
566  REAL jacobianstore[9],
567  axesstore[9];
568  TPZManVector<REAL> int_point(dimension),
569  coarse_int_point(dimension);
570  TPZFMatrix<REAL> jacobian(dimension, dimension, jacobianstore, 9), jacinv(dimension, dimension);
571  TPZFMatrix<REAL> axes(3, 3, axesstore, 9);
572  TPZManVector<REAL> x(3);
573  int_point.Fill(0., 0);
574  REAL jac_det = 1.;
575  ref->Jacobian(int_point, jacobian, axes, jac_det, jacinv);
576  REAL multiplier = 1. / jac_det;
577 
578  int numintpoints = intrule->NPoints();
579  REAL weight;
580  int lin, ljn, cjn;
581 
582  for (int int_ind = 0; int_ind < numintpoints; ++int_ind) {
583 
584  intrule->Point(int_ind, int_point, weight);
585  ref->Jacobian(int_point, jacobian, axes, jac_det, jacinv);
586  ref->X(int_point, x);
587  Shape(int_point, locphi, locdphi);
588  weight *= jac_det;
589  t.Apply(int_point, coarse_int_point);
590  corphi.Zero();
591  cordphi.Zero();
592  coarsel.Shape(coarse_int_point, corphi, cordphi);
593 
594  coarsel.ExpandShapeFunctions(connectlistcoarse, dependencyordercoarse, corblocksize, corphi, cordphi);
595 
596  for (lin = 0; lin < locmatsize; lin++) {
597  for (ljn = 0; ljn < locmatsize; ljn++) {
598  loclocmat(lin, ljn) += weight * locphi(lin, 0) * locphi(ljn, 0) * multiplier;
599  }
600  for (cjn = 0; cjn < cormatsize; cjn++) {
601  loccormat(lin, cjn) += weight * locphi(lin, 0) * corphi(cjn, 0) * multiplier;
602  }
603  }
604  jacobian.Zero();
605  }
606  loclocmat.SolveDirect(loccormat, ELDLt);
607 
608 
609  for (in = 0; in < locnod; in++) {
610  // int cind = connectlistcoarse[in];
611  if (Connect(in).HasDependency()) continue;
612  int64_t locblocknumber = Connect(in).SequenceNumber();
613  int locblocksize = locblock.Size(in);
614  int64_t locblockpos = locblock.Position(in);
615  TPZStack<int> locblockvec;
616  TPZStack<int> globblockvec;
617  int numnonzero = 0, jn;
618  // if(transfer.HasRowDefinition(locblocknumber)) continue;
619 
620  for (jn = 0; jn < cornod; jn++) {
621  int corblocksize = corblock.Size(jn);
622  int64_t corblockpos = corblock.Position(jn);
623  int cind = connectlistcoarse[jn];
624  TPZConnect &con = coarsel.Mesh()->ConnectVec()[cind];
625  if (con.HasDependency()) continue;
626  int64_t corblocknumber = con.SequenceNumber();
627  if (locblocksize == 0 || corblocksize == 0) continue;
628  TPZFMatrix<STATE> smalll(locblocksize, corblocksize, 0.);
629  loccormat.GetSub(locblockpos, corblockpos,
630  locblocksize, corblocksize, smalll);
631  REAL tol = Norm(smalll);
632  if (tol >= 1.e-10) {
633  locblockvec.Push(jn);
634  globblockvec.Push(corblocknumber);
635  numnonzero++;
636  }
637  }
638  if (transfer.HasRowDefinition(locblocknumber)) continue;
639  transfer.AddBlockNumbers(locblocknumber, globblockvec);
640  int jnn;
641  for (jnn = 0; jnn < numnonzero; jnn++) {
642  jn = locblockvec[jnn];
643  int corblocksize = corblock.Size(jn);
644  int64_t corblockpos = corblock.Position(jn);
645  if (corblocksize == 0 || locblocksize == 0) continue;
646  TPZFMatrix<STATE> smalll(locblocksize, corblocksize, 0.);
647  loccormat.GetSub(locblockpos, corblockpos, locblocksize, corblocksize, smalll);
648  transfer.SetBlockMatrix(locblocknumber, globblockvec[jnn], smalll);
649  }
650  }
651  intrule->SetOrder(prevorder);
652 }
653 
655  TPZCompMesh *cmesh = Mesh();
656  TPZMaterial * mat = Material();
657 #ifdef PZDEBUG
658  if (!mat) {
659  std::cout << __PRETTY_FUNCTION__ << " no material associated with matid " << Reference()->MaterialId() << std::endl;
660  }
661 #endif
662  int nvar = 1;
663  if (mat) nvar = mat->NStateVariables();
664  int64_t newnodeindex;
665  int64_t il;
666  int64_t nodloc = MidSideConnectLocId(side);
667 
668 
670  TPZCompElSide thisside(this, side);
671  if (side < NCornerConnects()) {
672  thisside.EqualLevelElementList(elvec, 1, 0);
673  int64_t nel = elvec.NElements(); // (1)
674  if (nel && elvec[nel - 1].Reference().Dimension() == thisside.Reference().Dimension()) {
675  newnodeindex = elvec[nel - 1].ConnectIndex();
676  SetConnectIndex(nodloc, newnodeindex);
677  } else {
678  // corner nodes have order 1
679  int order = 1; //cmesh->GetDefaultOrder();
680  int nshape = NConnectShapeF(nodloc, order);
681  // create the connects with order 1
682  newnodeindex = cmesh->AllocateNewConnect(nshape, nvar, order);
683  TPZConnect &newnod = cmesh->ConnectVec()[newnodeindex];
684  if (newnod.HasDependency()) {
685  LOGPZ_ERROR(logger, "CreateMidSideConnect, new node has dependency");
686  newnod.Print(*cmesh);
687  DebugStop();
688  }
689  int64_t seqnum = newnod.SequenceNumber();
690  SetConnectIndex(nodloc, newnodeindex); //Is true only to one-dimensional case
691  cmesh->Block().Set(seqnum, nvar * nshape);
692  // We created a new node, check whether the node needs to be constrained
693  TPZCompElSide father = thisside.LowerLevelElementList(1);
694  if (father.Exists()) {
695  int side_neig = father.Side();
696  TPZInterpolatedElement *cel = dynamic_cast<TPZInterpolatedElement *> (father.Element());
697  if (cel) {
698  // corner nodes to not change order
699  //newnod.SetOrder(cel->SideOrder(side_neig));
700  RestrainSide(side, cel, side_neig);
701  }
702  }
703  }
704  return newnodeindex;
705  }
706 
707  // Connect looks for a connecting element of equal or lower level
708  TPZInterpolatedElement *cel = 0;
709  int side_neig = 0;
710  thisside.EqualLevelElementList(elvec, 1, 1);
711  int64_t nelem = elvec.NElements();
712  // find an element in the list which is interpolated
713  if (nelem) {
714  cel = dynamic_cast<TPZInterpolatedElement *> (elvec[0].Element());
715  side_neig = elvec[0].Side();
716  }
717  int64_t newnodecreated = 0;
718  if (cel) {
719  newnodeindex = cel->ConnectIndex(cel->MidSideConnectLocId(side_neig));
720  SetConnectIndex(nodloc, newnodeindex);
721  } else {
722  int nshape = 0;
723  int order = cmesh->GetDefaultOrder();
724  newnodeindex = cmesh->AllocateNewConnect(nshape, nvar, order);
725  TPZConnect &newnod = cmesh->ConnectVec()[newnodeindex];
726  int64_t seqnum = newnod.SequenceNumber();
727  SetConnectIndex(nodloc, newnodeindex);
728  nshape = NConnectShapeF(nodloc, order);
729  newnod.SetNShape(nshape);
730  cmesh->Block().Set(seqnum, nvar * nshape);
731  newnodecreated = 1;
732  }
733  TPZCompElSide father = thisside.LowerLevelElementList(1);
734  if (father.Exists() && newnodecreated) {
735  // There is a larger element connected along the side that is being created
736  // We will adopt the interpolation order of the father and compute the
737  // restraints
738  // IT IS ASSUMED THAT ALL NEIGHBOURING ELEMENTS AND SMALLER ELEMENTS CONNECTED
739  // TO THIS SIDE HAVE CONSISTENT INTERPOLATION ORDERS
740  side_neig = father.Side();
741  TPZInterpolatedElement *elfather = dynamic_cast<TPZInterpolatedElement *> (father.Element());
742  int sideorder = elfather->EffectiveSideOrder(side_neig);
743  SetSideOrder(side, sideorder);
744  RestrainSide(side, elfather, side_neig);
745  elvec.Resize(0);
746  thisside.HigherLevelElementList(elvec, 1, 1);
747  // thisside.ExpandConnected(elvec,1);
748  // thisside.RemoveDuplicates(elvec);
749  int64_t cap = elvec.NElements();
750  int dim;
751  for (dim = 0; dim < 3; dim++) {
752  for (il = 0; il < cap; il++) {
753  if (elvec[il].Reference().Dimension() != dim) continue;
754  cel = dynamic_cast<TPZInterpolatedElement *> (elvec[il].Element());
756  cel->RemoveSideRestraintWithRespectTo(elvec[il].Side(), father);
757  Reference()->SetReference(this);
758 
759  cel->RestrainSide(elvec[il].Side(), this, side);
760  }
761  }
762  } else if (father.Exists() && !newnodecreated) {
763  side_neig = father.Side();
764  TPZInterpolatedElement *elfather = dynamic_cast<TPZInterpolatedElement *> (father.Element());
765  int sideorder = elfather->EffectiveSideOrder(side_neig);
766  SetSideOrder(side, sideorder);
767  } else if (!father.Exists() && !newnodecreated) {
768  // The element does not have a larger element connected along the side
769  // The insertion of the new element may have an effect on the interpolation
770  // order of all equal level elements which are connected
772  stringstream sout;
773  sout << "TPZInterpolatedElement fodeu side " << side << endl;
774  LOGPZ_ERROR(logger, sout.str());
775  father = thisside.LowerLevelElementList(1);
776  DebugStop();
777  }
778  elvec.Resize(0);
779  thisside.EqualLevelElementList(elvec, 1, 0);
780  int oldorder = -1;
781  if (elvec.NElements()) {
782  TPZInterpolatedElement *cel = dynamic_cast<TPZInterpolatedElement *> (elvec[0].Element());
783  oldorder = cel->MidSideConnect(elvec[0].Side()).Order();
784  }
785  elvec.Push(thisside);
786  int sideorder = ComputeSideOrder(elvec);
787  if (sideorder != oldorder) {
788  TPZInterpolatedElement *cel = dynamic_cast<TPZInterpolatedElement *> (elvec[0].Element());
789  cel->IdentifySideOrder(elvec[0].Side());
790  } else {
791  SetSideOrder(side, sideorder);
792  }
793  } else if (!father.Exists() && newnodecreated) {
794  elvec.Resize(0);
795  thisside.HigherLevelElementList(elvec, 1, 1);
796  // thisside.ExpandConnected(elvec,1);
797  // thisside.RemoveDuplicates(elvec);
798  int64_t cap = elvec.NElements();
799  int sideorder = PreferredSideOrder(side);
800  SetSideOrder(side, sideorder);
801  sideorder = EffectiveSideOrder(side);
802  // We check on all smaller elements connected to the current element
803  // whether their interpolation order is consistent with the interpolation
804  // order of the current element/side
805  int dim;
806  for (dim = 0; dim < 3; dim++) {
807  for (il = 0; il < cap; il++) {
808  if (elvec[il].Reference().Dimension() != dim) continue;
809  TPZInterpolatedElement *cel = dynamic_cast<TPZInterpolatedElement *> (elvec[il].Element());
810  if (!cel) continue;
811  // the restraint will only be applied if the first
812  // element in Connect is equal to the current element
813  int locindex = cel->MidSideConnectLocId(elvec[il].Side());
814  if (locindex < 0) {
815  continue;
816  }
817  int celsideorder = cel->Connect(locindex).Order();
818 #ifdef PZDEBUG
819  {
820  TPZInterpolatedElement *intel = dynamic_cast<TPZInterpolatedElement *> (elvec[il].Element());
821  TPZGeoEl *gel = Reference();
822  TPZConnect &c = intel->MidSideConnect(elvec[il].Side());
823  if (c.HasDependency()) {
824  int64_t cindex = intel->ConnectIndex(intel->MidSideConnectLocId(elvec[il].Side()));
825  gel->ResetReference();
826  TPZCompElSide locallarge;
827  TPZGeoElSide localgelside(intel->Reference(), elvec[il].Side());
828  locallarge = localgelside.LowerLevelCompElementList2(1);
829  std::cout << "I dont understand\n";
830  }
831  }
832 #endif
833  if (celsideorder != sideorder) {
834  cel->SetSideOrder(elvec[il].Side(), sideorder);
835  }
836  // if the interpolation order remains unchanged, just restrain the side
837  cel->RestrainSide(elvec[il].Side(), this, side);
838  if (celsideorder != sideorder) {
839  // if the interpolation order changed, recompute the side order of all
840  // smaller elements and recompute the constraints
841  cel->IdentifySideOrder(elvec[il].Side());
842  }
843  }
844  }
845  }
846  return newnodeindex;
847 }
848 
849 void TPZInterpolatedElement::RestrainSide(int side, TPZInterpolatedElement *large, int neighbourside) {
850  TPZCompElSide thisside(this, side);
851  TPZCompElSide largecompside(large, neighbourside);
852  TPZGeoElSide largecompsideref = largecompside.Reference();
853  TPZInterpolatedElement *cel = 0;
854  if (largecompside.Exists()) cel = dynamic_cast<TPZInterpolatedElement *> (largecompside.Element());
855  if (!cel) {
856  LOGPZ_ERROR(logger, "Exiting RestrainSide - null computational element.");
857  return;
858  }
859  int locind = MidSideConnectLocId(side);
860  if (locind < 0) {
861  DebugStop();
862  }
863  TPZConnect &myconnect = Connect(locind);
864  if (myconnect.NShape() == 0) {
866  return;
867  }
868  if (myconnect.HasDependency() && largecompsideref.Dimension() > 0) {
869  LOGPZ_WARN(logger, "RestrainSide - unnecessary call to restrainside");
870  DebugStop();
871  }
872  if (cel->ConnectIndex(cel->MidSideConnectLocId(largecompside.Side())) == -1) {
873  LOGPZ_ERROR(logger, "Exiting RestrainSide - Side of large element not initialized");
874  DebugStop();
875  return;
876  }
877  if (largecompsideref.Dimension() == 0) {
878  LOGPZ_ERROR(logger, "Exiting RestrainSide - dimension of large element is 0");
879  DebugStop();
880  return;
881  }
882  TPZGeoElSide thisgeoside(Reference(), side);
883  TPZGeoElSide largeside = largecompside.Reference();
884  TPZTransform<> t(thisgeoside.Dimension());
885  thisgeoside.SideTransform3(largeside, t);
886  int nsideconnects = NSideConnects(side);
887  int maxord = 1;
888  for (int sidecon = 0; sidecon < nsideconnects; sidecon++) {
889  TPZConnect &c = SideConnect(sidecon, side);
890  int sideord = c.Order();
891  maxord = maxord < sideord ? sideord : maxord;
892  }
893  int largeorder = large->EffectiveSideOrder(neighbourside);
894  int sideorder = MidSideConnect(side).Order();
895  if (sideorder < largeorder && thisgeoside.Dimension() && largeside.Dimension()) {
896  DebugStop();
897  }
898  TPZIntPoints *intrule = Reference()->CreateSideIntegrationRule(side, maxord * 2);
899  if (!intrule) {
900  LOGPZ_ERROR(logger, "Exiting RestrainSide - cannot create side integration rule");
901  return;
902  }
903  int numint = intrule->NPoints();
904  int numshape = NSideShapeF(side);
905  int sidedimension = thisgeoside.Dimension();
906  int largesidedimension = largeside.Dimension();
907  int numshapel = large->NSideShapeF(neighbourside);
908  TPZFNMatrix<100, REAL> phis(numshape, 1), dphis(2, numshape), phil(numshapel, 1), dphil(2, numshapel);
909  TPZFNMatrix<1000, REAL> MSL(numshape, numshapel, 0.);
910  TPZFNMatrix<1000, REAL> *M = new TPZFNMatrix<1000, REAL>(numshape, numshape, 0.);
911  TPZManVector<REAL, 3> par(sidedimension), pointl(largesidedimension); //,point(3);
912  int64_t in, jn;
913  REAL weight;
914  for (int it = 0; it < numint; it++) {
915  intrule->Point(it, par, weight);
916  SideShapeFunction(side, par, phis, dphis);
917  t.Apply(par, pointl);
918  large->SideShapeFunction(neighbourside, pointl, phil, dphil);
919  for (in = 0; in < numshape; in++) {
920  for (jn = 0; jn < numshape; jn++) {
921  (*M)(in, jn) += phis(in, 0) * phis(jn, 0) * weight;
922  }
923  for (jn = 0; jn < numshapel; jn++) {
924  MSL(in, jn) += phis(in, 0) * phil(jn, 0) * weight;
925  }
926  }
927  }
928 #ifdef LOG4CXX_keep
929  if (logger->isDebugEnabled()) {
930  std::stringstream sout;
931  M->Print("MSS = ", sout, EMathematicaInput);
932  LOGPZ_DEBUG(logger, sout.str())
933  }
934 #endif
935  TPZStepSolver<REAL> MSolve(M);
936  MSolve.SetDirect(ELU);
937 
938  MSolve.Solve(MSL, MSL);
939 
940  //MSolve.ResetMatrix();
941  int numsidenodes_small = NSideConnects(side);
942  // Philippe 12/3/99
943  // int numsidenodes_large = NSideConnects(neighbourside);
944  int numsidenodes_large = large->NSideConnects(neighbourside);
945  TPZBlock<REAL> MBlocksmall(0, numsidenodes_small), MBlocklarge(0, numsidenodes_large);
946  for (in = 0; in < numsidenodes_small; in++) {
947  int locid = SideConnectLocId(in, side);
948  TPZConnect &c = Connect(locid);
949 #ifdef PZDEBUG
950  if (NConnectShapeF(locid, c.Order()) != c.NShape()) {
951  DebugStop();
952  }
953 #endif
954  unsigned int nshape = c.NShape();
955  MBlocksmall.Set(in, nshape);
956  }
957  for (in = 0; in < numsidenodes_large; in++) {
958  int locid = large->SideConnectLocId(in, neighbourside);
959  TPZConnect &c = large->Connect(locid);
960  unsigned int nshape = c.NShape();
961 #ifdef PZDEBUG
962  if (large->NConnectShapeF(locid, c.Order()) != nshape) {
963  DebugStop();
964  }
965 #endif
966  MBlocklarge.Set(in, nshape);
967  }
968 
969  MBlocksmall.Resequence();
970  MBlocklarge.Resequence();
971  TPZFNMatrix<20, REAL> blocknorm(numsidenodes_small, numsidenodes_large, 0.);
972  for (in = 0; in < numsidenodes_small; in++) {
973  int ibl = MBlocksmall.Size(in);
974  if (!ibl) continue;
975  for (jn = 0; jn < numsidenodes_large; jn++) {
976  int jbl = MBlocklarge.Size(jn);
977  if (!jbl) continue;
978  int i, j;
979  int64_t ipos = MBlocksmall.Position(in);
980  int64_t jpos = MBlocklarge.Position(jn);
981  for (i = 0; i < ibl; i++) for (j = 0; j < jbl; j++) blocknorm(in, jn) += fabs(MSL(ipos + i, jpos + j)) * fabs(MSL(ipos + i, jpos + j));
982  blocknorm(in, jn) /= (ibl * jbl);
983  blocknorm(in, jn) = sqrt(blocknorm(in, jn));
984  }
985  }
986 #ifdef PZDEBUG
988 #endif
989  TPZConnect &inod = Connect(MidSideConnectLocId(side));
990  int64_t inodindex = ConnectIndex(MidSideConnectLocId(side));
991  int64_t ndepend = 0;
992  in = numsidenodes_small - 1;
993 #ifdef PZDEBUG
994  if (MBlocksmall.Size(in) == 0) {
995  DebugStop();
996  }
997 #endif
998  for (jn = 0; jn < numsidenodes_large; jn++) {
999  if (MBlocksmall.Size(in) == 0 || MBlocklarge.Size(jn) == 0) {
1000  continue;
1001  }
1002  int64_t jnodindex = large->SideConnectIndex(jn, neighbourside);
1003  TPZConnect::TPZDepend *depend = inod.AddDependency(inodindex, jnodindex, MSL, MBlocksmall.Position(in), MBlocklarge.Position(jn),
1004  MBlocksmall.Size(in), MBlocklarge.Size(jn));
1005  if (blocknorm(in, jn) < 1.e-8) {
1006  depend->fDepMatrix.Zero();
1007  }
1008  ndepend++;
1009  }
1010 
1011  if (!ndepend) {
1012  //cout << "Caso esquisito!!! Chame o Boss que vc receberem premio\n";
1013  for (jn = 0; jn < numsidenodes_large; jn++) {
1014  int64_t jnodindex = large->SideConnectIndex(jn, neighbourside);
1015  if (MBlocklarge.Size(jn)) {
1016  inod.AddDependency(inodindex, jnodindex, MSL, MBlocksmall.Position(in), MBlocklarge.Position(jn),
1017  MBlocksmall.Size(in), MBlocklarge.Size(jn));
1018  }
1019  ndepend++;
1020  }
1021  }
1022  delete intrule;
1023 
1024 #ifdef HUGE_DEBUG
1025  // a matriz frestraint deveria ser igual a MSL
1026  TPZCheckRestraint test(thisside, largecompside);
1027  //test.Print(cout);
1028  int64_t imsl, jmsl;
1029  int64_t rmsl = MSL.Rows();
1030  int64_t cmsl = MSL.Cols();
1031  int64_t rtest = test.RestraintMatrix().Rows();
1032  int64_t ctest = test.RestraintMatrix().Cols();
1033 
1034  if (rtest != rmsl || ctest != cmsl) {
1035  stringstream sout;
1036  sout << "Exiting - Restraint matrix side incompatibility: MSL (rows,cols): ( " << rmsl
1037  << " , " << cmsl << " )" << " RestraintMatrix (rows,cols): (" << rtest << " , " << ctest << " )\n"
1038  << "press any key to continue";
1039  LOGPZ_ERROR(logger, sout.str());
1040  int a;
1041  cin >> a;
1042  return;
1043  }
1044 
1045  TPZFMatrix<REAL> mslc(MSL);
1046  mslc -= test.RestraintMatrix();
1047 
1048  REAL normmsl = 0.;
1049  for (imsl = 0; imsl < rmsl; imsl++) {
1050  for (jmsl = 0; jmsl < cmsl; jmsl++) {
1051  normmsl += sqrt(mslc(imsl, jmsl) * mslc(imsl, jmsl));
1052  }
1053  }
1054  if (normmsl > 1.E-6) {
1055  stringstream sout;
1056  sout << "TPZInterpolatedElement::Error::MSL matrix has non zero norm " << normmsl << "\n";
1057  mslc.Print("Difference Matrix ", sout);
1058  for (imsl = 0; imsl < rmsl; imsl++) {
1059  for (jmsl = 0; jmsl < cmsl; jmsl++) {
1060  if (fabs(MSL(imsl, jmsl) - test.RestraintMatrix()(imsl, jmsl)) > 1.E-6) {
1061  sout << "msl[ " << imsl << " , " << jmsl << " ] = " << MSL(imsl, jmsl) << "\t "
1062  << test.RestraintMatrix()(imsl, jmsl) << endl;
1063  }
1064  }
1065  }
1066  LOGPZ_ERROR(logger, sout.str());
1067  // int a;
1068  // gDebug = 1;
1069  // cin >> a;
1070  }
1071 
1072  // verificar a norma de MSL
1073  if (test.CheckRestraint()) {
1074  stringstream sout
1075  sout << "TPZInterpolatedElement::Error::Bad restraints detected\n"; // recado de erro.
1076  test.Print(sout);
1077  // int a;
1078  // gDebug = 1;
1079  // cin >> a;
1080  test.Diagnose();
1081  LOGPZ_ERROR(logger, sout.str());
1082  TPZCheckRestraint test2(thisside, largecompside);
1083  }
1084 #endif
1085 }
1086 
1088  int nc = Reference()->NSides();
1089  // int a;
1090  for (int c = 0; c < nc; c++) CheckConstraintConsistency(c);
1091 }
1092 
1094  int dimel = Dimension();
1095  int iside;
1096  int a;
1097  int nstate = 1;
1098  nstate = Material()->NStateVariables();
1099 
1100  for (iside = 0; iside < NConnects(); iside++) {
1101  int nshape = Connect(iside).NShape();
1102  if (Connect(iside).CheckDependency(nshape, Mesh(), nstate) == -1) {
1103  LOGPZ_WARN(logger, "CheckElementConsistency detected inconsistency 1");
1104  return 0;
1105  }
1106  if (Connect(iside).NDof(*Mesh()) != nshape * nstate) {
1107  LOGPZ_WARN(logger, "CheckElementConsistency detected inconsistency 2");
1108  return 0;
1109  }
1110  }
1111  for (iside = 0; iside < (Reference()->NSides() - 1); iside++) {
1112  TPZCompElSide celside(this, iside);
1113  int dimsmall = celside.Reference().Dimension();
1114 
1116 
1117  if (dimsmall >= dimel) {
1118  stringstream sout;
1119  sout << "TPZInterpolatedElement::CheckConstraintConsistency : dismall >= dimel: "
1120  << dimsmall << " >= " << dimel << endl
1121  << "press any key to continue";
1122  LOGPZ_INFO(logger, sout.str());
1123  cin >> a;
1124  delete sirule;
1125  return 0;
1126  }
1127  int idim;
1128  int nshapes = NSideShapeF(iside);
1129  TPZFMatrix<REAL> phis(nshapes, 1);
1130  TPZFMatrix<REAL> dphis(dimsmall, nshapes);
1131  for (idim = (dimsmall + 1); idim <= dimel; idim++) {
1132  TPZStack <TPZGeoElSide> geoelsidevec;
1133  celside.Reference().Element()->AllHigherDimensionSides(iside, idim, geoelsidevec);
1134 
1135  int nelhigh = geoelsidevec.NElements();
1136  int inh;
1137  for (inh = 0; inh < nelhigh; inh++) {
1138  int sidel = geoelsidevec[inh].Side();
1139  int nshapel = NSideShapeF(sidel);
1140  TPZFMatrix<REAL> phil(nshapel, 1);
1141  TPZFMatrix<REAL> dphil(idim, nshapel);
1142  int npts = sirule->NPoints();
1143  int ipt;
1144  TPZTransform<> transform(Reference()->SideToSideTransform(iside, sidel));
1145  for (ipt = 0; ipt < npts; ipt++) {
1146  TPZVec <REAL> pts(dimsmall);
1147  TPZVec <REAL> ptl(idim);
1148  REAL w;
1149  sirule->Point(ipt, pts, w);
1150  SideShapeFunction(iside, pts, phis, dphis);
1151  transform.Apply(pts, ptl);
1152  SideShapeFunction(sidel, ptl, phil, dphil);
1153  int check = CompareShapeF(iside, sidel, phis, dphis, phil, dphil, transform);
1154  if (!check) {
1155  LOGPZ_INFO(logger, "Exiting CheckElementConsistency - don't compare shapefunctions.");
1156  delete sirule;
1157  return check;
1158  }
1159  }
1160  }
1161  }
1162  delete sirule;
1163  }
1164  return 1;
1165 }
1166 
1168  int ncons = NSideConnects(sides);
1169  int nconl = NSideConnects(sidel);
1170  TPZVec<int> posl(nconl + 1), poss(ncons + 1);
1171  int icon, icons, iconl;
1172  if (nconl) posl[0] = 0;
1173  if (ncons) poss[0] = 0;
1174  for (icon = 0; icon < nconl; icon++) {
1175  posl[icon + 1] = posl[icon] + Connect(SideConnectLocId(icon, sidel)).NShape();
1176  }
1177  for (icon = 0; icon < ncons; icon++) {
1178  poss[icon + 1] = poss[icon] + Connect(SideConnectLocId(icon, sides)).NShape();
1179  }
1180  REAL diff = 0.;
1181  for (icons = 0; icons < ncons; icons++) {
1182  int consind = SideConnectLocId(icons, sides);
1183  for (iconl = 0; iconl < nconl; iconl++) {
1184  int conlind = SideConnectLocId(iconl, sidel);
1185  if (consind == conlind) {
1186  int nshape = poss[icons + 1] - poss[icons];
1187  int dims = Reference()->SideDimension(sides);
1188  int diml = Reference()->SideDimension(sidel);
1189  int ishape, idim, jdim;
1190  for (ishape = 0; ishape < nshape; ishape++) {
1191  int shapel = posl[iconl] + ishape;
1192  int shapes = poss[icons] + ishape;
1193  diff += (phis(shapes, 0) - phil(shapel, 0))*(phis(shapes, 0) - phil(shapel, 0));
1194  REAL derivcomp[3];
1195  for (idim = 0; idim < dims; idim++) {
1196  derivcomp[idim] = 0.;
1197  for (jdim = 0; jdim < diml; jdim++) {
1198  derivcomp[idim] += dphil(jdim, shapel) * transform.Mult()(jdim, idim);
1199  }
1200  diff += (dphis(idim, shapes) - derivcomp[idim])*(dphis(idim, shapes) - derivcomp[idim]);
1201  }
1202  }
1203  }
1204  }
1205  }
1206 
1207  if (diff >= 1.e-6) {
1208  stringstream sout;
1209  sout << "TPZInterpolatedElement::CompareShapeF sides " << sides << " sidel " << sidel << " do not compare diff " << diff << endl;
1210  LOGPZ_ERROR(logger, sout.str());
1211  }
1212  return 1;
1213 }
1214 
1216  TPZCompElSide thisside(this, side);
1217  TPZCompElSide large = thisside.LowerLevelElementList(1);
1218  if (large.Exists()) {
1219  int largeside = large.Side();
1220  TPZInterpolatedElement *largel = dynamic_cast<TPZInterpolatedElement *> (large.Element());
1221  int nlargesideconnects = largel->NSideConnects(largeside);
1222  int n_small_side_connect = NSideConnects(side)-1;
1223  TPZConnect &thiscon = SideConnect(n_small_side_connect, side);
1224  int jn;
1225  TPZConnect::TPZDepend *dep = thiscon.FirstDepend();
1226  while (dep) {
1227  for (jn = 0; jn < nlargesideconnects; jn++) {
1228  int largeindex = largel->SideConnectIndex(jn, largeside);
1229  if (dep->fDepConnectIndex == largeindex || largeindex == ConnectIndex(side)) break;
1230  }
1231  if (jn == nlargesideconnects) {
1232  stringstream sout;
1233  sout << "Dependency inconsistency";
1234  thiscon.Print(*Mesh(), sout);
1235  largel->Print(sout);
1236  LOGPZ_ERROR(logger, sout.str());
1237  }
1238  dep = dep->fNext;
1239  }
1240  } else {
1241  int n_small_side_connect = NSideConnects(side)-1;
1242  TPZConnect &thiscon = SideConnect(n_small_side_connect, side);
1243  if (thiscon.HasDependency()) {
1244  stringstream sout;
1245  large = thisside.LowerLevelElementList(1);
1246  sout << "Dependency inconsistency\n";
1247  thiscon.Print(*Mesh(), sout);
1248  LOGPZ_ERROR(logger, sout.str());
1249  }
1250  }
1251 }
1252 
1254  const TPZCompElSide & neighbour) {
1255  TPZCompElSide thisside(this, side);
1256  TPZCompElSide largeset = thisside.LowerLevelElementList(1);
1257  if (!largeset.Exists()) {
1258  LOGPZ_WARN(logger, "Exiting RemoveSideRestraintWithRespectTo inconsistent 1");
1259  return;
1260  }
1261  TPZInterpolatedElement *smallfather = dynamic_cast<TPZInterpolatedElement *> (largeset.Element());
1262  int smallfatherside = largeset.Side();
1263  if (!neighbour.Reference().NeighbourExists(largeset.Reference())) {
1264  LOGPZ_WARN(logger, "Exiting RemoveSideRestraintWithRespectTo inconsistent 3");
1265  }
1266  int js;
1267  int nsfather = smallfather->NSideConnects(smallfatherside);
1268  int dfiindex = ConnectIndex(MidSideConnectLocId(side));
1269  TPZConnect *dfi = &Connect(MidSideConnectLocId(side));
1270  for (js = 0; js < nsfather; js++) {
1271  int dfjindex = smallfather->SideConnectIndex(js, smallfatherside);
1272  dfi->RemoveDepend(dfiindex, dfjindex);
1273  }
1274  if (dfi->HasDependency()) {
1275  int dim1, dim2;
1276  dim1 = Reference()->SideDimension(side);
1277  dim2 = neighbour.Element()->Reference()->SideDimension(neighbour.Side());
1278  if (dim1 || dim2) {
1279  stringstream sout;
1280  sout << "TPZInterpolatedElement::RemoveSideRestraintWithRespectTo fishy " << dfiindex;
1281  LOGPZ_ERROR(logger, sout.str());
1282  }
1283  }
1284 }
1285 
1287  if (mode == EInsert) {//modo insercao
1288  LOGPZ_WARN(logger, "Exiting RemoveSideRestraintsII with mode insert should not be called");
1289  return;
1290  }
1291  TPZCompElSide large; //elemento grande
1292  TPZStack<TPZCompElSide> elemset; //elementos pequenos
1293  int numsides = Reference()->NSides();
1294  int side, nelem, iel;
1295  if (mode == EDelete) {
1296  for (side = 0; side < numsides; side++) {
1297  if (NSideConnects(side) == 0) {
1298  continue;
1299  }
1300  TPZCompElSide thisside(this, side);
1301  elemset.Resize(0);
1302  thisside.EqualLevelElementList(elemset, 1, 0); //iguais
1303  if (side < NCornerConnects()) thisside.HigherLevelElementList(elemset, 1, 0);
1304  nelem = elemset.NElements();
1305  TPZStack<TPZCompElSide> smallset;
1306  thisside.HigherLevelElementList(smallset, 1, 1); //menores
1307  int nsmall = smallset.NElements();
1308  large = thisside.LowerLevelElementList(1);
1309  if (!nelem) {//nao existem iguais
1310  if (large.Exists()) {//existe grande : a23 , ab3
1311  RemoveSideRestraintWithRespectTo(side, large);
1312  }//fim large
1313  if (nsmall) {//existem pequenos : a23
1314  // thisside.ExpandConnected(smallset,1);
1315  nsmall = smallset.NElements();
1316  for (iel = 0; iel < nsmall; iel++) {
1317  TPZInterpolatedElement *cel = dynamic_cast<TPZInterpolatedElement *> (smallset[iel].Element());
1318  int smallside = smallset[iel].Side();
1319  if (cel && cel->NSideConnects(smallside) > 0) cel->RemoveSideRestraintWithRespectTo(smallset[iel].Side(), thisside);
1320  }
1321  }//ab3
1322  }
1323  }
1324  }
1325  TPZCompEl *refloaded = Reference()->Reference();
1327  for (side = 0; side < numsides; side++) {
1328  if (NSideConnects(side) == 0) {
1329  continue;
1330  }
1331  if (mode == EDelete) {//modo remocao
1332  TPZCompElSide thisside(this, side);
1333  elemset.Resize(0);
1334  thisside.EqualLevelElementList(elemset, 1, 0); //iguais
1335  if (side < NCornerConnects()) thisside.HigherLevelElementList(elemset, 1, 0);
1336  nelem = elemset.NElements();
1337  TPZStack<TPZCompElSide> smallset;
1338  thisside.HigherLevelElementList(smallset, 1, 1); //menores
1339  int nsmall = smallset.NElements();
1340  large = thisside.LowerLevelElementList(1);
1341  if (nelem && !large.Exists()) {//iguais e nao grande
1342  //se existem iguais s�deve-se recalcular a ordem de todos os iguais que restaram
1343  /* int oldorder = SideOrder(side); */
1344  /* int order = ComputeSideOrder(elemset); */
1345  /* if(order != oldorder) { */
1346  // Reference()->ResetReference();
1347  TPZInterpolatedElement *cel = dynamic_cast<TPZInterpolatedElement *> (elemset[0].Element());
1348  if (cel) {
1349  cel->IdentifySideOrder(elemset[0].Side());
1350  }
1351  } else if (!nelem) {//nao existem iguais
1352  if (large.Exists() && nsmall) {
1353  // Reference()->ResetReference();
1354  int dim;
1355  for (dim = 0; dim < 4; dim++) {
1356  for (iel = 0; iel < nsmall; iel++) {
1357  if (smallset[iel].Reference().Dimension() == dim) {
1358  TPZInterpolatedElement *cel = dynamic_cast<TPZInterpolatedElement *> (smallset[iel].Element());
1359  TPZInterpolatedElement *largel = dynamic_cast<TPZInterpolatedElement *> (large.Element());
1360  cel->RestrainSide(smallset[iel].Side(), largel, large.Side());
1361  }
1362  }
1363  }
1364  }
1365  }//fim nelem e large
1366  }//fim mode EDelete
1367  }//fim for
1368  Reference()->SetReference(refloaded);
1369 }//fim todos
1370 
1372  int nelem = smallset.NElements();
1373  if (!nelem) {
1374  LOGPZ_ERROR(logger, "Exiting ComputeSideOrder called for empty list, -1 returned");
1375  return -1;
1376  }
1377  TPZInterpolatedElement *cel = dynamic_cast<TPZInterpolatedElement *> (smallset[0].Element());
1378  int minorder = cel->PreferredSideOrder(smallset[0].Side());
1379 #ifdef LOG4CXX2
1380  if (logger->isDebugEnabled()) {
1381  std::stringstream sout;
1382  sout << "Order of first side " << minorder;
1383  LOGPZ_DEBUG(logger, sout.str())
1384  }
1385 #endif
1386  int iel;
1387  for (iel = 1; iel < nelem; iel++) {
1388  cel = dynamic_cast<TPZInterpolatedElement *> (smallset[iel].Element());
1389  int celorder = cel->PreferredSideOrder(smallset[iel].Side());
1390  minorder = minorder < celorder ? minorder : celorder;
1391  }
1392  return minorder;
1393 }
1394 
1396 void TPZInterpolatedElement::Divide(int64_t index,TPZVec<int64_t> &sub,int interpolatesolution) {
1397 
1398  Mesh()->SetAllCreateFunctions(*this);
1399 
1400  //necessary to allow continuous and discontinuous elements in same simulation
1401  this->RemoveInterfaces();
1402 
1403  if (fMesh->ElementVec()[index] != this) {
1404  LOGPZ_ERROR(logger,"Exiting Divide: index error");
1405  sub.Resize(0);
1406  return;
1407  }
1408  TPZGeoEl *ref = Reference();
1409 
1411  ref->Divide(pv);//o elemento geometrico correspondente ao atual elemento computacional �dividido
1412  if(!pv.NElements()) {
1413  sub.Resize(0);
1414  if(Type() != EPoint)
1415  LOGPZ_ERROR(logger,"Exiting Divide: no subelements acquired");
1416  return;
1417  }
1418  // The refinement pattern may be adjusted during the division process
1419  int nsubelements = ref->NSubElements();
1420  sub.Resize(nsubelements);
1421 
1422 #ifdef LOG4CXX
1423  {
1424  std::stringstream sout;
1425  sout << (void*) Mesh() << " Divide " << Index() << " " << Reference()->Index();
1426  LOGPZ_DEBUG(loggerdiv, sout.str())
1427  }
1428 #endif
1429 
1430  int i;
1431 
1432 #ifdef HUGE_DEBUG
1433  {
1434  stringstream sout;
1435  TPZCheckMesh chk(Mesh(), &sout);
1436  if (chk.CheckConnectOrderConsistency() != -1) {
1437  LOGPZ_WARN(logger, "CheckConnectOrderConsistency failed");
1438  LOGPZ_WARN(logger, sout.str());
1439  }
1440  }
1441 #endif
1442 
1443  RemoveSideRestraintsII(EDelete); //Cedric 25/03/99
1444 
1445  fMesh->ElementVec()[index] = NULL; //Cesar 2003-11-19
1447 
1448  TPZGeoEl *cref;
1450 
1451 #ifdef HUGE_DEBUG
1452  if (NConnects() == 7) {
1453  stringstream sout;
1454  TPZCheckMesh chk(Mesh(), &sout);
1455  if (chk.CheckConnectOrderConsistency() != -1) {
1456  LOGPZ_WARN(logger, "CheckConnectOrderConsistency failed after RemoveSideRestraintsII");
1457  LOGPZ_WARN(logger, sout.str());
1458  }
1459  }
1460 #endif
1461 
1462  int ncon = ref->NSides();
1464  for (i = 0; i < nsubelements; i++) {
1465  cref = pv[i]; //ponteiro para subelemento i
1466  fMesh->CreateCompEl(cref, sub[i]);
1467  // e' assumido que CreateCompEl inseri o elemento comp no vetor de elementos da malha
1468  }
1469  if (interpolatesolution) {
1470  Mesh()->ExpandSolution();
1471  for (i = 0; i < nsubelements; i++) {
1472  cel = dynamic_cast<TPZInterpolatedElement *> (fMesh->ElementVec()[sub[i]]);
1473  if (!cel) {
1474  LOGPZ_WARN(logger, "Divide interpolate cast error");
1475  continue;
1476  }
1478  cel->InterpolateSolution(*this);
1479  // e' assumido que CreateCompEl inseri o elemento comp no vetor de elementos da malha
1480  }
1481  }
1482  // we assume that the calling program will delete the element from
1483  // the data structure
1484  delete this; // deve ser relegado para o Refine
1485 }
1486 
1487 REAL TPZInterpolatedElement::CompareElement(int var, char *matname) {
1488  TPZMaterial * material = Material();
1489  if (!material) {
1490  PZError << "\nError at " << __PRETTY_FUNCTION__ << " - no material " << std::endl;
1491  LOGPZ_ERROR(logger, "InterpolateSolution no material");
1492  return 0.;
1493  }
1494  if (matname != material->Name()) return (0.);
1495  STATE error = 0.;
1496  int dim = Dimension();
1497  int numdof = material->NSolutionVariables(var);
1498 
1499  TPZFNMatrix<9> axes(3, 3, 0.);
1500  TPZFNMatrix<9> jacobian(dim, dim), jacinv(dim, dim);
1501 
1502  TPZManVector<STATE> sol(numdof, 0.), othersol(numdof, 0.);
1503  TPZVec<REAL> intpoint(dim, 0.);
1504  REAL weight = 0.;
1505  REAL detjac;
1506 
1507  // At this point we assume grids are identical
1508  TPZCompEl *otherelement = Reference()->Reference();
1509 
1510  const TPZIntPoints &intrule = GetIntegrationRule();
1511  TPZGeoEl *ref = Reference();
1512 
1513  for (int int_ind = 0; int_ind < intrule.NPoints(); ++int_ind) {
1514  intrule.Point(int_ind, intpoint, weight);
1515  this->Solution(intpoint, var, sol);
1516  otherelement->Solution(intpoint, var, othersol);
1517 
1518  ref->Jacobian(intpoint, jacobian, axes, detjac, jacinv);
1519  weight *= fabs(detjac);
1520 
1521  for (int i = 0; i < sol.NElements(); i++) {
1522  error += (sol[i] - othersol[i])*(sol[i] - othersol[i])*(STATE) weight;
1523  }
1524  }
1525  return fabs(error);
1526 }
1527 
1528 void TPZInterpolatedElement::Print(std::ostream &out) const {
1529  out << __PRETTY_FUNCTION__ << std::endl;
1531  out << "Index = " << fIndex;
1532  out << " - Center coordinate: ";
1533  for (int i = 0; i < Reference()->NCornerNodes(); i++) {
1534  TPZVec< REAL > center(3, 0.);
1535  for (int j = 0; j < 3; j++) center[j] = Reference()->NodePtr(i)->Coord(j);
1536  out << "[" << i << "]" << center << " ";
1537  }
1538  out << std::endl;
1539  int nconects = this->NConnects();
1540  out << "Number of connects = " << this->NConnects() << " Connect indexes/NShape : ";
1541  int nod;
1542  for (nod = 0; nod < nconects/*NConnects()*/; nod++) {
1543  TPZConnect &c = Connect(nod);
1544 #ifdef PZDEBUG
1545  if (c.NShape() != NConnectShapeF(nod, c.Order())) {
1546  DebugStop();
1547  }
1548 #endif
1549  out << ConnectIndex(nod) << '/' << c.NShape() << ' ';
1550  }
1551  out << endl;
1552  out << "Side orders = ";
1553  int NSides = Reference()->NSides();
1554  for (int is = 0; is < NSides; is++) {
1555  int nsconnect = NSideConnects(is);
1556  out << " side " << is << " orders ";
1557  for (int ic = 0; ic < nsconnect; ic++) {
1558  int sloc = SideConnectLocId(ic, is);
1559  int order = Connect(sloc).Order();
1560  out << order << " ";
1561  }
1562  out << std::endl;
1563  }
1564  // for (nod=0; nod< NConnects(); nod++) out << SideOrder(nod) << ' ';
1565  // out << endl;
1566  TPZMaterial * material = Material();
1567  if (!material) {
1568  out << " no material " << std::endl;
1569  }
1570 
1571  if (material) {
1572  out << "material id " << material->Id() << endl;
1573  }
1574  int id;
1575  const TPZIntPoints &intrule = GetIntegrationRule();
1576  int dim = Dimension();
1577 
1578  TPZManVector<int> prevorder(dim);
1579  intrule.GetOrder(prevorder);
1580 
1581  int norders = prevorder.NElements();
1582  out << "Integration orders : \t";
1583  for (id = 0; id < norders; id++) {
1584  out << prevorder[id] << "\t";
1585  }
1586 
1587  intrule.Print(out);
1588 
1589  out << endl;
1590 }
1591 
1593 #ifdef PZDEBUG
1594  auto elementGMesh = this->fMesh->Reference();
1595  auto referenceGMesh = this->Reference()->Mesh();
1596  if(elementGMesh != referenceGMesh){
1597  PZError<<__PRETTY_FUNCTION__;
1598  PZError<<"Computational mesh of this element seems not to be associated\n";
1599  PZError<<"with the same mesh as the one this element's reference belongs to.\n";
1600  PZError<<"You may want to call TPZGeoMesh::ResetReference()\n";
1601  PZError<<" and TPZCompMesh::LoadReferences() before PRefine\n";
1602  }
1603 
1604 #endif
1605  SetPreferredOrder(order);
1606 
1607 #ifdef LOG4CXX
1608  if (loggerdiv->isDebugEnabled()) {
1609  std::stringstream sout;
1610  sout << (void*) Mesh() << " PRefine elindex " << Index() << " gel index " << Reference()->Index() << " " << order;
1611  LOGPZ_DEBUG(loggerdiv, sout.str())
1612  }
1613 #endif
1614  TPZGeoEl *gel = Reference();
1615  int ns = gel->NSides();
1616  for (int is = 0; is < ns; is++) {
1617  IdentifySideOrder(is);
1618  }
1619 #ifdef LOG4CXX
1620  if (loggerdiv->isDebugEnabled()) {
1621  std::stringstream sout;
1622  sout << " PRefine connect orders ";
1623  int nc = NConnects();
1624  for(int ic=0; ic<nc; ic++) sout << (int)Connect(ic).Order() << " ";
1625  LOGPZ_DEBUG(loggerdiv, sout.str())
1626  }
1627 #endif
1628 }
1629 
1631  int dim = Dimension(), nvars;
1632  TPZMaterial * material = Material();
1633  if (!material) {
1634  cout << __PRETTY_FUNCTION__ << " no material " << std::endl;
1635  LOGPZ_ERROR(logger, "Meansolution no material");
1636  return 0.;
1637  }
1638 
1639  nvars = material->NSolutionVariables(var);
1640  if (nvars != 1) {
1641  LOGPZ_ERROR(logger, "Exiting MeanSolution: is not implemented to nvars != 1.");
1642  return 0.;
1643  }
1644  TPZManVector<STATE> sol(nvars, 0.);
1645 
1646  int i;
1647  TPZFMatrix<REAL> axes(3, 3, 0.);
1648  TPZFMatrix<REAL> jacobian(dim, dim);
1649  TPZFMatrix<REAL> jacinv(dim, dim);
1650  REAL detjac;
1651  TPZVec<REAL> intpoint(dim, 0.);
1652  REAL weight = 0.;
1653  REAL meanvalue = 0.;
1654  REAL area = 0.;
1655  TPZGeoEl *ref = Reference();
1656 
1657  for (i = 0; i < GetIntegrationRule().NPoints(); i++) {
1658  GetIntegrationRule().Point(i, intpoint, weight);
1659  ref->Jacobian(intpoint, jacobian, axes, detjac, jacinv);
1660 
1662  Solution(intpoint, var, sol);
1663  area += weight * fabs(detjac);
1664 #ifdef STATE_COMPLEX
1665  meanvalue += (weight * fabs(detjac)) * sol[0].real(); // meanvalue += (weight*fabs(detjac)*sol[j]);
1666 #else
1667  meanvalue += (weight * fabs(detjac)) * sol[0];
1668 #endif
1669  }
1670  return (meanvalue / area);
1671 }
1672 
1675  int i;
1676  TPZMaterial * material = Material();
1677  if (!material) {
1678  cout << __PRETTY_FUNCTION__ << " no material " << std::endl;
1679  LOGPZ_ERROR(logger, "CalcIntegral no material");
1680  ef.Reset();
1681  return;
1682  }
1683 
1684  int numdof = material->NStateVariables();
1685  int ncon = NConnects();
1686  int dim = Dimension();
1687  int nshape = NShapeF();
1688  TPZBlock<STATE> &block = Mesh()->Block();
1689  TPZFMatrix<STATE> &solution = Mesh()->Solution();
1690  int numloadcases = solution.Cols();
1691 
1692  int numeq = nshape*numdof;
1693  ef.fMat.Redim(numeq, numloadcases);
1694  ef.fBlock.SetNBlocks(ncon);
1695  TPZVec<STATE> sol(numdof, 0.);
1696  for (i = 0; i < ncon; i++) {
1697  TPZConnect &c = Connect(i);
1698  unsigned int nshape = c.NShape();
1699 #ifdef PZDEBUG
1700  if (NConnectShapeF(i, c.Order()) != nshape || c.NState() != numdof) {
1701  DebugStop();
1702  }
1703 #endif
1704  ef.fBlock.Set(i, nshape * numdof);
1705  }
1706  int in, jn;
1707  TPZConnect *df;
1708 
1709  ef.fConnect.Resize(ncon);
1710 
1711  for (i = 0; i < ncon; ++i)
1712  (ef.fConnect)[i] = ConnectIndex(i);
1713 
1714  TPZFMatrix<REAL> phi(nshape, 1);
1715  TPZFMatrix<REAL> dphi(dim, nshape);
1716  TPZFMatrix<REAL> dphix(dim, nshape);
1717  TPZFMatrix<REAL> axes(3, 3, 0.);
1718  TPZFMatrix<REAL> jacobian(dim, dim);
1719  TPZFMatrix<REAL> jacinv(dim, dim);
1720  REAL detjac;
1721  TPZVec<REAL> x(3, 0.);
1722  TPZVec<REAL> intpoint(dim, 0.);
1723  REAL weight = 0.;
1724  TPZGeoEl *ref = Reference();
1725 
1726  for (int int_ind = 0; int_ind < GetIntegrationRule().NPoints(); ++int_ind) {
1727  GetIntegrationRule().Point(int_ind, intpoint, weight);
1728  ref->Jacobian(intpoint, jacobian, axes, detjac, jacinv);
1729  ref->X(intpoint, x);
1730  weight *= fabs(detjac);
1731  Shape(intpoint, phi, dphi);
1732 
1733  int64_t l, iv = 0;
1734  STATE coef;
1735  for (int ist = 0; ist < numloadcases; ist++) {
1736  for (in = 0; in < numdof; in++) sol[in] = 0.;
1737  for (in = 0; in < ncon; in++) {
1738  df = &Connect(in);
1739  int64_t dfseq = df->SequenceNumber();
1740  int dfvar = block.Size(dfseq);
1741  for (jn = 0; jn < dfvar; jn++) {
1742  int64_t pos = block.Position(dfseq);
1743  coef = solution(pos + jn, ist);
1744  sol[iv % numdof] += (STATE) phi(iv / numdof, 0) * coef;
1745  iv++;
1746  }
1747  }
1748  for (in = 0; in < nshape; in++)
1749  for (l = 0; l < numdof; l++)
1750  (ef.fMat)(in * numdof + l, 0) += (STATE) weight * (STATE) phi(in, 0) * sol[l];
1751  }
1752  }
1753 }
1754 
1756  TPZGeoEl *gel = Reference();
1757  if (!gel) {
1758  LOGPZ_ERROR(logger, "Exiting AdjustPreferredSideOrder: null reference element.");
1759  return order;
1760  }
1761  int dim = gel->SideDimension(side);
1762  if (dim != 2 || ConnectIndex(MidSideConnectLocId(side)) == -1) {
1763  // std::stringstream sout;
1764  // sout << "Exiting AdjustPreferredSideOrder: dimension != 2 " << dim;
1765  // LOGPZ_ERROR(logger,sout.str().c_str());
1766  return order;
1767  }
1768  TPZGeoElSide gelside(gel, side);
1769  TPZStack<TPZCompElSide> celsidestack;
1770  gelside.HigherLevelCompElementList2(celsidestack, 1, 1);
1771  // if there are no smaller elements do nothing
1772  if (celsidestack.size() == 0) {
1773  return order;
1774  }
1775  TPZStack<int> elsides;
1776  gel->LowerDimensionSides(side, elsides);
1777  int maxorder = order;
1778  int nsides = elsides.NElements();
1779  int is;
1780  for (is = 0; is < nsides; is++) {
1781  TPZGeoElSide gelside(gel, elsides[is]);
1782  if (gelside.Dimension() != 1) continue;
1783  int s = elsides[is];
1784  int sorder = MidSideConnect(s).Order();
1785  maxorder = maxorder < sorder ? sorder : maxorder;
1786  }
1787  return maxorder;
1788 }
1789 
1790 
1791 #ifdef _AUTODIFF2
1792 
1794 void TPZInterpolatedElement::CalcEnergy(TPZElementMatrix &ek, TPZElementMatrix &ef) {
1795  int i;
1796 
1797  TPZMaterial * material = Material();
1798  if (!material) {
1799  cout << __PRETTY_FUNCTION__ << " no material " << std::endl;
1800  LOGPZ_ERROR(logger, "CalcEnergy no material");
1801  ef.Reset();
1802  return;
1803  }
1804 
1805  int numdof = material->NStateVariables();
1806  int ncon = NConnects();
1807  int dim = Dimension();
1808  int nshape = NShapeF();
1809  TPZBlock &block = Mesh()->Block();
1810  TPZFMatrix<REAL> &MeshSol = Mesh()->Solution();
1811  // clean ek and ef
1812 
1813  int numeq = nshape*numdof;
1814  ek.fMat.Redim(numeq, numeq);
1815  ef.fMat.Redim(numeq, 1);
1816  ek.fBlock.SetNBlocks(ncon);
1817  ef.fBlock.SetNBlocks(ncon);
1818 
1819  for (i = 0; i < ncon; i++) {
1820  int nshape = NConnectShapeF(i);
1821 #ifdef PZDEBUG
1822  TPZConnect &c = Connect(i);
1823  if (c.NShape() != nshape || c.NState() != numdof) {
1824  DebugStop();
1825  }
1826 #endif
1827  ek.fBlock.Set(i, nshape * numdof);
1828  ef.fBlock.Set(i, nshape * numdof);
1829  }
1830 
1831  ek.fConnect.Resize(ncon);
1832  ef.fConnect.Resize(ncon);
1833 
1834  for (i = 0; i < ncon; ++i) {
1835  (ef.fConnect)[i] = ConnectIndex(i);
1836  (ek.fConnect)[i] = ConnectIndex(i);
1837  }
1838  //suficiente para ordem 5 do cubo
1839  TPZFNMatrix<220> phi(nshape, 1);
1840  TPZFNMatrix<660> dphi(dim, nshape), dphix(dim, nshape);
1841  TPZFNMatrix<9> axes(3, 3, 0.);
1842  TPZFMatrix<9> jacobian(dim, dim);
1843  TPZFNMatrix<9> jacinv(dim, dim);
1844  REAL detjac;
1845  TPZManVector<REAL, 3> x(3, 0.);
1846  TPZManVector<REAL, 3> intpoint(dim, 0.);
1847  REAL weight = 0.;
1848 
1849  TPZVec<FADFADREAL> sol(numdof);
1850  TPZVec<FADFADREAL> dsol(numdof * dim); // x, y and z data aligned
1851 
1852  FADREAL defaultFAD(numeq, 0., 0.);
1853  if (defaultFAD.dx(0) == 1.) {
1854  LOGPZ_ERROR(logger, "FAD doesn't have default constructor for parameters: (number of derivatives, default value, default derivative value) !");
1855  return;
1856  }
1857  FADFADREAL defaultFADFAD(numeq, defaultFAD, defaultFAD);
1858 
1859  FADFADREAL U(defaultFADFAD); // Zeroed Energy Value -> ready for contribution
1860 
1861  TPZGeoEl *ref = Reference();
1862  TPZIntPoints &intrule = GetIntegrationRule();
1863  for (int int_ind = 0; int_ind < intrule.NPoints(); ++int_ind) {
1864 
1865  intrule.Point(int_ind, intpoint, weight);
1866  this->ComputeShape(intpoint, x, jacobian, axes, detjac, jacinv, phi, dphix);
1867  weight *= fabs(detjac);
1868 
1869  int64_t iv = 0, d;
1870 
1871  sol.Fill(defaultFADFAD);
1872  dsol.Fill(defaultFADFAD);
1873 
1874  for (int in = 0; in < ncon; in++) {
1875  TPZConnect *df = &Connect(in);
1876  int64_t dfseq = df->SequenceNumber();
1877  int dfvar = block.Size(dfseq);
1878  int64_t pos = block.Position(dfseq);
1879  for (int jn = 0; jn < dfvar; jn++) {
1880  /*FADFADREAL upos(numeq, iv, FADREAL(numeq, iv, MeshSol(pos+jn,0)));
1881 
1882  sol[iv%numdof] += upos * FADREAL(phi(iv/numdof,0));*/
1883  // Using direct access to the fad derivatives to enhance performance
1884 
1885  sol[iv % numdof].val().val() += MeshSol(pos + jn, 0) * phi(iv / numdof, 0);
1886  sol[iv % numdof].val().fastAccessDx(iv) += phi(iv / numdof, 0);
1887  sol[iv % numdof].fastAccessDx(iv).val() += phi(iv / numdof, 0);
1888  for (d = 0; d < dim; d++) {
1889  //dsol[d+(iv%numdof)*dim] += upos * FADREAL (dphix(d, iv/numdof));
1890  // Using direct access to the fad derivatives to enhance performance
1891 
1892  dsol[d + (iv % numdof) * dim].val().val() += MeshSol(pos + jn, 0) * dphix(d, iv / numdof);
1893  dsol[d + (iv % numdof) * dim].val().fastAccessDx(iv) += dphix(d, iv / numdof);
1894  dsol[d + (iv % numdof) * dim].fastAccessDx(iv).val() += dphix(d, iv / numdof);
1895  }
1896 
1897  iv++;
1898  }
1899  }
1900 
1901  material->ContributeEnergy(x, sol, dsol, U, weight);
1902  }
1903 
1904  FADToMatrix(U, ek.fMat, ef.fMat);
1905 }
1906 
1907 void TPZInterpolatedElement::FADToMatrix(FADFADREAL &U, TPZFMatrix<REAL> & ek, TPZFMatrix<REAL> & ef) {
1908  int64_t efsz = ef.Rows();
1909  int64_t ekrows = ek.Rows();
1910  int64_t ekcols = ek.Cols();
1911 
1912  int64_t Ucols = U.size();
1913  int64_t Urows = U.val().size();
1914 
1915  if (efsz != Urows) {
1916  LOGPZ_WARN(logger, "Energy Fad type and ef vectors are of different sizes");
1917  }
1918  if (ekrows != Urows || ekcols != Ucols) {
1919  LOGPZ_WARN(logger, "Energy Fad type and ek matrix are of different sizes");
1920  }
1921 
1922  FADREAL * pBufferFAD;
1923  int i, j;
1924  for (j = 0; j < Urows; j++) {
1925  pBufferFAD = &U.fastAccessDx(j);
1926  ef(j, 0) = -pBufferFAD->val();
1927  // U.val().fastAccessDx(i); must be the same as U.fastAccessDx(i).val();
1928  for (i = 0; i < Ucols; i++) {
1929  ek(i, j) = pBufferFAD->fastAccessDx(i);
1930  }
1931  }
1932 }
1933 #endif
1934 
1936  return Hash("TPZInterpolatedElement") ^ TPZInterpolationSpace::ClassId() << 1;
1937 }
1938 
1940 void TPZInterpolatedElement::Write(TPZStream &buf, int withclassid) const {
1941  TPZInterpolationSpace::Write(buf, withclassid);
1942 }
1943 
1945 void TPZInterpolatedElement::Read(TPZStream &buf, void *context) {
1946  TPZInterpolationSpace::Read(buf, context);
1947 }
1948 
1950 
1951  // this->InitMaterialData(data);
1952  // this->ComputeShape(qsi, data);
1953  this->ComputeSolution(qsi, data.phi, data.dphix, data.axes, data.sol, data.dsol);
1954 }
1955 
1957  const int nshape = this->NShapeF();
1958  TPZGeoEl * ref = this->Reference();
1959  const int dim = ref->Dimension();
1960 
1961  TPZFNMatrix<220> phi(nshape, 1);
1962  TPZFNMatrix<660> dphi(dim, nshape), dphix(dim, nshape);
1963  TPZFNMatrix<9> jacobian(dim, dim);
1964  TPZFNMatrix<9> jacinv(dim, dim);
1965  REAL detjac;
1966 
1967  ref->Jacobian(qsi, jacobian, axes, detjac, jacinv);
1968 
1969  this->Shape(qsi, phi, dphi);
1970 
1971  int ieq;
1972  switch (dim) {
1973  case 0:
1974  break;
1975  case 1:
1976  dphix = dphi;
1977  dphix *= (1. / detjac);
1978  break;
1979  case 2:
1980  for (ieq = 0; ieq < nshape; ieq++) {
1981  dphix(0, ieq) = jacinv(0, 0) * dphi(0, ieq) + jacinv(1, 0) * dphi(1, ieq);
1982  dphix(1, ieq) = jacinv(0, 1) * dphi(0, ieq) + jacinv(1, 1) * dphi(1, ieq);
1983  }
1984  break;
1985  case 3:
1986  for (ieq = 0; ieq < nshape; ieq++) {
1987  dphix(0, ieq) = jacinv(0, 0) * dphi(0, ieq) + jacinv(1, 0) * dphi(1, ieq) + jacinv(2, 0) * dphi(2, ieq);
1988  dphix(1, ieq) = jacinv(0, 1) * dphi(0, ieq) + jacinv(1, 1) * dphi(1, ieq) + jacinv(2, 1) * dphi(2, ieq);
1989  dphix(2, ieq) = jacinv(0, 2) * dphi(0, ieq) + jacinv(1, 2) * dphi(1, ieq) + jacinv(2, 2) * dphi(2, ieq);
1990  }
1991  break;
1992  default:
1993  stringstream sout;
1994  sout << "pzintel.c please implement the " << dim << "d Jacobian and inverse\n";
1995  LOGPZ_ERROR(logger, sout.str());
1996  }
1997 
1998  this->ComputeSolution(qsi, phi, dphix, axes, sol, dsol);
1999 
2000 }//method
2001 
2003  const TPZFMatrix<REAL> &axes, TPZSolVec &sol, TPZGradSolVec &dsol) {
2004  const int dim = this->Reference()->Dimension();
2005  const int numdof = this->Material()->NStateVariables();
2006  const int ncon = this->NConnects();
2007  TPZFMatrix<STATE> &MeshSol = Mesh()->Solution();
2008  int64_t numbersol = MeshSol.Cols();
2009  sol.Resize(numbersol);
2010  dsol.Resize(numbersol);
2011 
2012  for (int64_t is = 0; is < numbersol; is++) {
2013  sol[is].Resize(numdof);
2014  sol[is].Fill(0.);
2015  dsol[is].Redim(dim, numdof);
2016  dsol[is].Zero();
2017 
2018  }
2019 
2020  TPZBlock<STATE> &block = Mesh()->Block();
2021  int64_t iv = 0, d;
2022  for (int in = 0; in < ncon; in++) {
2023  TPZConnect *df = &this->Connect(in);
2024  int64_t dfseq = df->SequenceNumber();
2025  int dfvar = block.Size(dfseq);
2026  int64_t pos = block.Position(dfseq);
2027  for (int jn = 0; jn < dfvar; jn++) {
2028  for (int is = 0; is < numbersol; is++) {
2029  sol[is][iv % numdof] += (STATE) phi(iv / numdof, 0) * MeshSol(pos + jn, is);
2030  for (d = 0; d < dim; d++) {
2031  dsol[is](d, iv % numdof) += (STATE) dphix(d, iv / numdof) * MeshSol(pos + jn, is);
2032  }
2033  }
2034  iv++;
2035  }
2036  }
2037 }//method
2038 
2040  TPZVec<REAL> &normal,
2041  TPZSolVec &leftsol, TPZGradSolVec &dleftsol, TPZFMatrix<REAL> &leftaxes,
2042  TPZSolVec &rightsol, TPZGradSolVec &drightsol, TPZFMatrix<REAL> &rightaxes) {
2043  leftsol.Resize(0);
2044  dleftsol.Resize(0);
2045  leftaxes.Zero();
2046  rightsol.Resize(0);
2047  drightsol.Resize(0);
2048  rightaxes.Zero();
2049  normal.Resize(0);
2050 }//method
2051 
2053 void TPZInterpolatedElement::BuildCornerConnectList(std::set<int64_t> &connectindexes) const {
2054  int ncorner = NCornerConnects();
2055  for (int ic = 0; ic < ncorner; ic++) {
2056  connectindexes.insert(ConnectIndex(ic));
2057  }
2058 }
2059 
2061 
2063  int midsideconnectlocindex = MidSideConnectLocId(side);
2064  // there is no connect associated with the side
2065  if (midsideconnectlocindex < 0) {
2066  return true;
2067  }
2068  TPZGeoEl *gelref = Reference();
2069  TPZGeoElSide gelside(gelref, side);
2070  TPZConnect &c = Connect(midsideconnectlocindex);
2071  TPZInterpolatedElement *largel = dynamic_cast<TPZInterpolatedElement *> (large.Element());
2072  if (!largel) {
2073  DebugStop();
2074  }
2075  int nsideconnectslarge = largel->NSideConnects(large.Side());
2077  int nonzerosides = 0;
2078  TPZConnect &largec = largel->MidSideConnect(large.Side());
2079  for (int ic = 0; ic < nsideconnectslarge; ic++) {
2080  TPZConnect &cl = largel->SideConnect(ic, large.Side());
2081  if (cl.NShape() != 0) {
2082  nonzerosides++;
2083  }
2084  }
2085  int largeorder = largel->EffectiveSideOrder(large.Side());
2086  if (gelside.Dimension() != 0 && c.Order() != largeorder) {
2087  return false;
2088  }
2089  // if we optimized the dependency list to exclude zero norm dependencies, then we will pay the price of recomputing every time
2090  int cnumdepend = c.NumDepend();
2091  if (cnumdepend != nonzerosides && c.NShape() != 0) {
2092  return false;
2093  }
2094  if (cnumdepend == 0 && c.NShape() != 0) {
2095  DebugStop();
2096  }
2097  int nshapeconnect = c.NShape();
2098  std::map<int64_t, int> largenshapeconnect;
2099  for (int ic = 0; ic < nsideconnectslarge; ic++) {
2100  TPZConnect &clarge = largel->SideConnect(ic, large.Side());
2101  int64_t clargeindex = largel->SideConnectIndex(ic, large.Side());
2102  largenshapeconnect[clargeindex] = clarge.NShape();
2103  }
2104  TPZConnect::TPZDepend *depend = c.FirstDepend();
2105  while (depend) {
2106  int nrow = depend->fDepMatrix.Rows();
2107  int ncol = depend->fDepMatrix.Cols();
2109  if (nrow != c.NShape()) {
2110  return false;
2111  }
2112 #ifdef PZDEBUG
2113  if (largenshapeconnect.find(depend->fDepConnectIndex) == largenshapeconnect.end()) {
2114  DebugStop();
2115  }
2116 #endif
2117  if (ncol != largenshapeconnect[depend->fDepConnectIndex]) {
2119  return false;
2120  }
2121  depend = depend->fNext;
2122  }
2123  return true;
2124 }
2125 
2128 }
void RecomputeRestraints(int side)
Will recompute the restraints of all connects which are restrained by this side.
Definition: pzintel.cpp:404
void UpdateNeighbourSideOrder(int side, TPZVec< TPZCompElSide > &elvec)
Updates the interpolation order of all neighbouring elements along side to have side order equal to t...
Definition: pzintel.cpp:432
void HigherLevelCompElementList2(TPZStack< TPZCompElSide > &elsidevec, int onlyinterpolated, int removeduplicates)
Returns all connected computational elements which have level higher to the current element if onlyi...
virtual void GetOrder(TPZVec< int > &ord) const =0
Gets the order of the integration rule for each dimension of the master element.
TPZGeoMesh * Reference() const
Returns a pointer to the geometrical mesh associated.
Definition: pzcmesh.h:209
virtual int ClassId() const override
Define the class id associated with the class.
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
virtual void SetConnectIndex(int i, int64_t connectindex) override=0
Sets the node pointer of node i to nod.
Contains the TPZInt1d, TPZIntTriang, TPZIntQuad, TPZIntCube3D, TPZIntTetra3D, TPZIntPyram3D and TPZIn...
int Position(const int block_diagonal) const
Returns the position of first element block dependent on matrix diagonal.
Definition: pzblock.h:177
Will verify the consistency of the restraints of shape functions along a side. Computational Element...
virtual int NPoints() const =0
Returns number of points for the cubature rule related.
void SetAllCreateFunctionsContinuous()
Definition: pzcmesh.h:508
virtual void LowerDimensionSides(int side, TPZStack< int > &smallsides) const =0
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
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
void CheckConstraintConsistency(int side)
Check the consistency of the constrained connects along a side.
Definition: pzintel.cpp:1215
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
Definition: pzconnect.h:30
TPZGeoNode * NodePtr(int i) const
Returns a pointer to the ith node of the element.
Definition: pzgeoel.cpp:2566
Definition: pzmatrix.h:52
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
virtual MElementType Type()
Return the type of the element.
Definition: pzcompel.cpp:195
virtual void RestrainSide(int side, TPZInterpolatedElement *neighbour, int neighbourside)
Compute the shapefunction restraints which need to be applied to the shape functions on the side of t...
Definition: pzintel.cpp:849
virtual int Dimension() const override=0
Returns the dimension of the element.
int MaterialId() const
Returns the material index of the element.
Definition: pzgeoel.h:250
void SetBlockMatrix(int row, int col, TPZFMatrix< TVar > &mat)
Sets the row,col block equal to matrix mat if row col was not specified by AddBlockNumbers, an error will be issued and exit.
Definition: pztransfer.cpp:153
void Write(TPZStream &buf, int withclassid) const override
Saves the element data to a stream.
Definition: pzintel.cpp:1940
Contains declaration of TPZCheckRestraint class which verify the consistency of the restraints of sha...
virtual void BuildConnectList(std::set< int64_t > &indepconnectlist, std::set< int64_t > &depconnectlist)
Builds the list of all connectivities related to the element including the connects pointed to by dep...
Definition: pzcompel.cpp:435
void Print(std::ostream &out)
Prints the information into the computational elements and side and geometric information also...
REAL Coord(int i) const
Returns i-th coordinate of the current node.
Definition: pzgnode.h:99
virtual int NConnectShapeF(int icon, int order) const =0
Returns the number of shapefunctions associated with a connect.
clarg::argInt dimension("-d", "Matrices dimension M x M", 1000)
TPZStack< int64_t > fConnect
Vector of pointers to TPZConnect objects.
Definition: pzelmat.h:39
virtual int64_t AllocateNewConnect(int nshape, int nstate, int order)
Returns an index to a new connect.
Definition: pzcmesh.h:693
REAL MeanSolution(int var)
Returns total mass contained into the element.
Definition: pzintel.cpp:1630
void AddBlockNumbers(int row, TPZVec< int > &colnumbers)
Will specify the sparsity pattern of row.
Definition: pztransfer.cpp:121
int CheckConnectOrderConsistency()
This method will verify whether the fSiderOrder data structure is in sink with the Order of the Conne...
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
Definition: test.py:1
Defines step solvers class. Solver.
Definition: pzmganalysis.h:17
const TPZFMatrix< T > & Mult() const
Definition: pztrnsform.h:64
virtual int NCornerNodes() const =0
Returns the number of corner nodes of the element.
int AdjustPreferredSideOrder(int side, int order)
Adjusts the preferredSideOrder for faces.
Definition: pzintel.cpp:1755
void Diagnose()
Get the small element and check restraints with all elements with lower dimension on side correspondi...
virtual void Print(std::ostream &out=std::cout) const override
Prints the relevant data of the element to the output stream.
Definition: pzintel.cpp:1528
TPZDepend * AddDependency(int64_t myindex, int64_t dependindex, TPZFMatrix< REAL > &depmat, int64_t ipos, int64_t jpos, int isize, int jsize)
Add dependency between connects.
Definition: pzconnect.cpp:130
virtual void RemoveSideRestraintsII(MInsertMode mode)
Delete the restraints on the nodes of the connected elements if necessary.
Definition: pzintel.cpp:1286
virtual int NStateVariables() const =0
Returns the number of state variables associated with the material.
TPZGradSolVec dsol
vector of the derivatives of the solution at the integration point
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Definition: pzgeoelside.h:83
REAL val(STATE &number)
Returns value of the variable.
Definition: pzartdiff.h:23
#define LOGPZ_WARN(A, B)
Define log for warnings.
Definition: pzlog.h:91
virtual int64_t CreateMidSideConnect(int side)
Verify the neighbours of the element and create a node along this side.
Definition: pzintel.cpp:654
TPZGeoMesh * Mesh() const
Returns the mesh to which the element belongs.
Definition: pzgeoel.h:220
virtual int NSides() const =0
Returns the number of connectivities of the element.
virtual const TPZIntPoints & GetIntegrationRule() const override=0
Returns a reference to an integration rule suitable for integrating the interior of the element...
TPZBlock< STATE > fBlock
Block structure associated with fMat.
Definition: pzelmat.h:43
virtual void Divide(TPZVec< TPZGeoEl *> &pv)
Divides the element and puts the resulting elements in the vector.
Definition: pzgeoel.h:742
virtual void ComputeSolution(TPZVec< REAL > &qsi, TPZSolVec &sol, TPZGradSolVec &dsol, TPZFMatrix< REAL > &axes) override
Computes solution and its derivatives in the local coordinate qsi.
Definition: pzintel.cpp:1956
virtual void BuildCornerConnectList(std::set< int64_t > &connectindexes) const override
adds the connect indexes associated with base shape functions to the set
Definition: pzintel.cpp:2053
virtual void Print(std::ostream &out) const
Prints information of the cubature rule.
Definition: pzquad.cpp:38
Contains TPZBlockDiagonal class which defines block diagonal matrices.
virtual int SideDimension(int side) const =0
Return the dimension of side.
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
virtual void ForceSideOrder(int side, int order)
Impose an interpolation order on a given side (without using computesideorder)
Definition: pzintel.cpp:114
Contains the TPZTransfer class which implements a rectangular sparse block matrix.
virtual void Read(TPZStream &buf, void *context) override
Reads the element data from a stream.
TPZFNMatrix< 220, REAL > phi
vector of shapefunctions (format is dependent on the value of shapetype)
virtual int GetSub(const int64_t sRow, const int64_t sCol, const int64_t rowSize, const int64_t colSize, TPZFMatrix< TVar > &Target) const
Gets submatrix storing it on Target.
Definition: pzmatrix.cpp:602
int NShapeF() const override
Returns the total number of shapefunctions.
Definition: pzintel.cpp:63
void Read(TPZStream &buf, void *context) override
Reads the element data from a stream.
Definition: pzintel.cpp:1945
TPZConnect & SideConnect(int icon, int is)
Returns a pointer to the icon th connect object along side is.
Definition: pzintel.cpp:105
void SetDefaultOrder(int order)
Definition: pzcmesh.h:403
TPZFNMatrix< 660, REAL > dphix
values of the derivative of the shape functions
void CalcIntegral(TPZElementMatrix &ef)
Computes the integral over the finite element.
Definition: pzintel.cpp:1674
virtual void SideShapeFunction(int side, TPZVec< REAL > &point, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi) override=0
Compute the values of the shape function along the side.
Abstract class defining integration rules. Numerical Integration.
Definition: tpzintpoints.h:19
void error(char *string)
Definition: testShape.cc:7
virtual void IdentifySideOrder(int side)
Checks if the side order is consistent with the preferred side order and with the constraints and rec...
Definition: pzintel.cpp:216
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 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 void Shape(TPZVec< REAL > &qsi, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphidxi)=0
Computes the shape function set at the point x.
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
unsigned char LagrangeMultiplier() const
Access method to return the indication whether the connect is associated with a pressure lagrange mul...
Definition: pzconnect.h:230
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
virtual ~TPZInterpolatedElement()
Destructor, does nothing.
Definition: pzintel.cpp:60
int NumDepend() const
size of the dependency list
Definition: pzconnect.cpp:201
TPZCompEl * CreateCompEl(TPZGeoEl *gel, int64_t &index)
Create a computational element based on the geometric element.
Definition: pzcmesh.h:462
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 GetInterpolationOrder(TPZVec< int > &ord)=0
Identifies the interpolation order of all connects of the element different from the corner connects...
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 CheckConstraintConsistency()
Check the consistency of the constrained connects for all sides.
Definition: pzintel.cpp:1087
unsigned char Order() const
Access function to return the order associated with the connect.
Definition: pzconnect.h:217
int64_t SequenceNumber() const
Returns the Sequence number of the connect object.
Definition: pzconnect.h:158
static const double tol
Definition: pzgeoprism.cpp:23
void Push(const T object)
Pushes a copy of the object on the stack.
Definition: pzstack.h:80
void RemoveInterfaces()
Remove interfaces connected to this element.
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
#define LOGPZ_INFO(A, B)
Define log for informations.
Definition: pzlog.h:89
int64_t fDepConnectIndex
Definition: pzconnect.h:69
virtual void ComputeShape(TPZVec< REAL > &intpoint, TPZVec< REAL > &X, TPZFMatrix< REAL > &jacobian, TPZFMatrix< REAL > &axes, REAL &detjac, TPZFMatrix< REAL > &jacinv, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi, TPZFMatrix< REAL > &dphidx)
Compute shape functions based on master element in the classical FEM manner.
int HasRowDefinition(int row)
Returns 1 if the row is defined (i.e. has column entries)
Definition: pztransfer.cpp:114
Structure to reference dependency.
Definition: pzconnect.h:67
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
int64_t Index() const
Returns the index of the element within the element vector of the mesh.
Definition: pzgeoel.h:730
TVar Norm(const TPZFMatrix< TVar > &A)
Returns the norm of the matrix A.
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
void Divide(int64_t index, TPZVec< int64_t > &sub, int interpolatesolution=0) override
Implement the refinement of an interpolated element.
Definition: pzintel.cpp:1396
virtual void SetOrder(TPZVec< int > &ord, int type=0)=0
Sets the order of the cubature rule.
int CheckRestraint()
Gets the shape functions over the sides of the small and large elements and check the matrix restrain...
void SetAllCreateFunctions(TPZCompEl &cel)
Definition: pzcmesh.h:537
virtual int SideConnectLocId(int icon, int is) const override=0
Returns the local node number of icon along is.
virtual TPZConnect & MidSideConnect(int is) const
Returns a reference to the connect in the middle of the side.
Definition: pzintel.cpp:94
virtual void ExpandSolution()
Adapt the solution vector to new block dimensions.
Definition: pzcmesh.cpp:396
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
Definition: pzlog.h:87
TPZCompMesh * Mesh() const
Return a pointer to the grid of the element.
Definition: pzcompel.cpp:288
Free store vector implementation.
Definition: pzmatrix.h:52
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
TPZCompEl * Reference() const
Return a pointer to the element referenced by the geometric element.
Definition: pzgeoel.h:750
unsigned int NShape() const
Definition: pzconnect.h:151
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
int CompareShapeF(int sides, int sidel, TPZFMatrix< REAL > &phis, TPZFMatrix< REAL > &dphis, TPZFMatrix< REAL > &phil, TPZFMatrix< REAL > &dphil, TPZTransform<> &transform)
Compare the shape functions of sides of an element.
Definition: pzintel.cpp:1167
void SetNShape(int nshape)
Set the number of shape functions associated with the connect.
Definition: pzconnect.h:205
int HasDependency() const
Returns whether exist dependecy information.
Definition: pzconnect.h:292
bool VerifyConstraintConsistency(int side, TPZCompElSide large) const
return true if the connects associated with the side have dependency with large and if the dependency...
Definition: pzintel.cpp:2062
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
Definition: tfadfunc.h:120
TPZFNMatrix< 9, REAL > axes
axes indicating the directions of the derivatives of the shapefunctions
string res
Definition: test.py:151
const TPZBlock< STATE > & Block() const
Access the block structure of the solution vector.
Definition: pzcmesh.h:213
virtual void Solution(TPZVec< REAL > &qsi, int var, TPZVec< STATE > &sol) override
Post processing method which computes the solution for the var post processed variable.
Contains declaration of TPZCheckMesh class which verifies the consistency of the datastructure of a T...
int Exists() const
Verifies if the object is non null (initialized)
Definition: pzcompel.h:697
TPZDepend * fNext
Definition: pzconnect.h:71
Contains declaration of TPZCompelDisc class which implements a computational element for discontinuou...
expr_ expr_ fastAccessDx(i) *cos(expr_.val())) FAD_FUNC_MACRO(TFadFuncTan
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
Contains the TPZMaterialData class which implements an interface between TPZCompEl::CalcStiff and TPZ...
virtual int NConnects() const override=0
Returns the number of connect objects of the element.
virtual int PreferredSideOrder(int iside)=0
Returns the preferred order of the polynomial along side iside.
#define LOGPZ_ERROR(A, B)
Define log for errors (cout)
Definition: pzlog.h:93
int SetNBlocks(const int num_of_blocks)
Sets number of blocks on diagonal matrix.
Definition: pzblock.cpp:91
virtual void SetCreateFunctions(TPZCompMesh *mesh) override
Set create function in TPZCompMesh to create elements of this type.
Definition: pzintel.cpp:2126
Contains declaration of TPZCompMesh class which is a repository for computational elements...
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
void InterpolateSolution(TPZInterpolationSpace &coarsel)
Interpolates the solution into the degrees of freedom nodes from the degrees of freedom nodes from th...
virtual int CheckElementConsistency()
Checks element data structure consistancy.
Definition: pzintel.cpp:1093
unsigned char NState() const
Number of state variables associated with the connect.
Definition: pzconnect.h:146
virtual void BuildTransferMatrix(TPZInterpolatedElement &coarsel, TPZTransform<> &t, TPZTransfer< STATE > &transfer)
Accumulates the transfer coefficients between the current element and the coarse element into the tra...
Definition: pzintel.cpp:447
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.
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 EffectiveSideOrder(int side) const =0
Returns the actual interpolation order of the polynomial along the side.
TPZGeoEl * Element() const
Definition: pzgeoelside.h:162
TPZFNMatrix< 50, REAL > fDepMatrix
Definition: pzconnect.h:70
virtual int NCornerConnects() const =0
Returns the number of corner connects of the element.
MInsertMode
Defines a flag indicating the state of creation/deletion of the element This has an impact on how con...
Definition: pzintel.h:331
virtual void Write(TPZStream &buf, int withclassid) const override
Saves the element data to a stream.
int NSideShapeF(int side) const
Returns the number of shape functions on a side.
Definition: pzintel.cpp:73
virtual void SetPreferredOrder(int order) override=0
Sets the preferred interpolation order along a side.
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
Contains the TPZMat1dLin class which implements a one-dimensional linear problem. ...
virtual void AllHigherDimensionSides(int side, int targetdimension, TPZStack< TPZGeoElSide > &elsides)=0
TPZGeoEl * Reference() const
Return a pointer to the corresponding geometric element if such exists, return 0 otherwise.
Definition: pzcompel.cpp:1137
virtual int NSolutionVariables(int var)
Returns the number of variables associated with the variable indexed by var.
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...
Implements block matrices. Matrix utility.
void ExpandShapeFunctions(TPZVec< int64_t > &connectlist, TPZVec< int > &dependencyorder, TPZVec< int > &blocksizes, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi)
Auxiliary method to expand a vector of shapefunctions and their derivatives to acount for constraints...
virtual int NSideConnects(int iside) const override=0
Returns the number of dof nodes along side iside.
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
int64_t SideConnectIndex(int icon, int is) const
Returns the index of the c th connect object along side is.
Definition: pzintel.cpp:101
void Reset(TPZCompMesh *mesh=NULL, MType type=Unknown)
Reset the data structure.
Definition: pzelmat.h:59
TPZDepend * FirstDepend()
Definition: pzconnect.h:296
virtual std::string Name()
Returns the name of the material.
Definition: TPZMaterial.h:165
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
static void BuildDependencyOrder(TPZVec< int64_t > &connectlist, TPZVec< int > &DependenceOrder, TPZCompMesh &mesh)
This method builds the vector DependenceOrder which indicates in which order constrained nodes need t...
Definition: pzconnect.cpp:556
int Size(const int block_diagonal) const
Returns block dimension.
Definition: pzblock.h:171
virtual void RemoveSideRestraintWithRespectTo(int side, const TPZCompElSide &neighbour)
Removes the side restraints of the current element along side with respect to neighbour/side.
Definition: pzintel.cpp:1253
TPZAdmChunkVector< TPZCompEl * > & ElementVec()
Returns a reference to the element pointers vector.
Definition: pzcmesh.h:183
Contains TPZSolver class which defines a abstract class of solvers which will be used by matrix class...
static int sidedimension[27]
Vector of the dimension for each side.
Definition: tpzcube.cpp:100
void PRefine(int order) override
Changes the interpolation order of a side. Updates all constraints and block sizes ...
Definition: pzintel.cpp:1592
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 declaration of TPZInterpolatedElement class which implements computational element of the in...
virtual REAL CompareElement(int var, char *matname) override
Compare the L2 norm of the difference between the švarš solution of the current element with the švar...
Definition: pzintel.cpp:1487
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.
int Side() const
Returns the side index.
Definition: pzcompel.h:688
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
void RemoveDepend(int64_t myindex, int64_t dependindex)
Remove dependency between connects if exist.
Definition: pzconnect.cpp:178
virtual void Print(std::ostream &out) const
Definition: pzmatrix.h:253
Contains the TPZTransform<> class which implements an affine transformation between points in paramet...
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
int NeighbourExists(const TPZGeoElSide &neighbour) const
Returns 1 if neighbour is a neighbour of the element along side.
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
Implements an affine transformation between points in parameter space. Topology Utility.
Definition: pzmganalysis.h:14
virtual TPZIntPoints * Clone() const =0
Make a clone of the related cubature rule.
Implements rectangular matrix which extends a solution vector of the coarse mesh to a solution vector...
Definition: pzcmesh.h:33
int ClassId() const override
Define the class id associated with the class.
Definition: pzintel.cpp:1935
void Print(const TPZCompMesh &mesh, std::ostream &out=std::cout)
Print the information for the connect element.
Definition: pzconnect.cpp:67
TPZFMatrix< REAL > & RestraintMatrix()
Returns the restraint matrix.
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
TPZSolVec sol
vector of the solutions at the integration point
virtual int NSubElements() const =0
Returns the number of subelements of the element independent of the fact whether the element has alr...
int GetDefaultOrder()
Definition: pzcmesh.h:398
virtual int HasDependency()
Returns 1 if the element has at least one dependent node. Returns 0 otherwise.
Definition: pzcompel.cpp:565
int64_t fIndex
Element index into mesh element vector.
Definition: pzcompel.h:67
TPZFMatrix< STATE > & Solution()
Access the solution vector.
Definition: pzcmesh.h:219
void Apply(TPZVec< T > &vectorin, TPZVec< T > &vectorout)
Transforms the vector.
Definition: pztrnsform.cpp:121
virtual void SetSideOrder(int side, int order)=0
Sets the interpolation order of side to order.
Implements computational element based on an interpolation space. Computational Element.
Definition: pzintel.h:27
virtual int SolveDirect(TPZFMatrix< TVar > &F, const DecomposeType dt, std::list< int64_t > &singular)
Solves the linear system using Direct methods.
Definition: pzmatrix.cpp:710
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
Definition: pzfmatrix.h:716
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
int Resequence(const int start=0)
Resequences blocks positioning.
Definition: pzblock.cpp:150
TPZCompMesh * fMesh
Computational mesh to which the element belongs.
Definition: pzcompel.h:64
static int ComputeSideOrder(TPZVec< TPZCompElSide > &elementset)
Computes the minimum interpolation order of the elements contained in elementset this method is used ...
Definition: pzintel.cpp:1371
virtual void Print(std::ostream &out=std::cout) const override
Prints the relevant data of the element to the output stream.
virtual int MidSideConnectLocId(int is) const
Returns the local id of the connect in the middle of the side.
Definition: pzintel.cpp:83
This class verifies the consistency of the datastructure of a TPZCompMesh object. Computational Mesh...
Definition: pzcheckmesh.h:20