NeoPZ
CedricTest.cpp
Go to the documentation of this file.
1 #include "pzshapelinear.h"
2 
3 #include "pzgengrid.h"
5 #include "TPZVTKGeoMesh.h"
6 
7 #include "pzbstrmatrix.h"
8 #include "pzintel.h"
9 #include "pzcompel.h"
10 #include "pzcheckmesh.h"
11 
12 #include "TPZMaterial.h"
13 #include "pzbndcond.h"
14 #include "pzelasmat.h"
15 #include "pzpoisson3d.h"
16 
17 #include "pzanalysis.h"
18 #include "pzstepsolver.h"
19 
20 #include "CedricTest.h"
21 
22 #include "TPZRefPatternTools.h"
23 
26 
27 #include "pzelementgroup.h"
28 #include "pzcondensedcompel.h"
29 #include "arglib.h"
30 
31 #include <stdio.h>
32 
33 #include "pzlog.h"
34 
35 #include "pzgeoelbc.h"
36 
38 #ifdef LOG4CXX
39 static LoggerPtr logger(Logger::getLogger("pz.Cedric"));
40 #endif
41 
42 #define DEFORM
43 
45 
47 {
48  REAL coord[8][3] = {
49 // {0,0,0},
50 // {1,0,0},
51 // {1,1,0},
52 // {0,1,0},
53 // {0,0,1},
54 // {1,0,1},
55 // {1,1,1},
56 // {0,1,1}
57  {-0.5,-0.5,-0.5},
58  {2,-1,-1},
59  {1.1,1.1,-0.1},
60  {-1,2,-1},
61  {-1,-1,2},
62  {1.2,-0.2,1.2},
63  {2,2,2},
64  {-0.5,1.5,1.5}
65  };
67  TPZManVector<int64_t,8> indices(8);
68  for (int i=0; i<8; i++) {
69  indices[i] = i;
70  for (int c=0; c<3; c++) {
71  fDeformed.NodeVec()[i].SetCoord(c, coord[i][c]);
72  }
73  }
74  int64_t index;
75  fDeformed.CreateGeoElement(ECube, indices, 1, index);
76 }
77 
80 {
81  int64_t nnodes = gmesh.NodeVec().NElements();
82  TPZManVector<REAL,3> xbefore(3),xafter(3);
83  for (int64_t nod=0; nod<nnodes; nod++) {
84  gmesh.NodeVec()[nod].GetCoordinates(xbefore);
85  for (int i=0; i<3; i++) {
86  xbefore[i] = 2.*xbefore[i]-1.;
87  }
88  fDeformed.ElementVec()[0]->X(xbefore, xafter);
89  gmesh.NodeVec()[nod].SetCoord(xafter);
90  }
91 }
92 void TCedricTest::InterpolationError(int nsubdivisions,int geocase, int MaterialId,std::ostream &out)
93 {
94 
95  TPZGeoMesh *gmesh;
96  switch(geocase) {
97  case 1:
98  gmesh = HexahedralMesh(nsubdivisions,MaterialId);
99  break;
100  case 2:
101  gmesh = PyramidalAndTetrahedralMesh(nsubdivisions,MaterialId);
102  break;
103  case 3:
104  gmesh = TetrahedralMesh(nsubdivisions,MaterialId);
105  break;
106  case 4:
107  gmesh = TetrahedralMeshUsingRefinement(nsubdivisions,MaterialId);
108  break;
109  }
110 
111 #ifdef DEFORM
112  DeformGMesh(*gmesh);
113  out << "Deformed ";
114 #else
115  CheckConsistency(gmesh);
116  out << "Regular ";
117 #endif
118 
119 #ifdef LOG4CXX
120  if (logger->isDebugEnabled())
121  {
122  std::stringstream sout;
123  gmesh->Print(sout);
124  LOGPZ_DEBUG(logger, sout.str())
125  }
126 #endif
127  int nelembc = AddBoundaryElements(gmesh);
128 
130 
133  TPZCompMesh *cmesh = GenerateCompMesh(gmesh);
134  if(!cmesh) {
135  if(gmesh) {
136  delete gmesh;
137  gmesh = NULL;
138  }
139  out << "Interp_err nsubdivision " << nsubdivisions << " eltype " << geocase << " aborted\n";;
140  return;
141  }
142 
143  //int dim = cmesh->Dimension();
144 
145  TPZAnalysis analysis(cmesh);
146 
147  out << "Interp_err nsubdivision " << nsubdivisions << " nelem " << (cmesh->NElements()-nelembc) << " eltype ";
148 
149  LoadInterpolation(cmesh);
150 
151  switch(geocase) {
152  case 1:
153  out << "Hexahedra ";
154  break;
155  case 2:
156  out << " Pyramid ";
157  break;
158  case 4:
159  out << " Tetraedra ";
160  break;
161  case 3:
162  out << " TetraedraRef ";
163  break;
164  default:
165  out << "Undefined ";
166  break;
167  }
168 
169  out << "POrder " << 1 << " Neq " << cmesh->NEquations() ;
170  analysis.SetExact(Exact);
171  TPZManVector<REAL> errvec;
172 
173  analysis.Solution() = cmesh->Solution();
174 
175  analysis.PostProcessError(errvec,std::cout);
176 
177  // printing error
178  out << " ErrH1 " << errvec[0] << " ErrL2 " << errvec[1] << " ErrH1Semi " << errvec[2];
179 
180  // printing error
181 
182  out << std::endl;
183 
184 
185  int64_t nelem = cmesh->NElements();
186  for (int64_t el=0; el<nelem; el++) {
187  TPZCompEl *cel = cmesh->ElementVec()[el];
188  TPZMaterial *mat = cel->Material();
189  TPZBndCond *bc = dynamic_cast<TPZBndCond *>(mat);
190  if (!bc) {
191  continue;
192  }
193  TPZGeoEl *gel = cel->Reference();
194  int ncorner = gel->NCornerNodes();
195  for (int ic=0; ic<ncorner; ic++) {
196  TPZConnect &c = cmesh->ConnectVec()[ic];
197  int64_t seqnum = c.SequenceNumber();
198  STATE val = cmesh->Block()(seqnum,0,0,0);
199  if (fabs(val) > 1.e-6) {
201  gel->NodePtr(ic)->GetCoordinates(x);
202  std::cout << "Coordinate " << x << " solution " << val << std::endl;
203  }
204  }
205  }
206 
207 
209  if(cmesh) {
210  delete cmesh;
211  cmesh = NULL;
212  }
213  if(gmesh) {
214  delete gmesh;
215  gmesh = NULL;
216  }
217 
218 
219 }
221 {
222  cmesh->Solution().Zero();
223  TPZGeoMesh *gmesh = cmesh->Reference();
224  TPZManVector<REAL,3> value(1);
225  TPZFNMatrix<3,REAL> deriv(3,1);
226  int64_t nel = gmesh->NElements();
227  for (int64_t el=0; el<nel; el++) {
228  TPZGeoEl *gel = gmesh->ElementVec()[el];
229  TPZCompEl *cel = gel->Reference();
231  int ncorner = gel->NCornerNodes();
232  for (int ic=0; ic<ncorner; ic++) {
233  gel->NodePtr(ic)->GetCoordinates(x);
234  Exact(x, value, deriv);
235  TPZConnect &c = cel->Connect(ic);
236  int64_t seqnum = c.SequenceNumber();
237  cmesh->Block()(seqnum,0,0,0) = value[0];
238  }
239  }
240 }
241 
242 #define CONDENSE
243 
244 clarg::argInt nthreads ("-nt", "Number of threads.", 8);
245 
246 void TCedricTest::Run(int nsubdivisions,int geocase,int POrder,int MaterialId,std::ostream &out) {
247  TPZGeoMesh *gmesh;
248  switch(geocase) {
249  case 1:
250  gmesh = HexahedralMesh(nsubdivisions,MaterialId);
251  break;
252  case 2:
253  gmesh = PyramidalAndTetrahedralMesh(nsubdivisions,MaterialId);
254  break;
255  case 3:
256  gmesh = TetrahedralMesh(nsubdivisions,MaterialId);
257  break;
258  case 4:
259  gmesh = TetrahedralMeshUsingRefinement(nsubdivisions,MaterialId);
260  break;
261  }
262 #ifdef DEFORM
263  out << "Deformed ";
264  DeformGMesh(*gmesh);
265 #else
266  out << "Regular ";
267  CheckConsistency(gmesh);
268 #endif
269 
270 #ifdef LOG4CXX
271  if (logger->isDebugEnabled())
272  {
273  std::stringstream sout;
274  gmesh->Print(sout);
275  LOGPZ_DEBUG(logger, sout.str())
276  }
277 #endif
278  int nelembc = AddBoundaryElements(gmesh);
279 
282  TPZCompMesh *cmesh = GenerateCompMesh(gmesh);
283  if(!cmesh) {
284  if(gmesh) {
285  delete gmesh;
286  gmesh = NULL;
287  }
288  out << "Approx_err nsubdivision " << nsubdivisions << " eltype " << geocase << " aborted\n";;
289  return;
290  }
291 
292 #ifdef CONDENSE
294 #endif
295 
296  int dim = cmesh->Dimension();
297 
298  TPZAnalysis analysis(cmesh);
299 
300 #ifdef LOG4CXX
301  if (logger->isDebugEnabled())
302  {
303  std::stringstream sout;
304  cmesh->Print(sout);
305  LOGPZ_DEBUG(logger, sout.str())
306  }
307 #endif
308 
309  out << "Approx_err nsubdivision " << nsubdivisions << " nelem " << (cmesh->NElements()-nelembc) << " eltype ";
310  switch(geocase) {
311  case 1:
312  out << "Hexahedra ";
313  break;
314  case 2:
315  out << " Pyramid ";
316  break;
317  case 4:
318  out << " Tetraedra ";
319  break;
320  case 3:
321  out << " TetraedraRef ";
322  break;
323  default:
324  out << "Undefined ";
325  break;
326  }
327 
328  out << "POrder " << POrder << " Neq " << cmesh->NEquations() ;
329  analysis.SetExact(Exact);
330  TPZManVector<REAL> errvec;
331 
332 // TPZSkylineStructMatrix skylstr(cmesh);
334  skylstr.SetNumThreads(nthreads.get_value());
335  analysis.SetStructuralMatrix(skylstr);
337  step.SetDirect(ECholesky);
338  analysis.SetSolver(step);
339 
340  // To post process
342  TPZStack<std::string> scalnames, vecnames;
343  scalnames.Push("Solution");
344 
345  std::stringstream sout;
346  sout << std::setprecision(2) << "Laplace_P" << POrder << "_MESH" << geocase << "_Div" << nsubdivisions << ".vtk";
347  analysis.DefineGraphMesh(dim,scalnames,vecnames,sout.str());
348 
349  analysis.Run();
350 
351  static int printsol = 0;
352 // if(printsol == 4)
353  // analysis.PostProcess(3,dim);
354 // else
355  analysis.PostProcess(0,dim);
356  printsol++;
357 
358 #ifdef CONDENSE
359  UnwrapElements(cmesh);
360 #endif
361 
362  analysis.PostProcessError(errvec,std::cout);
363 
364  out << " ErrH1 " << errvec[0] << " ErrL2 " << errvec[1] << " ErrH1Semi " << errvec[2];
365 
366  // printing error
367 
368  out << std::endl;
369 
371  if(cmesh) {
372  delete cmesh;
373  cmesh = NULL;
374  }
375  if(gmesh) {
376  delete gmesh;
377  gmesh = NULL;
378  }
379 }
380 
381 
382 class ForceFunction : public TPZFunction<STATE>
383 {
385  {
386  val[0] = 0.;
387  for (int i=0; i<3; i++) {
388  REAL vx = TCedricTest::fx(x[i], TCedricTest::fX0[i], TCedricTest::fEps[i]);
389  int j = (i+1)%3;
390  REAL vy = TCedricTest::fx(x[j], TCedricTest::fX0[j], TCedricTest::fEps[j]);
391  int k = (j+1)%3;
392  REAL vz = TCedricTest::d2fx(x[k], TCedricTest::fX0[k], TCedricTest::fEps[k]);
393  val[0] += vx*vy*vz;
394  }
395  }
396 
397  virtual void Execute(const TPZVec<REAL> &x, TPZVec<STATE> &val)
398  {
399  int i = 0;
400  REAL vx = TCedricTest::fx(x[i], TCedricTest::fX0[i], TCedricTest::fEps[i]);
401  int j = (i+1)%3;
402  REAL vy = TCedricTest::fx(x[j], TCedricTest::fX0[j], TCedricTest::fEps[j]);
403  int k = (j+1)%3;
404  REAL vz = TCedricTest::fx(x[k], TCedricTest::fX0[k], TCedricTest::fEps[k]);
405  val[0] = vx*vy*vz;
406 
407  }
408  virtual int NFunctions()
409  {
410  return 1;
411  }
412 
413  virtual int PolynomialOrder()
414  {
415  return 5;
416  }
417 
418 };
419 
420 static int pyramid[2][5]=
421 {
422  {0,1,2,3,4},
423  {4,5,6,7,2}
424 };
425 static int tetraedra[2][4]=
426 {
427  {1,2,5,4},
428  {4,7,3,2}
429 };
430 static int tetraedra_2[6][4]=
431 {
432  {1,2,5,4},
433  {4,7,3,2},
434  {0,1,2,4},
435  {0,2,3,4},
436  {4,5,6,2},
437  {4,6,7,2}
438 };
439 
440 
441 void TCedricTest::GenerateNodes(TPZGeoMesh *gmesh, int64_t nelem)
442 {
443  gmesh->NodeVec().Resize((nelem+1)*(nelem+1)*(nelem+1));
444  for (int64_t i=0; i<=nelem; i++) {
445  for (int64_t j=0; j<=nelem; j++) {
446  for (int64_t k=0; k<=nelem; k++) {
448  x[0] = k*1./nelem;
449  x[1] = j*1./nelem;
450  x[2] = i*1./nelem;
451  gmesh->NodeVec()[i*(nelem+1)*(nelem+1)+j*(nelem+1)+k].Initialize(x, *gmesh);
452  }
453  }
454  }
455 }
456 
458 {
459  TPZGeoMesh *gmesh = new TPZGeoMesh;
460  GenerateNodes(gmesh, nelem);
461 
462  for (int64_t i=0; i<nelem; i++) {
463  for (int64_t j=0; j<nelem; j++) {
464  for (int64_t k=0; k<nelem; k++) {
465  TPZManVector<int64_t,8> nodes(8,0);
466  nodes[0] = k*(nelem+1)*(nelem+1)+j*(nelem+1)+i;
467  nodes[1] = k*(nelem+1)*(nelem+1)+j*(nelem+1)+i+1;
468  nodes[2] = k*(nelem+1)*(nelem+1)+(j+1)*(nelem+1)+i+1;
469  nodes[3] = k*(nelem+1)*(nelem+1)+(j+1)*(nelem+1)+i;
470  nodes[4] = (k+1)*(nelem+1)*(nelem+1)+j*(nelem+1)+i;
471  nodes[5] = (k+1)*(nelem+1)*(nelem+1)+j*(nelem+1)+i+1;
472  nodes[6] = (k+1)*(nelem+1)*(nelem+1)+(j+1)*(nelem+1)+i+1;
473  nodes[7] = (k+1)*(nelem+1)*(nelem+1)+(j+1)*(nelem+1)+i;
474 #ifdef LOG4CXX
475  {
476  std::stringstream sout;
477  sout << "Pyramid and tetrahedral nodes " << nodes;
478  LOGPZ_DEBUG(logger, sout.str())
479  }
480 #endif
481  for (int el=0; el<2; el++)
482  {
483  TPZManVector<int64_t,5> elnodes(5);
484  for (int il=0; il<5; il++) {
485  elnodes[il] = nodes[pyramid[el][il]];
486  }
487  int64_t index;
488  gmesh->CreateGeoElement(EPiramide, elnodes, MaterialId, index);
489  elnodes.resize(4);
490  for (int il=0; il<4; il++) {
491  elnodes[il] = nodes[tetraedra[el][il]];
492  }
493  gmesh->CreateGeoElement(ETetraedro, elnodes, MaterialId, index);
494  }
495  }
496  }
497  }
498  gmesh->BuildConnectivity();
499  return gmesh;
500 }
501 
502 TPZGeoMesh *TCedricTest::TetrahedralMesh(int64_t nelem,int MaterialId)
503 {
504  TPZGeoMesh *gmesh = new TPZGeoMesh;
505  GenerateNodes(gmesh,nelem);
506 
507  for (int64_t i=0; i<nelem; i++) {
508  for (int64_t j=0; j<nelem; j++) {
509  for (int64_t k=0; k<nelem; k++) {
510  TPZManVector<int64_t,8> nodes(8,0);
511  nodes[0] = k*(nelem+1)*(nelem+1)+j*(nelem+1)+i;
512  nodes[1] = k*(nelem+1)*(nelem+1)+j*(nelem+1)+i+1;
513  nodes[2] = k*(nelem+1)*(nelem+1)+(j+1)*(nelem+1)+i+1;
514  nodes[3] = k*(nelem+1)*(nelem+1)+(j+1)*(nelem+1)+i;
515  nodes[4] = (k+1)*(nelem+1)*(nelem+1)+j*(nelem+1)+i;
516  nodes[5] = (k+1)*(nelem+1)*(nelem+1)+j*(nelem+1)+i+1;
517  nodes[6] = (k+1)*(nelem+1)*(nelem+1)+(j+1)*(nelem+1)+i+1;
518  nodes[7] = (k+1)*(nelem+1)*(nelem+1)+(j+1)*(nelem+1)+i;
519 #ifdef LOG4CXX
520  {
521  std::stringstream sout;
522  sout << "Tetrahedral nodes " << nodes;
523  LOGPZ_DEBUG(logger, sout.str())
524  }
525 #endif
526  for (int el=0; el<6; el++)
527  {
528  TPZManVector<int64_t,4> elnodes(4);
529  int64_t index;
530  for (int il=0; il<4; il++) {
531  elnodes[il] = nodes[tetraedra_2[el][il]];
532  }
533  gmesh->CreateGeoElement(ETetraedro, elnodes, MaterialId, index);
534  }
535  }
536  }
537  }
538  gmesh->BuildConnectivity();
539  return gmesh;
540 }
541 
542 void UniformRefinement(const int nDiv, TPZGeoMesh *gmesh, const int dim, bool allmaterial=false, const int matidtodivided=1);
543 
544 TPZGeoMesh *TCedricTest::TetrahedralMeshUsingRefinement(int64_t nelemdata,int MaterialId)
545 {
546  // CONSIDERING A CUBE WITH MASS CENTER (0.5*INITIALL, 0.5*INITIALL, 0.5*INITIALL) AND VOLUME = INITIALL*INITIALL*INITIALL
547  // And dividing into five tetrahedras
548  int nrefs = nelemdata/5;
549  TPZGeoMesh *gmesh = new TPZGeoMesh();
550  REAL InitialL = 1.0;
551 
552  const int nelem = 5;
553  const int nnode = 8;
554  REAL co[nnode][3] = {
555  {0.,0.,0.},
556  {InitialL,0.,0.},
557  {InitialL,InitialL,0.},
558  {0.,InitialL,0.},
559  {0.,0.,InitialL},
560  {InitialL,0.,InitialL},
561  {InitialL,InitialL,InitialL},
562  {0.,InitialL,InitialL},
563  };
564  int nod;
565  for(nod=0; nod<nnode; nod++) {
566  int64_t nodind = gmesh->NodeVec().AllocateNewElement();
567  TPZVec<REAL> coord(3);
568  coord[0] = co[nod][0];
569  coord[1] = co[nod][1];
570  coord[2] = co[nod][2];
571  gmesh->NodeVec()[nodind] = TPZGeoNode(nod,coord,*gmesh);
572  }
573 
574  TPZVec<TPZVec<int64_t> > indices(nelem);
575  int nnodebyelement = 4;
576  int el;
577  for(el=0;el<nelem;el++)
578  indices[el].Resize(nnodebyelement);
579  // nodes to first element
580  indices[0][0] = 0;
581  indices[0][1] = 1;
582  indices[0][2] = 3;
583  indices[0][3] = 4;
584  // nodes to second element
585  indices[1][0] = 1;
586  indices[1][1] = 2;
587  indices[1][2] = 3;
588  indices[1][3] = 6;
589  // nodes to third element
590  indices[2][0] = 4;
591  indices[2][1] = 5;
592  indices[2][2] = 6;
593  indices[2][3] = 1;
594  // nodes to fourth element
595  indices[3][0] = 6;
596  indices[3][1] = 7;
597  indices[3][2] = 4;
598  indices[3][3] = 3;
599  // nodes to fifth element
600  indices[4][0] = 1;
601  indices[4][1] = 4;
602  indices[4][2] = 6;
603  indices[4][3] = 3;
604 
605  TPZGeoEl *elvec[nelem];
606  for(el=0; el<nelem; el++) {
607  int64_t index;
608  elvec[el] = gmesh->CreateGeoElement(ETetraedro,indices[el],MaterialId,index);
609  }
610  gmesh->BuildConnectivity();
611 
612  UniformRefinement(nrefs,gmesh,3);
613 
614  return gmesh;
615 }
616 
617 TPZGeoMesh *TCedricTest::HexahedralMesh(int64_t nelem,int MaterialId)
618 {
619  TPZGeoMesh *gmesh = new TPZGeoMesh;
620  GenerateNodes(gmesh, nelem);
621 
622  for (int64_t i=0; i<nelem; i++) {
623  for (int64_t j=0; j<nelem; j++) {
624  for (int64_t k=0; k<nelem; k++) {
625  TPZManVector<int64_t,8> nodes(8,0);
626  nodes[0] = k*(nelem+1)*(nelem+1)+j*(nelem+1)+i;
627  nodes[1] = k*(nelem+1)*(nelem+1)+j*(nelem+1)+i+1;
628  nodes[2] = k*(nelem+1)*(nelem+1)+(j+1)*(nelem+1)+i+1;
629  nodes[3] = k*(nelem+1)*(nelem+1)+(j+1)*(nelem+1)+i;
630  nodes[4] = (k+1)*(nelem+1)*(nelem+1)+j*(nelem+1)+i;
631  nodes[5] = (k+1)*(nelem+1)*(nelem+1)+j*(nelem+1)+i+1;
632  nodes[6] = (k+1)*(nelem+1)*(nelem+1)+(j+1)*(nelem+1)+i+1;
633  nodes[7] = (k+1)*(nelem+1)*(nelem+1)+(j+1)*(nelem+1)+i;
634 #ifdef LOG4CXX
635  if (logger->isDebugEnabled())
636  {
637  std::stringstream sout;
638  sout << "Cube nodes " << nodes;
639  LOGPZ_DEBUG(logger, sout.str())
640  }
641 #endif
642  int64_t index;
643  gmesh->CreateGeoElement(ECube, nodes, MaterialId, index);
644  }
645  }
646  }
647  gmesh->BuildConnectivity();
648  return gmesh;
649 }
650 
653 {
654  int64_t nel = mesh->NElements();
655  for(int64_t el=0; el<nel; el++) {
656  TPZGeoEl *gel = mesh->ElementVec()[el];
657  int nsides = gel->NSides();
658  for(int is=0; is<nsides; is++) {
659  TPZGeoElSide gelside(gel,is);
660  if(gelside.Dimension() != 2) {
661  continue;
662  }
663  if(gelside.Neighbour() != gelside) {
664  continue;
665  }
666  TPZManVector<REAL,2> xi(2,0.);
667  gelside.CenterPoint(xi);
668  TPZFNMatrix<6,REAL> axes(2,3);
669  TPZFNMatrix<4,REAL> jac(2,2),jacinv(2,2);
670  REAL detjac;
671  gelside.Jacobian(xi, jac, axes, detjac, jacinv);
672  TPZManVector<REAL,3> x(3,0.);
673  gelside.X(xi, x);
674  TPZManVector<REAL,3> normal(3);
675  normal[0] = fabs(axes(0,1)*axes(1,2)-axes(0,2)*axes(1,1));
676  normal[1] = fabs(-axes(0,0)*axes(1,2)+axes(0,2)*axes(1,0));
677  normal[2] = fabs(axes(0,0)*axes(1,1)-axes(0,1)*axes(1,0));
678  REAL tol = 1.e-6;
679  REAL xmin = 1., xmax = 0.;
680  int numtol = 0;
681  for(int i=0; i<3; i++) {
682  if(xmin > x[i]) xmin = x[i];
683  if(xmax < x[i]) {
684  xmax = x[i];
685  }
686  if(normal[i] > tol) {
687  numtol++;
688  }
689  }
690  if(numtol != 1) {
691  DebugStop();
692  }
693  if(xmin > tol && xmax < 1.-tol) {
694  DebugStop();
695  }
696  }
697  }
698 }
699 
701 {
702  int dim=3;
703  TPZCompMesh *cmesh = new TPZCompMesh(gmesh);
704  cmesh->SetDimModel(dim);
705 
707  TPZMatPoisson3d *poiss = new TPZMatPoisson3d(1,dim);
709  poiss->SetForcingFunction(force );
710  cmesh->InsertMaterialObject(poiss);
711 
713  TPZFMatrix<STATE> val1(1,1,0.), val2(1,1,0.);
714  TPZBndCond *bc = new TPZBndCond(poiss, -1, 0, val1, val2);
715  bc->TPZMaterial::SetForcingFunction(force);
716  cmesh->InsertMaterialObject(bc);
717 
719  cmesh->AutoBuild();
720 
721  return cmesh;
722 }
723 
725 {
726  int nelembc = 0;
727  int64_t nelem = gmesh->NElements();
728  for (int64_t el = 0; el<nelem; el++) {
729  TPZGeoEl *gel = gmesh->ElementVec()[el];
730  int ns = gel->NSides();
731  for (int is=0; is<ns; is++) {
732  TPZGeoElSide gelside(gel,is);
733  if (gelside.Dimension() != 2) {
734  continue;
735  }
736  if (gelside.Neighbour() == gelside) {
737  TPZGeoElBC(gelside, -1);
738  nelembc++;
739  }
740  }
741  }
742  return nelembc;
743 }
744 
746 {
747  int64_t nel = cmesh->NElements();
748  for (int64_t el = 0; el<nel; el++) {
749  TPZCompEl *cel = cmesh->ElementVec()[el];
750  TPZInterpolationSpace *intel = dynamic_cast<TPZInterpolationSpace *>(cel);
751  if (!intel) continue;
752  TPZGeoEl *gel = cel->Reference();
753  if (gel->Dimension() != 3) continue;
754  int64_t index;
755  TPZElementGroup *elgr = new TPZElementGroup(*cmesh,index);
756  int nsides = gel->NSides();
757  for (int is = 0; is<nsides; is++) {
758  int sidedim = gel->SideDimension(is);
759  TPZCompElSide celside(cel,is);
760  TPZGeoElSide gelside(gel,is);
761  TPZStack<TPZCompElSide> elsidevec;
762  gelside.ConnectedCompElementList(elsidevec, 0, 0);
763  int nelside = elsidevec.size();
764  for (int neigh=0; neigh<nelside; neigh++) {
765  TPZCompElSide celneigh = elsidevec[neigh];
766  TPZGeoElSide gelneigh = celneigh.Reference();
767  TPZGeoEl *geln = gelneigh.Element();
768  if (geln->Dimension() == sidedim) {
769  elgr->AddElement(celneigh.Element());
770  }
771  }
772  }
773  elgr->AddElement(intel);
774  }
775  cmesh->ComputeNodElCon();
776 
777  nel = cmesh->NElements();
778  for (int el = 0; el<nel; el++) {
779  TPZCompEl *cel = cmesh->ElementVec()[el];
780  if (!cel) continue;
781  TPZElementGroup *celgr = dynamic_cast<TPZElementGroup *>(cel);
782  if (!celgr) {
783  DebugStop();
784  }
785  //TPZCondensedCompEl *cond = new TPZCondensedCompEl(celgr);
786  }
787 }
788 
790 {
791  int64_t nel = cmesh->ElementVec().NElements();
792  for (int64_t el=0; el<nel; el++) {
793  TPZCompEl *cel = cmesh->ElementVec()[el];
794  TPZCondensedCompEl *cond = dynamic_cast<TPZCondensedCompEl *>(cel);
795  if(cond)
796  {
797  cond->Unwrap();
798  }
799  }
800  nel = cmesh->ElementVec().NElements();
801  for (int64_t el=0; el<nel; el++) {
802  TPZCompEl *cel = cmesh->ElementVec()[el];
803  TPZElementGroup *elgr = dynamic_cast<TPZElementGroup *>(cel);
804  if (elgr) {
805  elgr->Unwrap();
806  }
807  }
808 }
int64_t NElements() const
Number of computational elements allocated.
Definition: pzcmesh.h:169
TPZGeoMesh * HexahedralMesh(int64_t nelem, int MaterialId)
Definition: CedricTest.cpp:617
TPZGeoMesh * Reference() const
Returns a pointer to the geometrical mesh associated.
Definition: pzcmesh.h:209
static void SetgOrder(int order)
Sets the value of the default interpolation order.
Definition: pzcompel.h:825
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
int AllocateNewElement()
Makes more room for new elements.
Definition: pzadmchunk.h:184
Contains TPZAnalysis class which implements the sequence of actions to perform a finite element analy...
Implements computational element and a side. Computational Element.
Definition: pzcompel.h:632
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
Definition: pzconnect.h:30
TPZGeoNode * NodePtr(int i) const
Returns a pointer to the ith node of the element.
Definition: pzgeoel.cpp:2566
Contains the TPZParSkylineStructMatrix class which defines parallel structural matrix for skyline mat...
int AddBoundaryElements(TPZGeoMesh *gmesh)
Definition: CedricTest.cpp:724
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.
void SetStructuralMatrix(TPZAutoPointer< TPZStructMatrix > strmatrix)
Set structural matrix as auto pointer for analysis.
Definition: pzanalysis.cpp:82
static REAL d2fx(REAL x, REAL x0, REAL eps)
Definition: CedricTest.h:51
static int tetraedra[2][4]
Definition: CedricTest.cpp:425
TPZGeoMesh * TetrahedralMesh(int64_t nelem, int MaterialId)
Definition: CedricTest.cpp:502
clarg::argBool bc("-bc", "binary checkpoints", false)
void Unwrap()
put the elements in the element group back in the mesh and delete the element group ...
virtual TPZGeoEl * CreateGeoElement(MElementType type, TPZVec< int64_t > &cornerindexes, int matid, int64_t &index, int reftype=1)
Generic method for creating a geometric element. Putting this method centrally facilitates the modifi...
Definition: pzgmesh.cpp:1296
void CheckConsistency(TPZGeoMesh *mesh)
verify if the faces without neighbour should be orthogonal to the main planes
Definition: CedricTest.cpp:652
void LoadInterpolation(TPZCompMesh *cmesh)
Definition: CedricTest.cpp:220
virtual void resize(const int64_t newsize)
Definition: pzvec.h:213
static void Exact(const TPZVec< REAL > &x, TPZVec< STATE > &func, TPZFMatrix< STATE > &deriv)
Definition: CedricTest.h:67
int64_t NEquations()
This computes the number of equations associated with non-restrained nodes.
Definition: pzcmesh.cpp:721
TPZGeoElSide Reference() const
Reference to the geometric element.
Definition: pzcompel.cpp:748
Contains declaration of TPZCompEl class which defines the interface of a computational element...
virtual int PolynomialOrder()
Definition: CedricTest.cpp:413
Contains the declaration of the TPZElementGroup class, which implements an computational element whic...
Defines step solvers class. Solver.
Definition: pzmganalysis.h:17
void SetSolver(TPZMatrixSolver< STATE > &solver)
Set solver matrix.
virtual int NCornerNodes() const =0
Returns the number of corner nodes of the element.
void GenerateNodes(TPZGeoMesh *gmesh, int64_t nelem)
Definition: CedricTest.cpp:441
int64_t NElements() const
Number of elements of the mesh.
Definition: pzgmesh.h:129
clarg::argInt nthreads("-nt", "Number of threads.", 8)
void DeformGMesh(TPZGeoMesh &gmesh)
Deform the geometric mesh according to the coordinates of fDeformed.
Definition: CedricTest.cpp:79
static TPZManVector< REAL, 3 > fEps
Definition: CedricTest.h:14
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Definition: pzgeoelside.h:83
Class which groups elements to characterize dense matrices.
Contains declaration of TPZGeoElBC class, it is a structure to help the construction of geometric ele...
virtual void DefineGraphMesh(int dimension, const TPZVec< std::string > &scalnames, const TPZVec< std::string > &vecnames, const std::string &plotfile)
Define GrapMesh as V3D, DX, MV or VTK depending on extension of the file.
Definition: pzanalysis.cpp:952
int64_t NElements() const
Access method to query the number of elements of the vector.
REAL val(STATE &number)
Returns value of the variable.
Definition: pzartdiff.h:23
TPZGeoElSide Neighbour() const
Definition: pzgeoel.h:754
Implements a function. Utility.
Definition: pzfunction.h:19
virtual int NSides() const =0
Returns the number of connectivities of the element.
void CenterPoint(TPZVec< REAL > &center) const
return the coordinates of the center in master element space (associated with the side) ...
virtual int SideDimension(int side) const =0
Return the dimension of side.
Contains the TPZMatPoisson3d class.
void Run(int nsubdivisions, int geocase, int POrder, int MaterialId, std::ostream &out=std::cout)
Definition: CedricTest.cpp:246
Contains TPZShapeLinear class which implements the shape functions of a linear one-dimensional elemen...
void SetExact(std::function< void(const TPZVec< REAL > &loc, TPZVec< STATE > &result, TPZFMatrix< STATE > &deriv)> f)
Sets the pointer of the exact solution function.
Definition: pzanalysis.h:360
TPZGeoMesh * PyramidalAndTetrahedralMesh(int64_t nelem, int MaterialId)
Definition: CedricTest.cpp:457
TPZFMatrix< STATE > & Solution()
Returns the solution matrix.
Definition: pzanalysis.h:177
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
Contains the TPZBndCond class which implements a boundary condition for TPZMaterial objects...
virtual TPZMaterial * Material() const
Identify the material object associated with the element.
Definition: pzcompel.cpp:959
int Zero() override
Makes Zero all the elements.
Definition: pzfmatrix.h:651
TPZGeoMesh * TetrahedralMeshUsingRefinement(int64_t nelem, int MaterialId)
Definition: CedricTest.cpp:544
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
void UniformRefinement(const int nDiv, TPZGeoMesh *gmesh, const int dim, bool allmaterial=false, const int matidtodivided=1)
Definition: main.cpp:74
virtual int NFunctions()
Definition: CedricTest.cpp:408
void Resize(const int newsize)
Increase the size of the chunk vector.
Definition: pzadmchunk.h:280
void Unwrap()
unwrap the condensed element from the computational element and delete the condensed element ...
void InterpolationError(int nsubdivisions, int geocase, int MaterialId, std::ostream &out)
Definition: CedricTest.cpp:92
int64_t SequenceNumber() const
Returns the Sequence number of the connect object.
Definition: pzconnect.h:158
static const double tol
Definition: pzgeoprism.cpp:23
Implements the sequence of actions to perform a finite element analysis. Analysis.
Definition: pzanalysis.h:32
void Push(const T object)
Pushes a copy of the object on the stack.
Definition: pzstack.h:80
virtual void Print(std::ostream &out=std::cout) const
Print the information of the grid to an ostream.
Definition: pzgmesh.cpp:130
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
virtual void Execute(const TPZVec< REAL > &x, TPZVec< STATE > &val, TPZFMatrix< STATE > &df)
Performs function computation.
Definition: CedricTest.cpp:384
Contains the TPZBandStructMatrix class which implements Banded Structural Matrices.
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
virtual void SetNumThreads(int n)
static int pyramid[2][5]
Definition: CedricTest.cpp:420
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
Definition: pzlog.h:87
void X(TPZVec< REAL > &loc, TPZVec< REAL > &result) const
X coordinate of a point loc of the side.
This class defines the boundary condition for TPZMaterial objects.
Definition: pzbndcond.h:29
Contains the TPZElasticityMaterial class which implements a two dimensional elastic material in plane...
int Dimension() const
Returns the dimension of the simulation.
Definition: pzcmesh.h:148
virtual void ComputeNodElCon()
Compute the number of elements connected to each connect object.
Definition: pzcmesh.cpp:668
TPZAdmChunkVector< TPZGeoNode > & NodeVec()
Definition: pzgmesh.h:140
TPZCompEl * Reference() const
Return a pointer to the element referenced by the geometric element.
Definition: pzgeoel.h:750
virtual void AutoBuild(const std::set< int > *MaterialIDs)
Creates the computational elements, and the degree of freedom nodes.
Definition: pzcmesh.cpp:308
static TPZManVector< REAL, 3 > fX0
Definition: CedricTest.h:14
Contains the TPZGenGrid class which implements the generation of a multilayered geometric grid (two-d...
virtual void Execute(const TPZVec< REAL > &x, TPZVec< STATE > &val)
Simpler version of Execute method which does not compute function derivatives.
Definition: CedricTest.cpp:397
const TPZBlock< STATE > & Block() const
Access the block structure of the solution vector.
Definition: pzcmesh.h:213
Contains declaration of TPZCheckMesh class which verifies the consistency of the datastructure of a T...
Contains the TPZExtendGridDimension class which generates a three dimensional mesh as an extension of...
REAL co[8][3]
Coordinates of the eight nodes.
TPZAdmChunkVector< TPZConnect > & ConnectVec()
Return a reference to the connect pointers vector.
Definition: pzcmesh.h:198
Class which implements an element which condenses the internal connects.
virtual void PostProcess(int resolution)
Draw solution over mesh for all dimensions.
virtual TPZConnect & Connect(int i) const
Returns a pointer to the ith node.
Definition: pzcompel.cpp:298
void SetDimModel(int dim)
Set de dimension of the domain of the problem.
Definition: pzcmesh.h:139
virtual void Run(std::ostream &out=std::cout)
Calls the appropriate sequence of methods to build a solution or a time stepping sequence.
Definition: pzanalysis.cpp:920
void ConnectedCompElementList(TPZStack< TPZCompElSide > &elsidevec, int onlyinterpolated, int removeduplicates)
Returns all connected computational elements to the current element if onlyinterpolated == 1 only e...
static int tetraedra_2[6][4]
Definition: CedricTest.cpp:430
Implements the interfaces for TPZCompElDisc, TPZInterfaceElement and TPZInterpolatedElement. Computational element.
TPZGeoEl * Element() const
Definition: pzgeoelside.h:162
Structure to help the construction of geometric elements along side of a given geometric element...
Definition: pzgeoelbc.h:21
void BuildConnectivity()
Build the connectivity of the grid.
Definition: pzgmesh.cpp:967
int InsertMaterialObject(TPZMaterial *mat)
Insert a material object in the datastructure.
Definition: pzcmesh.cpp:287
DESCRIBE PLEASE.
Definition: pzpoisson3d.h:26
virtual int Dimension() const =0
Returns the dimension of the element.
TPZCompEl * Element() const
Gives a pointer to the reference computational element.
Definition: pzcompel.h:675
TPZGeoEl * Reference() const
Return a pointer to the corresponding geometric element if such exists, return 0 otherwise.
Definition: pzcompel.cpp:1137
Implements a geometric node in the pz environment. Geometry.
Definition: pzgnode.h:31
void CreateCondensedElements(TPZCompMesh *cmesh)
Definition: CedricTest.cpp:745
void UnwrapElements(TPZCompMesh *cmesh)
Definition: CedricTest.cpp:789
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
This class implements a stack object. Utility.
Definition: pzcheckmesh.h:14
void SetForcingFunction(TPZAutoPointer< TPZFunction< STATE > > fp)
Sets a procedure as source function for the material.
Definition: TPZMaterial.h:368
int Dimension() const
the dimension associated with the element/side
void Jacobian(TPZVec< REAL > &param, TPZFMatrix< REAL > &jacobian, TPZFMatrix< REAL > &axes, REAL &detjac, TPZFMatrix< REAL > &jacinv) const
Jacobian associated with the side of the element.
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
const T & get_value() const
Definition: arglib.h:177
TPZAdmChunkVector< TPZCompEl * > & ElementVec()
Returns a reference to the element pointers vector.
Definition: pzcmesh.h:183
Definition: pzeltype.h:61
Contains declaration of TPZInterpolatedElement class which implements computational element of the in...
Contains TPZStepSolver class which defines step solvers class.
TPZCompMesh * GenerateCompMesh(TPZGeoMesh *gmesh)
Definition: CedricTest.cpp:700
pthread_cond_t cond
Definition: numatst.cpp:318
void SetDirect(const DecomposeType decomp)
void GetCoordinates(TPZVec< REAL > &co)
Fill the coordinates of the node.
Definition: pzgnode.cpp:83
Is a structural matrix with parallel techniques included. Structural Matrix Frontal.
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
Contains the TPZVTKGeoMesh class which implements the graphical mesh to VTK environment to geometric ...
virtual void PostProcessError(TPZVec< REAL > &, bool store_error=true, std::ostream &out=std::cout)
Compute the local error over all elements and global errors in several norms and print out without ca...
Definition: pzanalysis.cpp:573
Contains the declaration of the TPZCondensedCompEl class, which implements an computational element w...
static int nodind[7][8]
virtual void AddElement(TPZCompEl *cel)
add an element to the element group
TPZGeoMesh fDeformed
Definition: CedricTest.h:16
static REAL fx(REAL x, REAL x0, REAL eps)
Definition: CedricTest.h:36
TPZFMatrix< STATE > & Solution()
Access the solution vector.
Definition: pzcmesh.h:219
Contains the TPZParFrontStructMatrix class which is a structural matrix with parallel techniques incl...
Contains the TPZRefPatternTools class which defines tools of pattern.
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
Definition: pzfmatrix.h:716
virtual void Print(std::ostream &out=std::cout) const
Prints mesh data.
Definition: pzcmesh.cpp:236
TPZAdmChunkVector< TPZGeoEl * > & ElementVec()
Methods for handling pzlists.
Definition: pzgmesh.h:138
This class implements a reference counter mechanism to administer a dynamically allocated object...