NeoPZ
substruct.cpp
Go to the documentation of this file.
1 
8 #ifdef HAVE_CONFIG_H
9 #include <pz_config.h>
10 #endif
11 
12 #include <iostream>
13 #include <cstdlib>
14 
15 #include "tpzdohrsubstruct.h"
16 #include "tpzdohrmatrix.h"
17 #include "tpzdohrprecond.h"
18 #include "pzdohrstructmatrix.h"
19 #include "pzstepsolver.h"
20 #include "pzcompel.h"
21 #include "pzgeoelbc.h"
22 
23 #include "pzelast3d.h"
24 #include "pzbndcond.h"
25 
26 #include "tpzdohrassembly.h"
27 
28 #include "pzlog.h"
29 #include "tpzgensubstruct.h"
30 #include "tpzpairstructmatrix.h"
31 #include "pzviscoelastic.h"
32 #include "TPZVTKGeoMesh.h"
33 #include "pzgeotetrahedra.h"
34 #include "pzskylstrmatrix.h"
35 
36 #include "tpzarc3d.h"
37 #include "tpzdohrmatrix.h"
38 
39 #include "pzvtkmesh.h"
40 
41 #include "pzlog.h"
42 
43 #include "pzbfilestream.h" // TPZBFileStream, TPZFileStream
44 #include "pzmd5stream.h"
45 
46 #include <fstream>
47 #include <string>
48 #include "TPZfTime.h"
49 
50 
51 #ifdef LOG4CXX
52 static LoggerPtr loggerconverge(Logger::getLogger("pz.converge"));
53 static LoggerPtr logger(Logger::getLogger("main"));
54 #endif
55 
56 //#include "timing_analysis.h"
57 #include "arglib.h"
58 #include "run_stats_table.h"
59 
60 #ifdef HAS_GETRUSAGE
61 #include <sys/resource.h> // getrusage
62 #endif
63 
64 #ifdef USING_TBB
65 #include "tbb/task_scheduler_init.h"
66 using namespace tbb;
67 // If you have issues with: dyld: Library not loaded: libtbb.dylib
68 // try setting the LD path. Ex:
69 // export DYLD_FALLBACK_LIBRARY_PATH=/Users/borin/Desktop/neopz/tbb40_297oss/lib/
70 #endif
71 
77 void SetPointBC(TPZGeoMesh *gr, TPZVec<REAL> &x, int bc);
78 REAL Height(TPZGeoMesh *gmesh);
79 int SubStructure(TPZAutoPointer<TPZCompMesh> cmesh, REAL height);
80 
81 using namespace std;
82 
83 void help(const char* prg)
84 {
85  cout << "Compute ...." << endl;
86  cout << "The application is divided in four main steps: s1, s2, s3 and s4" << endl;
87  cout << endl;
88  cout << " Step 1 (mp/mc -> ckpt 1): " << endl;
89  cout << " Step 2 (ckpt 1 -> ckpt 2): dohrstruct->Create()" << endl;
90  cout << " Step 3 (ckpt 2 -> ckpt 3): dohrstruct->Assemble(), dohrstruct->Preconditioner() " << endl;
91  cout << " Step 4 (ckpt 3 -> end ): cg.solve() ..." << endl << endl;
92  cout << "Usage: " << prg << "starting_point stop_point file [-of output_file]" << endl << endl;
93  cout << " starting_point = {-cf1|-cf2|-cf3|-mc|-mp} input_file" << endl;
94  cout << " starting_point = {-st1|-st2|-st3}" << endl;
95 
96  clarg::arguments_descriptions(cout, " ", "\n");
97 }
98 
99 clarg::argString cf1("-cf1", "starts execution from checkpoint 1 (read checkpoint file)", "ckpt1.ckpt");
100 clarg::argString cf2("-cf2", "starts execution from checkpoint 2 (read checkpoint file)", "ckpt2.ckpt");
101 clarg::argString cf3("-cf3", "starts execution from checkpoint 3 (read checkpoint file)", "ckpt3.ckpt");
102 clarg::argBool st1("-st1", "stop at checkpoint 1 (after dump)", false);
103 clarg::argBool st2("-st2", "stop at checkpoint 2 (after dump)", false);
104 clarg::argBool st3("-st3", "stop at checkpoint 3 (after dump)", false);
105 
106 clarg::argString gen_sig_ckpt1("-gen_c1_md5", "generates MD5 signature for checkpoint 1 and dump into file.", "ckpt1.md5");
107 clarg::argString chk_sig_ckpt1("-chk_c1_md5", "compute MD5 signature for checkpoint 1 and check against MD5 at file.", "ckpt1.md5");
108 clarg::argString gen_sig_ckpt2("-gen_c2_md5", "generates MD5 signature for checkpoint 2 and dump into file.", "ckpt2.md5");
109 clarg::argString chk_sig_ckpt2("-chk_c2_md5", "compute MD5 signature for checkpoint 2 and check against MD5 at file.", "ckpt2.md5");
110 clarg::argString gen_sig_ckpt3("-gen_c3_md5", "generates MD5 signature for checkpoint 3 and dump into file.", "ckpt3.md5");
111 clarg::argString chk_sig_ckpt3("-chk_c3_md5", "compute MD5 signature for checkpoint 3 and check against MD5 at file.", "ckpt3.md5");
112 clarg::argString gen_sig_ckpt4("-gen_c4_md5", "generates MD5 signature for checkpoint 4 and dump into file.", "ckpt4.md5");
113 clarg::argString chk_sig_ckpt4("-chk_c4_md5", "compute MD5 signature for checkpoint 4 and check against MD5 at file.", "ckpt4.md5");
114 
115 clarg::argString dc1("-dc1", "dump checkpoint 1 to file", "ckpt1.ckpt");
116 clarg::argString dc2("-dc2", "dump checkpoint 2 to file", "ckpt2.ckpt");
117 clarg::argString dc3("-dc3", "dump checkpoint 3 to file", "ckpt3.ckpt");
118 clarg::argString mc("-mc", "starts execution from beginning - read a \"malha_cubo\" input file",
119  "../cube1.txt");
120 clarg::argString mp("-mp", "starts execution from beginning - read a \"malha_predio\" input file",
121  "../8andares02.txt");
122 
123 clarg::argInt plevel ("-p", "plevel", 1);
124 clarg::argInt num_it ("-num_it", "number limit of iterations to the CG solver", 500);
125 clarg::argInt nt_sm("-nt_sm", "Dohr (l1): number of threads to process the submeshes", 0);
126 clarg::argInt nt_d("-nt_d", "Dohr (l1): number of threads to decompose each submesh", 0);
127 clarg::argInt nt_a("-nt_a", "Pair (l2): number of threads to assemble each submesh (multiply by nt_sm)", 0);
128 clarg::argBool dohr_tbb("-dohr_tbb", "assemble TPZDohrStructMatrix (level 1) using TBB", false);
129 clarg::argBool pair_tbb("-pair_tbb", "assemble TPZPairStructMatrix (level 2) using TBB", false);
130 clarg::argInt nt_multiply("-nt_m", "number of threads to multiply", 0);
131 clarg::argInt nsub("-nsub", "number of substructs", 4);
132 
133 clarg::argInt dim_arg("-dim", "dim???", 3);
134 clarg::argInt maxlevel("-maxlevel", "maxlevel???", 5);
135 clarg::argInt sublevel("-sublevel", "sublevel???", 3);
136 
137 clarg::argInt verb_level("-v", "verbosity level", 0);
138 
139 clarg::argBool bc("-bc", "binary checkpoints", false);
140 
141 clarg::argBool h("-h", "help message", false);
142 
143 clarg::argInt refin("-ref", "refine mesh", 1);
144 
145 /* Run statistics. */
146 RunStatsTable total_rst ("-tot_rdt", "Whole program (total) statistics raw data table");
147 RunStatsTable create_rst ("-cre_rdt", "Create statistics raw data table (step 2)");
148 RunStatsTable assemble_rst("-ass_rdt", "Assemble statistics raw data table (step 3)");
149 RunStatsTable precond_rst ("-pre_rdt", "Precond statistics raw data table (step 3)");
150 RunStatsTable solve_rst ("-sol_rdt", "Solver statistics raw data table (step 4)");
151 
152 #ifdef USING_LIKWID
153 #define PERF_START(obj) \
154 likwid_markerStartRegion(#obj); \
155 obj.start()
156 #define PERF_STOP(obj) \
157 obj.stop(); \
158 likwid_markerStopRegion(#obj)
159 #else
160 #define PERF_START(obj) obj.start()
161 #define PERF_STOP(obj) obj.stop()
162 #endif
163 
164 
165 class FileStreamWrapper
166 {
167 public:
170 
171  void OpenWrite(const std::string& fn)
172  {
173  if (bc.was_set())
174  bfs.OpenWrite(fn);
175  else
176  fs.OpenWrite(fn);
177  }
178 
179  void OpenRead(const std::string& fn)
180  {
181  if (bc.was_set())
182  bfs.OpenRead(fn);
183  else
184  fs.OpenRead(fn);
185  }
186 
187  operator TPZStream&()
188  {
189  if (bc.was_set())
190  return bfs;
191  else
192  return fs;
193  }
194 
195 protected:
196  TPZFileStream fs;
197  TPZBFileStream bfs;
198 };
199 
200 #ifdef USING_LIKWID
201 #include<likwid.h>
202 
203 struct likwid_manager_t {
204  likwid_manager_t() {
205  std::cout << "Calling likwid_markerInit()" << std::endl;
206  likwid_markerInit();
207  }
208  ~likwid_manager_t() {
209  likwid_markerClose();
210  std::cout << "Calling likwid_markerClose()" << std::endl;
211  }
212 };
213 
214 #endif
215 
216 
217 int main(int argc, char *argv[])
218 {
219 
220  TPZfTime serial;
221 
222 #ifdef USING_LIKWID
223  likwid_manager_t likwid_manager;
224 #endif
225 
226 #ifdef LOG4CXX
227  InitializePZLOG("log4cxx.cfg");
228 #endif
229 #ifdef USING_TBB
230  task_scheduler_init init;
231 #endif
232 
233  int main_ret = EXIT_SUCCESS;
234 
235  /* Parse the arguments */
236  if (clarg::parse_arguments(argc, argv)) {
237  cerr << "Error when parsing the arguments!" << endl;
238  return 1;
239  }
240 
241  if (h.get_value() == true) {
242  help(argv[0]);
243  return 1;
244  }
245 
246  /* Verbose macro. */
247  unsigned verbose = verb_level.get_value();
248 # define VERBOSE(level,...) if (level <= verbose) cout << __VA_ARGS__
249 
250  if (verbose >= 1) {
251  std::cout << "- Arguments -----------------------" << std::endl;
252  clarg::values(std::cout, false);
253  std::cout << "-----------------------------------" << std::endl;
254  }
255 
256  if (!mp.was_set() && !mc.was_set() && !cf1.was_set() &&
257  !cf2.was_set() && !cf3.was_set())
258  {
259  cerr << "A \"starting_point\" must be provided!" << endl;
260  help(argv[0]);
261  return 1;
262  }
263 
264  PERF_START(total_rst);
265 
266  if (pair_tbb.was_set())
268  else
270 
271  TPZGeoMesh *gmesh = 0;
272  TPZAutoPointer<TPZCompMesh> cmeshauto = 0;
273  TPZDohrStructMatrix* dohrstruct = 0;
274  TPZFMatrix<STATE> *rhs = NULL;
275  TPZMatrix<STATE> *matptr = 0;
276  int dim = dim_arg.get_value();
278 
279  bool running = false;
280 
281  /* Start from malha_cubo or malha_predio? */
282  if (mp.was_set() || mc.was_set())
283  {
284  if (mp.was_set()) // Predio Elastisco
285  {
286  if (running) {
287  cerr << "ERROR: you must select only one of the start modes: "
288  << "mp, mc, cf1, cf2 or cf3" << endl;
289  exit(1);
290  }
291  else
292  running = true;
293 
294  gmesh = MalhaPredio();
295  cmeshauto = new TPZCompMesh(gmesh);
296  cmeshauto->SetDimModel(dim);
297  InsertElasticity(cmeshauto);
298  cmeshauto->AutoBuild();
299  }
300  if (mc.was_set()) // Cubo Viscoso
301  {
302  if (running) {
303  cerr << "ERROR: you must select only one of the start modes: "
304  << "mp, mc, cf1, cf2 or cf3" << endl;
305  exit(1);
306  }
307  else running = true;
308 
309  VERBOSE(1, "Reading MalhaCubo from file: " << mc.get_value() << endl);
310  gmesh = MalhaCubo();
311  cmeshauto = new TPZCompMesh(gmesh);
312  cmeshauto->SetDimModel(dim);
313  cmeshauto->SetDefaultOrder(plevel.get_value());
314  //cmeshauto->SetAllCreateFunctionsContinuousWithMem();
315  //cmeshauto->SetAllCreateFunctionsContinuous();
316  InsertViscoElasticityCubo(cmeshauto);
317  cmeshauto->AutoBuild();
318  }
319 
320  VERBOSE(1, "Number of equations " << cmeshauto->NEquations() << endl);
321 
322  dohrstruct = new TPZDohrStructMatrix(cmeshauto);
323  dohrstruct->IdentifyExternalConnectIndexes();
324 
325  VERBOSE(1, "Substructuring the mesh" << endl);
326 
327  dohrstruct->SubStructure(nsub.get_value());
328 
329 #ifdef LOG4CXX
330  {
331  std::stringstream str;
332  cmeshauto->Print(str);
333  LOGPZ_DEBUG(logger,str.str());
334  }
335 #endif
336 
337  /* Dump checkpoint 1 */
338  if (dc1.was_set() && running)
339  {
340  VERBOSE(1, "Dumping checkpoint 1 into: " << dc1.get_value() << endl);
341  FileStreamWrapper CheckPoint1;
342  CheckPoint1.OpenWrite(dc1.get_value());
343  cmeshauto->Reference()->Write(CheckPoint1, 0);
344  cmeshauto->Write(CheckPoint1, 0);
345  dohrstruct->Write(CheckPoint1);
346  }
347  /* Gen/Check checkpoint 1 MD5 signature? */
348  if ((gen_sig_ckpt1.was_set() || chk_sig_ckpt1.was_set()) && running)
349  {
350  TPZMD5Stream sig;
351  cmeshauto->Reference()->Write(sig, 0);
352  cmeshauto->Write(sig, 0);
353  dohrstruct->Write(sig);
354  if (chk_sig_ckpt1.was_set()) {
355  int ret;
356  if ((ret=sig.CheckMD5(chk_sig_ckpt1.get_value()))) {
357  cerr << "ERROR: MD5 Signature for checkpoint 1 does not match. (ret = " << ret << ")" << endl;
358  return 1;
359  }
360  }
361  if (gen_sig_ckpt1.was_set()) {
362  int ret;
363  if ((ret = sig.WriteMD5(gen_sig_ckpt1.get_value()))) {
364  cerr << "ERROR when writing ckpt 1 MD5 Signature to file (ret = " << ret << "): "
365  << gen_sig_ckpt1.get_value() << endl;
366  return 1;
367  }
368  }
369  }
370  }
371 
372  if(st1.was_set()) running = false;
373 
374  // Start from Checkpoint 1
375  if (cf1.was_set())
376  {
377  if (running) {
378  cerr << "ERROR: you must select only one of the start modes: mp, mc, cf1, cf2 or cf3" << endl;
379  exit(1);
380  }
381  else
382  running = true;
383 
384  gmesh = new TPZGeoMesh;
385  cmeshauto = new TPZCompMesh(gmesh);
386  dohrstruct = new TPZDohrStructMatrix(cmeshauto);
387  /* Read the checkpoint. */
388  {
389  FileStreamWrapper CheckPoint1;
390  CheckPoint1.OpenRead(cf1.get_value());
391  gmesh->Read(CheckPoint1, 0);
392  cmeshauto->Read(CheckPoint1, gmesh);
393  dohrstruct->Read(CheckPoint1);
394  }
395 
396  dim = cmeshauto->Dimension();
397  VERBOSE(1, "Reading dim from file. new dim = " << dim << ", old dim = " << dim_arg.get_value() << endl);
398 
399  }
400 
401  /* Work between checkpoint 1 and checkpoint 2 */
402  if (running) {
403 
404  PERF_START(create_rst);
405  matptr = dohrstruct->Create();
406  PERF_STOP(create_rst);
407 
408  if (dc2.was_set())
409  {
410  VERBOSE(1, "Dumping checkpoint 2 into: " << dc2.get_value() << endl);
411  FileStreamWrapper CheckPoint2;
412  CheckPoint2.OpenWrite(dc2.get_value());
413  SAVEABLE_STR_NOTE(CheckPoint2,"cmeshauto->Reference()->Write()");
414  cmeshauto->Reference()->Write(CheckPoint2, 0);
415  SAVEABLE_STR_NOTE(CheckPoint2,"cmeshauto->Write()");
416  cmeshauto->Write(CheckPoint2, 0);
417  SAVEABLE_STR_NOTE(CheckPoint2,"matptr->Write()");
418  matptr->Write(CheckPoint2, 1);
419  SAVEABLE_STR_NOTE(CheckPoint2,"dohrstruct->Write()");
420  dohrstruct->Write(CheckPoint2);
421  }
422 
423  /* Gen/Check checkpoint 2 MD5 signature? */
424  if (gen_sig_ckpt2.was_set() || chk_sig_ckpt2.was_set())
425  {
426  TPZMD5Stream sig;
427  cmeshauto->Reference()->Write(sig, 0);
428  cmeshauto->Write(sig, 0);
429  matptr->Write(sig, 1);
430  dohrstruct->Write(sig);
431 
432  if (chk_sig_ckpt2.was_set()) {
433  if (sig.CheckMD5(chk_sig_ckpt2.get_value())) {
434  cerr << "ERROR: MD5 Signature for checkpoint 2 does not match." << endl;
435  return 1;
436  }
437  }
438  if (gen_sig_ckpt2.was_set()) {
439  if (sig.WriteMD5(gen_sig_ckpt2.get_value())) {
440  cerr << "ERROR when writing ckpt 2 MD5 Signature to file: "
441  << gen_sig_ckpt2.get_value() << endl;
442  return 1;
443  }
444  }
445  }
446  }
447 
448  if(st2.was_set()) running = false;
449 
450  // Start from Checkpoint 2
451  if (cf2.was_set())
452  {
453  if (running) {
454  cerr << "ERROR: you must select only one of the start modes: mp, mc, cf1, cf2 or cf3" << endl;
455  exit(1);
456  }
457  else
458  running = true;
459 
460  FileStreamWrapper CheckPoint2;
461  CheckPoint2.OpenRead(cf2.get_value());
462  gmesh = new TPZGeoMesh;
463  SAVEABLE_SKIP_NOTE(CheckPoint2);
464  gmesh->Read(CheckPoint2,0);
465  cmeshauto = new TPZCompMesh(gmesh);
466  SAVEABLE_SKIP_NOTE(CheckPoint2);
467  cmeshauto->Read(CheckPoint2, &gmesh);
468  SAVEABLE_SKIP_NOTE(CheckPoint2);
469  matptr = dynamic_cast<TPZMatrix<STATE> *>(TPZSavable::Restore(CheckPoint2, 0));
470  dohrstruct = new TPZDohrStructMatrix(cmeshauto);
471  SAVEABLE_SKIP_NOTE(CheckPoint2);
472  dohrstruct->Read(CheckPoint2);
473  }
474 
475  cout << "Serial Section: " << serial.ReturnTimeString() << endl;
476 
477  TPZAutoPointer<TPZMatrix<STATE> > precond = NULL;
478  /* Work between checkpoint 2 and checkpoint 3 */
479  if (running)
480  {
481  if (nt_multiply.was_set() && nt_multiply.get_value() != 1)
482  {
483  dohrstruct->SetNumThreads(nt_multiply.get_value());
484  }
485 
486  PERF_START(assemble_rst);
488  rhs = new TPZFMatrix<STATE>(cmeshauto->NEquations(),1,0.);
489  VERBOSE(1,"dohrstruct->Assemble()" << endl);
490  if (dohr_tbb.was_set())
491  dohrstruct->AssembleTBB(*matptr,*rhs, gui);
492  else
493  dohrstruct->Assemble(*matptr,*rhs, gui, nt_sm.get_value(), nt_d.get_value());
494  PERF_STOP(assemble_rst);
495 
496  PERF_START(precond_rst);
497  precond = dohrstruct->Preconditioner();
498  PERF_STOP(precond_rst);
499 
500  if (dc3.was_set())
501  {
502  VERBOSE(1, "Dumping checkpoint 3 into: " << dc3.get_value() << endl);
503  FileStreamWrapper CheckPoint3;
504  CheckPoint3.OpenWrite(dc3.get_value());
505  cmeshauto->Reference()->Write(CheckPoint3, 0);
506  cmeshauto->Write(CheckPoint3, 0);
507  matptr->Write(CheckPoint3, 1);
508  precond->Write(CheckPoint3, 1);
509  rhs->Write(CheckPoint3, 0);
510  }
511 
512  /* Gen/Check checkpoint 3 MD5 signature? */
513  if (gen_sig_ckpt3.was_set() || chk_sig_ckpt3.was_set())
514  {
515  TPZMD5Stream sig;
516  cmeshauto->Reference()->Write(sig, 0);
517  cmeshauto->Write(sig, 0);
518  matptr->Write(sig, 1);
519  precond->Write(sig, 1);
520  rhs->Write(sig, 0);
521  int ret;
522  if (chk_sig_ckpt3.was_set()) {
523  if ((ret=sig.CheckMD5(chk_sig_ckpt3.get_value()))) {
524  cerr << "ERROR(ret=" << ret << ") : MD5 Signature for checkpoint 3 does not match." << endl;
525  return 1;
526  }
527  }
528  if (gen_sig_ckpt3.was_set()) {
529  if ((ret=sig.WriteMD5(gen_sig_ckpt3.get_value()))) {
530  cerr << "ERROR (ret=" << ret << ") when writing ckpt 3 MD5 Signature to file: "
531  << gen_sig_ckpt3.get_value() << endl;
532  return 1;
533  }
534  }
535  }
536  }
537 
538  if(st3.was_set()) running = false;
539 
540  // Start from Checkpoint 3
541  if (cf3.was_set())
542  {
543  if (running) {
544  cerr << "ERROR: you must select only one of the start modes: mp, mc, cf1, cf2 or cf3" << endl;
545  exit(1);
546  }
547  else
548  running = true;
549  gmesh = new TPZGeoMesh;
550  cmeshauto = new TPZCompMesh(gmesh);
551  dohrstruct = new TPZDohrStructMatrix(cmeshauto);
552 
553  dim = cmeshauto->Dimension();
554  VERBOSE(1, "Reading dim from file. new dim = " << dim << ", old dim = " << dim_arg.get_value() << endl);
555 
556  FileStreamWrapper CheckPoint3;
557  CheckPoint3.OpenRead(cf3.get_value());
558  gmesh->Read(CheckPoint3, 0);
559  cmeshauto->Read(CheckPoint3, gmesh);
560  matptr = dynamic_cast<TPZMatrix<STATE> *>(TPZSavable::Restore(CheckPoint3, 0));
561  precond = dynamic_cast<TPZMatrix<STATE> *>(TPZSavable::Restore(CheckPoint3, matptr));
562  rhs = new TPZFMatrix<STATE>(cmeshauto->NEquations(),1,0.);
563  rhs->Read(CheckPoint3, 0);
564  }
565 
566  if (running) {
567 
568  /* Work after checkpoint 3 */
569  TPZAutoPointer<TPZMatrix<STATE> > dohr = matptr;
570 
571  int neq = dohr->Rows();
572  TPZFMatrix<STATE> diag(neq,1,0.), produto(neq,1);
573 
574  VERBOSE(1, "Number of equations " << neq << endl);
575 
576  TPZStepSolver<STATE> pre(precond);
577  pre.SetMultiply();
578  TPZStepSolver<STATE> cg(dohr);
579 
580  /* Configure the CG solver to iterate:
581  - until it converges (residual <= 1.e-8), or
582  - until it reaches 500 itearations.
583  */
584  cg.SetCG(num_it.get_value(),pre,1.e-8,0);
585 
586  PERF_START(solve_rst);
587  cg.Solve(*rhs,diag);
588  PERF_STOP(solve_rst);
589 
590 
591  /* checking if the solver converged */
592  if (cg.GetTolerance() > 1.e-8)
593  {
594  cerr << "ERROR: solver do not converged with the limit of iterations." << endl;
595  exit(1);
596  }
597 
599  dynamic_cast<TPZDohrMatrix<STATE,TPZDohrSubstructCondense<STATE> > *> (dohr.operator->());
600 
601  if (!dohrptr) {
602  DebugStop();
603  }
604 
605  dohrptr->AddInternalSolution(diag);
606 
607 
608  /* Gen/Check checkpoint 4 MD5 signature? */
609  if (gen_sig_ckpt4.was_set() || chk_sig_ckpt4.was_set())
610  {
611  TPZMD5Stream sig;
612 
613  dohrptr->Write(sig, 0);
614  diag.Write(sig, 0);
615  cg.Write(sig, 0);
616  //cmeshauto->Reference()->Write(sig, 0);
617  //cmeshauto->Write(sig, 0);
618  //matptr->Write(sig, 1);
619  //precond->Write(sig, 1);
620  //rhs->Write(sig, 0);
621 
622  int ret;
623  if (chk_sig_ckpt4.was_set()) {
624  if ((ret=sig.CheckMD5(chk_sig_ckpt4.get_value()))) {
625  cerr << "ERROR(ret=" << ret << ") : MD5 Signature for checkpoint 4 does not match." << endl;
626  main_ret = 1;
627  }
628  }
629  if (gen_sig_ckpt4.was_set()) {
630  if ((ret=sig.WriteMD5(gen_sig_ckpt4.get_value()))) {
631  cerr << "ERROR (ret=" << ret << ") when writting ckpt 4 MD5 Signature to file: "
632  << gen_sig_ckpt4.get_value() << endl;
633  main_ret = 2;
634  }
635  }
636  }
637 
638  typedef std::list<TPZAutoPointer<TPZDohrSubstructCondense<STATE> > > subtype;
639  const subtype &sublist = dohrptr->SubStructures();
640  subtype::const_iterator it = sublist.begin();
641  int subcount=0;
642  while (it != sublist.end()) {
643 
644  TPZFMatrix<STATE> subext,subu;
645  dohrptr->fAssembly->Extract(subcount,diag,subext);
646  (*it)->UGlobal(subext,subu);
647  TPZCompMesh *submesh = SubMesh(cmeshauto, subcount);
648  submesh->LoadSolution(subu);
649 
650  //ViscoElastico
651  //Atualizando memoria do material
652  std::map<int ,TPZMaterial * > materialmap(submesh->MaterialVec());
653  std::map<int ,TPZMaterial * >::iterator itmat;
654  for (itmat = materialmap.begin(); itmat != materialmap.end() ; itmat++)
655  {
656  TPZMaterial * mat = itmat->second;
657  TPZViscoelastic *vmat = dynamic_cast< TPZViscoelastic *> (mat);
658  if(vmat)
659  {
660  vmat->SetUpdateMem(true);
661  }
662  }
663  subcount++;
664  it++;
665  }
666 
667 #ifdef LOG4CXX
668  {
669  std::stringstream sout;
670  diag.Print("Resultado do processo iterativo",sout);
671  LOGPZ_INFO(loggerconverge,sout.str())
672  }
673 #endif
674 
675  TPZMaterial * mat = cmeshauto->FindMaterial(1);
676  int nstate = mat->NStateVariables();
677  int nscal = 0, nvec = 0;
678  if(nstate ==1)
679  {
680  nscal = 1;
681  }
682  else
683  {
684  nvec = 1;
685  }
686  TPZManVector<std::string> scalnames(nscal),vecnames(nvec);
687  if(nscal == 1)
688  {
689  scalnames[0]="state";
690  }
691  else
692  {
693  vecnames[0] = "state";
694  }
695  std::string postprocessname("dohrmann_visco.vtk");
696  TPZVTKGraphMesh vtkmesh(cmeshauto.operator->(),dim,mat,scalnames,vecnames);
697  vtkmesh.SetFileName(postprocessname);
698  vtkmesh.SetResolution(1);
699  int numcases = 1;
700 
701 
702  // Iteracoes de tempo
703  int istep = 0;
704  vtkmesh.DrawMesh(numcases);
705  vtkmesh.DrawSolution(istep, 1.);
706  }
707 
708  PERF_STOP(total_rst);
709 
710 
711  if (gmesh != NULL) delete gmesh;
712 
713  return main_ret;
714 }
715 
717 {
718  mesh->SetDimModel(3);
719  int nummat = 1;
720  STATE E = 1.e6;
721  STATE poisson = 0.3;
722  TPZManVector<STATE> force(3,0.);
723  force[1] = 20.;
724  TPZElasticity3D *elast = new TPZElasticity3D(nummat,E,poisson,force);
725  TPZMaterial * elastauto(elast);
726  TPZFMatrix<STATE> val1(3,3,0.),val2(3,1,0.);
727  TPZBndCond *bc = elast->CreateBC(elastauto, -1, 0, val1, val2);
728  TPZMaterial * bcauto(bc);
729  mesh->InsertMaterialObject(elastauto);
730  mesh->InsertMaterialObject(bcauto);
731 }
732 
734 {
735  mesh->SetDimModel(3);
736  int nummat = 1;
737  TPZManVector<STATE> force(3,0.);
738  force[1] = 20.;
739  STATE ElaE = 1000., poissonE = 0.2, ElaV = 100., poissonV = 0.1;
740 
741  STATE lambdaV = 0, muV = 0, alpha = 0, deltaT = 0;
742  lambdaV = 11.3636;
743  muV = 45.4545;
744  alpha = 1.;
745  deltaT = 0.01;
746 
747  TPZViscoelastic *viscoelast = new TPZViscoelastic(nummat);
748  viscoelast->SetMaterialDataHooke(ElaE, poissonE, ElaV, poissonV, alpha, deltaT, force);
749 
750  TPZMaterial * viscoelastauto(viscoelast);
751  TPZFMatrix<STATE> val1(3,3,0.),val2(3,1,0.);
752  TPZBndCond *bc = viscoelast->CreateBC(viscoelastauto, -1, 0, val1, val2);
753  TPZFNMatrix<6,STATE> qsi(6,1,0.);
754  viscoelast->SetDefaultMem(qsi); //elast
755  viscoelast->PushMemItem(); //elast
756  TPZMaterial * bcauto(bc);
757  mesh->InsertMaterialObject(viscoelastauto);
758  mesh->InsertMaterialObject(bcauto);
759 }
760 
762 {
763  mesh->SetDimModel(3);
764  int nummat = 1, neumann = 1, mixed = 2;
765  // int dirichlet = 0;
766  int dir1 = -1, dir2 = -2, dir3 = -3, neumann1 = -4., neumann2 = -5;
767  TPZManVector<STATE> force(3,0.);
768  //force[1] = 0.;
769  REAL Ela = 1000, poisson = 0.;
770  REAL lambdaV = 0, muV = 0, alphaT = 0;
771  lambdaV = 11.3636;
772  muV = 45.4545;
773  alphaT = 0.01;
774 
775 
776  //TPZViscoelastic *viscoelast = new TPZViscoelastic(nummat, Ela, poisson, lambdaV, muV, alphaT, force);
777  TPZElasticity3D *viscoelast = new TPZElasticity3D(nummat, Ela, poisson, force);
778 
779  TPZFNMatrix<6> qsi(6,1,0.);
780  //viscoelast->SetDefaultMem(qsi); //elast
781  //int index = viscoelast->PushMemItem(); //elast
782  TPZMaterial * viscoelastauto(viscoelast);
783  mesh->InsertMaterialObject(viscoelastauto);
784 
785  // Neumann em x = 1;
786  TPZFMatrix<STATE> val1(3,3,0.),val2(3,1,0.);
787  val2(0,0) = 1.;
788  TPZBndCond *bc4 = viscoelast->CreateBC(viscoelastauto, neumann1, neumann, val1, val2);
789  TPZMaterial * bcauto4(bc4);
790  mesh->InsertMaterialObject(bcauto4);
791 
792  // Neumann em x = -1;
793  val2(0,0) = -1.;
794  TPZBndCond *bc5 = viscoelast->CreateBC(viscoelastauto, neumann2, neumann, val1, val2);
795  TPZMaterial * bcauto5(bc5);
796  mesh->InsertMaterialObject(bcauto5);
797 
798  val2.Zero();
799  // Dirichlet em -1 -1 -1 xyz;
800  val1(0,0) = 1e4;
801  val1(1,1) = 1e4;
802  val1(2,2) = 1e4;
803  TPZBndCond *bc1 = viscoelast->CreateBC(viscoelastauto, dir1, mixed, val1, val2);
804  TPZMaterial * bcauto1(bc1);
805  mesh->InsertMaterialObject(bcauto1);
806 
807  // Dirichlet em 1 -1 -1 yz;
808  val1(0,0) = 0.;
809  val1(1,1) = 1e4;
810  val1(2,2) = 1e4;
811  TPZBndCond *bc2 = viscoelast->CreateBC(viscoelastauto, dir2, mixed, val1, val2);
812  TPZMaterial * bcauto2(bc2);
813  mesh->InsertMaterialObject(bcauto2);
814 
815  // Dirichlet em 1 1 -1 z;
816  val1(0,0) = 0.;
817  val1(1,1) = 0.;
818  val1(2,2) = 1e4;
819  TPZBndCond *bc3 = viscoelast->CreateBC(viscoelastauto, dir3, mixed, val1, val2);
820  TPZMaterial * bcauto3(bc3);
821  mesh->InsertMaterialObject(bcauto3);
822 }
823 
825 {
826  //int nBCs = 1;
827  int numnodes=-1;
828  int numelements=-1;
829 
830  string FileName = mp.get_value();
831  {
832  bool countnodes = false;
833  bool countelements = false;
834 
835  ifstream read (FileName.c_str());
836  if (!read.is_open()) {
837  cerr << "Could not open file: " << FileName << endl;
838  exit(1);
839  }
840 
841  while(read)
842  {
843  char buf[1024];
844  read.getline(buf, 1024);
845  std::string str(buf);
846  if(str == "Coordinates") countnodes = true;
847  if(str == "end coordinates") countnodes = false;
848  if(countnodes) numnodes++;
849 
850  if(str == "Elements") countelements = true;
851  if(str == "end elements") countelements = false;
852  if(countelements) numelements++;
853  }
854  }
855 
856  TPZGeoMesh * gMesh = new TPZGeoMesh;
857 
858  gMesh -> NodeVec().Resize(numnodes);
859 
860  TPZVec <int64_t> TopolTetra(4);
861 
862  const int Qnodes = numnodes;
863  TPZVec <TPZGeoNode> Node(Qnodes);
864 
865  //setting nodes coords
866  int64_t nodeId = 0, elementId = 0, matElId = 1;
867 
868  ifstream read;
869  read.open(FileName.c_str());
870 
871  double nodecoordX , nodecoordY , nodecoordZ ;
872 
873  char buf[1024];
874  read.getline(buf, 1024);
875  read.getline(buf, 1024);
876  std::string str(buf);
877  int in;
878  for(in=0; in<numnodes; in++)
879  {
880  read >> nodeId;
881  read >> nodecoordX;
882  read >> nodecoordY;
883  read >> nodecoordZ;
884  Node[nodeId-1].SetNodeId(nodeId);
885  Node[nodeId-1].SetCoord(0,nodecoordX);
886  Node[nodeId-1].SetCoord(1,nodecoordY);
887  Node[nodeId-1].SetCoord(2,nodecoordZ);
888  gMesh->NodeVec()[nodeId-1] = Node[nodeId-1];
889  }
890 
891  {
892  read.close();
893  read.open(FileName.c_str());
894 
895  int l , m = numnodes+5;
896  for(l=0; l<m; l++)
897  {
898  read.getline(buf, 1024);
899  }
900 
901  int el;
902  int matBCid = -1;
903  //std::set<int> ncoordz; //jeitoCaju
904  for(el=0; el<numelements; el++)
905  {
906  read >> elementId;
907  read >> TopolTetra[0]; //node 1
908  read >> TopolTetra[1]; //node 2
909  read >> TopolTetra[2]; //node 3
910  read >> TopolTetra[3]; //node 4
911 
912  // O GID comeca com 1 na contagem dos nodes, e nao zero como no PZ, assim o node 1 na verdade é o node 0
913  TopolTetra[0]--;
914  TopolTetra[1]--;
915  TopolTetra[2]--;
916  TopolTetra[3]--;
917 
918  int64_t index = el;
919 
920  new TPZGeoElRefPattern< pzgeom::TPZGeoTetrahedra> (index, TopolTetra, matElId, *gMesh);
921  }
922 
923  gMesh->BuildConnectivity();
924  // Colocando as condicoes de contorno
925 
926  for(el=0; el<numelements; el++)
927  {
928  TPZManVector <TPZGeoNode,4> Nodefinder(4);
929  TPZManVector <REAL,3> nodecoord(3);
930  TPZGeoEl *tetra = gMesh->ElementVec()[el];
931  // na face z = 0
932  TPZVec<int64_t> ncoordzVec(0); int64_t sizeOfVec = 0;
933  for (int i = 0; i < 4; i++)
934  {
935  int64_t pos = tetra->NodeIndex(i);
936  Nodefinder[i] = gMesh->NodeVec()[pos];
937  Nodefinder[i].GetCoordinates(nodecoord);
938  if (nodecoord[2] == 0.)
939  {
940  sizeOfVec++;
941  ncoordzVec.Resize(sizeOfVec);
942  ncoordzVec[sizeOfVec-1] = pos;
943  }
944  }
945  if(ncoordzVec.NElements() == 3)
946  {
947  int lado = tetra->WhichSide(ncoordzVec);
948  TPZGeoElSide tetraSide(tetra, lado);
949  TPZGeoElBC(tetraSide,matBCid);
950  }
951  }
952  }
953 
954  ofstream arg("malhaPZ.txt");
955  gMesh->Print(arg);
956  ofstream predio("GeoPredio.vtk");
957  TPZVTKGeoMesh::PrintGMeshVTK(gMesh,predio,true);
958 
959  return gMesh;
960 }
961 
963 {
964  int numnodes=-1;
965  int numelements=-1;
966 
967  string FileName = mc.get_value();
968  {
969  bool countnodes = false;
970  bool countelements = false;
971 
972  ifstream read (FileName.c_str());
973  if (!read.is_open()) {
974  cerr << "Could not open file: " << FileName << endl;
975  exit(1);
976  }
977 
978  while(read)
979  {
980  char buf[1024];
981  read.getline(buf, 1024);
982  std::string str(buf);
983  if(str == "Coordinates") countnodes = true;
984  if(str == "end coordinates") countnodes = false;
985  if(countnodes) numnodes++;
986 
987  if(str == "Elements") countelements = true;
988  if(str == "end elements") countelements = false;
989  if(countelements) numelements++;
990  }
991  }
992 
993  TPZGeoMesh * gMesh = new TPZGeoMesh;
994 
995  gMesh -> NodeVec().Resize(numnodes);
996 
997  TPZManVector <int64_t> TopolTetra(4);
998 
999  const int Qnodes = numnodes;
1000  TPZVec <TPZGeoNode> Node(Qnodes);
1001 
1002  //setting nodes coords
1003  int nodeId = 0, elementId = 0, matElId = 1;
1004 
1005  ifstream read;
1006  read.open(FileName.c_str());
1007 
1008  double nodecoordX , nodecoordY , nodecoordZ ;
1009 
1010  char buf[1024];
1011  read.getline(buf, 1024);
1012  read.getline(buf, 1024);
1013  std::string str(buf);
1014  int in;
1015  for(in=0; in<numnodes; in++)
1016  {
1017  read >> nodeId;
1018  read >> nodecoordX;
1019  read >> nodecoordY;
1020  read >> nodecoordZ;
1021  Node[nodeId-1].SetNodeId(nodeId);
1022  Node[nodeId-1].SetCoord(0,nodecoordX);
1023  Node[nodeId-1].SetCoord(1,nodecoordY);
1024  Node[nodeId-1].SetCoord(2,nodecoordZ);
1025  gMesh->NodeVec()[nodeId-1] = Node[nodeId-1];
1026  }
1027 
1028  {
1029  read.close();
1030  read.open(FileName.c_str());
1031 
1032  int l , m = numnodes+5;
1033  for(l=0; l<m; l++)
1034  {
1035  read.getline(buf, 1024);
1036  }
1037 
1038 
1039  int el;
1040  int neumann1 = -4, neumann2 = -5;
1041  //std::set<int> ncoordz; //jeitoCaju
1042  for(el=0; el<numelements; el++)
1043  {
1044  read >> elementId;
1045  read >> TopolTetra[0]; //node 1
1046  read >> TopolTetra[1]; //node 2
1047  read >> TopolTetra[2]; //node 3
1048  read >> TopolTetra[3]; //node 4
1049 
1050  // O GID comeca com 1 na contagem dos nodes, e nao zero como no PZ, assim o node 1 na verdade é o node 0
1051  TopolTetra[0]--;
1052  TopolTetra[1]--;
1053  TopolTetra[2]--;
1054  TopolTetra[3]--;
1055 
1056  int64_t index = el;
1057 
1058  new TPZGeoElRefPattern< pzgeom::TPZGeoTetrahedra> (index, TopolTetra, matElId, *gMesh);
1059  }
1060 
1061  gMesh->BuildConnectivity();
1062 
1063  // Colocando as condicoes de contorno
1064  for(el=0; el<numelements; el++)
1065  {
1066  TPZManVector <TPZGeoNode,4> Nodefinder(4);
1067  TPZManVector <REAL,3> nodecoord(3);
1068  TPZGeoEl *tetra = gMesh->ElementVec()[el];
1069 
1070  // na face x = 1
1071  TPZVec<int64_t> ncoordzVec(0); int64_t sizeOfVec = 0;
1072  for (int i = 0; i < 4; i++)
1073  {
1074  int64_t pos = tetra->NodeIndex(i);
1075  Nodefinder[i] = gMesh->NodeVec()[pos];
1076  Nodefinder[i].GetCoordinates(nodecoord);
1077  if (nodecoord[0] == 1.)
1078  {
1079  sizeOfVec++;
1080  ncoordzVec.Resize(sizeOfVec);
1081  ncoordzVec[sizeOfVec-1] = pos;
1082  }
1083  }
1084  if(ncoordzVec.NElements() == 3)
1085  {
1086  int lado = tetra->WhichSide(ncoordzVec);
1087  TPZGeoElSide tetraSide(tetra, lado);
1088  TPZGeoElBC(tetraSide,neumann1);
1089  }
1090 
1091  // Na face x = -1
1092  ncoordzVec.Resize(0);
1093  sizeOfVec = 0;
1094  for (int i = 0; i < 4; i++)
1095  {
1096  int pos = tetra->NodeIndex(i);
1097  Nodefinder[i] = gMesh->NodeVec()[pos];
1098 
1099  Nodefinder[i].GetCoordinates(nodecoord);
1100  if (nodecoord[0] == -1.)
1101  {
1102  sizeOfVec++;
1103  ncoordzVec.Resize(sizeOfVec);
1104  ncoordzVec[sizeOfVec-1] = pos;
1105  }
1106  }
1107  if(ncoordzVec.NElements() == 3)
1108  {
1109  int lado = tetra->WhichSide(ncoordzVec);
1110  TPZGeoElSide tetraSide(tetra, lado);
1111  TPZGeoElBC(tetraSide,neumann2);
1112  }
1113 
1114  }
1115 
1116  TPZVec <REAL> xyz(3,-1.), yz(3,-1.), z(3,1.);
1117  yz[0] = 1.;
1118  z[2] = -1;
1119  int bcidxyz = -1, bcidyz = -2, bcidz = -3;
1120  SetPointBC(gMesh, xyz, bcidxyz);
1121  SetPointBC(gMesh, yz, bcidyz);
1122  SetPointBC(gMesh, z, bcidz);
1123 
1124  }
1125 
1126  /* refine mesh */
1127  if (refin.was_set()) {
1128 
1129  int nh = refin.get_value();
1130 
1131  for ( int ref = 0; ref < nh; ref++ ){
1132  TPZVec<TPZGeoEl *> filhos;
1133  int64_t n = gMesh->NElements();
1134  for ( int64_t i = 0; i < n; i++ ){
1135  TPZGeoEl * gel = gMesh->ElementVec() [i];
1136 
1137  if(!gel) continue;
1138  if(gel->Dimension() < 1) continue;
1139  if(gel->HasSubElement()) continue;
1140 
1141  gel->Divide (filhos);
1142  }
1143  }
1144  }
1145 
1146  ofstream arg("malhaPZ1BC.txt");
1147  gMesh->Print(arg);
1148 
1149  std::ofstream out("Cube.vtk");
1150  TPZVTKGeoMesh::PrintGMeshVTK(gMesh, out, true);
1151 
1152  return gMesh;
1153 }
1154 
1156 void SetPointBC(TPZGeoMesh *gr, TPZVec<REAL> &x, int bc)
1157 {
1158  // look for an element/corner node whose distance is close to start
1159  TPZGeoNode *gn1 = gr->FindNode(x);
1160  int64_t iel;
1161  int64_t nelem = gr->ElementVec().NElements();
1162  TPZGeoEl *gel;
1163  for (iel = 0; iel<nelem; iel++) {
1164  gel = gr->ElementVec()[iel];
1165  if(!gel) continue;
1166  int nc = gel->NCornerNodes();
1167  int c;
1168  for (c=0; c<nc; c++) {
1169  TPZGeoNode *gn = gel->NodePtr(c);
1170  if (gn == gn1) {
1171  break;
1172  }
1173  }
1174  if (c<nc) {
1175  TPZGeoElBC(gel, c, bc);
1176  return;
1177  }
1178  }
1179 }
1180 
1181 REAL Height(TPZGeoMesh *gmesh)
1182 {
1183  TPZAdmChunkVector<TPZGeoNode> &nodevec = gmesh->NodeVec();
1184  int nnodes = nodevec.NElements();
1185  int in;
1186  REAL maxz = 0.;
1187  for (in=0; in<nnodes; in++) {
1188  REAL z = nodevec[in].Coord(2);
1189  maxz = (maxz < z) ? z : maxz;
1190  }
1191  return maxz;
1192 }
1193 
1195 {
1196  int64_t nelem = cmesh->NElements();
1197  TPZManVector<int64_t> subindex(nelem,-1);
1198  int64_t iel;
1199  int nsub = 0;
1200  for (iel=0; iel<nelem; iel++)
1201  {
1202  TPZCompEl *cel = cmesh->ElementVec()[iel];
1203  if (!cel) {
1204  continue;
1205  }
1206  TPZGeoEl *gel = cel->Reference();
1207  if (!gel) {
1208  continue;
1209  }
1210  int nsides = gel->NSides();
1211  TPZManVector<REAL> center(gel->Dimension(),0.), xco(3,0.);
1212  gel->CenterPoint(nsides-1,center);
1213  gel->X(center,xco);
1214  REAL z = xco[2];
1215  int floor = (int) z/height;
1216  nsub = (floor+1) > nsub ? (floor+1) : nsub;
1217  subindex[iel] = floor;
1218  }
1219 
1220 #ifdef PZDEBUG
1221  {
1222  TPZGeoMesh *gmesh = cmesh->Reference();
1223  int64_t nelgeo = gmesh->NElements();
1224  TPZVec<int> domaincolor(nelgeo,-999);
1225  int64_t cel;
1226  int64_t nel = cmesh->NElements();
1227  for (cel=0; cel<nel; cel++) {
1228  TPZCompEl *compel = cmesh->ElementVec()[cel];
1229  if(!compel) continue;
1230  TPZGeoEl *gel = compel->Reference();
1231  if (!gel) {
1232  continue;
1233  }
1234  domaincolor[gel->Index()] = subindex[cel];
1235  }
1236  ofstream vtkfile("partition.vtk");
1237  TPZVTKGeoMesh::PrintGMeshVTK(gmesh, vtkfile, domaincolor);
1238  }
1239 #endif
1240 
1241  int isub;
1242  TPZManVector<TPZSubCompMesh *> submeshes(nsub,0);
1243  for (isub=0; isub<nsub; isub++)
1244  {
1245  int64_t index;
1246  std::cout << '^'; std::cout.flush();
1247  submeshes[isub] = new TPZSubCompMesh(cmesh,index);
1248 
1249  if (index < subindex.NElements())
1250  {
1251  subindex[index] = -1;
1252  }
1253  }
1254  for (iel=0; iel<nelem; iel++)
1255  {
1256  int domindex = subindex[iel];
1257  if (domindex >= 0)
1258  {
1259  TPZCompEl *cel = cmesh->ElementVec()[iel];
1260  if (!cel)
1261  {
1262  continue;
1263  }
1264  submeshes[domindex]->TransferElement(cmesh.operator->(),iel);
1265  }
1266  }
1267  cmesh->ComputeNodElCon();
1268  for (isub=0; isub<nsub; isub++)
1269  {
1270  submeshes[isub]->MakeAllInternal();
1271  std::cout << '*'; std::cout.flush();
1272  }
1273 
1274  cmesh->ComputeNodElCon();
1275  cmesh->CleanUpUnconnectedNodes();
1276  return nsub;
1277 }
int64_t NElements() const
Number of computational elements allocated.
Definition: pzcmesh.h:169
Contains a class to record running statistics on CSV tables.
RunStatsTable assemble_rst("-ass_rdt", "Assemble statistics raw data table (step 3)")
TPZGeoMesh * Reference() const
Returns a pointer to the geometrical mesh associated.
Definition: pzcmesh.h:209
void Extract(int isub, const TPZFMatrix< TVar > &global, TPZFMatrix< TVar > &local) const
Extract the values from the global matrix into the local matrix.
clarg::argInt nt_a("-nt_a", "Pair (l2): number of threads to assemble each submesh (multiply by nt_sm)", 0)
clarg::argString cf2("-cf2", "starts execution from checkpoint 2 (read checkpoint file)", "ckpt2.ckpt")
static void SetgOrder(int order)
Sets the value of the default interpolation order.
Definition: pzcompel.h:825
TPZGeoNode * NodePtr(int i) const
Returns a pointer to the ith node of the element.
Definition: pzgeoel.cpp:2566
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.
Contains declaration of the TPZMD5Stream class which implements the interface to write and check md5 ...
Implements a vector class which allows to use external storage provided by the user. Utility.
Definition: pzquad.h:16
#define PERF_STOP(obj)
Definition: substruct.cpp:161
void Write(TPZStream &buf, int withclassid) const override
Packs the object structure in a stream of bytes.
Definition: pzmatrix.cpp:1420
RunStatsTable total_rst("-tot_rdt", "Whole program (total) statistics raw data table")
clarg::argBool bc("-bc", "binary checkpoints", false)
RunStatsTable create_rst("-cre_rdt", "Create statistics raw data table (step 2)")
#define PERF_START(obj)
Definition: substruct.cpp:160
Contains the TPZDohrSubstruct class which implements sub structure matrices using Dohrman algorithm...
void values(ostream &os, bool defined_only)
Definition: arglib.cpp:183
int main(int argc, char *argv[])
Definition: substruct.cpp:219
void OpenRead(const std::string &fn)
Definition: substruct.cpp:179
clarg::argInt nsub("-nsub", "number of substructs", 4)
int64_t NEquations()
This computes the number of equations associated with non-restrained nodes.
Definition: pzcmesh.cpp:721
clarg::argInt verb_level("-v", "verbosity level", 0)
Contains the TPZVTKGraphMesh class which implements the graphical mesh to VTK environment.
Contains declaration of TPZCompEl class which defines the interface of a computational element...
TPZGeoMesh * MalhaPredio()
Definition: substruct.cpp:887
static TPZSubCompMesh * SubMesh(TPZAutoPointer< TPZCompMesh > compmesh, int isub)
return a pointer to the isub submesh
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Definition: pzgmesh.cpp:1505
Defines step solvers class. Solver.
Definition: pzmganalysis.h:17
Calculate the Times. Utility.
Definition: TPZfTime.h:21
virtual int NCornerNodes() const =0
Returns the number of corner nodes of the element.
This class implements a 3D isotropic elasticity material.
Definition: pzelast3d.h:21
Contains the TPZDohrMatrix class which implements a matrix divided into substructures. Also contains the TPZDohrThreadMultData and TPZDohrThreadMultList structs.
To export a graphical mesh to VTK environment. Post processing.
Definition: pzvtkmesh.h:19
int64_t NElements() const
Number of elements of the mesh.
Definition: pzgmesh.h:129
virtual int NStateVariables() const =0
Returns the number of state variables associated with the material.
clarg::argBool pair_tbb("-pair_tbb", "assemble TPZPairStructMatrix (level 2) using TBB", false)
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Definition: pzgeoelside.h:83
clarg::argString chk_sig_ckpt4("-chk_c4_md5", "compute MD5 signature for checkpoint 4 and check against MD5 at file.", "ckpt4.md5")
Contains declaration of TPZGeoElBC class, it is a structure to help the construction of geometric ele...
virtual void SetDefaultMem(TMEM &defaultMem)
Sets the default memory settings for initialization.
int64_t NElements() const
Access method to query the number of elements of the vector.
void OpenWrite(const std::string &fn)
Definition: substruct.cpp:171
clarg::argString cf3("-cf3", "starts execution from checkpoint 3 (read checkpoint file)", "ckpt3.ckpt")
clarg::argBool dohr_tbb("-dohr_tbb", "assemble TPZDohrStructMatrix (level 1) using TBB", false)
REAL GetTolerance() const
return the value of tolerance from the solver
Definition: pzstepsolver.h:57
virtual int NSides() const =0
Returns the number of connectivities of the element.
void SetPointBC(TPZGeoMesh *gr, TPZVec< REAL > &x, int bc)
Generate a boundary geometric element at the indicated node.
Definition: substruct.cpp:1220
virtual void Divide(TPZVec< TPZGeoEl *> &pv)
Divides the element and puts the resulting elements in the vector.
Definition: pzgeoel.h:742
Implements a matrix divided into substructures. Matrix Sub structure.
Definition: tpzdohrmatrix.h:30
virtual int64_t NodeIndex(int i) const =0
Returns the index of the ith node the index is the location of the node in the nodevector of the mesh...
Contains the TPZDohrAssembly class which implements assembling using Dohrmann algorithm.
TPZGeoMesh * MalhaCubo()
Definition: substruct.cpp:1026
clarg::argBool st1("-st1", "stop at checkpoint 1 (after dump)", false)
clarg::argInt refin("-ref", "refine mesh", 1)
static TPZGraphNode gn
Definition: pzgraphmesh.cpp:76
int WhichSide(TPZVec< int64_t > &SideNodeIds)
Returns the side number which is connected to the SideNodes returns -1 if no side is found...
Definition: pzgeoel.cpp:165
Contains the TPZDohrStructMatrix class which implements structural matrix divided in sub structures...
const int bc3
Definition: main.cpp:88
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
void Read(TPZStream &buf, void *context) override
read objects from the stream
Definition: pzgmesh.cpp:1487
clarg::argBool h("-h", "help message", false)
fn
Definition: test.py:253
clarg::argString gen_sig_ckpt1("-gen_c1_md5", "generates MD5 signature for checkpoint 1 and dump into file.", "ckpt1.md5")
RunStatsTable precond_rst("-pre_rdt", "Precond statistics raw data table (step 3)")
TPZGeoNode * FindNode(TPZVec< REAL > &co)
Returns the nearest node to the coordinate. This method is VERY INEFFICIENT.
Definition: pzgmesh.cpp:419
Contains the TPZElasticity3D class which implements a 3D isotropic elasticity material.
const int bc4
Definition: main.cpp:89
void SetDefaultOrder(int order)
Definition: pzcmesh.h:403
clarg::argInt maxlevel("-maxlevel", "maxlevel???", 5)
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...
Contains the TPZBndCond class which implements a boundary condition for TPZMaterial objects...
void InsertViscoElasticityCubo(TPZAutoPointer< TPZCompMesh > mesh)
Definition: substruct.cpp:761
clarg::argInt plevel("-p", "plevel", 1)
clarg::argString dc3("-dc3", "dump checkpoint 3 to file", "ckpt3.ckpt")
int Zero() override
Makes Zero all the elements.
Definition: pzfmatrix.h:651
clarg::argString mp("-mp", "starts execution from beginning - read a \alha_predio\input file", "../8andares02.txt")
TPZAutoPointer< TPZMatrix< STATE > > Preconditioner()
This will return the pointer to the preconditioner AND abandon the pointer.
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 TPZGenSubStruct class which is an interface to "feed" the datastructure of the Dohrmann ...
int CheckMD5(const std::string &filename)
Check Stream MD5 signature against MD5 signature store on file.
Definition: pzmd5stream.h:65
void AssembleTBB(TPZMatrix< STATE > &mat, TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface)
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 Write(TPZStream &str, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
void SetCG(const int64_t numiterations, const TPZMatrixSolver< TVar > &pre, const REAL tol, const int64_t FromCurrent)
clarg::argInt dim_arg("-dim", "dim???", 3)
clarg::argString dc2("-dc2", "dump checkpoint 2 to file", "ckpt2.ckpt")
#define LOGPZ_INFO(A, B)
Define log for informations.
Definition: pzlog.h:89
Implements reading from and writing to an ascii file. Persistency.
Definition: TPZFileStream.h:15
virtual void Print(std::ostream &out=std::cout) const
Print the information of the grid to an ostream.
Definition: pzgmesh.cpp:130
Implements a generic geometric element which is refined according to a generic refinement pattern...
Definition: pzgmesh.h:35
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
void InsertElasticity(TPZAutoPointer< TPZCompMesh > mesh)
Definition: substruct.cpp:779
clarg::argString gen_sig_ckpt3("-gen_c3_md5", "generates MD5 signature for checkpoint 3 and dump into file.", "ckpt3.md5")
clarg::argInt sublevel("-sublevel", "sublevel???", 3)
int64_t Index() const
Returns the index of the element within the element vector of the mesh.
Definition: pzgeoel.h:730
Contains the TPZGeoTetrahedra class which implements the geometry of a tetrahedral element...
Implements a group of computational elements as a mesh and an element. Computational Mesh...
Definition: pzsubcmesh.h:36
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
void Read(TPZStream &buf, void *context) override
Read the element data from a stream.
Definition: pzcmesh.cpp:2006
clarg::argString chk_sig_ckpt2("-chk_c2_md5", "compute MD5 signature for checkpoint 2 and check against MD5 at file.", "ckpt2.md5")
clarg::argInt nt_sm("-nt_sm", "Dohr (l1): number of threads to process the submeshes", 0)
int parse_arguments(int argc, char *argv[])
Definition: arglib.cpp:195
virtual void SetNumThreads(int n)
def read(filename)
Definition: stats.py:13
#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 the TPZSkylineStructMatrix class which implements SkyLine Structural Matrices.
virtual void SetUpdateMem(bool update=1)
Sets/Unsets the internal memory data to be updated in the next assemble/contribute call...
RunStatsTable solve_rst("-sol_rdt", "Solver statistics raw data table (step 4)")
int Dimension() const
Returns the dimension of the simulation.
Definition: pzcmesh.h:148
clarg::argBool st2("-st2", "stop at checkpoint 2 (after dump)", false)
virtual void ComputeNodElCon()
Compute the number of elements connected to each connect object.
Definition: pzcmesh.cpp:668
virtual int PushMemItem(int sourceIndex=-1) override
Pushes a new entry in the context of materials with memory.
virtual void Assemble(TPZMatrix< STATE > &mat, TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface, unsigned numthreads_assemble, unsigned numthreads_decompose) override
Assemble the global system of equations into the matrix which has already been created.
TPZMaterial * FindMaterial(int id)
Find the material with identity id.
Definition: pzcmesh.cpp:297
TPZAdmChunkVector< TPZGeoNode > & NodeVec()
Definition: pzgmesh.h:140
Contains the TPZDohrPrecond class which implements a matrix which computes the preconditioner develop...
virtual void AutoBuild(const std::set< int > *MaterialIDs)
Creates the computational elements, and the degree of freedom nodes.
Definition: pzcmesh.cpp:308
virtual TPZMatrix< STATE > * Create() override
This will create a DohrMatrix.
Contains the TPZPairStructMatrix class.
clarg::argInt num_it("-num_it", "number limit of iterations to the CG solver", 1000)
void Read(TPZStream &buf, void *context) override
Unpacks the object structure from a stream of bytes.
Definition: pzmatrix.cpp:1413
void AddInternalSolution(TPZFMatrix< TVar > &solution)
Add the solution corresponding to the internal residual.
Contains the TPZfTime class which calculates times.
void arguments_descriptions(ostream &os, string prefix, string suffix)
Definition: arglib.cpp:189
static void PrintGMeshVTK(TPZGeoMesh *gmesh, std::ofstream &file, bool matColor=true)
Default constructor for graphical mesh with VTK format.
void help(const char *prg)
Definition: substruct.cpp:86
void Solve(const TPZFMatrix< TVar > &F, TPZFMatrix< TVar > &result, TPZFMatrix< TVar > *residual=0) override
Solves the system of linear equations.
void SetDimModel(int dim)
Set de dimension of the domain of the problem.
Definition: pzcmesh.h:139
void InsertViscoElasticity(TPZAutoPointer< TPZCompMesh > mesh)
Definition: substruct.cpp:796
std::map< int,TPZMaterial *> & MaterialVec()
Returns a reference to the material pointers vector.
Definition: pzcmesh.h:203
clarg::argString chk_sig_ckpt1("-chk_c1_md5", "compute MD5 signature for checkpoint 1 and check against MD5 at file.", "ckpt1.md5")
virtual int HasSubElement() const =0
Return 1 if the element has subelements.
virtual void SetFileName(const std::string &filename)
Sets the filename to output of graph.
clarg::argInt nt_multiply("-nt_m", "number of threads to multiply", 0)
std::string ReturnTimeString()
When called, returns the time since the creation of the object in a string.
Definition: TPZfTime.cpp:20
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
virtual TPZBndCond * CreateBC(TPZMaterial *reference, int id, int typ, TPZFMatrix< STATE > &val1, TPZFMatrix< STATE > &val2)
Creates an object TPZBndCond derived of TPZMaterial.
int InsertMaterialObject(TPZMaterial *mat)
Insert a material object in the datastructure.
Definition: pzcmesh.cpp:287
int WriteMD5(const std::string &filename)
Write computed MD5 signature to file.
Definition: pzmd5stream.h:121
void InitializePZLOG()
Initializes log file for log4cxx with commom name log4cxx.cfg.
Definition: pzlog.cpp:14
virtual void CleanUpUnconnectedNodes()
Delete the nodes which have no elements connected to them.
Definition: pzcmesh.cpp:498
virtual int Dimension() const =0
Returns the dimension of the element.
Contains the TPZArc3D class which implements three dimensional arc.
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
const SubsList & SubStructures() const
Definition: tpzdohrmatrix.h:64
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...
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
This class implements an isotropic viscoelasticity material.
int verbose
Definition: decompose.cpp:67
bool was_set() const
Definition: arglib.h:138
const int bc1
Definition: main.cpp:86
clarg::argString dc1("-dc1", "dump checkpoint 1 to file", "ckpt1.ckpt")
REAL Height(TPZGeoMesh *gmesh)
Definition: substruct.cpp:1245
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
clarg::argInt nt_d("-nt_d", "Dohr (l1): number of threads to decompose each submesh", 0)
clarg::argString gen_sig_ckpt2("-gen_c2_md5", "generates MD5 signature for checkpoint 2 and dump into file.", "ckpt2.md5")
void Write(TPZStream &buf, int withclassid) const override
Packs the object structure in a stream of bytes.
Contains TPZStepSolver class which defines step solvers class.
const int bc2
Definition: main.cpp:87
clarg::argString chk_sig_ckpt3("-chk_c3_md5", "compute MD5 signature for checkpoint 3 and check against MD5 at file.", "ckpt3.md5")
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
clarg::argString cf1("-cf1", "starts execution from checkpoint 1 (read checkpoint file)", "ckpt1.ckpt")
clarg::argBool st3("-st3", "stop at checkpoint 3 (after dump)", false)
#define SAVEABLE_STR_NOTE(buf, str)
Definition: TPZSavable.h:42
clarg::argString m("-m", "input matrix file name (text format)", "matrix.txt")
clarg::argString gen_sig_ckpt4("-gen_c4_md5", "generates MD5 signature for checkpoint 4 and dump into file.", "ckpt4.md5")
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
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 ...
#define VERBOSE(level,...)
void SetMaterialDataHooke(STATE ElaE, STATE poissonE, STATE ElaV, STATE poissonV, STATE alpha, STATE deltaT, TPZVec< STATE > &force)
Set material Data with hooke constants.
int SubStructure(TPZAutoPointer< TPZCompMesh > cmesh, REAL height)
Definition: substruct.cpp:1258
void Read(TPZStream &str, void *context) override
read objects from the stream
clarg::argString mc("-mc", "starts execution from beginning - read a \alha_cubo\input file", "../cube1.txt")
Implements the interface to write and check MD5 files. Persistency.
Definition: pzmd5stream.h:22
void Write(TPZStream &buf, int withclassid) const override
Save the element data to a stream.
Definition: pzcmesh.cpp:1975
TPZAutoPointer< TPZDohrAssembly< TVar > > fAssembly
Definition: tpzdohrmatrix.h:45
#define SAVEABLE_SKIP_NOTE(buf)
Definition: TPZSavable.h:43
virtual void Print(std::ostream &out=std::cout) const
Prints mesh data.
Definition: pzcmesh.cpp:236
Implements structural matrix divided in sub structures. Structural Matrix Sub structure.
TPZAdmChunkVector< TPZGeoEl * > & ElementVec()
Methods for handling pzlists.
Definition: pzgmesh.h:138