OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
vtkxmlexportmodule.C
Go to the documentation of this file.
1 /*
2  *
3  * ##### ##### ###### ###### ### ###
4  * ## ## ## ## ## ## ## ### ##
5  * ## ## ## ## #### #### ## # ##
6  * ## ## ## ## ## ## ## ##
7  * ## ## ## ## ## ## ## ##
8  * ##### ##### ## ###### ## ##
9  *
10  *
11  * OOFEM : Object Oriented Finite Element Code
12  *
13  * Copyright (C) 1993 - 2013 Borek Patzak
14  *
15  *
16  *
17  * Czech Technical University, Faculty of Civil Engineering,
18  * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19  *
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Lesser General Public
22  * License as published by the Free Software Foundation; either
23  * version 2.1 of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28  * Lesser General Public License for more details.
29  *
30  * You should have received a copy of the GNU Lesser General Public
31  * License along with this library; if not, write to the Free Software
32  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33  */
34 
35 #include "vtkxmlexportmodule.h"
36 #include "element.h"
37 #include "gausspoint.h"
38 #include "timestep.h"
39 #include "engngm.h"
40 #include "node.h"
41 #include "dof.h"
42 #include "materialinterface.h"
43 #include "mathfem.h"
44 #include "cltypes.h"
45 #include "material.h"
46 #include "classfactory.h"
47 #include "crosssection.h"
48 #include "unknownnumberingscheme.h"
49 
50 #include "xfem/xfemmanager.h"
51 #include "xfem/enrichmentitem.h"
52 
53 #ifdef __PFEM_MODULE
54  #include "pfem/pfemparticle.h"
55 #endif
56 
57 #include <string>
58 #include <sstream>
59 #include <fstream>
60 #include <ctime>
61 
62 #ifdef __VTK_MODULE
63  #include <vtkPoints.h>
64  #include <vtkPointData.h>
65  #include <vtkDoubleArray.h>
66  #include <vtkCellArray.h>
67  #include <vtkCellData.h>
68  #include <vtkXMLUnstructuredGridWriter.h>
69  #include <vtkXMLPUnstructuredGridWriter.h>
70  #include <vtkUnstructuredGrid.h>
71  #include <vtkSmartPointer.h>
72 #endif
73 
74 namespace oofem {
76 
77 IntArray VTKXMLExportModule :: redToFull = {
78  1, 5, 9, 8, 7, 4, 6, 3, 2
79 }; //position of xx, yy, zz, yz, xz, xy in tensor
80 
81 VTKXMLExportModule :: VTKXMLExportModule(int n, EngngModel *e) : ExportModule(n, e), internalVarsToExport(), primaryVarsToExport()
82 {
83  primVarSmoother = NULL;
84  smoother = NULL;
85 }
86 
87 
89 {
90  if ( this->smoother ) {
91  delete this->smoother;
92  }
93 
94  if ( this->primVarSmoother ) {
95  delete this->primVarSmoother;
96  }
97 }
98 
99 
102 {
103  IRResultType result; // Required by IR_GIVE_FIELD macro
104  int val;
105 
106  IR_GIVE_OPTIONAL_FIELD(ir, cellVarsToExport, _IFT_VTKXMLExportModule_cellvars); // Macro - see internalstatetype.h
107  IR_GIVE_OPTIONAL_FIELD(ir, internalVarsToExport, _IFT_VTKXMLExportModule_vars); // Macro - see internalstatetype.h
110  IR_GIVE_OPTIONAL_FIELD(ir, ipInternalVarsToExport, _IFT_VTKXMLExportModule_ipvars); // Macro - see internalstatetype.h
111 
112  val = 1;
115 
116  this->particleExportFlag = false;
118 
120 }
121 
122 
123 void
125 {
126  if ( this->smoother ) {
127  delete this->smoother;
128  this->smoother = NULL;
129  }
130 
132 }
133 
134 
135 void
137 { }
138 
139 
140 void
142 {
143  answer.resize(9);
144  answer.zero();
145 
146  for ( int i = 1; i <= reducedForm.giveSize(); i++ ) {
147  answer.at( redToFull.at(i) ) = reducedForm.at(i);
148  }
149 
150  if ( vtype == ISVT_TENSOR_S3E ) {
151  answer.at(4) *= 0.5;
152  answer.at(7) *= 0.5;
153  answer.at(8) *= 0.5;
154  }
155 
156  // Symmetrize if needed
157  if ( vtype != ISVT_TENSOR_G ) {
158  answer.at(2) = answer.at(4);
159  answer.at(3) = answer.at(7);
160  answer.at(6) = answer.at(8);
161  }
162 }
163 
164 
165 std :: string
167 {
168  return this->giveOutputBaseFileName(tStep) + ".vtu";
169 }
170 
171 
172 FILE *
174 {
175  FILE *answer;
176  std :: string fileName = giveOutputFileName(tStep);
177  if ( ( answer = fopen(fileName.c_str(), "w") ) == NULL ) {
178  OOFEM_ERROR( "failed to open file %s", fileName.c_str() );
179  }
180 
181  return answer;
182 }
183 
184 int
186 {
187  Element_Geometry_Type elemGT = elem->giveGeometryType();
188  int vtkCellType = 0;
189 
190  if ( elemGT == EGT_point ) {
191  vtkCellType = 1;
192  } else if ( elemGT == EGT_line_1 ) {
193  vtkCellType = 3;
194  } else if ( elemGT == EGT_line_2 ) {
195  vtkCellType = 21;
196  } else if ( elemGT == EGT_triangle_1 ) {
197  vtkCellType = 5;
198  } else if ( elemGT == EGT_triangle_2 ) {
199  vtkCellType = 22;
200  } else if ( elemGT == EGT_tetra_1 ) {
201  vtkCellType = 10;
202  } else if ( elemGT == EGT_tetra_2 ) {
203  vtkCellType = 24;
204  } else if ( elemGT == EGT_quad_1 || elemGT == EGT_quad_1_interface ) {
205  vtkCellType = 9;
206  } else if ( elemGT == EGT_quad_21_interface ) {
207  vtkCellType = 30;
208  } else if ( elemGT == EGT_quad_2 ) {
209  vtkCellType = 23;
210  } else if ( elemGT == EGT_quad9_2 ) {
211  vtkCellType = 23;
212  } else if ( elemGT == EGT_hexa_1 ) {
213  vtkCellType = 12;
214  } else if ( elemGT == EGT_hexa_2 ) {
215  vtkCellType = 25;
216  } else if ( elemGT == EGT_hexa_27 ) {
217  vtkCellType = 29;
218  } else if ( elemGT == EGT_wedge_1 ) {
219  vtkCellType = 13;
220  } else if ( elemGT == EGT_wedge_2 ) {
221  vtkCellType = 26;
222  } else {
223  OOFEM_ERROR( "unsupported element geometry type on element %d", elem->giveNumber() );
224  }
225 
226  return vtkCellType;
227 }
228 
229 int
231 {
232  switch ( cellType ) {
233  case 1:
234  return 1;
235 
236  case 3:
237  return 2;
238 
239  case 5:
240  case 21:
241  return 3;
242 
243  case 9:
244  case 10:
245  return 4;
246 
247  case 14:
248  return 5;
249 
250  case 13:
251  case 22:
252  case 30:
253  return 6;
254 
255  case 12:
256  case 23:
257  return 8;
258 
259  case 24:
260  return 10;
261 
262  case 25:
263  return 20;
264 
265  case 29:
266  return 27;
267 
268  default:
269  OOFEM_ERROR("unsupported cell type ID");
270  }
271 
272  return 0; // to make compiler happy
273 }
274 
275 
276 void
278 {
279  // Gives the node mapping from the order used in OOFEM to that used in VTK
280 
281  Element_Geometry_Type elemGT = elem->giveGeometryType();
282  IntArray nodeMapping(0);
283  if ( ( elemGT == EGT_point ) ||
284  ( elemGT == EGT_line_1 ) || ( elemGT == EGT_line_2 ) ||
285  ( elemGT == EGT_triangle_1 ) || ( elemGT == EGT_triangle_2 ) ||
286  ( elemGT == EGT_tetra_1 ) || ( elemGT == EGT_tetra_2 ) ||
287  ( elemGT == EGT_quad_1 ) || ( elemGT == EGT_quad_2 ) ||
288  ( elemGT == EGT_hexa_1 ) || ( elemGT == EGT_quad9_2 ) ||
289  ( elemGT == EGT_wedge_1 ) ) {} else if ( elemGT == EGT_hexa_27 ) {
290  nodeMapping = {
291  5, 8, 7, 6, 1, 4, 3, 2, 16, 15, 14, 13, 12, 11, 10, 9, 17, 20, 19, 18, 23, 25, 26, 24, 22, 21, 27
292  };
293  } else if ( elemGT == EGT_hexa_2 ) {
294  nodeMapping = {
295  5, 8, 7, 6, 1, 4, 3, 2, 16, 15, 14, 13, 12, 11, 10, 9, 17, 20, 19, 18
296  };
297  } else if ( elemGT == EGT_wedge_2 ) {
298  nodeMapping = {
299  4, 6, 5, 1, 3, 2, 12, 11, 10, 9, 8, 7, 13, 15, 14
300  };
301  } else if ( elemGT == EGT_quad_1_interface ) {
302  nodeMapping = {
303  1, 2, 4, 3
304  };
305  } else if ( elemGT == EGT_quad_21_interface ) {
306 // nodeMapping = {
307 // 1, 2, 5, 4, 3, 6
308 // };
309  nodeMapping = {
310  1, 2, 5, 4, 3, 6
311  };
312  } else {
313  OOFEM_ERROR("VTKXMLExportModule: unsupported element geometry type");
314  }
315 
316  int nelemNodes = elem->giveNumberOfNodes();
317  answer.resize(nelemNodes);
318  if ( nodeMapping.giveSize() > 0 ) {
319  for ( int i = 1; i <= nelemNodes; i++ ) {
320  answer.at(i) = elem->giveNode( nodeMapping.at(i) )->giveNumber();
321  }
322  } else {
323  for ( int i = 1; i <= nelemNodes; i++ ) {
324  answer.at(i) = elem->giveNode(i)->giveNumber();
325  }
326  }
327 }
328 
329 
330 bool
332 {
333  return ( elem->giveGeometryType() == EGT_Composite );
334 }
335 
336 
337 void
338 VTKXMLExportModule :: doOutput(TimeStep *tStep, bool forcedOutput)
339 {
340  if ( !( testTimeStepOutput(tStep) || forcedOutput ) ) {
341  return;
342  }
343 
344 
345 
346 #ifdef __VTK_MODULE
347  this->fileStream = vtkSmartPointer< vtkUnstructuredGrid > :: New();
348  this->nodes = vtkSmartPointer< vtkPoints > :: New();
349  this->elemNodeArray = vtkSmartPointer< vtkIdList > :: New();
350 
351 #else
352  this->fileStream = this->giveOutputStream(tStep);
353  struct tm *current;
354  time_t now;
355  time(& now);
356  current = localtime(& now);
357 
358 #endif
359 
360  // Write output: VTK header
361 #ifndef __VTK_MODULE
362  fprintf(this->fileStream, "<!-- TimeStep %e Computed %d-%02d-%02d at %02d:%02d:%02d -->\n", tStep->giveTargetTime() * timeScale, current->tm_year + 1900, current->tm_mon + 1, current->tm_mday, current->tm_hour, current->tm_min, current->tm_sec);
363  fprintf(this->fileStream, "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n");
364  fprintf(this->fileStream, "<UnstructuredGrid>\n");
365 #endif
366 
367  this->giveSmoother(); // make sure smoother is created, Necessary? If it doesn't exist it is created /JB
368 
369 
370  if ( !this->particleExportFlag ) {
371  /* Loop over pieces ///@todo: this feature has been broken but not checked if it currently works /JB
372  * Start default pieces containing all single cell elements. Elements built up from several vtk
373  * cells (composite elements) are exported as individual pieces after the default ones.
374  */
375  int nPiecesToExport = this->giveNumberOfRegions(); //old name: region, meaning: sets
376  int anyPieceNonEmpty = 0;
377 
378  for ( int pieceNum = 1; pieceNum <= nPiecesToExport; pieceNum++ ) {
379  // Fills a data struct (VTKPiece) with all the necessary data.
380  this->setupVTKPiece(this->defaultVTKPiece, tStep, pieceNum);
381 
382  // Write the VTK piece to file.
383  anyPieceNonEmpty += this->writeVTKPiece(this->defaultVTKPiece, tStep);
384  }
385 
386  /*
387  * Output all composite elements - one piece per composite element
388  * Each element is responsible of setting up a VTKPiece which can then be exported
389  */
390  Domain *d = emodel->giveDomain(1);
391 
392  for ( int pieceNum = 1; pieceNum <= nPiecesToExport; pieceNum++ ) {
393  const IntArray &elements = this->giveRegionSet(pieceNum)->giveElementList();
394  for ( int i = 1; i <= elements.giveSize(); i++ ) {
395  Element *el = d->giveElement( elements.at(i) );
396  if ( this->isElementComposite(el) ) {
397  if ( el->giveParallelMode() != Element_local ) {
398  continue;
399  }
400 
401 #ifndef __VTK_MODULE
402  //this->exportCompositeElement(this->defaultVTKPiece, el, tStep);
403  this->exportCompositeElement(this->defaultVTKPieces, el, tStep);
404 
405  for ( int j = 0; j < ( int ) this->defaultVTKPieces.size(); j++ ) {
406  anyPieceNonEmpty += this->writeVTKPiece(this->defaultVTKPieces [ j ], tStep);
407  }
408 #else
409  // No support for binary export yet
410 #endif
411  }
412  }
413  } // end loop over composite elements
414 
415  if (anyPieceNonEmpty == 0) {
416  // write empty piece, Otherwise ParaView complains if the whole vtu file is without <Piece></Piece>
417  fprintf(this->fileStream, "<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\">\n");
418  fprintf(this->fileStream, "<Cells>\n<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\"> </DataArray>\n</Cells>\n");
419  fprintf(this->fileStream, "</Piece>\n");
420  }
421 
422 
423  } else { // if (particleExportFlag)
424 #ifdef __PFEM_MODULE
425  // write out the particles (nodes exported as vertices = VTK_VERTEX)
426  Domain *d = emodel->giveDomain(1);
427  int nnode = d->giveNumberOfDofManagers();
428 
429  int nActiveNode = 0;
430  for ( int inode = 1; inode <= nnode; inode++ ) {
431  PFEMParticle *particle = dynamic_cast< PFEMParticle * >( d->giveNode(inode) );
432  if ( particle ) {
433  if ( particle->isActive() ) {
434  nActiveNode++;
435  }
436  }
437  }
438 
439  DofManager *node;
440  FloatArray *coords;
441  fprintf(this->fileStream, "<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n", nActiveNode, nActiveNode);
442  fprintf(this->fileStream, "<Points>\n <DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\"> ");
443 
444  for ( int inode = 1; inode <= nnode; inode++ ) {
445  node = d->giveNode(inode);
446  PFEMParticle *particle = dynamic_cast< PFEMParticle * >(node);
447  if ( particle ) {
448  if ( particle->isActive() ) {
449  coords = node->giveCoordinates();
451  for ( int i = 1; i <= coords->giveSize(); i++ ) {
452  fprintf( this->fileStream, "%e ", coords->at(i) );
453  }
454 
455  for ( int i = coords->giveSize() + 1; i <= 3; i++ ) {
456  fprintf(this->fileStream, "%e ", 0.0);
457  }
458  }
459  }
460  }
461 
462  fprintf(this->fileStream, "</DataArray>\n</Points>\n");
463 
464 
465  // output the cells connectivity data
466  fprintf(this->fileStream, "<Cells>\n");
467  fprintf(this->fileStream, " <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\"> ");
468 
469  for ( int ielem = 1; ielem <= nActiveNode; ielem++ ) {
470  fprintf(this->fileStream, "%d ", ielem - 1);
471  }
472 
473  fprintf(this->fileStream, "</DataArray>\n");
474 
475  // output the offsets (index of individual element data in connectivity array)
476  fprintf(this->fileStream, " <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\"> ");
477 
478  for ( int ielem = 1; ielem <= nActiveNode; ielem++ ) {
479  fprintf(this->fileStream, "%d ", ielem);
480  }
481  fprintf(this->fileStream, "</DataArray>\n");
482 
483 
484  // output cell (element) types
485  fprintf(this->fileStream, " <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\"> ");
486  for ( int ielem = 1; ielem <= nActiveNode; ielem++ ) {
487  fprintf(this->fileStream, "%d ", 1);
488  }
489 
490  fprintf(this->fileStream, "</DataArray>\n");
491  fprintf(this->fileStream, "</Cells>\n");
492  fprintf(this->fileStream, "</Piece>\n");
493 #endif //__PFEM_MODULE
494  }
495 
496 
497  // Finilize the output:
498  std :: string fname = giveOutputFileName(tStep);
499 #ifdef __VTK_MODULE
500 
501  #if 0
502  // Code fragment intended for future support of composite elements in binary format
503  // Doesn't as well as I would want it to, interface to VTK is to limited to control this.
504  // * The PVTU-file is written by every process (seems to be impossible to avoid).
505  // * Part files are renamed and time step and everything else is cut off => name collisions
506  vtkSmartPointer< vtkXMLPUnstructuredGridWriter >writer = vtkSmartPointer< vtkXMLPUnstructuredGridWriter > :: New();
507  writer->SetTimeStep(tStep->giveNumber() - 1);
508  writer->SetNumberOfPieces( this->emodel->giveNumberOfProcesses() );
509  writer->SetStartPiece( this->emodel->giveRank() );
510  writer->SetEndPiece( this->emodel->giveRank() );
511 
512 
513  #else
514  vtkSmartPointer< vtkXMLUnstructuredGridWriter >writer = vtkSmartPointer< vtkXMLUnstructuredGridWriter > :: New();
515  #endif
516 
517  writer->SetFileName( fname.c_str() );
518  writer->SetInput(this->fileStream); // VTK 4
519  //writer->SetInputData(this->fileStream); // VTK 6
520 
521  // Optional - set the mode. The default is binary.
522  //writer->SetDataModeToBinary();
523  writer->SetDataModeToAscii();
524  writer->Write();
525 #else
526  fprintf(this->fileStream, "</UnstructuredGrid>\n</VTKFile>");
527  fclose(this->fileStream);
528 #endif
529 
530  // export raw ip values (if required), works only on one domain
531  if ( !this->ipInternalVarsToExport.isEmpty() ) {
533  if ( !emodel->isParallel() && tStep->giveNumber() >= 1 ) { // For non-parallel enabled OOFEM, then we only check for multiple steps.
534  std :: ostringstream pvdEntry;
535  std :: stringstream subStep;
536  if ( tstep_substeps_out_flag ) {
537  subStep << "." << tStep->giveSubStepNumber();
538  }
539  pvdEntry << "<DataSet timestep=\"" << tStep->giveTargetTime() * this->timeScale << subStep.str() << "\" group=\"\" part=\"\" file=\"" << this->giveOutputBaseFileName(tStep) + ".gp.vtu" << "\"/>";
540  this->gpPvdBuffer.push_back( pvdEntry.str() );
541  this->writeGPVTKCollection();
542  }
543  }
544 
545  // Write the *.pvd-file. Currently only contains time step information. It's named "timestep" but is actually the total time.
546  // First we check to see that there are more than 1 time steps, otherwise it is redundant;
547  if ( emodel->isParallel() && emodel->giveRank() == 0 ) {
549  // For this to work, all processes must have an identical output file name.
550  for ( int i = 0; i < this->emodel->giveNumberOfProcesses(); ++i ) {
551  std :: ostringstream pvdEntry;
552  std :: stringstream subStep;
553  char fext [ 100 ];
554  if ( this->emodel->giveNumberOfProcesses() > 1 ) {
555  sprintf( fext, "_%03d.m%d.%d", i, this->number, tStep->giveNumber() );
556  } else {
557  sprintf( fext, "m%d.%d", this->number, tStep->giveNumber() );
558  }
559  if ( tstep_substeps_out_flag ) {
560  subStep << "." << tStep->giveSubStepNumber();
561  }
562  pvdEntry << "<DataSet timestep=\"" << tStep->giveTargetTime() * this->timeScale << subStep.str() << "\" group=\"\" part=\"" << i << "\" file=\"" << this->emodel->giveOutputBaseFileName() << fext << ".vtu\"/>";
563  this->pvdBuffer.push_back( pvdEntry.str() );
564  }
565 
566  this->writeVTKCollection();
567  } else if ( !emodel->isParallel() && tStep->giveNumber() >= 1 ) { // For non-parallel, then we only check for multiple steps.
568  std :: ostringstream pvdEntry;
569  std :: stringstream subStep;
570  if ( tstep_substeps_out_flag ) {
571  subStep << "." << tStep->giveSubStepNumber();
572  }
573  pvdEntry << "<DataSet timestep=\"" << tStep->giveTargetTime() * this->timeScale << subStep.str() << "\" group=\"\" part=\"\" file=\"" << fname << "\"/>";
574  this->pvdBuffer.push_back( pvdEntry.str() );
575  this->writeVTKCollection();
576  }
577 }
578 
579 
580 void
582 {
583  this->numNodes = numNodes;
584  this->nodeCoords.resize(numNodes);
585 }
586 
587 void
589 {
590  this->numCells = numCells;
591  this->connectivity.resize(numCells);
592  this->elCellTypes.resize(numCells);
593  this->elOffsets.resize(numCells);
594 }
595 
596 void
598 {
599  this->connectivity [ cellNum - 1 ] = nodes;
600 }
601 
602 void
604 {
605  this->nodeCoords [ nodeNum - 1 ] = coords;
606 }
607 
608 void
610 {
611  this->nodeVars.resize(numVars);
612  for ( int i = 1; i <= numVars; i++ ) {
613  this->nodeVars [ i - 1 ].resize(numNodes);
614  }
615 }
616 
617 void
618 VTKPiece :: setNumberOfLoadsToExport(int numVars, int numNodes)
619 {
620  this->nodeLoads.resize(numVars);
621  for ( int i = 1; i <= numVars; i++ ) {
622  this->nodeLoads [ i - 1 ].resize(numNodes);
623  }
624 }
625 
626 void
628 {
629  this->nodeVarsFromIS.resize(numVars);
630  for ( int i = 1; i <= numVars; i++ ) {
631  this->nodeVarsFromIS [ i - 1 ].resize(numNodes);
632  }
633 }
634 
635 void
636 VTKPiece :: setNumberOfInternalXFEMVarsToExport(int numVars, int numEnrichmentItems, int numNodes)
637 {
638  this->nodeVarsFromXFEMIS.resize(numVars);
639  for ( int i = 1; i <= numVars; i++ ) {
640  this->nodeVarsFromXFEMIS [ i - 1 ].resize(numEnrichmentItems);
641  for ( int j = 1; j <= numEnrichmentItems; j++ ) {
642  this->nodeVarsFromXFEMIS [ i - 1 ] [ j - 1 ].resize(numNodes);
643  }
644  }
645 }
646 
647 void
648 VTKPiece :: setNumberOfCellVarsToExport(int numVars, int numCells)
649 {
650  this->elVars.resize(numVars);
651  for ( int i = 1; i <= numVars; i++ ) {
652  this->elVars [ i - 1 ].resize(numCells);
653  }
654 }
655 
656 void
657 VTKPiece :: setPrimaryVarInNode(int varNum, int nodeNum, FloatArray valueArray)
658 {
659  this->nodeVars [ varNum - 1 ] [ nodeNum - 1 ] = std :: move(valueArray);
660 }
661 
662 void
663 VTKPiece :: setLoadInNode(int varNum, int nodeNum, FloatArray valueArray)
664 {
665  this->nodeLoads [ varNum - 1 ] [ nodeNum - 1 ] = std :: move(valueArray);
666 }
667 
668 void
669 VTKPiece :: setInternalVarInNode(int varNum, int nodeNum, FloatArray valueArray)
670 {
671  this->nodeVarsFromIS [ varNum - 1 ] [ nodeNum - 1 ] = std :: move(valueArray);
672 }
673 
674 void
675 VTKPiece :: setInternalXFEMVarInNode(int varNum, int eiNum, int nodeNum, FloatArray valueArray)
676 {
677  this->nodeVarsFromXFEMIS [ varNum - 1 ] [ eiNum - 1 ] [ nodeNum - 1 ] = std :: move(valueArray);
678 }
679 
680 
681 void
682 VTKPiece :: setCellVar(int varNum, int cellNum, FloatArray valueArray)
683 {
684  this->elVars [ varNum - 1 ] [ cellNum - 1 ] = std :: move(valueArray);
685 }
686 
687 
688 void
690 {
691  // Stores all neccessary data (of a region) in a VTKPiece so it can be exported later.
692 
693  Domain *d = emodel->giveDomain(1);
694  Element *elem;
695  FloatArray *coords;
696 
697  this->giveSmoother(); // make sure smoother is created
698 
699  // output nodes Region By Region
700  int numNodes, numRegionEl;
701  IntArray mapG2L, mapL2G;
702 
703  // Assemble local->global and global->local region map and get number of
704  // single cells to process, the composite cells exported individually.
705  this->initRegionNodeNumbering(mapG2L, mapL2G, numNodes, numRegionEl, d, tStep, region);
706  if ( numNodes > 0 && numRegionEl > 0 ) {
707  // Export nodes as vtk vertices
708  vtkPiece.setNumberOfNodes(numNodes);
709  for ( int inode = 1; inode <= numNodes; inode++ ) {
710  coords = d->giveNode( mapL2G.at(inode) )->giveCoordinates();
711  vtkPiece.setNodeCoords(inode, * coords);
712  }
713 
714 
715  //-------------------------------------------
716  // Export all the cell data for the piece
717  //-------------------------------------------
718  IntArray cellNodes;
719  vtkPiece.setNumberOfCells(numRegionEl);
720  IntArray regionElInd;
721 
722  int offset = 0;
723  int cellNum = 0;
724  IntArray elems = this->giveRegionSet(region)->giveElementList();
725  for ( int ei = 1; ei <= elems.giveSize(); ei++ ) {
726  int elNum = elems.at(ei);
727  elem = d->giveElement(elNum);
728 
729  // Skip elements that:
730  // are inactivated or of composite type ( these are exported individually later)
731  if ( this->isElementComposite(elem) || !elem->isActivated(tStep) ) {
732  continue;
733  }
734 
735  //skip materials with casting time > current time
736  if ( !elem->isCast(tStep) ) {
737  continue;
738  }
739 
740  if ( elem->giveParallelMode() != Element_local ) {
741  continue;
742  }
743 
744  regionElInd.followedBy(ei);
745 
746  cellNum++;
747 
748  // Set the connectivity
749  this->giveElementCell(cellNodes, elem); // node numbering of the cell with according to the VTK format
750 
751  // Map from global to local node numbers for the current piece
752  int numElNodes = cellNodes.giveSize();
753  IntArray connectivity(numElNodes);
754  for ( int i = 1; i <= numElNodes; i++ ) {
755  connectivity.at(i) = mapG2L.at( cellNodes.at(i) );
756  }
757 
758  vtkPiece.setConnectivity(cellNum, connectivity);
759 
760  vtkPiece.setCellType( cellNum, this->giveCellType(elem) ); // VTK cell type
761 
762  offset += numElNodes;
763  vtkPiece.setOffset(cellNum, offset);
764  }
765 
766 
767  // Export primary, internal and XFEM variables as nodal quantities
768  this->exportPrimaryVars(vtkPiece, mapG2L, mapL2G, region, tStep);
769  this->exportIntVars(vtkPiece, mapG2L, mapL2G, region, tStep);
770  this->exportExternalForces(vtkPiece, mapG2L, mapL2G, region, tStep);
771 
772  this->exportCellVars(vtkPiece, regionElInd, tStep);
773  } // end of default piece for simple geometry elements
774 }
775 
776 
777 bool
779 {
780  // Write a VTK piece to file. This could be the whole domain (most common case) or it can be a
781  // (so-called) composite element consisting of several VTK cells (layered structures, XFEM, etc.).
782 
783  /*
784  if ( !vtkPiece.giveNumberOfCells() ) { // handle piece with no elements. Otherwise ParaView complains if the whole vtu file is without <Piece></Piece>
785 // fprintf(this->fileStream, "<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\">\n");
786 // fprintf(this->fileStream, "<Cells>\n<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\"> </DataArray>\n</Cells>\n");
787 // fprintf(this->fileStream, "</Piece>\n");
788  return;
789  }
790  */
791  if ( !vtkPiece.giveNumberOfCells() ) return false;
792 
793 
794  // Write output: node coords
795  int numNodes = vtkPiece.giveNumberOfNodes();
796  int numEl = vtkPiece.giveNumberOfCells();
797  FloatArray coords;
798 
799 #ifdef __VTK_MODULE
800  FloatArray vtkCoords(3);
801  for ( int inode = 1; inode <= numNodes; inode++ ) {
802  coords = vtkPiece.giveNodeCoords(inode);
803  vtkCoords.zero();
804  for ( int i = 1; i <= coords.giveSize(); i++ ) {
805  vtkCoords.at(i) = coords.at(i);
806  }
807 
808  this->nodes->InsertNextPoint( vtkCoords.at(1), vtkCoords.at(2), vtkCoords.at(3) );
809  this->fileStream->SetPoints(nodes);
810  }
811 
812 #else
813  fprintf(this->fileStream, "<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n", numNodes, numEl);
814  fprintf(this->fileStream, "<Points>\n <DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\"> ");
815 
816  for ( int inode = 1; inode <= numNodes; inode++ ) {
817  coords = vtkPiece.giveNodeCoords(inode);
819  for ( int i = 1; i <= coords.giveSize(); i++ ) {
820  fprintf( this->fileStream, "%e ", coords.at(i) );
821  }
822 
823  for ( int i = coords.giveSize() + 1; i <= 3; i++ ) {
824  fprintf(this->fileStream, "%e ", 0.0);
825  }
826  }
827 
828  fprintf(this->fileStream, "</DataArray>\n</Points>\n");
829 #endif
830 
831 
832  // Write output: connectivity, offsets, cell types
833 
834  // output the connectivity data
835 #ifdef __VTK_MODULE
836  this->fileStream->Allocate(numEl);
837 #else
838  fprintf(this->fileStream, "<Cells>\n");
839  fprintf(this->fileStream, " <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\"> ");
840 #endif
841  IntArray cellNodes;
842  for ( int ielem = 1; ielem <= numEl; ielem++ ) {
843  cellNodes = vtkPiece.giveCellConnectivity(ielem);
844 
845 #ifdef __VTK_MODULE
846  elemNodeArray->Reset();
847  elemNodeArray->SetNumberOfIds( cellNodes.giveSize() );
848 #endif
849  for ( int i = 1; i <= cellNodes.giveSize(); i++ ) {
850 #ifdef __VTK_MODULE
851  elemNodeArray->SetId(i - 1, cellNodes.at(i) - 1);
852 #else
853  fprintf(this->fileStream, "%d ", cellNodes.at(i) - 1);
854 #endif
855  }
856 
857 #ifdef __VTK_MODULE
858  this->fileStream->InsertNextCell(vtkPiece.giveCellType(ielem), elemNodeArray);
859 #else
860  fprintf(this->fileStream, " ");
861 #endif
862  }
863 
864 #ifndef __VTK_MODULE
865  fprintf(this->fileStream, "</DataArray>\n");
866 
867  // output the offsets (index of individual element data in connectivity array)
868  fprintf(this->fileStream, " <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\"> ");
869 
870  for ( int ielem = 1; ielem <= numEl; ielem++ ) {
871  fprintf( this->fileStream, "%d ", vtkPiece.giveCellOffset(ielem) );
872  }
873 
874  fprintf(this->fileStream, "</DataArray>\n");
875 
876 
877  // output cell (element) types
878  fprintf(this->fileStream, " <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\"> ");
879  for ( int ielem = 1; ielem <= numEl; ielem++ ) {
880  fprintf( this->fileStream, "%d ", vtkPiece.giveCellType(ielem) );
881  }
882 
883  fprintf(this->fileStream, "</DataArray>\n");
884  fprintf(this->fileStream, "</Cells>\n");
885 
886 
888  std :: string pointHeader, cellHeader;
889  this->giveDataHeaders(pointHeader, cellHeader);
890 
891  fprintf( this->fileStream, "%s", pointHeader.c_str() );
892 #endif
893 
894  this->writePrimaryVars(vtkPiece); // Primary field
895  this->writeIntVars(vtkPiece); // Internal State Type variables smoothed to the nodes
896  this->writeExternalForces(vtkPiece); // External forces
897 
898  if ( emodel->giveDomain(1)->hasXfemManager() ) {
899  this->writeXFEMVars(vtkPiece); // XFEM State Type variables associated with XFEM structure
900  }
901 
902 #ifndef __VTK_MODULE
903  fprintf(this->fileStream, "</PointData>\n");
904  fprintf( this->fileStream, "%s", cellHeader.c_str() );
905 #endif
906 
907  this->writeCellVars(vtkPiece); // Single cell variables ( if given in the integration points then an average will be exported)
908 
909 #ifndef __VTK_MODULE
910  fprintf(this->fileStream, "</CellData>\n");
911  fprintf(this->fileStream, "</Piece>\n");
912 #endif
913 
914  //}
915 
916 
917  // Clear object so it can be filled with new data for the next piece
918  vtkPiece.clear();
919  return true;
920 }
921 
922 
923 
924 #ifndef __VTK_MODULE
925 void
926 VTKXMLExportModule :: giveDataHeaders(std :: string &pointHeader, std :: string &cellHeader)
927 {
928  std :: string scalars, vectors, tensors;
929 
930  for ( int i = 1; i <= primaryVarsToExport.giveSize(); i++ ) {
932  if ( type == DisplacementVector || type == EigenVector || type == VelocityVector || type == DirectorField ) {
933  vectors += __UnknownTypeToString(type);
934  vectors.append(" ");
935  } else if ( type == FluxVector || type == PressureVector || type == Temperature || type == Humidity || type == DeplanationFunction ) {
936  scalars += __UnknownTypeToString(type);
937  scalars.append(" ");
938  } else {
939  OOFEM_ERROR( "unsupported UnknownType %s", __UnknownTypeToString(type) );
940  }
941  }
942 
943  for ( int i = 1; i <= internalVarsToExport.giveSize(); i++ ) {
946 
947  if ( vtype == ISVT_SCALAR ) {
948  scalars += __InternalStateTypeToString(isttype);
949  scalars.append(" ");
950  } else if ( vtype == ISVT_VECTOR ) {
951  vectors += __InternalStateTypeToString(isttype);
952  vectors.append(" ");
953  } else if ( vtype == ISVT_TENSOR_S3 || vtype == ISVT_TENSOR_S3E || vtype == ISVT_TENSOR_G ) {
954  tensors += __InternalStateTypeToString(isttype);
955  tensors.append(" ");
956  } else {
957  OOFEM_ERROR( "unsupported variable type %s\n", __InternalStateTypeToString(isttype) );
958  }
959  }
960 
961  for ( int i = 1; i <= externalForcesToExport.giveSize(); i++ ) {
963  if ( type == DisplacementVector || type == VelocityVector || type == DirectorField ) {
964  vectors += std :: string("Load") + __UnknownTypeToString(type);
965  vectors.append(" ");
966  } else if ( type == FluxVector || type == PressureVector || type == Temperature || type == Humidity ) {
967  scalars += std :: string("Load") + __UnknownTypeToString(type);
968  scalars.append(" ");
969  } else {
970  OOFEM_ERROR( "unsupported UnknownType %s", __UnknownTypeToString(type) );
971  }
972  }
973 
974  // print header
975  pointHeader = "<PointData Scalars=\"" + scalars + "\" "
976  + "Vectors=\"" + vectors + "\" "
977  + "Tensors=\"" + tensors + "\" >\n";
978 
979 
980  scalars.clear();
981  vectors.clear();
982  tensors.clear();
983  // prepare header
984  for ( int i = 1; i <= this->cellVarsToExport.giveSize(); i++ ) {
987 
988  if ( vtype == ISVT_SCALAR ) {
989  scalars += __InternalStateTypeToString(isttype);
990  scalars.append(" ");
991  } else if ( vtype == ISVT_VECTOR ) {
992  vectors += __InternalStateTypeToString(isttype);
993  vectors.append(" ");
994  } else if ( vtype == ISVT_TENSOR_S3 || vtype == ISVT_TENSOR_S3E || vtype == ISVT_TENSOR_G ) {
995  tensors += __InternalStateTypeToString(isttype);
996  tensors.append(" ");
997  } else {
998  OOFEM_WARNING( "unsupported variable type %s\n", __InternalStateTypeToString(isttype) );
999  }
1000  }
1001 
1002  // print header
1003  cellHeader = "<CellData Scalars=\"" + scalars + "\" "
1004  + "Vectors=\"" + vectors + "\" "
1005  + "Tensors=\"" + tensors + "\" >\n";
1006 }
1007 #endif
1008 
1009 
1010 
1011 
1012 
1013 
1014 
1015 //----------------------------------------------------
1016 // Internal variables and XFEM realted fields (keyword "vars" in OOFEM input file)
1017 //----------------------------------------------------
1018 void
1019 VTKXMLExportModule :: exportIntVars(VTKPiece &vtkPiece, IntArray &mapG2L, IntArray &mapL2G, int region, TimeStep *tStep)
1020 {
1021  Domain *d = emodel->giveDomain(1);
1022  InternalStateType isType;
1023  FloatArray answer;
1024 
1025  this->giveSmoother()->clear(); // Makes sure smoother is up-to-date with potentially new mesh.
1026 
1027  // Export of Internal State Type fields
1029  for ( int field = 1; field <= internalVarsToExport.giveSize(); field++ ) {
1030  isType = ( InternalStateType ) internalVarsToExport.at(field);
1031 
1032  for ( int nodeNum = 1; nodeNum <= mapL2G.giveSize(); nodeNum++ ) {
1033  Node *node = d->giveNode( mapL2G.at(nodeNum) );
1034  this->getNodalVariableFromIS(answer, node, tStep, isType, region);
1035  vtkPiece.setInternalVarInNode(field, nodeNum, answer);
1036  }
1037  }
1038 
1039  // Export of XFEM related quantities
1040  if ( d->hasXfemManager() ) {
1041  XfemManager *xFemMan = d->giveXfemManager();
1042  int nEnrIt = xFemMan->giveNumberOfEnrichmentItems();
1043 
1044  vtkPiece.setNumberOfInternalXFEMVarsToExport( xFemMan->vtkExportFields.giveSize(), nEnrIt, mapL2G.giveSize() );
1045  for ( int field = 1; field <= xFemMan->vtkExportFields.giveSize(); field++ ) {
1046  XFEMStateType xfemstype = ( XFEMStateType ) xFemMan->vtkExportFields [ field - 1 ];
1047 
1048  for ( int enrItIndex = 1; enrItIndex <= nEnrIt; enrItIndex++ ) {
1049  for ( int nodeIndx = 1; nodeIndx <= mapL2G.giveSize(); nodeIndx++ ) {
1050  Node *node = d->giveNode( mapL2G.at(nodeIndx) );
1051  getNodalVariableFromXFEMST( answer, node, tStep, xfemstype, region, xFemMan->giveEnrichmentItem(enrItIndex) );
1052  vtkPiece.setInternalXFEMVarInNode(field, enrItIndex, nodeIndx, answer);
1053  }
1054  }
1055  }
1056  }
1057 }
1058 
1059 
1060 void
1062 {
1063  // Recovers nodal values from Internal States defined in the integration points.
1064  // Should return an array with proper size supported by VTK (1, 3 or 9)
1065  // Domain *d = emodel->giveDomain(1);
1066  this->giveSmoother();
1067  IntArray redIndx;
1068 
1069  if ( !( type == IST_DisplacementVector || type == IST_MaterialInterfaceVal ) ) {
1070  this->smoother->recoverValues(* this->giveRegionSet(ireg), type, tStep);
1071  }
1072 
1073 
1074  const FloatArray *val = NULL;
1075  FloatArray valueArray;
1077 
1078  if ( type == IST_DisplacementVector ) {
1079  valueArray.resize(3);
1081  val = & valueArray;
1082  for ( int i = 1; i <= 3; i++ ) {
1083  valueArray.at(i) = node->giveUpdatedCoordinate(i, tStep, 1.0) - node->giveCoordinate(i);
1084  }
1085  } else if ( type == IST_MaterialInterfaceVal ) {
1087  if ( mi ) {
1088  valueArray.resize(1);
1089  val = & valueArray;
1090  valueArray.at(1) = mi->giveNodalScalarRepresentation( node->giveNumber() );
1091  }
1092  } else {
1093  int found = this->smoother->giveNodalVector( val, node->giveNumber() );
1094  if ( !found ) {
1095  valueArray.resize( redIndx.giveSize() );
1096  val = & valueArray;
1097  }
1098  }
1099 
1100  int ncomponents = giveInternalStateTypeSize(valType);
1101  answer.resize(ncomponents);
1102  int valSize = val->giveSize(); // size of recovered quantity
1103 
1104  // check if valSize corresponds to the expected size otherwise pad with zeros
1105  if ( valType == ISVT_SCALAR ) {
1106  answer.at(1) = valSize ? val->at(1) : 0.0;
1107  } else if ( valType == ISVT_VECTOR ) {
1108  answer = * val;
1109  // bp: hack for BeamForceMomentTensor, which should be splitted into force and momentum vectors
1110  if (type == IST_BeamForceMomentTensor) {
1111  answer.resizeWithValues(6);
1112  } else {
1113  answer.resizeWithValues(3);
1114  }
1115  } else if ( valType == ISVT_TENSOR_S3 || valType == ISVT_TENSOR_S3E || valType == ISVT_TENSOR_G ) {
1116  this->makeFullTensorForm(answer, * val, valType);
1117  } else {
1118  OOFEM_ERROR("ISVT_UNDEFINED encountered")
1119  }
1120 }
1121 
1122 
1123 void
1125 {
1126  // Recovers nodal values from XFEM state variables (e.g. levelset function)
1127  // Should return an array with proper size supported by VTK (1, 3 or 9)
1128  // This could be moved into EnrichmentItem such that VTKExport doesn't need to know anything about XFEM
1129 
1130  const FloatArray *val = NULL;
1131  FloatArray valueArray;
1132 
1133  Domain *d = emodel->giveDomain(1);
1134  XfemManager *xFemMan = d->giveXfemManager();
1135  InternalStateValueType valType = xFemMan->giveXFEMStateValueType(xfemstype);
1136 
1137 
1138  // The xfem level set function is defined in the nodes and recovery of nodal values is trivial.
1139  if ( xfemstype == XFEMST_LevelSetPhi ) {
1140  valueArray.resize(1);
1141  val = & valueArray;
1142  ei->evalLevelSetNormalInNode( valueArray.at(1), node->giveNumber(), * ( node->giveCoordinates() ) );
1143  } else if ( xfemstype == XFEMST_LevelSetGamma ) {
1144  valueArray.resize(1);
1145  val = & valueArray;
1146  ei->evalLevelSetTangInNode( valueArray.at(1), node->giveNumber(), * ( node->giveCoordinates() ) );
1147  } else if ( xfemstype == XFEMST_NodeEnrMarker ) {
1148  valueArray.resize(1);
1149  val = & valueArray;
1150  ei->evalNodeEnrMarkerInNode( valueArray.at(1), node->giveNumber() );
1151  } else {
1152  //OOFEM_WARNING("invalid data in node %d", inode);
1153  }
1154 
1156  int ncomponents = giveInternalStateTypeSize(valType);
1157  answer.resize(ncomponents);
1158  int valSize = val->giveSize(); // size of recovered quantity
1159 
1160  // check if valSize corresponds to the expected size otherwise pad with zeros
1161  if ( valType == ISVT_SCALAR ) {
1162  answer.at(1) = valSize ? val->at(1) : 0.0;
1163  } else if ( valType == ISVT_VECTOR ) {
1164  answer = * val;
1165  answer.resizeWithValues(3);
1166  } else if ( valType == ISVT_TENSOR_S3 || valType == ISVT_TENSOR_S3E || valType == ISVT_TENSOR_G ) {
1167  this->makeFullTensorForm(answer, * val, valType);
1168  } else {
1169  OOFEM_ERROR("ISVT_UNDEFINED encountered")
1170  }
1171 }
1172 
1173 
1174 void
1176 {
1177  int n = internalVarsToExport.giveSize();
1178  for ( int i = 1; i <= n; i++ ) {
1180  int ncomponents;
1181 
1182  const char *name = __InternalStateTypeToString(type);
1183  int numNodes = vtkPiece.giveNumberOfNodes();
1184  FloatArray valueArray;
1185  valueArray = vtkPiece.giveInternalVarInNode(i, 1);
1186  ncomponents = valueArray.giveSize();
1187 
1188  // Header
1189 #ifdef __VTK_MODULE
1190  vtkSmartPointer< vtkDoubleArray >varArray = vtkSmartPointer< vtkDoubleArray > :: New();
1191  varArray->SetName(name);
1192  varArray->SetNumberOfComponents(ncomponents);
1193  varArray->SetNumberOfTuples(numNodes);
1194 
1195  for ( int inode = 1; inode <= numNodes; inode++ ) {
1196  valueArray = vtkPiece.giveInternalVarInNode(i, inode);
1197  for ( int i = 1; i <= ncomponents; ++i ) {
1198  varArray->SetComponent( inode - 1, i - 1, valueArray.at(i) );
1199  }
1200  }
1201 
1202  this->writeVTKPointData(name, varArray);
1203 
1204 #else
1205 
1206  fprintf(this->fileStream, " <DataArray type=\"Float64\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"> ", name, ncomponents);
1207  for ( int inode = 1; inode <= numNodes; inode++ ) {
1208  valueArray = vtkPiece.giveInternalVarInNode(i, inode);
1209  this->writeVTKPointData(valueArray);
1210  }
1211 
1212 #endif
1213 
1214 
1215 
1216 
1217 
1218  // Footer
1219 #ifndef __VTK_MODULE
1220  fprintf(this->fileStream, "</DataArray>\n");
1221 #endif
1222  }
1223 }
1224 
1225 void
1227 {
1228  Domain *d = emodel->giveDomain(1);
1229  XfemManager *xFemMan = d->giveXfemManager();
1230  int nEnrIt = xFemMan->giveNumberOfEnrichmentItems();
1231  FloatArray valueArray;
1232 
1233 
1234  for ( int field = 1; field <= xFemMan->vtkExportFields.giveSize(); field++ ) {
1235  XFEMStateType xfemstype = ( XFEMStateType ) xFemMan->vtkExportFields.at(field);
1236  const char *namePart = __XFEMStateTypeToString(xfemstype);
1237  InternalStateValueType valType = xFemMan->giveXFEMStateValueType(xfemstype);
1238  int ncomponents = giveInternalStateTypeSize(valType);
1239 
1240  int numNodes = vtkPiece.giveNumberOfNodes();
1241  for ( int enrItIndex = 1; enrItIndex <= nEnrIt; enrItIndex++ ) {
1242  // Header
1243  char name [ 100 ]; // Must I define a fixed size? /JB
1244  sprintf( name, "%s_%d ", namePart, xFemMan->giveEnrichmentItem(enrItIndex)->giveNumber() );
1245 
1246 #ifdef __VTK_MODULE
1247  vtkSmartPointer< vtkDoubleArray >varArray = vtkSmartPointer< vtkDoubleArray > :: New();
1248  varArray->SetName(name);
1249  varArray->SetNumberOfComponents(ncomponents);
1250  varArray->SetNumberOfTuples(numNodes);
1251  for ( int inode = 1; inode <= numNodes; inode++ ) {
1252  valueArray = vtkPiece.giveInternalXFEMVarInNode(field, enrItIndex, inode);
1253  for ( int i = 1; i <= ncomponents; ++i ) {
1254  varArray->SetComponent( inode - 1, i - 1, valueArray.at(i) );
1255  }
1256  }
1257 
1258  this->writeVTKPointData(name, varArray);
1259 #else
1260  fprintf(this->fileStream, " <DataArray type=\"Float64\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"> ", name, ncomponents);
1261  for ( int inode = 1; inode <= numNodes; inode++ ) {
1262  valueArray = vtkPiece.giveInternalXFEMVarInNode(field, enrItIndex, inode);
1263  this->writeVTKPointData(valueArray);
1264  }
1265  fprintf(this->fileStream, "</DataArray>\n");
1266 #endif
1267  }
1268  }
1269 }
1270 
1271 
1272 
1273 
1274 //----------------------------------------------------
1275 // Misc. functions
1276 //----------------------------------------------------
1277 #ifdef __VTK_MODULE
1278 void
1279 VTKXMLExportModule :: writeVTKPointData(const char *name, vtkSmartPointer< vtkDoubleArray >varArray)
1280 {
1281  // Write the data to file
1282  int ncomponents = varArray->GetNumberOfComponents();
1283  switch ( ncomponents ) {
1284  case 1:
1285  this->fileStream->GetPointData()->SetActiveScalars(name);
1286  this->fileStream->GetPointData()->SetScalars(varArray);
1287  break;
1288  case 3:
1289  this->fileStream->GetPointData()->SetActiveVectors(name);
1290  this->fileStream->GetPointData()->SetVectors(varArray);
1291  break;
1292  case 9:
1293  this->fileStream->GetPointData()->SetActiveTensors(name);
1294  this->fileStream->GetPointData()->SetTensors(varArray);
1295  break;
1296  }
1297 }
1298 #else
1299 void
1301 {
1302  // Write the data to file
1303  for ( int i = 1; i <= valueArray.giveSize(); i++ ) {
1304  fprintf( this->fileStream, "%e ", valueArray.at(i) );
1305  }
1306 }
1307 #endif
1308 
1309 
1310 
1311 
1312 
1313 #ifdef __VTK_MODULE
1314 void
1315 VTKXMLExportModule :: writeVTKCellData(const char *name, vtkSmartPointer< vtkDoubleArray >varArray)
1316 {
1317  // Write the data to file
1318  int ncomponents = varArray->GetNumberOfComponents();
1319  switch ( ncomponents ) {
1320  case 1:
1321  this->fileStream->GetCellData()->SetActiveScalars(name);
1322  this->fileStream->GetCellData()->SetScalars(varArray);
1323  break;
1324  case 3:
1325  this->fileStream->GetCellData()->SetActiveVectors(name);
1326  this->fileStream->GetCellData()->SetVectors(varArray);
1327  break;
1328  case 9:
1329  this->fileStream->GetCellData()->SetActiveTensors(name);
1330  this->fileStream->GetCellData()->SetTensors(varArray);
1331  break;
1332  }
1333 }
1334 
1335 #else
1336 
1337 void
1339 {
1340  // Write the data to file ///@todo exact copy of writeVTKPointData so remove
1341  for ( int i = 1; i <= valueArray.giveSize(); i++ ) {
1342  fprintf( this->fileStream, "%e ", valueArray.at(i) );
1343  }
1344 }
1345 #endif
1346 
1347 
1348 
1349 
1350 int
1352  IntArray &regionL2GNodalNumbers,
1353  int &regionDofMans,
1354  int &regionSingleCells,
1355  Domain *domain, TimeStep *tStep, int reg)
1356 {
1357  // regionG2LNodalNumbers is array with mapping from global numbering to local region numbering.
1358  // The i-th value contains the corresponding local region number (or zero, if global numbar is not in region).
1359 
1360  // regionL2GNodalNumbers is array with mapping from local to global numbering.
1361  // The i-th value contains the corresponding global node number.
1362 
1363 
1364  int nnodes = domain->giveNumberOfDofManagers();
1365  int elemNodes;
1366  int elementNode, node;
1367  int currOffset = 1;
1368  Element *element;
1369 
1370  regionG2LNodalNumbers.resize(nnodes);
1371  regionG2LNodalNumbers.zero();
1372  regionDofMans = 0;
1373  regionSingleCells = 0;
1374 
1375  IntArray elements = this->giveRegionSet(reg)->giveElementList();
1376  for ( int ie = 1; ie <= elements.giveSize(); ie++ ) {
1377  int ielem = elements.at(ie);
1378  element = domain->giveElement(ielem);
1379 
1380  if ( this->isElementComposite(element) ) {
1381  continue; // composite cells exported individually
1382  }
1383 
1384  if ( !element->isActivated(tStep) ) { //skip inactivated elements
1385  continue;
1386  }
1387 
1388  //skip materials with casting time > current time
1389  if ( !element->isCast(tStep) ) {
1390  continue;
1391  }
1392 
1393  if ( element->giveParallelMode() != Element_local ) {
1394  continue;
1395  }
1396 
1397  regionSingleCells++;
1398  elemNodes = element->giveNumberOfNodes();
1399  // elemSides = element->giveNumberOfSides();
1400 
1401  // determine local region node numbering
1402  for ( elementNode = 1; elementNode <= elemNodes; elementNode++ ) {
1403  node = element->giveNode(elementNode)->giveNumber();
1404  if ( regionG2LNodalNumbers.at(node) == 0 ) { // assign new number
1405  /* mark for assignment. This is done later, as it allows to preserve
1406  * natural node numbering.
1407  */
1408  regionG2LNodalNumbers.at(node) = 1;
1409  regionDofMans++;
1410  }
1411  }
1412  }
1413 
1414  regionL2GNodalNumbers.resize(regionDofMans);
1415 
1416  for ( int i = 1; i <= nnodes; i++ ) {
1417  if ( regionG2LNodalNumbers.at(i) ) {
1418  regionG2LNodalNumbers.at(i) = currOffset++;
1419  regionL2GNodalNumbers.at( regionG2LNodalNumbers.at(i) ) = i;
1420  }
1421  }
1422 
1423  return 1;
1424 }
1425 
1426 
1427 
1428 
1429 
1430 
1431 
1432 
1433 //----------------------------------------------------
1434 // Primary variables - readily available in the nodes
1435 //----------------------------------------------------
1436 void
1437 VTKXMLExportModule :: exportPrimaryVars(VTKPiece &vtkPiece, IntArray &mapG2L, IntArray &mapL2G, int region, TimeStep *tStep)
1438 {
1439  Domain *d = emodel->giveDomain(1);
1440  FloatArray valueArray;
1441  this->givePrimVarSmoother()->clear(); // Makes sure primary smoother is up-to-date with potentially new mesh.
1442 
1444  for ( int i = 1, n = primaryVarsToExport.giveSize(); i <= n; i++ ) {
1446 
1447  for ( int inode = 1; inode <= mapL2G.giveSize(); inode++ ) {
1448  DofManager *dman = d->giveNode( mapL2G.at(inode) );
1449 
1450  this->getNodalVariableFromPrimaryField(valueArray, dman, tStep, type, region);
1451  vtkPiece.setPrimaryVarInNode( i, inode, std :: move(valueArray) );
1452  }
1453  }
1454 }
1455 
1456 
1457 void
1459 {
1460  // This code is not perfect. It should be rewritten to handle all cases more gracefully.
1463 
1464  IntArray dofIDMask(3);
1465  int size;
1466  const FloatArray *recoveredVal;
1467 
1468  InternalStateType iState = IST_DisplacementVector; // Shouldn't be necessary
1469 
1470  dofIDMask.clear();
1471 
1472  if ( type == DisplacementVector ) {
1473  dofIDMask = {
1474  ( int ) Undef, ( int ) Undef, ( int ) Undef
1475  };
1476  for ( Dof *dof : *dman ) {
1477  DofIDItem id = dof->giveDofID();
1478  if ( id == D_u ) {
1479  dofIDMask.at(1) = id;
1480  } else if ( id == D_v ) {
1481  dofIDMask.at(2) = id;
1482  } else if ( id == D_w ) {
1483  dofIDMask.at(3) = id;
1484  }
1485  }
1486 
1487  answer.resize(3);
1488  } else if ( type == VelocityVector ) {
1489  dofIDMask = {
1490  ( int ) Undef, ( int ) Undef, ( int ) Undef
1491  };
1492  for ( Dof *dof : *dman ) {
1493  DofIDItem id = dof->giveDofID();
1494  if ( id == V_u ) {
1495  dofIDMask.at(1) = id;
1496  } else if ( id == V_v ) {
1497  dofIDMask.at(2) = id;
1498  } else if ( id == V_w ) {
1499  dofIDMask.at(3) = id;
1500  }
1501  }
1502 
1503  answer.resize(3);
1504  } else if ( type == EigenVector ) {
1505  dofIDMask = {
1506  ( int ) Undef, ( int ) Undef, ( int ) Undef
1507  };
1508  for ( Dof *dof : *dman ) {
1509  DofIDItem id = dof->giveDofID();
1510  if ( ( id == V_u ) || ( id == D_u ) ) {
1511  dofIDMask.at(1) = id;
1512  } else if ( ( id == V_v ) || ( id == D_v ) ) {
1513  dofIDMask.at(2) = id;
1514  } else if ( ( id == V_w ) || ( id == D_w ) ) {
1515  dofIDMask.at(3) = id;
1516  }
1517  }
1518 
1519  answer.resize(3);
1520  } else if ( type == FluxVector || type == Humidity ) {
1521  dofIDMask.followedBy(C_1);
1522  iState = IST_MassConcentration_1;
1523  answer.resize(1);
1524  } else if ( type == DeplanationFunction ) {
1525  dofIDMask.followedBy(Warp_PsiTheta);
1526  iState = IST_Temperature;
1527  answer.resize(1);
1528  } else if ( type == Temperature ) {
1529  dofIDMask.followedBy(T_f);
1530  iState = IST_Temperature;
1531  answer.resize(1);
1532  } else if ( type == PressureVector ) {
1533  dofIDMask.followedBy(P_f);
1534  iState = IST_Pressure;
1535  answer.resize(1);
1536  } else if ( type == DirectorField ) {
1537  for ( Dof *dof : *dman ) {
1538  DofIDItem id = dof->giveDofID();
1539  if ( ( id == W_u ) || ( id == W_v ) || ( id == W_w ) ) {
1540  dofIDMask.followedBy(id);
1541  }
1542 
1543  answer.resize(3);
1544  }
1545 
1546  iState = IST_DirectorField;
1547  } else {
1548  OOFEM_ERROR( "unsupported unknownType %s", __UnknownTypeToString(type) );
1549  }
1550 
1551  size = dofIDMask.giveSize();
1552  answer.zero();
1553 
1554  for ( int j = 1; j <= size; j++ ) {
1555  DofIDItem id = ( DofIDItem ) dofIDMask.at(j);
1556  if ( id == Undef ) {
1557  answer.at(j) = 0.;
1558  } else if ( iState == IST_DirectorField ) {
1559  answer.at(j) = dman->giveDofWithID(id)->giveUnknown(VM_Total, tStep);
1560  // recover values if not done before
1561  this->givePrimVarSmoother()->recoverValues(* this->giveRegionSet(ireg), iState, tStep);
1562  this->givePrimVarSmoother()->giveNodalVector( recoveredVal, dman->giveNumber() );
1563  if ( size == recoveredVal->giveSize() ) {
1564  answer.at(j) = recoveredVal->at(j);
1565  } else {
1566  OOFEM_WARNING("Recovered variable size mismatch for %d for id %d", type, id);
1567  answer.at(j) = 0.0;
1568  }
1569  } else if ( dman->hasDofID(id) ) {
1570  // primary variable available directly in DOF-manager
1571  answer.at(j) = dman->giveDofWithID(id)->giveUnknown(VM_Total, tStep);
1572  //mj - if incremental value needed: answer.at(j) = dman->giveDofWithID(id)->giveUnknown(VM_Incremental, tStep);
1573  } else if ( iState != IST_Undefined ) {
1574  // primary variable not directly available
1575  // but equivalent InternalStateType provided
1576  // in this case use smoother to recover nodal value
1577 
1578  // This can't deal with ValueModeType, and would recover over and over for some vectorial quantities like velocity
1579  // recover values if not done before.
1580  this->givePrimVarSmoother()->recoverValues(* this->giveRegionSet(ireg), iState, tStep);
1581  this->givePrimVarSmoother()->giveNodalVector( recoveredVal, dman->giveNumber() );
1582  // here we have a lack of information about how to convert recovered values to response
1583  // if the size is compatible we accept it, otherwise give a warning and zero value.
1584  if ( size == recoveredVal->giveSize() ) {
1585  answer.at(j) = recoveredVal->at(j);
1586  } else {
1587  OOFEM_WARNING("Recovered variable size mismatch for \"%s\" for dof id %d. Size is %d, should be %d", __UnknownTypeToString(type), id, recoveredVal->giveSize(), size);
1588  answer.at(j) = 0.0;
1589  }
1590  }
1591  }
1592 
1593 
1594 
1596  //rotate back from nodal CS to global CS if applies
1597  if ( valType == ISVT_VECTOR ) {
1598  Node *node = dynamic_cast< Node * >(dman);
1599  if ( node && node->hasLocalCS() ) {
1600  answer.rotatedWith(* node->giveLocalCoordinateTriplet(), 't');
1601  }
1602  }
1603 }
1604 
1605 void
1607 {
1608  for ( int i = 1; i <= primaryVarsToExport.giveSize(); i++ ) {
1611  int ncomponents = giveInternalStateTypeSize(valType);
1612  int numNodes = vtkPiece.giveNumberOfNodes();
1613  const char *name = __UnknownTypeToString(type);
1614 
1615  // Header
1616 #ifdef __VTK_MODULE
1617  vtkSmartPointer< vtkDoubleArray >varArray = vtkSmartPointer< vtkDoubleArray > :: New();
1618  varArray->SetName(name);
1619  varArray->SetNumberOfComponents(ncomponents);
1620  varArray->SetNumberOfTuples(numNodes);
1621 
1622  for ( int inode = 1; inode <= numNodes; inode++ ) {
1623  FloatArray &valueArray = vtkPiece.givePrimaryVarInNode(i, inode);
1624  for ( int j = 1; j <= ncomponents; ++j ) {
1625  varArray->SetComponent( inode - 1, j - 1, valueArray.at(j) );
1626  }
1627  }
1628 
1629  this->writeVTKPointData(name, varArray);
1630 
1631 #else
1632  fprintf(this->fileStream, " <DataArray type=\"Float64\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"> ", name, ncomponents);
1633  for ( int inode = 1; inode <= numNodes; inode++ ) {
1634  FloatArray &valueArray = vtkPiece.givePrimaryVarInNode(i, inode);
1635  this->writeVTKPointData(valueArray);
1636  }
1637  fprintf(this->fileStream, "</DataArray>\n");
1638 #endif
1639  }
1640 }
1641 
1642 
1643 //----------------------------------------------------
1644 // Load vectors
1645 //----------------------------------------------------
1646 void
1647 VTKXMLExportModule :: exportExternalForces(VTKPiece &vtkPiece, IntArray &mapG2L, IntArray &mapL2G, int region, TimeStep *tStep)
1648 {
1649  Domain *d = emodel->giveDomain(1);
1650  this->givePrimVarSmoother()->clear(); // Makes sure primary smoother is up-to-date with potentially new mesh.
1651 
1652  if ( externalForcesToExport.giveSize() == 0 ) {
1653  return;
1654  }
1655 
1660  FloatArray extForces(neq), extForcesP(npeq);
1661  emodel->assembleVector(extForces, tStep, ExternalForceAssembler(), VM_Total, EModelDefaultEquationNumbering(), d);
1663 
1665  for ( int i = 1; i <= externalForcesToExport.giveSize(); i++ ) {
1668  IntArray dofids;
1669  if ( type == VelocityVector ) {
1670  dofids = {
1671  V_u, V_v, V_w
1672  };
1673  } else if ( type == DisplacementVector ) {
1674  dofids = {
1675  D_u, D_v, D_w
1676  };
1677  } else if ( type == PressureVector ) {
1678  dofids = {
1679  P_f
1680  };
1681  } else {
1682  OOFEM_WARNING("Unrecognized UnknownType (%d), no external forces exported", type);
1683  }
1684 
1685  for ( int inode = 1; inode <= mapL2G.giveSize(); inode++ ) {
1686  DofManager *dman = d->giveNode( mapL2G.at(inode) );
1687 
1688  FloatArray valueArray( dofids.giveSize() );
1689  for ( int k = 1; k <= dofids.giveSize(); ++k ) {
1690  Dof *dof = dman->giveDofWithID( dofids.at(k) );
1692  int eq;
1693  if ( ( eq = dof->giveEquationNumber( EModelDefaultEquationNumbering() ) ) > 0 ) {
1694  valueArray.at(k) = extForces.at(eq);
1695  } else if ( ( eq = dof->giveEquationNumber( EModelDefaultPrescribedEquationNumbering() ) ) > 0 ) {
1696  valueArray.at(k) = extForcesP.at(eq);
1697  }
1698  }
1699  //this->getNodalVariableFromPrimaryField(valueArray, dman, tStep, type, region);
1700  vtkPiece.setLoadInNode( i, inode, std :: move(valueArray) );
1701  }
1702  }
1703 }
1704 
1705 
1706 void
1708 {
1709  for ( int i = 1; i <= externalForcesToExport.giveSize(); i++ ) {
1712  int ncomponents = giveInternalStateTypeSize(valType);
1713  int numNodes = vtkPiece.giveNumberOfNodes();
1714  std :: string name = std :: string("Load") + __UnknownTypeToString(type);
1715 
1716  // Header
1717 #ifdef __VTK_MODULE
1718  vtkSmartPointer< vtkDoubleArray >varArray = vtkSmartPointer< vtkDoubleArray > :: New();
1719  varArray->SetName(name);
1720  varArray->SetNumberOfComponents(ncomponents);
1721  varArray->SetNumberOfTuples(numNodes);
1722 
1723  for ( int inode = 1; inode <= numNodes; inode++ ) {
1724  FloatArray &valueArray = vtkPiece.giveLoadInNode(i, inode);
1725  for ( int j = 1; j <= ncomponents; ++j ) {
1726  varArray->SetComponent( inode - 1, j - 1, valueArray.at(j) );
1727  }
1728  }
1729 
1730  this->writeVTKPointData(name.c_str(), varArray);
1731 
1732 #else
1733  fprintf(this->fileStream, " <DataArray type=\"Float64\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"> ", name.c_str(), ncomponents);
1734  for ( int inode = 1; inode <= numNodes; inode++ ) {
1735  FloatArray &valueArray = vtkPiece.giveLoadInNode(i, inode);
1736  this->writeVTKPointData(valueArray);
1737  }
1738  fprintf(this->fileStream, "</DataArray>\n");
1739 #endif
1740  }
1741 }
1742 
1743 
1744 
1745 
1746 //----------------------------------------------------
1747 // Cell vars
1748 //----------------------------------------------------
1749 
1750 void
1752 {
1753  Domain *d = emodel->giveDomain(1);
1754  FloatArray valueArray;
1755 
1757  for ( int field = 1; field <= cellVarsToExport.giveSize(); field++ ) {
1759 
1760  for ( int subIndex = 1; subIndex <= elems.giveSize(); ++subIndex ) {
1761  Element *el = d->giveElement( elems.at(subIndex) );
1762  if ( el->giveParallelMode() != Element_local ) {
1763  continue;
1764  }
1765 
1766  this->getCellVariableFromIS(valueArray, el, type, tStep);
1767  vtkPiece.setCellVar(field, subIndex, valueArray);
1768  }
1769  }
1770 }
1771 
1772 
1773 void
1775 {
1777  int ncomponents = giveInternalStateTypeSize(valType);
1778 
1779  answer.resize(ncomponents);
1780 
1781  switch ( type ) {
1782  // Special scalars
1783  case IST_MaterialNumber:
1784  // commented by bp: do what user wants
1785  //OOFEM_WARNING1("Material numbers are deprecated, outputing cross section number instead...");
1786  answer.at(1) = ( double ) el->giveMaterial()->giveNumber();
1787  break;
1788  case IST_CrossSectionNumber:
1789  answer.at(1) = ( double ) el->giveCrossSection()->giveNumber();
1790  break;
1791  case IST_ElementNumber:
1792  answer.at(1) = ( double ) el->giveNumber();
1793  break;
1794  case IST_Pressure:
1795  if ( el->giveNumberOfInternalDofManagers() == 1 ) {
1796  //IntArray pmask(1); pmask.at(1) = P_f;
1797  //el->giveInternalDofManager(1)->giveUnknownVector (answer, pmask, VM_Total, tStep);
1798  //answer.at(1) = answer.at(1);
1799  }
1800 
1801  break;
1802  case IST_AbaqusStateVector:
1803  {
1804  // compute cell average from ip values
1806  computeIPAverage(answer, iRule, el, type, tStep); // if element has more than one iRule?? /JB
1807  }
1808  break;
1809 
1810  // Special vectors
1811  case IST_MaterialOrientation_x:
1812  case IST_MaterialOrientation_y:
1813  case IST_MaterialOrientation_z:
1814  {
1815  FloatMatrix rotMat;
1816  int col = 0;
1817  if ( type == IST_MaterialOrientation_x ) {
1818  col = 1;
1819  } else if ( type == IST_MaterialOrientation_y ) {
1820  col = 2;
1821  } else if ( type == IST_MaterialOrientation_z ) {
1822  col = 3;
1823  }
1824 
1825  if ( !el->giveLocalCoordinateSystem(rotMat) ) {
1826  rotMat.resize(3, 3);
1827  rotMat.beUnitMatrix();
1828  }
1829 
1830  answer.beColumnOf(rotMat, col);
1831  break;
1832  }
1833 
1834  // Export cell data as average from ip's as default
1835  default:
1836 
1837  // compute cell average from ip values
1839  computeIPAverage(answer, iRule, el, type, tStep); // if element has more than one iRule?? /JB
1840  // Reshape the Voigt vectors to include all components (duplicated if necessary, VTK insists on 9 components for tensors.)
1843  if ( valType == ISVT_TENSOR_S3 || valType == ISVT_TENSOR_S3E || valType == ISVT_TENSOR_G ) {
1844  FloatArray temp = answer;
1845  this->makeFullTensorForm(answer, temp, valType);
1846  } else if ( valType == ISVT_VECTOR && answer.giveSize() < 3 ) {
1847  answer.resizeWithValues(3);
1848  } else if ( ncomponents != answer.giveSize() ) { // Trying to gracefully handle bad cases, just output zeros.
1849  answer.resizeWithValues(ncomponents);
1850  }
1851  }
1852 }
1853 
1854 
1855 void
1857 {
1858  FloatArray valueArray;
1859  int numCells = vtkPiece.giveNumberOfCells();
1860  for ( int i = 1; i <= cellVarsToExport.giveSize(); i++ ) {
1863  int ncomponents = giveInternalStateTypeSize(valType);
1864  const char *name = __InternalStateTypeToString(type);
1865 
1866  // Header
1867 #ifdef __VTK_MODULE
1868  vtkSmartPointer< vtkDoubleArray >cellVarsArray = vtkSmartPointer< vtkDoubleArray > :: New();
1869  cellVarsArray->SetName(name);
1870  cellVarsArray->SetNumberOfComponents(ncomponents);
1871  cellVarsArray->SetNumberOfTuples(numCells);
1872  for ( int ielem = 1; ielem <= numCells; ielem++ ) {
1873  valueArray = vtkPiece.giveCellVar(i, ielem);
1874  for ( int i = 1; i <= ncomponents; ++i ) {
1875  cellVarsArray->SetComponent( ielem - 1, i - 1, valueArray.at(i) );
1876  }
1877  }
1878 
1879  this->writeVTKCellData(name, cellVarsArray);
1880 
1881 #else
1882  fprintf(this->fileStream, " <DataArray type=\"Float64\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"> ", name, ncomponents);
1883  valueArray.resize(ncomponents);
1884  for ( int ielem = 1; ielem <= numCells; ielem++ ) {
1885  valueArray = vtkPiece.giveCellVar(i, ielem);
1886  this->writeVTKCellData(valueArray);
1887  }
1888  fprintf(this->fileStream, "</DataArray>\n");
1889 #endif
1890  }
1891 }
1892 
1893 
1894 void
1896 {
1897  // Computes the volume average (over an element) for the quantity defined by isType
1898  double gptot = 0.0;
1899  answer.clear();
1900  FloatArray temp;
1901  if ( iRule ) {
1902  for ( IntegrationPoint *ip : *iRule ) {
1903  elem->giveIPValue(temp, ip, isType, tStep);
1904  gptot += ip->giveWeight();
1905  answer.add(ip->giveWeight(), temp);
1906  }
1907 
1908  answer.times(1. / gptot);
1909  }
1910 }
1911 
1912 
1913 void
1915 {
1916  struct tm *current;
1917  time_t now;
1918  time(& now);
1919  current = localtime(& now);
1920  char buff [ 1024 ];
1921  std :: string fname;
1922 
1923  if ( tstep_substeps_out_flag ) {
1924  fname = this->emodel->giveOutputBaseFileName() + ".m" + std :: to_string(this->number) + ".substep.pvd";
1925  } else {
1926  fname = this->emodel->giveOutputBaseFileName() + ".m" + std :: to_string(this->number) + ".pvd";
1927  }
1928 
1929  std :: ofstream outfile( fname.c_str() );
1930 
1931  sprintf(buff, "<!-- Computation started %d-%02d-%02d at %02d:%02d:%02d -->\n", current->tm_year + 1900, current->tm_mon + 1, current->tm_mday, current->tm_hour, current->tm_min, current->tm_sec);
1932  // outfile << buff;
1933 
1934  outfile << "<?xml version=\"1.0\"?>\n<VTKFile type=\"Collection\" version=\"0.1\">\n<Collection>\n";
1935  for ( auto pvd : this->pvdBuffer ) {
1936  outfile << pvd << "\n";
1937  }
1938 
1939  outfile << "</Collection>\n</VTKFile>";
1940 
1941  outfile.close();
1942 }
1943 
1944 void
1946 {
1947  struct tm *current;
1948  time_t now;
1949  time(& now);
1950  current = localtime(& now);
1951  char buff [ 1024 ];
1952  std :: string fname;
1953 
1954  if ( tstep_substeps_out_flag ) {
1955  fname = this->emodel->giveOutputBaseFileName() + ".m" + std :: to_string(this->number) + ".substep.gp.pvd";
1956  } else {
1957  fname = this->emodel->giveOutputBaseFileName() + ".m" + std :: to_string(this->number) + ".gp.pvd";
1958  }
1959 
1960  std :: ofstream outfile( fname.c_str() );
1961 
1962  sprintf(buff, "<!-- Computation started %d-%02d-%02d at %02d:%02d:%02d -->\n", current->tm_year + 1900, current->tm_mon + 1, current->tm_mday, current->tm_hour, current->tm_min, current->tm_sec);
1963  // outfile << buff;
1964 
1965  outfile << "<?xml version=\"1.0\"?>\n<VTKFile type=\"Collection\" version=\"0.1\">\n<Collection>\n";
1966  for ( auto pvd : this->gpPvdBuffer ) {
1967  outfile << pvd << "\n";
1968  }
1969 
1970  outfile << "</Collection>\n</VTKFile>";
1971 
1972  outfile.close();
1973 }
1974 
1975 
1976 
1977 
1978 // Export of composite elements
1979 
1981 {
1983  static_cast< VTKXMLExportModuleElementInterface * >( el->giveInterface(VTKXMLExportModuleElementInterfaceType) );
1984  if ( interface ) {
1985  interface->giveCompositeExportData(vtkPiece, this->primaryVarsToExport, this->internalVarsToExport, this->cellVarsToExport, tStep);
1986 
1987  //this->writeVTKPiece(this->defaultVTKPiece, tStep);
1988  }
1989 }
1990 
1991 void VTKXMLExportModule :: exportCompositeElement(std :: vector< VTKPiece > &vtkPieces, Element *el, TimeStep *tStep)
1992 {
1994  static_cast< VTKXMLExportModuleElementInterface * >( el->giveInterface(VTKXMLExportModuleElementInterfaceType) );
1995  if ( interface ) {
1996  interface->giveCompositeExportData(vtkPieces, this->primaryVarsToExport, this->internalVarsToExport, this->cellVarsToExport, tStep);
1997 
1998  //this->writeVTKPiece(this->defaultVTKPiece, tStep);
1999  }
2000 }
2001 
2002 void
2004 {
2006  numCells = 0;
2007  numNodes = 0;
2008  this->connectivity.clear();
2009  this->elCellTypes.clear();
2010  this->elOffsets.clear();
2011  this->elVars.clear();
2012  this->nodeCoords.clear();
2013  this->nodeVars.clear();
2014  this->nodeVarsFromIS.clear();
2015  this->nodeVarsFromXFEMIS.clear();
2016 }
2017 
2018 
2021 {
2022  Domain *d = emodel->giveDomain(1);
2023 
2024  if ( this->smoother == NULL ) {
2026  }
2027 
2028  return this->smoother;
2029 }
2030 
2031 
2034 {
2035  Domain *d = emodel->giveDomain(1);
2036 
2037  if ( this->primVarSmoother == NULL ) {
2039  }
2040 
2041  return this->primVarSmoother;
2042 }
2043 
2044 
2045 void
2047 {
2048  Domain *d = emodel->giveDomain(1);
2049  int nc = 0;
2050  FloatArray gc, value;
2051  FILE *stream;
2052  InternalStateType isttype;
2053  InternalStateValueType vtype;
2054  std :: string scalars, vectors, tensors;
2055 
2056  // output nodes Region By Region
2057  int nregions = this->giveNumberOfRegions(); // aka sets
2058  // open output stream
2059  std :: string outputFileName = this->giveOutputBaseFileName(tStep) + ".gp.vtu";
2060  if ( ( stream = fopen(outputFileName.c_str(), "w") ) == NULL ) {
2061  OOFEM_ERROR( "failed to open file %s", outputFileName.c_str() );
2062  }
2063 
2064  fprintf(stream, "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n");
2065  fprintf(stream, "<UnstructuredGrid>\n");
2066 
2067  /* loop over regions */
2068  for ( int ireg = 1; ireg <= nregions; ireg++ ) {
2069  const IntArray &elements = this->giveRegionSet(ireg)->giveElementList();
2070  int nip = 0;
2071  for ( int i = 1; i <= elements.giveSize(); i++ ) {
2072  nip += d->giveElement( elements.at(i) )->giveDefaultIntegrationRulePtr()->giveNumberOfIntegrationPoints();
2073  }
2074 
2075  //Create one cell per each GP
2076  fprintf(stream, "<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n", nip, nip);
2077  fprintf(stream, "<Points>\n <DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\"> ");
2078  for ( int i = 1; i <= elements.giveSize(); i++ ) {
2079  int ielem = elements.at(i);
2080 
2081  for ( GaussPoint *gp : *d->giveElement(ielem)->giveDefaultIntegrationRulePtr() ) {
2082  d->giveElement(ielem)->computeGlobalCoordinates( gc, gp->giveNaturalCoordinates() );
2083  for ( double c : gc ) {
2084  fprintf(stream, "%e ", c);
2085  }
2086 
2087  for ( int k = gc.giveSize() + 1; k <= 3; k++ ) {
2088  fprintf(stream, "%e ", 0.0);
2089  }
2090  }
2091  }
2092 
2093  fprintf(stream, " </DataArray>\n");
2094  fprintf(stream, "</Points>\n");
2095  fprintf(stream, "<Cells>\n");
2096  fprintf(stream, " <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">");
2097  for ( int j = 0; j < nip; j++ ) {
2098  fprintf(stream, "%d ", j);
2099  }
2100 
2101  fprintf(stream, " </DataArray>\n");
2102  fprintf(stream, " <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">");
2103  for ( int j = 1; j <= nip; j++ ) {
2104  fprintf(stream, "%d ", j);
2105  }
2106 
2107  fprintf(stream, " </DataArray>\n");
2108  fprintf(stream, " <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">");
2109  for ( int j = 1; j <= nip; j++ ) {
2110  fprintf(stream, "1 ");
2111  }
2112 
2113  fprintf(stream, " </DataArray>\n");
2114  fprintf(stream, "</Cells>\n");
2115  // prepare the data header
2116  for ( int vi = 1; vi <= valIDs.giveSize(); vi++ ) {
2117  isttype = ( InternalStateType ) valIDs.at(vi);
2118  vtype = giveInternalStateValueType(isttype);
2119 
2120  if ( vtype == ISVT_SCALAR ) {
2121  scalars += __InternalStateTypeToString(isttype);
2122  scalars.append(" ");
2123  } else if ( vtype == ISVT_VECTOR ) {
2124  vectors += __InternalStateTypeToString(isttype);
2125  vectors.append(" ");
2126  } else if ( vtype == ISVT_TENSOR_S3 || vtype == ISVT_TENSOR_S3E || vtype == ISVT_TENSOR_G ) {
2127  tensors += __InternalStateTypeToString(isttype);
2128  tensors.append(" ");
2129  } else {
2130  OOFEM_WARNING( "unsupported variable type %s\n", __InternalStateTypeToString(isttype) );
2131  }
2132  }
2133 
2134  // print collected data summary in header
2135  fprintf( stream, "<PointData Scalars=\"%s\" Vectors=\"%s\" Tensors=\"%s\" >\n", scalars.c_str(), vectors.c_str(), tensors.c_str() );
2136  scalars.clear();
2137  vectors.clear();
2138  tensors.clear();
2139 
2140  // export actual data, loop over individual IDs to export
2141  for ( int vi = 1; vi <= valIDs.giveSize(); vi++ ) {
2142  isttype = ( InternalStateType ) valIDs.at(vi);
2143  vtype = giveInternalStateValueType(isttype);
2144  if ( vtype == ISVT_SCALAR ) {
2145  nc = 1;
2146  } else if ( vtype == ISVT_VECTOR ) {
2147  nc = 3;
2148  } else if ( vtype == ISVT_TENSOR_S3 || vtype == ISVT_TENSOR_S3E || vtype == ISVT_TENSOR_G ) {
2149  nc = 9;
2150  } else {
2151  OOFEM_WARNING( "unsupported variable type %s\n", __InternalStateTypeToString(isttype) );
2152  }
2153 
2154  fprintf(stream, " <DataArray type=\"Float64\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\">", __InternalStateTypeToString(isttype), nc);
2155  for ( int i = 1; i <= elements.giveSize(); i++ ) {
2156  int ielem = elements.at(i);
2157 
2158  // loop over default IRule gps
2159  for ( GaussPoint *gp : *d->giveElement(ielem)->giveDefaultIntegrationRulePtr() ) {
2160  d->giveElement(ielem)->giveIPValue(value, gp, isttype, tStep);
2161 
2162  if ( vtype == ISVT_VECTOR ) {
2163  // bp: hack for BeamForceMomentTensor, which should be splitted into force and momentum vectors
2164  if (isttype == IST_BeamForceMomentTensor) {
2165  value.resizeWithValues(6);
2166  } else {
2167  value.resizeWithValues(3);
2168  }
2169  } else if ( vtype == ISVT_TENSOR_S3 || vtype == ISVT_TENSOR_S3E || vtype == ISVT_TENSOR_G ) {
2170  FloatArray help = value;
2171  this->makeFullTensorForm(value, help, vtype);
2172  }
2173 
2174  for ( double v : value ) {
2175  fprintf(stream, "%e ", v);
2176  }
2177  } // end loop over IPs
2178  } // end loop over elements
2179 
2180  fprintf(stream, " </DataArray>\n");
2181  } // end loop over values to be exported
2182  fprintf(stream, "</PointData>\n</Piece>\n");
2183  } // end loop over regions
2184 
2185  fprintf(stream, "</UnstructuredGrid>\n");
2186  fprintf(stream, "</VTKFile>\n");
2187  fclose(stream);
2188 }
2189 } // end namespace oofem
void setInternalVarInNode(int varNum, int nodeNum, FloatArray valueArray)
CrossSection * giveCrossSection()
Definition: element.C:495
void setInternalXFEMVarInNode(int varNum, int eiNum, int nodeNum, FloatArray valueArray)
InternalStateType
Type representing the physical meaning of element or constitutive model internal variable.
virtual bool isActivated(TimeStep *tStep)
Definition: element.C:793
int giveCellType(int cellNum)
The representation of EngngModel default unknown numbering.
void setCellVar(int varNum, int cellNum, FloatArray valueArray)
void exportExternalForces(VTKPiece &piece, IntArray &mapG2L, IntArray &mapL2G, int region, TimeStep *tStep)
Export external forces.
void writePrimaryVars(VTKPiece &vtkPiece)
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
VTKXMLExportModule(int n, EngngModel *e)
Constructor. Creates empty Output Manager. By default all components are selected.
bool testTimeStepOutput(TimeStep *tStep)
Tests if given time step output is required.
Definition: exportmodule.C:148
void getCellVariableFromIS(FloatArray &answer, Element *el, InternalStateType type, TimeStep *tStep)
NodalRecoveryModel * createNodalRecoveryModel(NodalRecoveryModel::NodalRecoveryModelType type, Domain *d)
Creates new instance of nodal recovery model corresponding to given type.
Definition: classfactory.C:153
void writeXFEMVars(VTKPiece &vtkPiece)
Abstract class representing entity, which is included in the FE model using one (or more) global func...
virtual int giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
Returns the integration point corresponding value in full form.
Definition: element.C:1257
bool evalNodeEnrMarkerInNode(double &oNodeEnrMarker, int iNodeInd) const
std::string giveOutputBaseFileName()
Returns base output file name to which extensions, like .out .vtu .osf should be added.
Definition: engngm.h:363
IntArray ipInternalVarsToExport
List of internal variables to export directly in Integration Points (no smoothing to nodes) ...
void exportCompositeElement(VTKPiece &vtkPiece, Element *el, TimeStep *tStep)
Returns true if element geometry type is composite (not a single cell).
Class and object Domain.
Definition: domain.h:115
virtual IntegrationRule * giveDefaultIntegrationRulePtr()
Access method for default integration rule.
Definition: element.h:822
#define _IFT_VTKXMLExportModule_vars
bool isElementComposite(Element *elem)
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
Returns number of equations for given domain in active (current time step) time step.
Definition: engngm.C:391
bool hasLocalCS()
Returns nonzero if node has prescribed local coordinate system.
Definition: node.h:150
Element_Geometry_Type
Enumerative type used to classify element geometry Possible values are: EGT_point - point in space EG...
void exportCellVars(VTKPiece &piece, const IntArray &elems, TimeStep *tStep)
int giveNumberOfDofManagers() const
Returns number of dof managers in domain.
Definition: domain.h:432
int giveCellType(Element *element)
Returns corresponding element cell_type.
FloatMatrix * giveLocalCoordinateTriplet()
Returns pointer to local coordinate triplet in node.
Definition: node.h:158
bool isEmpty() const
Checks if receiver is empty (i.e., zero sized).
Definition: intarray.h:208
virtual void terminate()
Terminates the receiver.
NodalRecoveryModel * smoother
Smoother.
void setNumberOfNodes(int numNodes)
void writeVTKCellData(FloatArray &valueArray)
void zero()
Sets all component to zero.
Definition: intarray.C:52
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
InternalStateValueType giveXFEMStateValueType(XFEMStateType type)
Definition: xfemmanager.C:88
void setNumberOfInternalVarsToExport(int numVars, int numNodes)
void clear()
Clears receiver (zero size).
Definition: floatarray.h:206
Elements with geometry defined as EGT_Composite are exported using individual pieces.
std::string giveOutputFileName(TimeStep *tStep)
Returns the filename for the given time step.
virtual MaterialInterface * giveMaterialInterface(int n)
Returns material interface representation for given domain.
Definition: engngm.h:351
oofem::oofegGraphicContext gc[OOFEG_LAST_LAYER]
virtual FloatArray * giveCoordinates()
Definition: dofmanager.h:382
virtual double giveUnknown(ValueModeType mode, TimeStep *tStep)=0
The key method of class Dof.
void exportIntVarsInGpAs(IntArray valIDs, TimeStep *tStep)
Exports given internal variables directly in integration points (raw data, no smoothing) ...
FILE * giveOutputStream(TimeStep *tStep)
Returns the output stream for given solution step.
virtual void initialize()
Definition: exportmodule.C:86
double giveTargetTime()
Returns target time.
Definition: timestep.h:146
bool isParallel() const
Returns true if receiver in parallel mode.
Definition: engngm.h:1056
Abstract base class for all finite elements.
Definition: element.h:145
InternalStateValueType
Determines the type of internal variable.
symmetric 3x3 tensor, packed with off diagonal components multiplied by 2 (engineering strain vector...
void writeGPVTKCollection()
Writes a VTK collection file for Gauss points.
Base class for dof managers.
Definition: dofmanager.h:113
#define _IFT_VTKXMLExportModule_externalForces
int giveNumberOfProcesses() const
Returns the number of collaborating processes.
Definition: engngm.h:1060
int giveCellOffset(int cellNum)
void exportIntVars(VTKPiece &piece, IntArray &mapG2L, IntArray &mapL2G, int ireg, TimeStep *tStep)
Export internal variables by smoothing.
virtual double giveCoordinate(int i)
Definition: node.C:82
virtual bool isActive()
Returns the activeFlag.
Definition: pfemparticle.h:94
Represents export output module - a base class for all output modules.
Definition: exportmodule.h:71
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
int giveNumberOfNodesPerCell(int cellType)
Returns number of nodes corresponding to cell type.
void setNumberOfCells(int numCells)
const char * __UnknownTypeToString(UnknownType _value)
Definition: cltypes.C:302
int giveInternalStateTypeSize(InternalStateValueType valType)
Definition: cltypes.C:217
XfemManager * giveXfemManager()
Definition: domain.C:375
virtual ~VTKXMLExportModule()
Destructor.
FloatArray & giveInternalVarInNode(int varNum, int nodeNum)
void rotatedWith(FloatMatrix &r, char mode)
Returns the receiver a rotated according the change-of-base matrix r.
Definition: floatarray.C:799
Abstract base class representing integration rule.
void setNumberOfLoadsToExport(int numVars, int numNodes)
virtual void setupVTKPiece(VTKPiece &vtkPiece, TimeStep *tStep, int region)
std::list< std::string > pvdBuffer
Buffer for earlier time steps exported to *.pvd file.
#define _IFT_VTKXMLExportModule_primvars
void beColumnOf(const FloatMatrix &mat, int col)
Reciever will be set to a given column in a matrix.
Definition: floatarray.C:1114
void setNodeCoords(int nodeNum, FloatArray &coords)
virtual int giveNumberOfNodes() const
Returns number of nodes of receiver.
Definition: element.h:662
FloatArray & giveLoadInNode(int varNum, int nodeNum)
void setLoadInNode(int varNum, int nodeNum, FloatArray valueArray)
int giveNumberOfEnrichmentItems() const
Definition: xfemmanager.h:185
int giveSubStepNumber()
Returns receiver&#39;s substep number.
Definition: timestep.h:137
IntArray cellVarsToExport
List of cell data to export.
virtual int initRegionNodeNumbering(IntArray &mapG2L, IntArray &mapL2G, int &regionDofMans, int &totalcells, Domain *domain, TimeStep *tStep, int reg)
Assembles the region node map.
void giveElementCell(IntArray &answer, Element *elem)
Returns the element cell geometry.
void setCellType(int cellNum, int type)
void setNumberOfInternalXFEMVarsToExport(int numVars, int numEnrichmentItems, int numNodes)
IntArray internalVarsToExport
List of InternalStateType values, identifying the selected vars for export.
void writeExternalForces(VTKPiece &vtkPiece)
#define _IFT_VTKXMLExportModule_ipvars
void setNumberOfPrimaryVarsToExport(int numVars, int numNodes)
int giveNumber()
Returns receiver&#39;s number.
Definition: timestep.h:129
Element * giveElement(int n)
Service for accessing particular domain fe element.
Definition: domain.C:160
int giveNodalVector(const FloatArray *&ptr, int node)
Returns vector of recovered values for given node and region.
void getNodalVariableFromPrimaryField(FloatArray &answer, DofManager *dman, TimeStep *tStep, UnknownType type, int ireg)
#define OOFEM_ERROR(...)
Definition: error.h:61
void clear()
Clears the array (zero size).
Definition: intarray.h:177
bool tstep_substeps_out_flag
Flag turning output in solution step substeps/itarations.
Definition: exportmodule.h:90
void setNumberOfCellVarsToExport(int numVars, int numCells)
DofIDItem
Type representing particular dof type.
Definition: dofiditem.h:86
FloatArray & giveInternalXFEMVarInNode(int varNum, int eiNum, int nodeNum)
EngngModel * emodel
Problem pointer.
Definition: exportmodule.h:77
FloatArray & givePrimaryVarInNode(int varNum, int nodeNum)
Implementation for assembling external forces vectors in standard monolithic FE-problems.
UnknownType
Type representing particular unknown (its physical meaning).
Definition: unknowntype.h:55
Abstract base class representing (moving) material interfaces.
bool evalLevelSetNormalInNode(double &oLevelSet, int iNodeInd, const FloatArray &iGlobalCoord) const
Set * giveRegionSet(int i)
Returns element set.
Definition: exportmodule.C:109
void writeIntVars(VTKPiece &vtkPiece)
virtual double giveUpdatedCoordinate(int ic, TimeStep *tStep, double scale=1.)
Returns updated ic-th coordinate of receiver.
Definition: node.C:245
void resizeWithValues(int s, int allocChunk=0)
Checks size of receiver towards requested bounds.
Definition: floatarray.C:615
virtual int giveLocalCoordinateSystem(FloatMatrix &answer)
Returns local coordinate system of receiver Required by material models with ortho- and anisotrophy...
Definition: element.C:1234
void resize(int n)
Checks size of receiver towards requested bounds.
Definition: intarray.C:124
NodalRecoveryModel * primVarSmoother
Smoother for primary variables.
Represents VTK (Visualization Toolkit) export module.
bool particleExportFlag
particle export flag
virtual int clear()
Clears the receiver&#39;s nodal table.
IntArray externalForcesToExport
List of primary unknowns to export.
void setPrimaryVarInNode(int varNum, int nodeNum, FloatArray valueArray)
#define _IFT_VTKXMLExportModule_cellvars
void getNodalVariableFromXFEMST(FloatArray &answer, Node *node, TimeStep *tStep, XFEMStateType xfemstype, int ireg, EnrichmentItem *ei)
void writeCellVars(VTKPiece &vtkPiece)
bool hasXfemManager()
Definition: domain.C:386
Symmetric 3x3 tensor.
virtual void giveCompositeExportData(VTKPiece &vtkPiece, IntArray &primaryVarsToExport, IntArray &internalVarsToExport, IntArray cellVarsToExport, TimeStep *tStep)
bool evalLevelSetTangInNode(double &oLevelSet, int iNodeInd, const FloatArray &iGlobalCoord) const
Class representing vector of real numbers.
Definition: floatarray.h:82
#define _IFT_VTKXMLExportModule_particleexportflag
bool writeVTKPiece(VTKPiece &vtkPiece, TimeStep *tStep)
elementParallelMode giveParallelMode() const
Return elementParallelMode of receiver.
Definition: element.h:1069
const char * __XFEMStateTypeToString(XFEMStateType _value)
Definition: cltypes.C:351
bool hasDofID(DofIDItem id) const
Checks if receiver contains dof with given ID.
Definition: dofmanager.C:166
Element is local, there are no contributions from other domains to this element.
Definition: element.h:101
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
This class manages the xfem part.
Definition: xfemmanager.h:109
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
IntArray primaryVarsToExport
List of primary unknowns to export.
static void computeIPAverage(FloatArray &answer, IntegrationRule *iRule, Element *elem, InternalStateType isType, TimeStep *tStep)
Computes a cell average of an InternalStateType varible based on the weights in the integrationpoints...
IntArray vtkExportFields
List with the fields that should be exported to VTK.
Definition: xfemmanager.h:167
NodalRecoveryModel * giveSmoother()
Returns the internal smoother.
void setOffset(int cellNum, int offset)
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Definition: exportmodule.C:58
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
Definition: floatmatrix.C:1358
virtual int recoverValues(Set elementSet, InternalStateType type, TimeStep *tStep)=0
Recovers the nodal values for all regions.
Class representing the general Input Record.
Definition: inputrecord.h:101
The representation of EngngModel default prescribed unknown numbering.
#define _IFT_VTKXMLExportModule_stype
IntArray & giveCellConnectivity(int cellNum)
void getNodalVariableFromIS(FloatArray &answer, Node *node, TimeStep *tStep, InternalStateType type, int ireg)
std::list< std::string > gpPvdBuffer
Buffer for earlier time steps with gauss points exported to *.gp.pvd file.
int number
Component number.
Definition: exportmodule.h:75
Dof * giveDofWithID(int dofID) const
Returns DOF with given dofID; issues error if not present.
Definition: dofmanager.C:119
XFEMStateType
Definition: xfemmanager.h:92
void followedBy(const IntArray &b, int allocChunk=0)
Appends array b at the end of receiver.
Definition: intarray.C:145
virtual int giveNumberOfInternalDofManagers() const
Definition: element.h:232
void exportPrimaryVars(VTKPiece &piece, IntArray &mapG2L, IntArray &mapL2G, int region, TimeStep *tStep)
Export primary variables.
void zero()
Zeroes all coefficients of receiver.
Definition: floatarray.C:658
NodalRecoveryModel::NodalRecoveryModelType stype
Smoother type.
static IntArray redToFull
Map from Voigt to full tensor.
void giveDataHeaders(std::string &pointHeader, std::string &cellHeader)
int giveRank() const
Returns domain rank in a group of collaborating processes (0..groupSize-1)
Definition: engngm.h:1058
virtual double giveNodalScalarRepresentation(int)=0
Returns scalar value representation of material Interface at given point.
virtual Interface * giveInterface(InterfaceType t)
Interface requesting service.
Definition: femcmpnn.h:179
std::vector< VTKPiece > defaultVTKPieces
void times(double s)
Multiplies receiver with scalar.
Definition: floatarray.C:818
EnrichmentItem * giveEnrichmentItem(int n)
Definition: xfemmanager.h:184
ClassFactory & classFactory
Definition: classfactory.C:59
virtual FloatArray * giveCoordinates()
Definition: node.h:114
FloatArray & giveCellVar(int field, int cellNum)
Particle class being used in PFEM computations.
Definition: pfemparticle.h:56
void setConnectivity(int cellNum, IntArray &nodes)
int giveEquationNumber(const UnknownNumberingScheme &s)
Returns equation number of receiver for given equation numbering scheme.
Definition: dof.C:56
void beUnitMatrix()
Sets receiver to unity matrix.
Definition: floatmatrix.C:1332
const char * __InternalStateTypeToString(InternalStateType _value)
Definition: cltypes.C:298
static void makeFullTensorForm(FloatArray &answer, const FloatArray &reducedForm, InternalStateValueType vtype)
Gives the full form of given symmetrically stored tensors, missing components are filled with zeros...
double timeScale
Scaling time in output, e.g. conversion from seconds to hours.
Definition: exportmodule.h:101
Abstract base class representing the "problem" under consideration.
Definition: engngm.h:181
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
InternalStateValueType giveInternalStateValueType(InternalStateType type)
Definition: cltypes.C:77
int giveSize() const
Definition: intarray.h:203
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
virtual void doOutput(TimeStep *tStep, bool forcedOutput=false)
Writes the output.
virtual Element_Geometry_Type giveGeometryType() const
Returns the element geometry type.
Definition: element.C:1529
Node * giveNode(int n)
Service for accessing particular domain node.
Definition: domain.h:371
the oofem namespace is to define a context or scope in which all oofem names are defined.
FloatArray & giveNodeCoords(int nodeNum)
Domain * giveDomain(int n)
Service for accessing particular problem domain.
Definition: engngm.C:1720
Class implementing node in finite element mesh.
Definition: node.h:87
int giveNumberOfRegions()
Returns number of regions (aka regionSets)
Definition: exportmodule.C:100
Abstract class Dof represents Degree Of Freedom in finite element mesh.
Definition: dof.h:93
virtual bool isCast(TimeStep *tStep)
Definition: element.C:809
void writeVTKCollection()
Writes a VTK collection file where time step data is stored.
int giveNumber() const
Definition: femcmpnn.h:107
The base class for all recovery models, which perform nodal averaging or projection processes for int...
Node * giveNode(int i) const
Returns reference to the i-th node of element.
Definition: element.h:610
void writeVTKPointData(FloatArray &valueArray)
std::string giveOutputBaseFileName(TimeStep *tStep)
Gives the appropriate name (minus specific file extension).
Definition: exportmodule.C:125
NodalRecoveryModel * givePrimVarSmoother()
Returns the smoother for primary variables (nodal averaging).
Class representing integration point in finite element program.
Definition: gausspoint.h:93
#define OOFEM_WARNING(...)
Definition: error.h:62
void assembleVector(FloatArray &answer, TimeStep *tStep, const VectorAssembler &va, ValueModeType mode, const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms=NULL)
Assembles characteristic vector of required type from dofManagers, element, and active boundary condi...
Definition: engngm.C:986
Class representing solution step.
Definition: timestep.h:80
virtual int computeGlobalCoordinates(FloatArray &answer, const FloatArray &lcoords)
Computes the global coordinates from given element&#39;s local coordinates.
Definition: element.C:1207
const IntArray & giveElementList()
Returns list of elements within set.
Definition: set.C:138
REGISTER_ExportModule(ErrorCheckingExportModule)
void add(const FloatArray &src)
Adds array src to receiver.
Definition: floatarray.C:156
virtual Material * giveMaterial()
Definition: element.C:484
void resize(int s)
Resizes receiver towards requested size.
Definition: floatarray.C:631

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:32 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011