NeoPZ
pzanalysis.cpp
Go to the documentation of this file.
1 
6 #include "pzanalysis.h"
7 #include <math.h> // for sqrt, fabs
8 #include <stdio.h> // for NULL
9 #include <string.h> // for strcpy, strlen
10 #ifdef MACOSX
11 #include <__functional_base> // for less
12 #include <__tree> // for __tree_const_iterator, ope...
13 #endif
14 #include <list> // for list, __list_iterator, lis...
15 #include <map> // for __map_iterator, map, map<>...
16 #include <string> // for allocator, basic_string
17 #include <utility> // for pair
18 #include "TPZLagrangeMultiplier.h" // for TPZLagrangeMultiplier
19 #include "TPZSkylineNSymStructMatrix.h" // for TPZSkylineNSymStructMatrix
20 #include "TPZSloanRenumbering.h" // for TPZSloanRenumbering
21 #include "pzadmchunk.h" // for TPZAdmChunkVector
22 #include "pzbdstrmatrix.h" // for TPZBlockDiagonalStructMatrix
23 #include "pzblock.h" // for TPZBlock
24 #include "pzblockdiag.h" // for TPZBlockDiagonal
25 #include "pzbndcond.h" // for TPZBndCond
26 #include "TPZChunkVector.h" // for TPZChunkVector
27 #include "pzcmesh.h" // for TPZCompMesh
28 #include "pzcompel.h" // for TPZCompEl
29 #include "pzconnect.h" // for TPZConnect
30 #include "pzdxmesh.h" // for TPZDXGraphMesh
31 #include "TPZEquationFilter.h" // for TPZEquationFilter
32 #include "pzgeoel.h" // for TPZGeoEl
33 #include "pzgmesh.h" // for TPZGeoMesh
34 #include "pzgraphmesh.h" // for TPZGraphMesh
35 #include "pzlog.h" // for glogmutex, LOGPZ_DEBUG
36 #include "pzmanvector.h" // for TPZManVector
37 #include "TPZMaterial.h" // for TPZMaterial
38 #include "pzmetis.h" // for TPZMetis
39 #include "pzmvmesh.h" // for TPZMVGraphMesh
40 #include "pzseqsolver.h" // for TPZSequenceSolver
41 #include "pzsolve.h" // for TPZMatrixSolver, TPZSolver
42 #include "pzstack.h" // for TPZStack
43 #include "pzstepsolver.h" // for TPZStepSolver
44 #include "pzstrmatrix.h" // for TPZStructMatrix, TPZStruct...
45 #include "pzv3dmesh.h" // for TPZV3DGraphMesh
46 #include "pzvec.h" // for TPZVec, operator<<
47 #include "pzvtkmesh.h" // for TPZVTKGraphMesh
48 #include "tpznodesetcompute.h" // for TPZNodesetCompute
49 #include "tpzsparseblockdiagonal.h" // for TPZSparseBlockDiagonal
50 
51 #ifdef WIN32
52 #include "pzsloan.h" // for TPZSloan
53 #endif
54 
55 #ifdef LOG4CXX
56 static LoggerPtr logger(Logger::getLogger("pz.analysis"));
57 static LoggerPtr loggerError(Logger::getLogger("pz.analysis.error"));
58 #endif
59 
60 #ifdef USING_BOOST
61 #include "TPZBoostGraph.h"
66 #define RENUMBER TPZSloanRenumbering()
67 #else
68 
72 #define RENUMBER TPZSloanRenumbering()
73 //#define RENUMBER TPZCutHillMcKee()
74 #endif
75 
76 using namespace std;
77 
79  fStructMatrix = TPZAutoPointer<TPZStructMatrix>(strmatrix.Clone());
80 }
81 
83  fStructMatrix = TPZAutoPointer<TPZStructMatrix>(strmatrix->Clone());
84 }
86 fGeoMesh(0), fCompMesh(0), fRhs(), fSolution(), fSolver(0), fStep(0), fTime(0.), fNthreadsError(0),fStructMatrix(0), fRenumber(new RENUMBER)
87 , fGuiInterface(NULL), fTable(), fExact(NULL) {
88  fGraphMesh[0] = 0;
89  fGraphMesh[1] = 0;
90  fGraphMesh[2] = 0;
91 }
92 
93 
94 TPZAnalysis::TPZAnalysis(TPZCompMesh *mesh, bool mustOptimizeBandwidth, std::ostream &out) :
97 {
98  fGraphMesh[0] = 0;
99  fGraphMesh[1] = 0;
100  fGraphMesh[2] = 0;
101  this->SetCompMesh(mesh, mustOptimizeBandwidth);
102 }
103 
104 TPZAnalysis::TPZAnalysis(TPZAutoPointer<TPZCompMesh> mesh, bool mustOptimizeBandwidth, std::ostream &out) :
107 {
108  fGraphMesh[0] = 0;
109  fGraphMesh[1] = 0;
110  fGraphMesh[2] = 0;
111  this->SetCompMesh(mesh.operator ->(), mustOptimizeBandwidth);
112 }
113 
114 
115 void TPZAnalysis::SetCompMesh(TPZCompMesh * mesh, bool mustOptimizeBandwidth) {
116  if(mesh)
117  {
118  fCompMesh = mesh;
119  fGeoMesh = mesh->Reference();
120  fGraphMesh[0] = 0;
121  fGraphMesh[1] = 0;
122  fGraphMesh[2] = 0;
123  if(fSolver) fSolver->ResetMatrix();
124 // fCompMesh->InitializeBlock();
125  int64_t neq = fCompMesh->NEquations();
126  if(neq > 20000 && mustOptimizeBandwidth)
127  {
128  std::cout << __PRETTY_FUNCTION__ << " optimizing bandwidth\n";
129  std::cout.flush();
130  }
131  if(mustOptimizeBandwidth)
132  {
134  }
135  if(neq > 20000 && mustOptimizeBandwidth)
136  {
137  std::cout << __PRETTY_FUNCTION__ << " optimizing bandwidth finished\n";
138  std::cout.flush();
139  }
141  fSolution.Resize(neq,1);
142  }
143  else
144  {
145  CleanUp();
146  }
147  fStep = 0;
148  fTime = 0.;
149  if(!this->fSolver){
150  //seta default do stepsolver como LU
151  TPZStepSolver<STATE> defaultSolver;
152  defaultSolver.SetDirect(ELU);
153  this->SetSolver(defaultSolver);
154 
155  }
156  if(!this->fStructMatrix && mesh)
157  {
158  //seta default do StructMatrix como Full Matrix
159  TPZSkylineNSymStructMatrix defaultMatrix(mesh);
160  this->SetStructuralMatrix(defaultMatrix);
161  }
162 
163 
164 }
165 
167  CleanUp();
168 }
169 
172 {
173  if(fSolver) {
174  delete fSolver;
175  fSolver = NULL;
176  }
177  int dim;
178  for(dim=0; dim<3; dim++) {
179  if(fGraphMesh[dim]) delete fGraphMesh[dim];
180  fGraphMesh[dim] = 0;
181  fScalarNames[dim].resize(0);
182  fVectorNames[dim].resize(0);
183  }
184  fCompMesh = 0;
185  fGeoMesh = 0;
186  fSolution.Redim(0,0);
187  fRhs.Redim(0,0);
188  fStructMatrix = 0;
189  fRenumber = 0;
190  fGuiInterface = 0;
191 
192 }
193 
194 
196  //enquanto nao compilamos o BOOST no windows, vai o sloan antigo
197 #ifdef WIN32
198  if(!fCompMesh) return;
199 // fCompMesh->InitializeBlock();
200  TPZVec<int64_t> perm,iperm;
201 
202  TPZStack<int64_t> elgraph;
203  TPZStack<int64_t> elgraphindex;
204  int64_t nindep = fCompMesh->NIndependentConnects();
205  fCompMesh->ComputeElGraph(elgraph,elgraphindex);
206  int64_t nel = elgraphindex.NElements()-1;
207  TPZSloan sloan(nel,nindep);
208  sloan.SetElementGraph(elgraph,elgraphindex);
209  sloan.Resequence(perm,iperm);
210  fCompMesh->Permute(perm);
211 #else
212  if(!fCompMesh) return;
213 // fCompMesh->InitializeBlock();
214 
215  TPZVec<int64_t> perm,iperm;
216 
217  TPZStack<int64_t> elgraph,elgraphindex;
218  int64_t nindep = fCompMesh->NIndependentConnects();
219 
221  if(nindep == 0) return;
222 
223  fCompMesh->ComputeElGraph(elgraph,elgraphindex);
224  int64_t nel = elgraphindex.NElements()-1;
225  int64_t el,ncel = fCompMesh->NElements();
226  int maxelcon = 0;
227  for(el = 0; el<ncel; el++)
228  {
229  TPZCompEl *cel = fCompMesh->ElementVec()[el];
230  if(!cel) continue;
231  std::set<int64_t> indepconlist,depconlist;
232  cel->BuildConnectList(indepconlist,depconlist);
233  int64_t locnindep = indepconlist.size();
234  maxelcon = maxelcon < locnindep ? locnindep : maxelcon;
235  }
236  fRenumber->SetElementsNodes(nel,nindep);
237  fRenumber->SetElementGraph(elgraph,elgraphindex);
238 #ifdef LOG4CXX2
239  if(logger->isDebugEnabled())
240  {
241  std::stringstream sout;
242  fRenumber->Print(elgraph, elgraphindex, "Elgraph of submesh", sout);
243  LOGPZ_DEBUG(logger, sout.str())
244  }
245 #endif
246  fRenumber->Resequence(perm,iperm);
247  fCompMesh->Permute(perm);
248  if (nel > 100000) {
249  std::cout << "Applying Saddle Permute\n";
250  }
252 // fCompMesh->SaddlePermute2();
253 
254 #endif
255 
256 }
257 
264 {
265  int res = 1;
266  if(!fCompMesh)
267  {
268  return res;
269  }
270  std::map<int, TPZMaterial *>::iterator it;
271  // compute the maximum number of load cases for all material objects
272  for( it = fCompMesh->MaterialVec().begin(); it != fCompMesh->MaterialVec().end(); it++)
273  {
274  TPZMaterial *mat = it->second;
275  int matnumstate = mat->MinimumNumberofLoadCases();
276  res = res < matnumstate ? matnumstate : res;
277  }
278  // set the number of load cases for all material objects
279  for( it = fCompMesh->MaterialVec().begin(); it != fCompMesh->MaterialVec().end(); it++)
280  {
281  TPZMaterial *mat = it->second;
282  mat->SetNumLoadCases(res);
283  }
284  return res;
285 }
286 
287 
289  int numloadcases = ComputeNumberofLoadCases();
290 
291  if(Mesh()->NEquations()==0)
292  {
293  cout << "\n ########################################################################" <<endl;
294  cout << "\n Imprimindo malha computacional de pos processamento no assemble residual " <<endl;
295  cout << "\n Malha nula! " <<endl;
296  DebugStop();
297  }
298  int64_t sz = this->Mesh()->NEquations();
299  this->Rhs().Redim(sz,numloadcases);
300  //int64_t othersz = fStructMatrix->Mesh()->NEquations();
301  fStructMatrix->Assemble(this->Rhs(),fGuiInterface);
302 }//void
303 
305 {
306  if(!fCompMesh || !fStructMatrix || !fSolver)
307  {
308  std::stringstream sout;
309  sout << "TPZAnalysis::Assemble lacking definition for Assemble fCompMesh "<< (void *) fCompMesh
310  << " fStructMatrix " << (void *) fStructMatrix.operator->()
311  << " fSolver " << (void *) fSolver;
312 #ifndef WINDOWS
313  sout << " at file " << __FILE__ << " line " << __LINE__ ;
314 #else
315  sout << " TPZAnalysis::Assemble() " ;
316 #endif
317 #ifdef LOG4CXX
318  LOGPZ_ERROR(logger,sout.str().c_str());
319 #else
320  std::cout << sout.str().c_str() << std::endl;
321 #endif
322  return;
323  }
324  int numloadcases = ComputeNumberofLoadCases();
325  int64_t sz = fCompMesh->NEquations();
326  fRhs.Redim(sz,numloadcases);
327  if(fSolver->Matrix() && fSolver->Matrix()->Rows()==sz)
328  {
329  fSolver->Matrix()->Zero();
330  fStructMatrix->Assemble(*(fSolver->Matrix().operator ->()),fRhs,fGuiInterface);
331  }
332  else
333  {
334 
335  TPZMatrix<STATE> *mat = fStructMatrix->CreateAssemble(fRhs,fGuiInterface);
336  fSolver->SetMatrix(mat);
337  //aqui TPZFMatrix<STATE> nao eh nula
338  }
339 #ifdef LOG4CXX
340  if(logger->isDebugEnabled())
341  {
342  std::stringstream sout;
343  PrintVectorByElement(sout, fRhs, 1.e-6);
344 // fRhs.Print("Rhs",sout);
345  LOGPZ_DEBUG(logger,sout.str())
346  }
347 #endif
348 
350 }
351 
353  int64_t numeq = fCompMesh->NEquations();
354  if(fRhs.Rows() != numeq )
355  {
356  DebugStop();
357  }
358  int64_t nReducedEq = fStructMatrix->NReducedEquations();
359  if (nReducedEq == numeq)
360  {
361  TPZFMatrix<STATE> residual(fRhs);
362  TPZFMatrix<STATE> delu(numeq,1,0.);
363  // STATE normres = Norm(residual);
364  // cout << "TPZAnalysis::Solve residual : " << normres << " neq " << numeq << endl;
365 #ifdef LOG4CXX
366  if (logger->isDebugEnabled())
367  {
368  TPZFMatrix<STATE> res2(fRhs);
370  std::stringstream sout;
371  sout << "Residual norm " << Norm(res2) << std::endl;
372  // res2.Print("Residual",sout);
373  LOGPZ_DEBUG(logger,sout.str())
374  }
375 #endif
376 
377 // {
378 // std::ofstream out("Matrix.nb");
379 // fSolver->Matrix()->Print("Stiffness = ",out,EMathematicaInput);
380 //
381 // }
382  fSolver->Solve(residual, delu);
383  fSolution = delu;
384 #ifdef LOG4CXX
385  if (logger->isDebugEnabled())
386  {
387  if(!fSolver->Matrix()->IsDecomposed())
388  {
389  TPZFMatrix<STATE> res2(fRhs);
390  fSolver->Matrix()->Residual(delu,fRhs,res2);
391  std::stringstream sout;
392  sout << "Residual norm " << Norm(res2) << std::endl;
393  // res2.Print("Residual",sout);
394  LOGPZ_DEBUG(logger,sout.str())
395  }
396  }
397 #endif
398 
399  }
400  else
401  {
402  TPZFMatrix<STATE> residual(nReducedEq,1,0.);
403  TPZFMatrix<STATE> delu(nReducedEq,1,0.);
404  fStructMatrix->EquationFilter().Gather(fRhs,residual);
405  fSolver->Solve(residual, delu);
406  fSolution.Redim(numeq,1);
407  fStructMatrix->EquationFilter().Scatter(delu,fSolution);
408  }
409 #ifdef LOG4CXX
410  std::stringstream sout;
411  TPZStepSolver<STATE> *step = dynamic_cast<TPZStepSolver<STATE> *> (fSolver);
412  if(!step) DebugStop();
413  int64_t nsing = step->Singular().size();
414  if(nsing && logger->isWarnEnabled()) {
415  sout << "Number of singular equations " << nsing;
416  std::list<int64_t>::iterator it = step->Singular().begin();
417  if(nsing) sout << "\nSingular modes ";
418  while(it != step->Singular().end())
419  {
420  sout << *it << " ";
421  it++;
422  }
423  if(nsing) sout << std::endl;
424  LOGPZ_WARN(logger,sout.str())
425  }
426 #endif
427 #ifdef LOG4CXX
428  if (logger->isDebugEnabled())
429  {
430  std::stringstream sout;
431  sout << "Solution norm " << Norm(fSolution) << std::endl;
432  fSolution.Print("delu",sout);
433  LOGPZ_DEBUG(logger,sout.str())
434  }
435 #endif
438 
439 }
440 
442  if(fCompMesh) {
444  }
445 }
446 
447 void TPZAnalysis::Print( const std::string &name, std::ostream &out) {
448  out<<endl<<name<<endl;
449  if (!fCompMesh) {
450  out << "No computational mesh\n";
451  }
452  else
453  {
454  int64_t i,nelements = fCompMesh->ConnectVec().NElements();
455  for(i=0;i<nelements;i++) {
456  TPZConnect &gnod = fCompMesh->ConnectVec()[i];
457  if(gnod.SequenceNumber()!=-1) {
458  out << "Connect index " << i << endl;
459  gnod.Print(*fCompMesh,out);
460  }
461  }
462  }
463  fSolution.Print("fSolution",out);
464  if (fCompMesh) {
466  }
467 }
468 
469 
470 void TPZAnalysis::PostProcess(TPZVec<REAL> &ervec, std::ostream &out) {
471  int64_t i;
472  //TPZVec<REAL> ux((int) neq);
473  //TPZVec<REAL> sigx((int) neq);
475  TPZManVector<REAL,10> values2(10,0.);
478  TPZManVector<REAL,10> errors(10);
479  errors.Fill(0.0);
480  int64_t nel = elvec.NElements();
481  int matId0 = 0;
482  for(i=0;i<nel;i++) {
483  TPZCompEl *cel = elvec[i];
484  if(!cel) continue;
485  matId0=cel->Material()->Id();
486  if(matId0 > 0)
487  break;
488  }
489  bool lastEl=false;
490  for(i=0;i<nel;i++) {
491  TPZCompEl *el = (TPZCompEl *) elvec[i];
492  if(el) {
493  errors.Fill(0.0);
494  TPZGeoEl *gel = el->Reference();
495  if(gel->Dimension() != fCompMesh->Dimension()) continue;
496  el->EvaluateError(fExact, errors, 0);
497  if(matId0==el->Material()->Id()){
498  for(int ier = 0; ier < errors.NElements(); ier++) values[ier] += errors[ier] * errors[ier];
499  lastEl=false;
500  }
501  else {
502  for(int ier = 0; ier < errors.NElements(); ier++) values2[ier] += errors[ier] * errors[ier];
503  lastEl=true;
504  }
505  }
506  }
507  int nerrors = errors.NElements();
508  ervec.Resize(2*nerrors);
509  ervec.Fill(-10.0);
510 
511  if (nerrors==4) {
512  if(lastEl){
513  out << endl << "############" << endl;
514  out << endl << "L2 Norm for pressure = " << sqrt(values2[0]) << endl;
515  out << endl << "L2 Norm for flux = " << sqrt(values2[1]) << endl;
516  out << endl << "L2 Norm for divergence = " << sqrt(values2[2]) <<endl;
517  out << endl << "Hdiv Norm for flux = " << sqrt(values2[3]) <<endl;
518 
519  out << endl << "############" << endl;
520  out << endl << "true_error (Norma H1) = " << sqrt(values[0]) << endl;
521  out << endl << "L2_error (Norma L2) = " << sqrt(values[1]) << endl;
522  out << endl << "estimate (Semi-norma H1) = " << sqrt(values[2]) <<endl;
523  }
524  else{
525  out << endl << "############" << endl;
526  out << endl << "L2 Norm for pressure = " << sqrt(values[0]) << endl;
527  out << endl << "L2 Norm for flux = " << sqrt(values[1]) << endl;
528  out << endl << "L2 Norm for divergence = " << sqrt(values[2]) <<endl;
529  out << endl << "Hdiv Norm for flux = " << sqrt(values[3]) <<endl;
530 
531  out << endl << "############" << endl;
532  out << endl << "true_error (Norma H1) = " << sqrt(values2[0]) << endl;
533  out << endl << "L2_error (Norma L2) = " << sqrt(values2[1]) << endl;
534  out << endl << "estimate (Semi-norma H1) = " << sqrt(values2[2]) <<endl;
535  }
536  }
537  else {
538  if(lastEl){
539  out << endl << "############" << endl;
540  out << endl << "L2 Norm for pressure = " << sqrt(values[0]) << endl;
541  out << endl << "L2 Norm for flux = " << sqrt(values[1]) << endl;
542  out << endl << "L2 Norm for divergence = " << sqrt(values[2]) <<endl;
543  out << endl << "Hdiv Norm for flux = " << sqrt(values[3]) <<endl;
544 
545  out << endl << "############" << endl;
546  out << endl << "true_error (Norma H1) = " << sqrt(values2[0]) << endl;
547  out << endl << "L2_error (Norma L2) = " << sqrt(values2[1]) << endl;
548  out << endl << "estimate (Semi-norma H1) = " << sqrt(values2[2]) <<endl;
549  }
550  else{
551  out << endl << "############" << endl;
552  out << endl << "L2 Norm for pressure = " << sqrt(values2[0]) << endl;
553  out << endl << "L2 Norm for flux = " << sqrt(values2[1]) << endl;
554  out << endl << "L2 Norm for divergence = " << sqrt(values2[2]) <<endl;
555  out << endl << "Hdiv Norm for flux = " << sqrt(values2[3]) <<endl;
556 
557  out << endl << "############" << endl;
558  out << endl << "true_error (Norma H1) = " << sqrt(values[0]) << endl;
559  out << endl << "L2_error (Norma L2) = " << sqrt(values[1]) << endl;
560  out << endl << "estimate (Semi-norma H1) = " << sqrt(values[2]) <<endl;
561  }
562 
563  for(i=0;i<nerrors;i++) {
564  ervec[i] = sqrt(values[i]);
565  }
566  for(i=nerrors;i<2*nerrors;i++){
567  ervec[i] = sqrt(values2[i-nerrors]);
568  }
569  }
570  return;
571 }
572 
573 void TPZAnalysis::PostProcessError(TPZVec<REAL> &ervec, bool store_error, std::ostream &out ){
574  if(!fNthreadsError){
575  PostProcessErrorSerial(ervec, store_error, out);
576  }
577  else{
578  PostProcessErrorParallel(ervec, store_error, out);
579  }
580 }
581 
582 #ifdef USING_BOOST
583 #include "boost/date_time/posix_time/posix_time.hpp"
584 #endif
585 
587 
588  int64_t neq = fCompMesh->NEquations();
590  const int64_t ncompel = elvec.NElements();
591  elvecToComputeError.Resize(ncompel);
592  int64_t i, nel = elvec.NElements();
593  int64_t nelToCompute = 0;
594  for(i=0;i<nel;i++) {
595  TPZCompEl *el = (TPZCompEl *) elvec[i];
596  if(el) {
597  TPZMaterial *mat = el->Material();
598  TPZBndCond *bc = dynamic_cast<TPZBndCond *>(mat);
599  if(!bc){
600  elvecToComputeError[nelToCompute] = el;
601  nelToCompute++;
602  }
603  }//if(el)
604  }//i
605 
606  elvecToComputeError.Resize(nelToCompute);
607 
608 }
609 
611 {
612  ThreadData *data = (ThreadData *) datavoid;
613  const int64_t nelem = data->fElvec.NElements();
614  TPZManVector<REAL,10> errors(10);
615 
616  // Getting unique id for each thread
617  PZ_PTHREAD_MUTEX_LOCK(&data->fGetUniqueId,"TPZAnalysis::ThreadData::ThreadWork");
618  const int64_t myid = data->ftid;
619  data->ftid++;
620  PZ_PTHREAD_MUTEX_UNLOCK(&data->fGetUniqueId,"TPZAnalysis::ThreadData::ThreadWork");
621 
622 
623  do{
624  PZ_PTHREAD_MUTEX_LOCK(&data->fAccessElement,"TPZAnalysis::ThreadData::ThreadWork");
625  const int64_t iel = data->fNextElement;
626  data->fNextElement++;
627  PZ_PTHREAD_MUTEX_UNLOCK(&data->fAccessElement,"TPZAnalysis::ThreadData::ThreadWork");
628 
629  // For all the elements it tries to get after the last one
630  if ( iel >= nelem ) continue;
631 
632  TPZCompEl *cel = data->fElvec[iel];
633 
634  cel->EvaluateError(data->fExact, errors, data->fStoreError);
635 
636  const int nerrors = errors.NElements();
637  data->fvalues[myid].Resize(nerrors, 0.);
638 
639  //PZ_PTHREAD_MUTEX_LOCK(&data->fGetUniqueId,"TPZAnalysis::ThreadData::ThreadWork");
640  //std::cout << "size of fvalues[" << myid << "] = " << data->fvalues[myid].NElements() << std::endl;
641  for(int ier = 0; ier < nerrors; ier++)
642  {
643  (data->fvalues[myid])[ier] += errors[ier] * errors[ier];
644  }
645  //PZ_PTHREAD_MUTEX_UNLOCK(&data->fGetUniqueId,"TPZAnalysis::ThreadData::ThreadWork");
646 
647 
648  } while (data->fNextElement < nelem);
649  return data;
650 }
651 
652 void TPZAnalysis::PostProcessErrorParallel(TPZVec<REAL> &ervec, bool store_error, std::ostream &out ){ //totto
653 
655  const int numthreads = this->fNthreadsError;
656  TPZVec<pthread_t> allthreads(numthreads);
657 
659 
660 #ifdef USING_BOOST
661  boost::posix_time::ptime tsim1 = boost::posix_time::microsec_clock::local_time();
662 #endif
664 #ifdef USING_BOOST
665  boost::posix_time::ptime tsim2 = boost::posix_time::microsec_clock::local_time();
666  std::cout << "Total wall time of CreateListOfCompElsToComputeError = " << tsim2 - tsim1 << " s" << std::endl;
667 #endif
668 
669 
670  ThreadData threaddata(elvec,store_error, this->fExact);
671  threaddata.fvalues.Resize(numthreads);
672  for(int iv = 0 ; iv < numthreads ; iv++){
673  threaddata.fvalues[iv].Resize(10);
674  threaddata.fvalues[iv].Fill(0.0);
675  }
676 
677 #ifdef USING_BOOST
678  boost::posix_time::ptime tthread1 = boost::posix_time::microsec_clock::local_time();
679 #endif
680 
681  for(int itr=0; itr<numthreads; itr++)
682  {
683  PZ_PTHREAD_CREATE(&allthreads[itr], NULL,ThreadData::ThreadWork, &threaddata, __FUNCTION__);
684  }
685 
686  for(int itr=0; itr<numthreads; itr++)
687  {
688  PZ_PTHREAD_JOIN(allthreads[itr], NULL, __FUNCTION__);
689  }
690 
691 #ifdef USING_BOOST
692  boost::posix_time::ptime tthread2 = boost::posix_time::microsec_clock::local_time();
693  std::cout << "Total wall time of ThreadWork = " << tthread2 - tthread1 << " s" << std::endl;
694 #endif
695 
696 
697  // Sanity check. There should be number of ids equal to number of threads
698  if(threaddata.ftid != numthreads){
699  DebugStop();
700  }
701 
702 
704  // Assuming the first is equal to the others
705  const int nerrors = threaddata.fvalues[0].NElements();
706  values.Resize(nerrors,0);
707  // Summing up all the values of all threads
708  for(int it = 0 ; it < numthreads ; it++){
709  for(int ir = 0 ; ir < nerrors ; ir++){
710  values[ir] += (threaddata.fvalues[it])[ir];
711  }
712  }
713 
714  //const int nerrors = values.NElements();
715  ervec.Resize(nerrors);
716  ervec.Fill(-10.0);
717 
718  if (nerrors < 3) {
719  PZError << endl << "TPZAnalysis::PostProcess - At least 3 norms are expected." << endl;
720  out<<endl<<"############"<<endl;
721 
722 #ifdef PZDEBUG
723  for(int ier = 0; ier < nerrors; ier++)
724  out << endl << "error " << ier << " = " << sqrt(values[ier]);
725 #endif
726  }
727  else{
728 #ifdef PZDEBUG
729  out << "############" << endl;
730  out <<"Norma H1 or L2 -> p = " << sqrt(values[0]) << endl;
731  out <<"Norma L2 or L2 -> u = " << sqrt(values[1]) << endl;
732  out << "Semi-norma H1 or L2 -> div = " << sqrt(values[2]) <<endl;
733  for(int ier = 3; ier < nerrors; ier++)
734  out << "other norms = " << sqrt(values[ier]) << endl;
735 #endif
736  }
737 
738  // Returns the calculated errors.
739  for(int i=0;i<nerrors;i++)
740  ervec[i] = sqrt(values[i]);
741  return;
742 
743 }
744 
745 #include "pzsubcmesh.h"
746 
747 void TPZAnalysis::PostProcessErrorSerial(TPZVec<REAL> &ervec, bool store_error, std::ostream &out ){
748 
749  int64_t neq = fCompMesh->NEquations();
750  TPZVec<REAL> ux(neq);
751  TPZVec<REAL> sigx(neq);
754  TPZGeoMesh *gmesh = fCompMesh->Reference();
755  int64_t i, nel = elvec.NElements();
756  int64_t nelgeom = gmesh->NElements();
757  TPZFMatrix<REAL> elvalues(nelgeom,10,0.);
759  // SetExact(&Exact);
760  TPZManVector<REAL,10> errors(10);
761  errors.Fill(0.0);
762  for(i=0;i<nel;i++) {
763  TPZCompEl *el = (TPZCompEl *) elvec[i];
764  if(el) {
765  TPZMaterial *mat = el->Material();
766  TPZBndCond *bc = dynamic_cast<TPZBndCond *>(mat);
767  if(!mat || (!bc && mat->Dimension() == fCompMesh->Dimension()))
768  {
769  errors.Fill(0.0);
770 
771  el->EvaluateError(fExact, errors, store_error);
772  int nerrors = errors.NElements();
773  values.Resize(nerrors, 0.);
774  elvalues.Resize(nelgeom,nerrors);
775  for(int ier = 0; ier < nerrors; ier++)
776  {
777  if(el->Reference()){
778  elvalues(el->Reference()->Index(),ier) = errors[ier];
779  }
780 
781  values[ier] += errors[ier] * errors[ier];
782 
783  }
784  }
785  }
786  }
787 
788 
789  int nerrors = errors.NElements();
790  ervec.Resize(nerrors);
791  ervec.Fill(-10.0);
792 
793  if (nerrors < 3) {
794  PZError << endl << "TPZAnalysis::PostProcess - At least 3 norms are expected." << endl;
795  out<<endl<<"############"<<endl;
796  for(int ier = 0; ier < nerrors; ier++)
797  out << endl << "error " << ier << " = " << sqrt(values[ier]);
798  }
799  else{
800 #ifdef PZDEBUG
801  out << "############" << endl;
802  out <<"Norma H1 or L2 -> p = " << sqrt(values[0]) << endl;
803  out <<"Norma L2 or L2 -> u = " << sqrt(values[1]) << endl;
804  out << "Semi-norma H1 or L2 -> div = " << sqrt(values[2]) <<endl;
805  for(int ier = 3; ier < nerrors; ier++)
806  out << "other norms = " << sqrt(values[ier]) << endl;
807 #endif
808  }
809 #ifdef LOG4CXX
810  if(loggerError->isDebugEnabled())
811  {
812  std::stringstream sout;
813  elvalues.Print("Errors = ",sout,EMathematicaInput);
814  LOGPZ_DEBUG(loggerError,sout.str())
815  }
816 #endif
817  // Returns the calculated errors.
818  for(i=0;i<nerrors;i++)
819  ervec[i] = sqrt(values[i]);
820  return;
821 }
822 
823 void TPZAnalysis::PostProcessTable( TPZFMatrix<REAL> &,std::ostream & )//pos,out
824 {
826  int64_t nel = elvec.NElements();
827  for(int64_t i=0;i<nel;i++) {
828  //TPZCompEl *el = (TPZCompEl *) elvec[i];
829  //if(el) el->PrintTable(fExact,pos,out);
830  }
831  return;
832 }
833 
834 void TPZAnalysis::ShowShape(const std::string &plotfile, TPZVec<int64_t> &equationindices)
835 {
836 
837  SetStep(1);
838  TPZStack<std::string> scalnames,vecnames;
839  TPZMaterial *mat = fCompMesh->MaterialVec().begin()->second;
840  int nstate = mat->NStateVariables();
841  if (nstate == 1) {
842  scalnames.Push("Solution");
843  }
844  else
845  {
846  vecnames.Push("Solution");
847  }
848  DefineGraphMesh(fCompMesh->Dimension(), scalnames, vecnames, plotfile);
850 
851  int neq = equationindices.size();
852  TPZFMatrix<STATE> solkeep(fSolution);
853  fSolution.Zero();
854  for (int ieq = 0; ieq < neq; ieq++) {
855  fSolution(equationindices[ieq],0) = 1.;
856  LoadSolution();
858  PostProcess(porder+1);
859  fSolution.Zero();
860  }
861  fSolution = solkeep;
862  LoadSolution();
863 }
864 
865 void TPZAnalysis::ShowShape(const std::string &plotfile, TPZVec<int64_t> &equationindices, int matid, const TPZVec<std::string> &varname)
866 {
867  TPZMaterial *mat = fCompMesh->FindMaterial(matid);
868  if(!mat) DebugStop();
869 
870  int n_varnames = varname.size();
871  TPZStack<std::string> scalnames,vecnames;
872  for(int i_var = 0 ; i_var<n_varnames ; i_var++){
873  int varindex = mat->VariableIndex(varname[i_var]);
874  if(varindex == -1) DebugStop();
875  SetStep(1);
876 
877  int nstate = mat->NSolutionVariables(varindex);
878  if (nstate == 1) {
879  scalnames.Push(varname[i_var]);
880  }
881  else
882  {
883  vecnames.Push(varname[i_var]);
884  }
885  }
886 
887  DefineGraphMesh(fCompMesh->Dimension(), scalnames, vecnames, plotfile);
889 
890  int neq = equationindices.size();
891  TPZFMatrix<STATE> solkeep(fSolution);
892  fSolution.Zero();
893  for (int ieq = 0; ieq < neq; ieq++) {
894  fSolution(equationindices[ieq],0) = 1.;
895  LoadSolution();
897 
898  PostProcess(0);
899  fSolution.Zero();
900  }
901  fSolution = solkeep;
902  LoadSolution();
903 
904 }
905 
906 
907 
908 void TPZAnalysis::LoadShape(double ,double , int64_t ,TPZConnect* start){
909  //void TPZAnalysis::LoadShape(double dx,double dy, int numelem,TPZConnect* start){
910  Assemble();
911  fRhs.Zero();
912  fSolution.Zero();
913 
914 }
915 
916 #ifdef USING_BOOST
917 #include "boost/date_time/posix_time/posix_time.hpp"
918 #endif
919 
920 void TPZAnalysis::Run(std::ostream &out)
921 {
922  int64_t neq = fCompMesh->NEquations();
923 
924  if(neq > 20000)
925  {
926  std::cout << "Entering Assemble Equations\n";
927  std::cout.flush();
928  }
929 #ifdef USING_BOOST
930  boost::posix_time::ptime t1 = boost::posix_time::microsec_clock::local_time();
931 #endif
932  Assemble();
933 
934  if(neq > 20000)
935  {
936  std::cout << "Entering Solve\n";
937  std::cout.flush();
938  }
939 
940 #ifdef USING_BOOST
941  boost::posix_time::ptime t2 = boost::posix_time::microsec_clock::local_time();
942 #endif
943  Solve();
944 
945 #ifdef USING_BOOST
946  boost::posix_time::ptime t3 = boost::posix_time::microsec_clock::local_time();
947  std::cout << "Time for assembly " << t2-t1 << " Time for solving " << t3-t2 << std::endl;
948 #endif
949 }
950 
952 void TPZAnalysis::DefineGraphMesh(int dimension, const TPZVec<std::string> &scalnames, const TPZVec<std::string> &vecnames, const std::string &plotfile){
953  std::set<int> matids;
954  IdentifyPostProcessingMatIds(dimension, matids);
955  this->DefineGraphMesh(dimension, matids, scalnames, vecnames, plotfile);
956 
957 }
959 void TPZAnalysis::DefineGraphMesh(int dimension, const TPZVec<std::string> &scalnames, const TPZVec<std::string> &vecnames, const TPZVec<std::string> &tensnames, const std::string &plotfile){
960  std::set<int> matids;
961  IdentifyPostProcessingMatIds(dimension, matids);
962  this->DefineGraphMesh(dimension, matids, scalnames, vecnames, tensnames, plotfile);
963 }
964 
965 void TPZAnalysis::DefineGraphMesh(int dim, const std::set<int> & matids , const TPZVec<std::string> &scalnames, const TPZVec<std::string> &vecnames, const TPZVec<std::string> &tensnames, const std::string &plotfile) {
966 
967  int dim1 = dim - 1;
968  if (!fCompMesh || matids.size() == 0) {
969  cout << "TPZAnalysis::DefineGraphMesh nothing to post-process\n";
970  return;
971  }
972 
973  if (fGraphMesh[dim1]) delete fGraphMesh[dim1];
974  fScalarNames[dim1] = scalnames;
975  fVectorNames[dim1] = vecnames;
976  int posplot = plotfile.rfind(".plt");
977  int64_t filelength = plotfile.size();
978  if (filelength - posplot == 3) {
979  if(tensnames.size() != 0)
980  {
981  std::cout << "Tensors are not beint post-process for file = " << plotfile << std::endl;
982  }
983  fGraphMesh[dim1] = new TPZV3DGraphMesh(fCompMesh, dim, matids, scalnames, vecnames);
984  } else {
985  int posdx = plotfile.rfind(".dx");
986  if (filelength - posdx == 3) {
987  if(tensnames.size() != 0) {
988  std::cout << "Tensors are not beint post-process for file = " << plotfile << std::endl;
989 
990  }
991  fGraphMesh[dim1] = new TPZDXGraphMesh(fCompMesh, dim, matids, scalnames, vecnames);
992  } else {
993  int pospos = plotfile.rfind(".pos");
994  if (filelength - pospos == 3) {
995  if(tensnames.size() != 0) {
996  std::cout << "Tensors are not beint post-process for file = " << plotfile << std::endl;
997  }
998  fGraphMesh[dim1] = new TPZMVGraphMesh(fCompMesh, dim, matids, scalnames, vecnames);
999  } else {
1000  int posvtk = plotfile.rfind(".vtk");
1001  if (filelength - posvtk == 4) {
1002  fGraphMesh[dim1] = new TPZVTKGraphMesh(fCompMesh, dim, matids, scalnames, vecnames, tensnames);
1003  } else {
1004  cout << "grafgrid was not created\n";
1005  fGraphMesh[dim1] = 0;
1006  }
1007  }
1008  }
1009  }
1010  if (fGraphMesh[dim1]) {
1011  fGraphMesh[dim1]->SetFileName(plotfile);
1012  }
1013 }
1014 
1015 void TPZAnalysis::DefineGraphMesh(int dim, const std::set<int> & matids, const TPZVec<std::string> &scalnames, const TPZVec<std::string> &vecnames, const std::string &plotfile){
1016  TPZVec<std::string> tensnames;
1017  this->DefineGraphMesh(dim,matids, scalnames, vecnames, tensnames, plotfile);
1018 }
1019 
1020 
1021 
1023  for(int i = 0; i < 3; i++){
1024  if ( this->fGraphMesh[i] ){
1025  delete this->fGraphMesh[i];
1026  this->fGraphMesh[i] = NULL;
1027  }
1028  }
1029 }
1030 
1031 void TPZAnalysis::PostProcess(int resolution) {
1032  int dim;
1033  for(dim=1; dim<=3; dim++) {
1034  PostProcess(resolution, dim);
1035  }
1036 }
1037 
1039 void TPZAnalysis::IdentifyPostProcessingMatIds(int dimension, std::set<int> & matids){
1040  std::map<int, TPZMaterial * >::iterator matit;
1041  for (matit = fCompMesh->MaterialVec().begin(); matit != fCompMesh->MaterialVec().end(); matit++) {
1042 
1043  TPZMaterial *mat = matit->second;
1044  TPZBndCond *bc = dynamic_cast<TPZBndCond *> (mat);
1045  TPZLagrangeMultiplier *lag = dynamic_cast<TPZLagrangeMultiplier *> (mat);
1046  if (mat && !bc && !lag && mat->Dimension() == dimension){
1047  matids.insert(mat->Id());
1048  }
1049  }
1050  if (matids.size() == 0) {
1051  std::cout << __PRETTY_FUNCTION__ << " No materials were identified to perform post-processing. \n";
1052  DebugStop();
1053  return;
1054  }
1055 }
1056 
1057 void TPZAnalysis::PostProcess(int resolution, int dimension){
1058  int dim1 = dimension-1;
1059  if(!fGraphMesh[dim1]) return;
1060 
1061  fGraphMesh[dim1]->SetCompMesh(fCompMesh,fGraphMesh[dim1]->MaterialIds());
1062  fGraphMesh[dim1]->SetResolution(resolution);
1063  fGraphMesh[dim1]->DrawMesh(1);
1065  fStep++;
1066 }
1067 
1068 void TPZAnalysis::AnimateRun(int64_t num_iter, int steps, TPZVec<std::string> &scalnames,
1069  TPZVec<std::string> &vecnames, const std::string &plotfile) {
1070  Assemble();
1071 
1072  int64_t numeq = fCompMesh->NEquations();
1073  if(fRhs.Rows() != numeq ) return;
1074 
1075  TPZFMatrix<STATE> residual(fRhs);
1076  int dim = HighestDimension();
1077  std::set<int> matids;
1078  IdentifyPostProcessingMatIds(dim, matids);
1079  TPZDXGraphMesh gg(fCompMesh,dim,matids,scalnames,vecnames) ;
1080  gg.SetFileName(plotfile);
1081  gg.SetResolution(0);
1082  gg.DrawMesh(num_iter);
1083 
1084  int64_t i;
1085  for(i=1; i<=num_iter;i+=steps){
1086 
1087 
1089  sol.ShareMatrix(Solver());
1090  sol.SetJacobi(i,0.,0);
1091  SetSolver(sol);
1093 
1095  gg.DrawSolution(i-1,0);
1096  }
1097 }
1098 
1100  int dim = 0;
1101  std::map<int, TPZMaterial * >::iterator matit;
1102  for(matit = fCompMesh->MaterialVec().begin(); matit != fCompMesh->MaterialVec().end(); matit++)
1103  {
1104  if(!matit->second) continue;
1105  dim = matit->second->Dimension() > dim ? matit->second->Dimension() : dim;
1106  }
1107  return dim;
1108 }
1109 
1111 fGeoElId(), fCompElPtr(), fDimension(-1), fLocations(), fVariableNames() {
1112 }
1113 
1115  return Hash("TPZAnalysis::TTablePostProcess");
1116 }
1117 
1118 void TPZAnalysis::TTablePostProcess::Write(TPZStream &buf, int withclassid) const {
1119  buf.Write(fGeoElId);
1121  buf.Write(&fDimension);
1122  buf.Write(fLocations);
1123  buf.Write(fVariableNames);
1124 }
1125 
1127  buf.Read(fGeoElId);
1128  buf.ReadPointers(fCompElPtr);
1129  buf.Read(&fDimension);
1130  buf.Read(fLocations);
1131  buf.Read(fVariableNames);
1132 }
1133 
1134 
1136  fDimension = -1;
1137 }
1138 
1141  fTable.fGeoElId = GeoElIds;
1142  fTable.fLocations = points;
1143  int64_t numel = GeoElIds.NElements();
1144  fTable.fCompElPtr.Resize(numel);
1145  int64_t iel;
1146  for(iel=0; iel<numel; iel++) {
1147  TPZGeoEl *gel = (TPZGeoEl *) fGeoMesh->FindElement(GeoElIds[iel]);
1148  fTable.fCompElPtr[iel] = (gel) ? gel->Reference() : 0;
1149  }
1150 }
1151 
1153  fTable.fVariableNames = varnames;
1154 }
1155 
1156 void TPZAnalysis::PrePostProcessTable(std::ostream &out_file){
1157  TPZCompEl *cel;
1158  int numvar = fTable.fVariableNames.NElements();
1159  for(int iv=0; iv<numvar; iv++) {
1160  int64_t numel = fTable.fCompElPtr.NElements();
1161  for(int64_t iel=0; iel<numel; iel++) {
1162  cel = (TPZCompEl *) fTable.fCompElPtr[iel];
1163  if(cel) cel->PrintTitle(fTable.fVariableNames[iv].c_str(),out_file);
1164  }
1165  }
1166  out_file << endl;
1167  int dim;
1169  for(dim=1; dim<fTable.fDimension+1; dim++) {
1170  for(int iv=0; iv<numvar; iv++) {
1171  int64_t numel = fTable.fCompElPtr.NElements();
1172  for(int64_t iel=0; iel<numel; iel++) {
1173  int d;
1174  for(d=0; d<fTable.fDimension; d++) {
1175  point[d] = fTable.fLocations[iel*fTable.fDimension+d];
1176  }
1177  cel = (TPZCompEl *) fTable.fCompElPtr[iel];
1178  if(cel) cel->PrintCoordinate(point,dim,out_file);
1179  }
1180  }
1181  out_file << endl;
1182  }
1183 }
1184 
1185 void TPZAnalysis::PostProcessTable(std::ostream &out_file) {
1187  int numvar = fTable.fVariableNames.NElements();
1188  TPZCompEl *cel;
1189  for(int iv=0; iv<numvar; iv++) {
1190  int64_t numel = fTable.fCompElPtr.NElements();
1191  for(int64_t iel=0; iel<numel; iel++) {
1192  int d;
1193  for(d=0; d<fTable.fDimension; d++) {
1194  point[d] = fTable.fLocations[iel*fTable.fDimension+d];
1195  }
1196  cel = (TPZCompEl *) fTable.fCompElPtr[iel];
1197  if(cel) cel->PrintSolution(point,fTable.fVariableNames[iv].c_str(),out_file);
1198  }
1199  }
1200  out_file << endl;
1201 }
1203  if(fSolver) delete fSolver;
1204  fSolver = (TPZMatrixSolver<STATE> *) solver.Clone();
1205 }
1206 
1208 {
1209  if(!fSolver || !fSolver->Matrix())
1210  {
1211 #ifndef BORLAND
1212  cout << __FUNCTION__ << " called with uninitialized stiffness matrix\n";
1213 #else
1214  cout << "TPZMatrixSolver *TPZAnalysis::BuildPreconditioner" << " called with uninitialized stiffness matrix\n";
1215 #endif
1216 
1217  }
1218  if(preconditioner == EJacobi)
1219  {
1220  }
1221  else
1222  {
1223  TPZNodesetCompute nodeset;
1224  TPZStack<int64_t> elementgraph,elementgraphindex;
1225  int64_t nindep = fCompMesh->NIndependentConnects();
1226  int64_t neq = fCompMesh->NEquations();
1227  fCompMesh->ComputeElGraph(elementgraph,elementgraphindex);
1228  int64_t nel = elementgraphindex.NElements()-1;
1229  TPZMetis renum(nel,nindep);
1230  renum.ConvertGraph(elementgraph,elementgraphindex,nodeset.Nodegraph(),nodeset.Nodegraphindex());
1231  nodeset.AnalyseGraph();
1232 
1233  TPZStack<int64_t> blockgraph,blockgraphindex;
1234  switch(preconditioner)
1235  {
1236  case EJacobi:
1237  return 0;
1238  case EBlockJacobi:
1239  nodeset.BuildNodeGraph(blockgraph,blockgraphindex);
1240  break;
1241  case EElement:
1242  nodeset.BuildElementGraph(blockgraph,blockgraphindex);
1243  break;
1244  case ENodeCentered:
1245  nodeset.BuildVertexGraph(blockgraph,blockgraphindex);
1246  break;
1247  }
1248  TPZStack<int64_t> expblockgraph,expblockgraphindex;
1249 
1250  nodeset.ExpandGraph(blockgraph,blockgraphindex,fCompMesh->Block(),expblockgraph,expblockgraphindex);
1251 #ifdef LOG4CXX
1252 #ifdef PZDEBUG2
1253  if (logger->isDebugEnabled())
1254  {
1255  std::map<int64_t,int64_t> blocksizes;
1256  int64_t i;
1257  int64_t totalsize = 0;
1258  for(i=0; i< expblockgraphindex.NElements()-1;i++)
1259  {
1260  int64_t bls = expblockgraphindex[i+1]-expblockgraphindex[i];
1261  blocksizes[bls]++;
1262  totalsize += bls*bls;
1263  }
1264  std::map<int64_t,int64_t>::iterator it;
1265  std::stringstream sout;
1266  sout << __PRETTY_FUNCTION__ << " total size of allocation " << totalsize << std::endl;
1267  for(it=blocksizes.begin(); it != blocksizes.end(); it++)
1268  {
1269  sout << "block size " << (*it).first << " number of blocks " << (*it).second << std::endl;
1270  }
1271  LOGPZ_DEBUG(logger,sout.str().c_str());
1272  }
1273 #endif
1274 #endif
1275  if(overlap && !(preconditioner == EBlockJacobi))
1276  {
1277  TPZSparseBlockDiagonal<STATE> *sp = new TPZSparseBlockDiagonal<STATE>(expblockgraph,expblockgraphindex,neq);
1279  step->SetDirect(ELU);
1280  step->SetReferenceMatrix(fSolver->Matrix());
1281  return step;
1282  }
1283  else if (overlap)
1284  {
1287  blstr.AssembleBlockDiagonal(*sp);
1289  step->SetDirect(ELU);
1290  return step;
1291  }
1292  else
1293  {
1294  TPZVec<int> blockcolor;
1295  int numcolors = nodeset.ColorGraph(expblockgraph,expblockgraphindex,neq,blockcolor);
1296  return BuildSequenceSolver(expblockgraph,expblockgraphindex,neq,numcolors,blockcolor);
1297  }
1298  }
1299  return 0;
1300 }
1301 
1304 {
1305  TPZVec<TPZMatrix<STATE> *> blmat(numcolors);
1306  TPZVec<TPZStepSolver<STATE> *> steps(numcolors);
1307  int c;
1308  for(c=0; c<numcolors; c++)
1309  {
1310  blmat[c] = new TPZSparseBlockDiagonal<STATE>(graph,graphindex, neq, c, colors);
1311  steps[c] = new TPZStepSolver<STATE>(blmat[c]);
1312  steps[c]->SetDirect(ELU);
1313  steps[c]->SetReferenceMatrix(fSolver->Matrix());
1314  }
1315  if(numcolors == 1) return steps[0];
1317  result->ShareMatrix(*fSolver);
1318  for(c=numcolors-1; c>=0; c--)
1319  {
1320  result->AppendSolver(*steps[c]);
1321  }
1322  for(c=1; c<numcolors; c++)
1323  {
1324  steps[c]->SetReferenceMatrix(0);
1325  result->AppendSolver(*steps[c]);
1326  }
1327  for(c=0; c<numcolors; c++)
1328  {
1329  delete steps[c];
1330  }
1331  return result;
1332 }
1333 
1335 TPZVec<STATE> TPZAnalysis::Integrate(const std::string &varname, const std::set<int> &matids)
1336 {
1337  // the postprocessed index of the varname for each material id
1338  std::map<int,int> variableids;
1339  int nvars = 0;
1340 
1341  std::map<int,TPZMaterial *>::iterator itmap;
1342  for (itmap = fCompMesh->MaterialVec().begin(); itmap != fCompMesh->MaterialVec().end(); itmap++) {
1343  if (matids.find(itmap->first) != matids.end()) {
1344  variableids[itmap->first] = itmap->second->VariableIndex(varname);
1345  nvars = itmap->second->NSolutionVariables(variableids[itmap->first]);
1346  }
1347  }
1348  TPZManVector<STATE,3> result(nvars,0.);
1349  int64_t nelem = fCompMesh->NElements();
1350  for (int64_t el=0; el<nelem; el++) {
1351  TPZCompEl *cel = fCompMesh->Element(el);
1352  if (!cel) {
1353  continue;
1354  }
1355  TPZGeoEl *gel = cel->Reference();
1356  if (!gel) {
1357  continue;
1358  }
1359  int matid = gel->MaterialId();
1360  if (matids.find(matid) == matids.end()) {
1361  continue;
1362  }
1363  TPZManVector<STATE,3> locres(nvars,0.);
1364  locres = cel->IntegrateSolution(variableids[matid]);
1365  for (int iv=0; iv<nvars; iv++)
1366  {
1367  result[iv] += locres[iv];
1368  }
1369  }
1370  return result;
1371 }
1372 
1374 static void ConnectSolution(int64_t cindex, TPZCompMesh *cmesh, TPZFMatrix<STATE> &glob, TPZVec<STATE> &sol)
1375 {
1376  int64_t seqnum = cmesh->ConnectVec()[cindex].SequenceNumber();
1377  int blsize = cmesh->Block().Size(seqnum);
1378  int position = cmesh->Block().Position(seqnum);
1379  sol.resize(blsize);
1380  for (int64_t i=position; i< position+blsize; i++) {
1381  sol[i-position] = glob(i,0);
1382  }
1383 }
1384 
1385 static STATE ConnectNorm(int64_t cindex, TPZCompMesh *cmesh, TPZFMatrix<STATE> &glob)
1386 {
1388  ConnectSolution(cindex, cmesh, glob, cvec);
1389  STATE norm = 0.;
1390  for (int64_t i=0; i<cvec.size(); i++) {
1391  norm += cvec[i]*cvec[i];
1392  }
1393  norm = sqrt(norm);
1394  return norm;
1395 }
1396 
1398 void TPZAnalysis::PrintVectorByElement(std::ostream &out, TPZFMatrix<STATE> &vec, REAL tol)
1399 {
1400  int64_t nel = fCompMesh->NElements();
1401  for (int64_t el=0; el<nel; el++) {
1402  TPZCompEl *cel = fCompMesh->Element(el);
1403  if (!cel) {
1404  continue;
1405  }
1406  int nc = cel->NConnects();
1407  int ic;
1408  for (ic=0; ic<nc; ic++) {
1409  int64_t cindex = cel->ConnectIndex(ic);
1410  TPZConnect &c = cel->Connect(ic);
1411  if(c.HasDependency() || c.IsCondensed())
1412  {
1413  continue;
1414  }
1415 #ifndef STATE_COMPLEX
1416  if (ConnectNorm(cindex, fCompMesh, vec) >= tol) {
1417  break;
1418  }
1419 #endif
1420  }
1421  // if all connects have norm below tol, do not print the element
1422  if (ic == nc) {
1423  continue;
1424  }
1425  bool hasgeometry = false;
1426  TPZManVector<REAL> xcenter(3,0.);
1427  TPZGeoEl *gel = cel->Reference();
1428  // if a geometric element exists, extract its center coordinate
1429  if (gel) {
1430  hasgeometry = true;
1431  TPZManVector<REAL,3> xicenter(gel->Dimension(),0.);
1432  gel->CenterPoint(gel->NSides()-1, xicenter);
1433  gel->X(xicenter,xcenter);
1434  }
1435  out << "CompEl " << el;
1436  if (hasgeometry) {
1437  out << " Gel " << gel->Index() << " matid " << gel->MaterialId() << " Center " << xcenter << std::endl;
1438  }
1439  for (ic = 0; ic<nc; ic++) {
1440  TPZManVector<STATE> connectsol;
1441  int64_t cindex = cel->ConnectIndex(ic);
1442  TPZConnect &c = fCompMesh->ConnectVec()[cindex];
1443  if(c.HasDependency() || c.IsCondensed()) {
1444  out << "connect " << ic << " is restrained\n";
1445  continue;
1446  }
1447  ConnectSolution(cindex, fCompMesh, vec, connectsol);
1448  for (int i=0; i<connectsol.size(); i++) {
1449  if (fabs(connectsol[i]) < tol) {
1450  connectsol[i] = 0.;
1451  }
1452  }
1453  out << ic << " index " << cindex << " values " << connectsol << std::endl;
1454  }
1455  }
1456 
1457 }
1458 
1460  return Hash("TPZAnalysis");
1461 }
1462 
1463 void TPZAnalysis::Write(TPZStream &buf, int withclassid) const{
1469  fRhs.Write(buf,withclassid);
1470  fSolution.Write(buf,withclassid);
1472  buf.Write(fScalarNames[0]);
1473  buf.Write(fScalarNames[1]);
1474  buf.Write(fScalarNames[2]);
1475  buf.Write(fVectorNames[0]);
1476  buf.Write(fVectorNames[1]);
1477  buf.Write(fVectorNames[2]);
1478  buf.Write(&fStep);
1479  buf.Write(&fTime);
1480  buf.Write(&fNthreadsError);
1482  TPZPersistenceManager::WritePointer(fRenumber.operator ->(), &buf);
1484  fTable.Write(buf,withclassid);
1485  buf.Write(fTensorNames[0]);
1486  buf.Write(fTensorNames[1]);
1487  buf.Write(fTensorNames[2]);
1488  //@TODOFran: How to persist fExact?
1489 }
1490 
1491 void TPZAnalysis::Read(TPZStream &buf, void *context){
1492  fGeoMesh = dynamic_cast<TPZGeoMesh*>(TPZPersistenceManager::GetInstance(&buf));
1494  fGraphMesh[0] = dynamic_cast<TPZGraphMesh*>(TPZPersistenceManager::GetInstance(&buf));
1495  fGraphMesh[1] = dynamic_cast<TPZGraphMesh*>(TPZPersistenceManager::GetInstance(&buf));
1496  fGraphMesh[2] = dynamic_cast<TPZGraphMesh*>(TPZPersistenceManager::GetInstance(&buf));
1497  fRhs.Read(buf,context);
1498  fSolution.Read(buf,context);
1500  buf.Read(fScalarNames[0]);
1501  buf.Read(fScalarNames[1]);
1502  buf.Read(fScalarNames[2]);
1503  buf.Read(fVectorNames[0]);
1504  buf.Read(fVectorNames[1]);
1505  buf.Read(fVectorNames[2]);
1506  buf.Read(&fStep);
1507  buf.Read(&fTime);
1508  buf.Read(&fNthreadsError);
1509  fStructMatrix = TPZAutoPointerDynamicCast<TPZStructMatrix>(TPZPersistenceManager::GetAutoPointer(&buf));
1510  fRenumber = TPZAutoPointerDynamicCast<TPZRenumbering>(TPZPersistenceManager::GetAutoPointer(&buf));
1511  fGuiInterface = TPZAutoPointerDynamicCast<TPZGuiInterface>(TPZPersistenceManager::GetAutoPointer(&buf));
1512  fTable.Read(buf,context);
1513  buf.Read(fTensorNames[0]);
1514  buf.Read(fTensorNames[1]);
1515  buf.Read(fTensorNames[2]);
1516  //@TODOFran: How to persist fExact?
1517 }
1518 
1519 TPZAnalysis::ThreadData::ThreadData(TPZAdmChunkVector<TPZCompEl *> &elvec, bool store_error, std::function<void (const TPZVec<REAL> &loc, TPZVec<STATE> &result, TPZFMatrix<STATE> &deriv)> f) : fNextElement(0), fvalues(0), fStoreError(store_error), fExact(f), ftid(0), fElvec(elvec){
1520  PZ_PTHREAD_MUTEX_INIT(&fAccessElement,NULL,"TPZAnalysis::ThreadData::ThreadData()");
1521  PZ_PTHREAD_MUTEX_INIT(&fGetUniqueId,NULL,"TPZAnalysis::ThreadData::ThreadData()");
1522 }
1523 
1524 
1526 {
1527  PZ_PTHREAD_MUTEX_DESTROY(&fAccessElement,"TPZStructMatrixOR::ThreadData::~ThreadData()");
1528  PZ_PTHREAD_MUTEX_DESTROY(&fGetUniqueId,"TPZStructMatrixOR::ThreadData::~ThreadData()");
1529 }
int64_t NElements() const
Number of computational elements allocated.
Definition: pzcmesh.h:169
pthread_mutex_t fGetUniqueId
Mutexes (to sum error)
Definition: pzanalysis.h:349
TPZVec< TPZCompEl * > fCompElPtr
Definition: pzanalysis.h:80
TPZMatrixSolver< STATE > * fSolver
Type of solver to be applied.
Definition: pzanalysis.h:52
virtual TPZVec< STATE > IntegrateSolution(int var) const
Compute the integral of a variable.
Definition: pzcompel.cpp:1054
TPZGeoMesh * Reference() const
Returns a pointer to the geometrical mesh associated.
Definition: pzcmesh.h:209
#define PZ_PTHREAD_MUTEX_UNLOCK(mutex, fn)
Definition: pz_pthread.h:79
void LoadShape(double dx, double dy, int64_t numelem, TPZConnect *nod)
Make assembling and clean the load and solution vectors.
Definition: pzanalysis.cpp:908
Represents a graphical mesh used for post processing purposes. Post processing.
Definition: pzgraphmesh.h:34
void AnalyseGraph()
Group the node graph as passed by the parameters.
Material which implements a Lagrange Multiplier.
Contains the TPZMVGraphMesh class which implements graphical mesh to MVGraph package.
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
Contains TPZAnalysis class which implements the sequence of actions to perform a finite element analy...
const int64_t numel
Number of elements to test.
Definition: pzsubcmesh.cpp:47
int Position(const int block_diagonal) const
Returns the position of first element block dependent on matrix diagonal.
Definition: pzblock.h:177
void SetElementGraph(TPZVec< int64_t > &elgraph, TPZVec< int64_t > &elgraphindex)
This method declares the element graph to the object.
void ResetMatrix() override
Resets current object.
Definition: pzsolve.cpp:50
virtual void SetFileName(const std::string &filename)
Sets the name of the output file.
Definition: pzdxmesh.cpp:418
virtual void Residual(const TPZFMatrix< TVar > &x, const TPZFMatrix< TVar > &rhs, TPZFMatrix< TVar > &res)
Computes res = rhs - this * x.
Definition: pzmatrix.h:827
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
Definition: pzconnect.h:30
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 void Solve()
Invert the stiffness matrix.
Definition: pzanalysis.cpp:352
void ShareMatrix(TPZMatrixSolver< TVar > &other)
Shares the current matrix with another object of same type.
Definition: pzsolve.cpp:57
void SetStructuralMatrix(TPZAutoPointer< TPZStructMatrix > strmatrix)
Set structural matrix as auto pointer for analysis.
Definition: pzanalysis.cpp:82
Implements Block Diagonal Structural Matrices. Structural Matrix.
Definition: pzbdstrmatrix.h:21
void Print(const std::string &name, std::ostream &out)
Print connect and solution information.
Definition: pzanalysis.cpp:447
virtual void PrintCoordinate(TPZVec< REAL > &point, int CoordinateIndex, std::ostream &out)
Prints one coordinate index corresponding to the point to the output stream.
Definition: pzcompel.cpp:380
void OptimizeBandwidth()
Sets the computer connection block number from the graphical connections block number otimization...
Definition: pzanalysis.cpp:195
Contains TPZSparseBlockDiagonal class which implements a block diagonal matrix where the blocks are n...
int MaterialId() const
Returns the material index of the element.
Definition: pzgeoel.h:250
TPZFMatrix< STATE > fSolution
Solution vector.
Definition: pzanalysis.h:50
clarg::argBool bc("-bc", "binary checkpoints", false)
virtual void PostProcessTable(std::ostream &out_file)
Print the solution related with the computational element vector in post process. ...
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
virtual void EvaluateError(std::function< void(const TPZVec< REAL > &loc, TPZVec< STATE > &val, TPZFMatrix< STATE > &deriv)> func, TPZVec< REAL > &errors, bool store_error)
Performs an error estimate on the elemen.
Definition: pzcompel.cpp:415
Implements renumbering for elements of a mesh. Utility.
Definition: pzmetis.h:17
void ConvertGraph(TPZVec< int64_t > &elgraph, TPZVec< int64_t > &elgraphindex, TPZManVector< int64_t > &nodegraph, TPZManVector< int64_t > &nodegraphindex)
Will convert an element graph defined by elgraph and elgraphindex into a node graph defined by nodegr...
virtual void UpdateFrom(TPZAutoPointer< TPZMatrix< TVar > > matrix) override
Updates the values of the current matrix based on the values of the matrix.
Definition: pzsolve.h:121
virtual void resize(const int64_t newsize)
Definition: pzvec.h:213
virtual void PrintSolution(TPZVec< REAL > &point, const char *VarName, std::ostream &out)
Prints the solution - sol - for the variable "VarName" at point specified in terms of the master elem...
Definition: pzcompel.cpp:358
TPZManVector< int64_t > & Nodegraphindex()
Implements the interface of the graphmesh to the OpenDX graphics package. Post processing.
Definition: pzdxmesh.h:17
int64_t NEquations()
This computes the number of equations associated with non-restrained nodes.
Definition: pzcmesh.cpp:721
int64_t NIndependentConnects()
Number of independent connect objects.
Definition: pzcmesh.cpp:1080
clarg::argInt dimension("-d", "Matrices dimension M x M", 1000)
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Contains the TPZVTKGraphMesh class which implements the graphical mesh to VTK environment.
void SaddlePermute()
Put the sequence number of the pressure connects after the seq number of the flux connects...
Definition: pzcmesh.cpp:2328
int fNthreadsError
Number of threads to be used for post-processing error.
Definition: pzanalysis.h:65
Contains declaration of TPZCompEl class which defines the interface of a computational element...
Templated vector implementation.
virtual void Resequence(TPZVec< int64_t > &perm, TPZVec< int64_t > &iperm)
Definition: pzsloan.cpp:20
void WritePointers(const TPZVec< TPZAutoPointer< T >> &vec)
Definition: TPZStream.h:214
int ClassId() const override
Define the class id associated with the class.
virtual int Zero()
Zeroes the matrix.
Definition: pzmatrix.h:296
Defines step solvers class. Solver.
Definition: pzmganalysis.h:17
void SetSolver(TPZMatrixSolver< STATE > &solver)
Set solver matrix.
TPZCompMesh * fCompMesh
Computational mesh.
Definition: pzanalysis.h:44
virtual int VariableIndex(const std::string &name)
Returns the variable index associated with the name.
#define RENUMBER
To renumbering will use sloan library.
Definition: pzanalysis.cpp:72
Implements a block diagonal matrix where the blocks are not contiguous. Matrix.
virtual void Assemble()
Assemble the stiffness matrix and load vector.
Definition: pzanalysis.cpp:304
To export a graphical mesh to VTK environment. Post processing.
Definition: pzvtkmesh.h:19
void PrintVectorByElement(std::ostream &out, TPZFMatrix< STATE > &vec, REAL tol=1.e-10)
Print the residual vector for those elements with entry above a given tolerance.
TPZCompMesh * Mesh() const
Returns the pointer to the computational mesh.
Definition: pzanalysis.h:180
To export a graphical three dimensional mesh to use at V3D package. Post processing.
Definition: pzv3dmesh.h:20
int64_t NElements() const
Number of elements of the mesh.
Definition: pzgmesh.h:129
TPZVec< STATE > Integrate(const std::string &varname, const std::set< int > &matids)
Integrate the postprocessed variable name over the elements included in the set matids.
virtual void Solve(const TPZFMatrix< TVar > &F, TPZFMatrix< TVar > &result, TPZFMatrix< TVar > *residual=0)=0
Solves the system of linear equations.
virtual int Dimension() const =0
Returns the integrable dimension of the material.
virtual int NStateVariables() const =0
Returns the number of state variables associated with the material.
static void * ThreadWork(void *threaddata)
Definition: pzanalysis.cpp:610
Declarates the TPZBlock<REAL>class which implements block matrices.
static void ConnectSolution(int64_t cindex, TPZCompMesh *cmesh, TPZFMatrix< STATE > &glob, TPZVec< STATE > &sol)
extract the values corresponding to the connect from the vector
virtual void PrePostProcessTable(std::ostream &out_file)
Prepare data to print post processing and print coordinates.
virtual int MinimumNumberofLoadCases()
returns the minimum number of load cases for this material
Definition: TPZMaterial.h:192
void AppendSolver(TPZMatrixSolver< TVar > &solve)
Definition: pzseqsolver.cpp:30
virtual void PrintTitle(const char *VarName, std::ostream &out)
Prints the variables names associated with the element material.
Definition: pzcompel.cpp:392
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.
Implements a chunk vector with free store administration. Utility.
Definition: TPZStream.h:39
#define LOGPZ_WARN(A, B)
Define log for warnings.
Definition: pzlog.h:91
TPZVec< std::string > fVariableNames
Definition: pzanalysis.h:83
static int ColorGraph(TPZVec< int64_t > &graph, TPZVec< int64_t > &graphindex, int64_t neq, TPZVec< int > &colors)
Color the graph into mutually independent blocks.
virtual int NSides() const =0
Returns the number of connectivities of the element.
Contains the TPZStructMatrixOR class which responsible for a interface among Matrix and Finite Elemen...
EPrecond
Preconditioners which can be created by objects of this class.
Definition: pzanalysis.h:37
static TPZSavable * GetInstance(const int64_t &objId)
void ReadPointers(TPZVec< TPZAutoPointer< T >> &vec)
Definition: TPZStream.h:305
TPZMatrixSolver< STATE > * BuildPreconditioner(EPrecond preconditioner, bool overlap)
Define the type of preconditioner used.
Contains TPZBlockDiagonal class which defines block diagonal matrices.
int fStep
Time step.
Definition: pzanalysis.h:60
std::function< void(const TPZVec< REAL > &loc, TPZVec< STATE > &result, TPZFMatrix< STATE > &deriv)> fExact
Pointer to Exact solution function, it is necessary to calculating errors.
Definition: pzanalysis.h:99
TPZManVector< TPZManVector< REAL, 10 >, 100 > fvalues
Definition: pzanalysis.h:343
TPZMatrixSolver< STATE > & Solver()
Get the solver matrix.
Definition: pzanalysis.h:367
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
Definition: pzmanvector.h:426
void ComputeElGraph(TPZStack< int64_t > &elgraph, TPZVec< int64_t > &elgraphindex)
Computes the connectivity graph of the elements, as appropriate for the TPZRenumbering class...
Definition: pzcmesh.cpp:1091
void BuildNodeGraph(TPZVec< int64_t > &blockgraph, TPZVec< int64_t > &blockgraphindex)
Build the graph which groups the equations of each node.
virtual ~TPZAnalysis(void)
Destructor: deletes all protected dynamic allocated objects.
Definition: pzanalysis.cpp:166
int ClassId() const override
Define the class id associated with the class.
Refines geometrical mesh (all the elements) num times.
Definition: pzstrmatrix.h:35
void CleanUp()
deletes all data structures
Definition: pzanalysis.cpp:171
Contains the TPZBlockDiagonalStructMatrix class which implements Block Diagonal Structural Matrices...
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
virtual void CenterPoint(int side, TPZVec< REAL > &masscent) const =0
It returns the coordinates from the center of the side of the element in the element coordinate space...
void SetResolution(int res)
Sets resolution.
Definition: pzgraphmesh.h:86
TPZAutoPointer< TPZGuiInterface > fGuiInterface
Pointer for gui interface object.
Definition: pzanalysis.h:74
#define PZ_PTHREAD_JOIN(thread, val, fn)
Definition: pz_pthread.h:34
TPZAdmChunkVector< TPZCompEl * > fElvec
Definition: pzanalysis.h:326
static TPZAutoPointer< TPZSavable > GetAutoPointer(const int64_t &objId)
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
TPZAnalysis()
Create an empty TPZAnalysis object.
Definition: pzanalysis.cpp:85
void ShowShape(const std::string &plotfile, TPZVec< int64_t > &equationindices)
Graphic of the solution as V3DGrap visualization.
Definition: pzanalysis.cpp:834
virtual TPZStructMatrixOR * Clone() override
Definition: pzstrmatrix.cpp:70
void SetJacobi(const int64_t numiterations, const REAL tol, const int64_t FromCurrent)
Contains the TPZV3DGraphMesh class which implements the graphical three dimensional mesh to use at V3...
int Zero() override
Makes Zero all the elements.
Definition: pzfmatrix.h:651
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
Definition: pzvec.h:373
Contains the TPZBoostGraph class which implements an interface to the BGL for graph operations...
TPZCompEl * Element(int64_t iel)
Definition: pzcmesh.h:185
std::list< int64_t > & Singular()
returns the equations for which the equations had zero pivot
Definition: pzstepsolver.h:71
void LoadSolution(const TPZFMatrix< STATE > &sol)
Given the solution of the global system of equations, computes and stores the solution for the restri...
Definition: pzcmesh.cpp:441
void Resize(const int newsize)
Increase the size of the chunk vector.
Definition: pzadmchunk.h:280
Contains declaration of TPZMesh class which defines a geometrical mesh and contains a corresponding l...
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
f
Definition: test.py:287
virtual void DrawSolution(TPZBlock< REAL > &Sol)
Draw solution as dx file.
Definition: pzdxmesh.cpp:384
#define PZ_PTHREAD_MUTEX_LOCK(mutex, fn)
Definition: pz_pthread.h:76
virtual void LoadSolution()
Load the solution into the computable grid.
Definition: pzanalysis.cpp:441
virtual void Write(const bool val)
Definition: TPZStream.cpp:8
TPZAutoPointer< TPZRenumbering > fRenumber
Renumbering scheme.
Definition: pzanalysis.h:71
virtual void PostProcessErrorParallel(TPZVec< REAL > &, bool store_error=true, std::ostream &out=std::cout)
Definition: pzanalysis.cpp:652
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
ThreadData(TPZAdmChunkVector< TPZCompEl *> &elvec, bool store_error, std::function< void(const TPZVec< REAL > &loc, TPZVec< STATE > &result, TPZFMatrix< STATE > &deriv)> f)
int IsDecomposed() const
Checks if current matrix is already decomposed.
Definition: pzmatrix.h:405
TPZGeoMesh * fGeoMesh
Geometric Mesh.
Definition: pzanalysis.h:42
virtual void CloseGraphMesh()
Clean the GrapMesh vector.
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.
Computes the cardinality of a nodegraph, identifying nodes as vertices, lines, faces or volumes...
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
virtual void SetCompMesh(TPZCompMesh *mesh, const std::set< int > &matids)
Sets the computational mesh to associate.
TPZVec< std::string > fScalarNames[3]
Scalar variables names - to post process.
Definition: pzanalysis.h:54
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
Definition: pzlog.h:87
This class defines the boundary condition for TPZMaterial objects.
Definition: pzbndcond.h:29
Contains declaration of TPZConnect class which represents a set of shape functions associated with a ...
Free store vector implementation.
Definition: pzmatrix.h:52
int Dimension() const
Returns the dimension of the simulation.
Definition: pzcmesh.h:148
virtual void SetMatrix(TPZAutoPointer< TPZMatrix< TVar > > Refmat)
Sets a matrix to the current object.
Definition: pzsolve.h:115
void Read(TPZStream &buf, void *context) override
read objects from the stream
void SetElementsNodes(int64_t NElements, int64_t NNodes)
TPZMaterial * FindMaterial(int id)
Find the material with identity id.
Definition: pzcmesh.cpp:297
TPZCompEl * Reference() const
Return a pointer to the element referenced by the geometric element.
Definition: pzgeoel.h:750
TPZVec< int64_t > fGeoElId
Definition: pzanalysis.h:79
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
static STATE ConnectNorm(int64_t cindex, TPZCompMesh *cmesh, TPZFMatrix< STATE > &glob)
TPZMatrixSolver< STATE > * BuildSequenceSolver(TPZVec< int64_t > &graph, TPZVec< int64_t > &graphindex, int64_t neq, int numcolors, TPZVec< int > &colors)
Build a sequence solver based on the block graph and its colors.
virtual void DrawMesh(int numcases)
Draw the graphical mesh.
int HasDependency() const
Returns whether exist dependecy information.
Definition: pzconnect.h:292
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
TTablePostProcess fTable
Definition: pzanalysis.h:94
~TTablePostProcess()
TTablePostProcess()
Contains TPZSequenceSolver class which defines sequence solvers.
string res
Definition: test.py:151
TPZGeoEl * FindElement(TPZVec< REAL > &x, TPZVec< REAL > &qsi, int64_t &InitialElIndex, int targetDim) const
Returns the element that contains the given point x and it respective point in parametric domain qsi...
Definition: pzgmesh.cpp:579
const TPZBlock< STATE > & Block() const
Access the block structure of the solution vector.
Definition: pzcmesh.h:213
TPZVec< std::string > fVectorNames[3]
Vectorial variables names - to post process.
Definition: pzanalysis.h:56
Contains the TPZGraphMesh class which represents a graphical mesh used for post processing purposes...
void SetNumLoadCases(int numloadcases)
changes the number of load cases for this material
Definition: TPZMaterial.h:198
#define PZ_PTHREAD_MUTEX_DESTROY(mutex, fn)
Definition: pz_pthread.h:73
void IdentifyPostProcessingMatIds(int dimension, std::set< int > &matids)
Fill mat ids with materials with provided dimension wich are not boundary conditinos or interface...
TPZAdmChunkVector< TPZConnect > & ConnectVec()
Return a reference to the connect pointers vector.
Definition: pzcmesh.h:198
pthread_mutex_t fAccessElement
Mutexes (to choose which element is next)
Definition: pzanalysis.h:346
#define LOGPZ_ERROR(A, B)
Define log for errors (cout)
Definition: pzlog.h:93
Contains declaration of TPZCompMesh class which is a repository for computational elements...
virtual void PostProcess(int resolution)
Draw solution over mesh for all dimensions.
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Definition: pzfmatrix.h:616
void Print(TPZVec< int64_t > &grapho, TPZVec< int64_t > &graphoindex, const char *name=0, std::ostream &out=std::cout)
Prints graph.
virtual void DrawMesh(int numcases)
Draw mesh as dx file.
Definition: pzdxmesh.cpp:93
int fDimension
Definition: pzanalysis.h:81
virtual TPZConnect & Connect(int i) const
Returns a pointer to the ith node.
Definition: pzcompel.cpp:298
void BuildVertexGraph(TPZStack< int64_t > &blockgraph, TPZVec< int64_t > &blockgraphindex)
build the graph which builds the equations linked to vertices
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
A simple stack.
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
std::map< int,TPZMaterial *> & MaterialVec()
Returns a reference to the material pointers vector.
Definition: pzcmesh.h:203
virtual int64_t ConnectIndex(int i) const =0
Returns the index of the ith connectivity of the element.
virtual void SetFileName(const std::string &filename)
Sets the filename to output of graph.
virtual TPZSolver * Clone() const =0
Clones the current object returning a pointer of type TPZSolver.
virtual int NConnects() const =0
Returns the number of nodes of the element.
virtual void DefineElementTable(int dimension, TPZVec< int64_t > &GeoElIds, TPZVec< REAL > &points)
Fill the computational element vector to post processing depending over geometric mesh defined...
void SetStep(int step)
ste the step for post processing
Definition: pzanalysis.h:195
void Read(TPZStream &buf, void *context) override
read objects from the stream
Contains declaration of TPZSubCompMesh class which implements a group of computational elements as a ...
virtual int Dimension() const =0
Returns the dimension of the element.
void BuildElementGraph(TPZStack< int64_t > &blockgraph, TPZStack< int64_t > &blockgraphindex)
Build the graph which groups the equations grouped by elements.
TPZGraphMesh * fGraphMesh[3]
Graphical mesh.
Definition: pzanalysis.h:46
TPZAutoPointer< TPZStructMatrix > fStructMatrix
Structural matrix.
Definition: pzanalysis.h:68
virtual void AssembleResidual()
Assemble the load vector.
Definition: pzanalysis.cpp:288
void Read(TPZStream &buf, void *context) override
read objects from the stream
Definition: pzfmatrix.cpp:2205
virtual void DrawSolution(int step, REAL time)
Draw solution depending on the resolution.
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...
Free store vector implementation in chunks.
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
static void ExpandGraph(TPZVec< int64_t > &graph, TPZVec< int64_t > &graphindex, TPZBlock< STATE > &block, TPZVec< int64_t > &expgraph, TPZVec< int64_t > &expgraphindex)
Expand the graph acording to the block structure.
Defines sequence solvers. Solver.
Definition: pzseqsolver.h:23
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
int Size(const int block_diagonal) const
Returns block dimension.
Definition: pzblock.h:171
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...
TPZAutoPointer< TPZMatrix< TVar > > Matrix() const
Returns a pointer to TPZMatrix<>
Definition: pzsolve.h:138
#define PZ_PTHREAD_CREATE(thread, attr, routine, args, fn)
Definition: pz_pthread.h:31
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.
virtual void Print(std::ostream &out) const
Definition: pzmatrix.h:253
int Resize(const int64_t newRows, const int64_t wCols) override
Redimension a matrix, but maintain your elements.
Definition: pzfmatrix.cpp:1016
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
std::function< void(const TPZVec< REAL > &loc, TPZVec< STATE > &result, TPZFMatrix< STATE > &deriv)> fExact
Definition: pzanalysis.h:334
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
Contains the TPZSloan class.
def values
Definition: rdt.py:119
TPZFMatrix< STATE > & Rhs()
Returns the load vector.
Definition: pzanalysis.h:174
virtual void PostProcessErrorSerial(TPZVec< REAL > &, bool store_error=true, std::ostream &out=std::cout)
Definition: pzanalysis.cpp:747
void SetDirect(const DecomposeType decomp)
Contains the TPZDXGraphMesh class which implements the interface of the graphmesh to the OpenDX graph...
clarg::argInt porder("-porder", "polinomial order", 1)
void CreateListOfCompElsToComputeError(TPZAdmChunkVector< TPZCompEl *> &elvec)
Definition: pzanalysis.cpp:586
virtual void Resequence(TPZVec< int64_t > &perm, TPZVec< int64_t > &iperm)
#define PZ_PTHREAD_MUTEX_INIT(mutex, attr, fn)
Definition: pz_pthread.h:70
TPZFMatrix< STATE > fRhs
Load vector.
Definition: pzanalysis.h:48
TPZVec< std::string > fTensorNames[3]
Tensorial variables names - to post process.
Definition: pzanalysis.h:58
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Definition: pzfmatrix.cpp:2225
int HighestDimension()
Returns the dimension of the material which has the highest dimension.
void Print(const TPZCompMesh &mesh, std::ostream &out=std::cout)
Print the information for the connect element.
Definition: pzconnect.cpp:67
void AssembleBlockDiagonal(TPZBlockDiagonal< STATE > &block)
void AnimateRun(int64_t num_iter, int steps, TPZVec< std::string > &scalnames, TPZVec< std::string > &vecnames, const std::string &plotfile)
Run and print the solution step by step.
Contains the TPZNodesetCompute class which computes the cardinality of a nodegraph.
void ConnectSolution(std::ostream &out)
Print the solution by connect index.
Definition: pzcmesh.cpp:1373
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
Implements graphical mesh to MVGraph package. Post processing.
Definition: pzmvmesh.h:23
bool IsCondensed() const
Access method to return the indication whether the connect is condensed or not.
Definition: pzconnect.h:223
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
Interface to sloan subrotines. Utility.
Definition: pzsloan.h:21
TPZVec< REAL > fLocations
Definition: pzanalysis.h:82
int GetDefaultOrder()
Definition: pzcmesh.h:398
virtual void SetCompMesh(TPZCompMesh *mesh, bool mustOptimizeBandwidth)
Set the computational mesh of the analysis.
Definition: pzanalysis.cpp:115
void TransferMultiphysicsSolution()
Transfer multiphysics mesh solution.
Definition: pzcmesh.cpp:470
TPZFMatrix< STATE > & Solution()
Access the solution vector.
Definition: pzcmesh.h:219
static void WritePointer(const TPZSavable *obj, TPZStream *stream)
REAL fTime
Time variable which is used in dx output.
Definition: pzanalysis.h:62
Contains TPZMetis class which implements the renumbering for elements of a mesh to minimize the band...
virtual void SetTableVariableNames(TPZVec< std::string > varnames)
Sets the names of the variables into the data structure for post processing.
TPZManVector< int64_t > & Nodegraph()
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15
virtual void Read(bool &val)
Definition: TPZStream.cpp:91
int ComputeNumberofLoadCases()
Determine the number of load cases from the material objects and return its value.
Definition: pzanalysis.cpp:263
void Permute(TPZVec< int64_t > &permute)
Permute the sequence number of the connect objects It is a permute gather operation.
Definition: pzcmesh.cpp:1321
This class implements a reference counter mechanism to administer a dynamically allocated object...
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.