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> 78 1, 5, 9, 8, 7, 4, 6, 3, 2
146 for (
int i = 1; i <= reducedForm.
giveSize(); i++ ) {
158 answer.
at(2) = answer.
at(4);
159 answer.
at(3) = answer.
at(7);
160 answer.
at(6) = answer.
at(8);
177 if ( ( answer = fopen(fileName.c_str(),
"w") ) == NULL ) {
178 OOFEM_ERROR(
"failed to open file %s", fileName.c_str() );
190 if ( elemGT == EGT_point ) {
192 }
else if ( elemGT == EGT_line_1 ) {
194 }
else if ( elemGT == EGT_line_2 ) {
196 }
else if ( elemGT == EGT_triangle_1 ) {
198 }
else if ( elemGT == EGT_triangle_2 ) {
200 }
else if ( elemGT == EGT_tetra_1 ) {
202 }
else if ( elemGT == EGT_tetra_2 ) {
204 }
else if ( elemGT == EGT_quad_1 || elemGT == EGT_quad_1_interface ) {
206 }
else if ( elemGT == EGT_quad_21_interface ) {
208 }
else if ( elemGT == EGT_quad_2 ) {
210 }
else if ( elemGT == EGT_quad9_2 ) {
212 }
else if ( elemGT == EGT_hexa_1 ) {
214 }
else if ( elemGT == EGT_hexa_2 ) {
216 }
else if ( elemGT == EGT_hexa_27 ) {
218 }
else if ( elemGT == EGT_wedge_1 ) {
220 }
else if ( elemGT == EGT_wedge_2 ) {
232 switch ( cellType ) {
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 ) {
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
293 }
else if ( elemGT == EGT_hexa_2 ) {
295 5, 8, 7, 6, 1, 4, 3, 2, 16, 15, 14, 13, 12, 11, 10, 9, 17, 20, 19, 18
297 }
else if ( elemGT == EGT_wedge_2 ) {
299 4, 6, 5, 1, 3, 2, 12, 11, 10, 9, 8, 7, 13, 15, 14
301 }
else if ( elemGT == EGT_quad_1_interface ) {
305 }
else if ( elemGT == EGT_quad_21_interface ) {
313 OOFEM_ERROR(
"VTKXMLExportModule: unsupported element geometry type");
317 answer.
resize(nelemNodes);
319 for (
int i = 1; i <= nelemNodes; i++ ) {
320 answer.
at(i) = elem->
giveNode( nodeMapping.
at(i) )->giveNumber();
323 for (
int i = 1; i <= nelemNodes; i++ ) {
347 this->
fileStream = vtkSmartPointer< vtkUnstructuredGrid > :: New();
348 this->nodes = vtkSmartPointer< vtkPoints > :: New();
349 this->elemNodeArray = vtkSmartPointer< vtkIdList > :: New();
356 current = localtime(& now);
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");
376 int anyPieceNonEmpty = 0;
378 for (
int pieceNum = 1; pieceNum <= nPiecesToExport; pieceNum++ ) {
392 for (
int pieceNum = 1; pieceNum <= nPiecesToExport; pieceNum++ ) {
394 for (
int i = 1; i <= elements.
giveSize(); i++ ) {
415 if (anyPieceNonEmpty == 0) {
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");
430 for (
int inode = 1; inode <= nnode; inode++ ) {
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\"> ");
444 for (
int inode = 1; inode <= nnode; inode++ ) {
451 for (
int i = 1; i <= coords->
giveSize(); i++ ) {
455 for (
int i = coords->
giveSize() + 1; i <= 3; i++ ) {
462 fprintf(this->
fileStream,
"</DataArray>\n</Points>\n");
467 fprintf(this->
fileStream,
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\"> ");
469 for (
int ielem = 1; ielem <= nActiveNode; ielem++ ) {
476 fprintf(this->
fileStream,
" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\"> ");
478 for (
int ielem = 1; ielem <= nActiveNode; ielem++ ) {
485 fprintf(this->
fileStream,
" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\"> ");
486 for (
int ielem = 1; ielem <= nActiveNode; ielem++ ) {
493 #endif //__PFEM_MODULE 506 vtkSmartPointer< vtkXMLPUnstructuredGridWriter >writer = vtkSmartPointer< vtkXMLPUnstructuredGridWriter > :: New();
514 vtkSmartPointer< vtkXMLUnstructuredGridWriter >writer = vtkSmartPointer< vtkXMLUnstructuredGridWriter > :: New();
517 writer->SetFileName( fname.c_str() );
523 writer->SetDataModeToAscii();
526 fprintf(this->
fileStream,
"</UnstructuredGrid>\n</VTKFile>");
534 std :: ostringstream pvdEntry;
535 std :: stringstream subStep;
551 std :: ostringstream pvdEntry;
552 std :: stringstream subStep;
563 this->
pvdBuffer.push_back( pvdEntry.str() );
568 std :: ostringstream pvdEntry;
569 std :: stringstream subStep;
573 pvdEntry <<
"<DataSet timestep=\"" << tStep->
giveTargetTime() * this->
timeScale << subStep.str() <<
"\" group=\"\" part=\"\" file=\"" << fname <<
"\"/>";
574 this->
pvdBuffer.push_back( pvdEntry.str() );
583 this->numNodes = numNodes;
584 this->nodeCoords.resize(numNodes);
590 this->numCells = numCells;
591 this->connectivity.resize(numCells);
592 this->elCellTypes.resize(numCells);
593 this->elOffsets.resize(numCells);
599 this->connectivity [ cellNum - 1 ] = nodes;
605 this->nodeCoords [ nodeNum - 1 ] = coords;
611 this->nodeVars.resize(numVars);
612 for (
int i = 1; i <= numVars; i++ ) {
613 this->nodeVars [ i - 1 ].resize(numNodes);
620 this->nodeLoads.resize(numVars);
621 for (
int i = 1; i <= numVars; i++ ) {
622 this->nodeLoads [ i - 1 ].resize(numNodes);
629 this->nodeVarsFromIS.resize(numVars);
630 for (
int i = 1; i <= numVars; i++ ) {
631 this->nodeVarsFromIS [ i - 1 ].resize(numNodes);
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);
650 this->elVars.resize(numVars);
651 for (
int i = 1; i <= numVars; i++ ) {
652 this->elVars [ i - 1 ].resize(numCells);
659 this->nodeVars [ varNum - 1 ] [ nodeNum - 1 ] = std :: move(valueArray);
665 this->nodeLoads [ varNum - 1 ] [ nodeNum - 1 ] = std :: move(valueArray);
671 this->nodeVarsFromIS [ varNum - 1 ] [ nodeNum - 1 ] = std :: move(valueArray);
677 this->nodeVarsFromXFEMIS [ varNum - 1 ] [ eiNum - 1 ] [ nodeNum - 1 ] = std :: move(valueArray);
684 this->elVars [ varNum - 1 ] [ cellNum - 1 ] = std :: move(valueArray);
700 int numNodes, numRegionEl;
706 if ( numNodes > 0 && numRegionEl > 0 ) {
709 for (
int inode = 1; inode <= numNodes; inode++ ) {
710 coords = d->
giveNode( mapL2G.
at(inode) )->giveCoordinates();
725 for (
int ei = 1; ei <= elems.
giveSize(); ei++ ) {
726 int elNum = elems.
at(ei);
736 if ( !elem->
isCast(tStep) ) {
752 int numElNodes = cellNodes.
giveSize();
754 for (
int i = 1; i <= numElNodes; i++ ) {
755 connectivity.
at(i) = mapG2L.
at( cellNodes.
at(i) );
762 offset += numElNodes;
769 this->
exportIntVars(vtkPiece, mapG2L, mapL2G, region, tStep);
801 for (
int inode = 1; inode <= numNodes; inode++ ) {
804 for (
int i = 1; i <= coords.
giveSize(); i++ ) {
805 vtkCoords.
at(i) = coords.
at(i);
808 this->nodes->InsertNextPoint( vtkCoords.
at(1), vtkCoords.
at(2), vtkCoords.
at(3) );
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\"> ");
816 for (
int inode = 1; inode <= numNodes; inode++ ) {
819 for (
int i = 1; i <= coords.
giveSize(); i++ ) {
823 for (
int i = coords.
giveSize() + 1; i <= 3; i++ ) {
828 fprintf(this->
fileStream,
"</DataArray>\n</Points>\n");
839 fprintf(this->
fileStream,
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\"> ");
842 for (
int ielem = 1; ielem <= numEl; ielem++ ) {
846 elemNodeArray->Reset();
847 elemNodeArray->SetNumberOfIds( cellNodes.
giveSize() );
849 for (
int i = 1; i <= cellNodes.
giveSize(); i++ ) {
851 elemNodeArray->SetId(i - 1, cellNodes.
at(i) - 1);
868 fprintf(this->
fileStream,
" <DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\"> ");
870 for (
int ielem = 1; ielem <= numEl; ielem++ ) {
878 fprintf(this->
fileStream,
" <DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\"> ");
879 for (
int ielem = 1; ielem <= numEl; ielem++ ) {
888 std :: string pointHeader, cellHeader;
891 fprintf( this->
fileStream,
"%s", pointHeader.c_str() );
904 fprintf( this->
fileStream,
"%s", cellHeader.c_str() );
928 std :: string scalars, vectors, tensors;
932 if ( type == DisplacementVector || type == EigenVector || type == VelocityVector || type == DirectorField ) {
935 }
else if ( type == FluxVector || type == PressureVector || type == Temperature || type == Humidity || type == DeplanationFunction ) {
963 if ( type == DisplacementVector || type == VelocityVector || type == DirectorField ) {
966 }
else if ( type == FluxVector || type == PressureVector || type == Temperature || type == Humidity ) {
975 pointHeader =
"<PointData Scalars=\"" + scalars +
"\" " 976 +
"Vectors=\"" + vectors +
"\" " 977 +
"Tensors=\"" + tensors +
"\" >\n";
1003 cellHeader =
"<CellData Scalars=\"" + scalars +
"\" " 1004 +
"Vectors=\"" + vectors +
"\" " 1005 +
"Tensors=\"" + tensors +
"\" >\n";
1032 for (
int nodeNum = 1; nodeNum <= mapL2G.
giveSize(); nodeNum++ ) {
1048 for (
int enrItIndex = 1; enrItIndex <= nEnrIt; enrItIndex++ ) {
1049 for (
int nodeIndx = 1; nodeIndx <= mapL2G.
giveSize(); nodeIndx++ ) {
1069 if ( !( type == IST_DisplacementVector || type == IST_MaterialInterfaceVal ) ) {
1078 if ( type == IST_DisplacementVector ) {
1082 for (
int i = 1; i <= 3; i++ ) {
1085 }
else if ( type == IST_MaterialInterfaceVal ) {
1101 answer.
resize(ncomponents);
1106 answer.
at(1) = valSize ? val->
at(1) : 0.0;
1110 if (type == IST_BeamForceMomentTensor) {
1139 if ( xfemstype == XFEMST_LevelSetPhi ) {
1143 }
else if ( xfemstype == XFEMST_LevelSetGamma ) {
1147 }
else if ( xfemstype == XFEMST_NodeEnrMarker ) {
1157 answer.
resize(ncomponents);
1162 answer.
at(1) = valSize ? val->
at(1) : 0.0;
1178 for (
int i = 1; i <= n; i++ ) {
1186 ncomponents = valueArray.
giveSize();
1190 vtkSmartPointer< vtkDoubleArray >varArray = vtkSmartPointer< vtkDoubleArray > :: New();
1191 varArray->SetName(name);
1192 varArray->SetNumberOfComponents(ncomponents);
1193 varArray->SetNumberOfTuples(numNodes);
1195 for (
int inode = 1; inode <= numNodes; inode++ ) {
1197 for (
int i = 1; i <= ncomponents; ++i ) {
1198 varArray->SetComponent( inode - 1, i - 1, valueArray.
at(i) );
1206 fprintf(this->
fileStream,
" <DataArray type=\"Float64\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"> ", name, ncomponents);
1207 for (
int inode = 1; inode <= numNodes; inode++ ) {
1219 #ifndef __VTK_MODULE 1241 for (
int enrItIndex = 1; enrItIndex <= nEnrIt; enrItIndex++ ) {
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++ ) {
1253 for (
int i = 1; i <= ncomponents; ++i ) {
1254 varArray->SetComponent( inode - 1, i - 1, valueArray.
at(i) );
1260 fprintf(this->
fileStream,
" <DataArray type=\"Float64\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"> ", name, ncomponents);
1261 for (
int inode = 1; inode <= numNodes; inode++ ) {
1282 int ncomponents = varArray->GetNumberOfComponents();
1283 switch ( ncomponents ) {
1285 this->
fileStream->GetPointData()->SetActiveScalars(name);
1286 this->
fileStream->GetPointData()->SetScalars(varArray);
1289 this->
fileStream->GetPointData()->SetActiveVectors(name);
1290 this->
fileStream->GetPointData()->SetVectors(varArray);
1293 this->
fileStream->GetPointData()->SetActiveTensors(name);
1294 this->
fileStream->GetPointData()->SetTensors(varArray);
1303 for (
int i = 1; i <= valueArray.
giveSize(); i++ ) {
1318 int ncomponents = varArray->GetNumberOfComponents();
1319 switch ( ncomponents ) {
1321 this->
fileStream->GetCellData()->SetActiveScalars(name);
1322 this->
fileStream->GetCellData()->SetScalars(varArray);
1325 this->
fileStream->GetCellData()->SetActiveVectors(name);
1326 this->
fileStream->GetCellData()->SetVectors(varArray);
1329 this->
fileStream->GetCellData()->SetActiveTensors(name);
1330 this->
fileStream->GetCellData()->SetTensors(varArray);
1341 for (
int i = 1; i <= valueArray.
giveSize(); i++ ) {
1354 int ®ionSingleCells,
1366 int elementNode,
node;
1370 regionG2LNodalNumbers.
resize(nnodes);
1371 regionG2LNodalNumbers.
zero();
1373 regionSingleCells = 0;
1376 for (
int ie = 1; ie <= elements.
giveSize(); ie++ ) {
1377 int ielem = elements.
at(ie);
1389 if ( !element->
isCast(tStep) ) {
1397 regionSingleCells++;
1402 for ( elementNode = 1; elementNode <= elemNodes; elementNode++ ) {
1404 if ( regionG2LNodalNumbers.
at(node) == 0 ) {
1408 regionG2LNodalNumbers.
at(node) = 1;
1414 regionL2GNodalNumbers.
resize(regionDofMans);
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;
1447 for (
int inode = 1; inode <= mapL2G.
giveSize(); inode++ ) {
1472 if ( type == DisplacementVector ) {
1474 ( int ) Undef, (
int ) Undef, ( int ) Undef
1476 for (
Dof *dof : *dman ) {
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;
1488 }
else if ( type == VelocityVector ) {
1490 ( int ) Undef, (
int ) Undef, ( int ) Undef
1492 for (
Dof *dof : *dman ) {
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;
1504 }
else if ( type == EigenVector ) {
1506 ( int ) Undef, (
int ) Undef, ( int ) Undef
1508 for (
Dof *dof : *dman ) {
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;
1520 }
else if ( type == FluxVector || type == Humidity ) {
1522 iState = IST_MassConcentration_1;
1524 }
else if ( type == DeplanationFunction ) {
1526 iState = IST_Temperature;
1528 }
else if ( type == Temperature ) {
1530 iState = IST_Temperature;
1532 }
else if ( type == PressureVector ) {
1534 iState = IST_Pressure;
1536 }
else if ( type == DirectorField ) {
1537 for (
Dof *dof : *dman ) {
1539 if ( (
id == W_u ) || (
id == W_v ) || (
id == W_w ) ) {
1546 iState = IST_DirectorField;
1554 for (
int j = 1; j <= size; j++ ) {
1556 if (
id == Undef ) {
1558 }
else if ( iState == IST_DirectorField ) {
1563 if ( size == recoveredVal->
giveSize() ) {
1564 answer.
at(j) = recoveredVal->
at(j);
1566 OOFEM_WARNING(
"Recovered variable size mismatch for %d for id %d", type,
id);
1573 }
else if ( iState != IST_Undefined ) {
1584 if ( size == recoveredVal->
giveSize() ) {
1585 answer.
at(j) = recoveredVal->
at(j);
1617 vtkSmartPointer< vtkDoubleArray >varArray = vtkSmartPointer< vtkDoubleArray > :: New();
1618 varArray->SetName(name);
1619 varArray->SetNumberOfComponents(ncomponents);
1620 varArray->SetNumberOfTuples(numNodes);
1622 for (
int inode = 1; inode <= numNodes; inode++ ) {
1624 for (
int j = 1; j <= ncomponents; ++j ) {
1625 varArray->SetComponent( inode - 1, j - 1, valueArray.
at(j) );
1632 fprintf(this->
fileStream,
" <DataArray type=\"Float64\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"> ", name, ncomponents);
1633 for (
int inode = 1; inode <= numNodes; inode++ ) {
1669 if ( type == VelocityVector ) {
1673 }
else if ( type == DisplacementVector ) {
1677 }
else if ( type == PressureVector ) {
1682 OOFEM_WARNING(
"Unrecognized UnknownType (%d), no external forces exported", type);
1685 for (
int inode = 1; inode <= mapL2G.
giveSize(); inode++ ) {
1689 for (
int k = 1; k <= dofids.
giveSize(); ++k ) {
1694 valueArray.at(k) = extForces.at(eq);
1696 valueArray.at(k) = extForcesP.
at(eq);
1700 vtkPiece.
setLoadInNode( i, inode, std :: move(valueArray) );
1718 vtkSmartPointer< vtkDoubleArray >varArray = vtkSmartPointer< vtkDoubleArray > :: New();
1719 varArray->SetName(name);
1720 varArray->SetNumberOfComponents(ncomponents);
1721 varArray->SetNumberOfTuples(numNodes);
1723 for (
int inode = 1; inode <= numNodes; inode++ ) {
1725 for (
int j = 1; j <= ncomponents; ++j ) {
1726 varArray->SetComponent( inode - 1, j - 1, valueArray.
at(j) );
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++ ) {
1760 for (
int subIndex = 1; subIndex <= elems.
giveSize(); ++subIndex ) {
1767 vtkPiece.
setCellVar(field, subIndex, valueArray);
1779 answer.
resize(ncomponents);
1783 case IST_MaterialNumber:
1788 case IST_CrossSectionNumber:
1791 case IST_ElementNumber:
1802 case IST_AbaqusStateVector:
1811 case IST_MaterialOrientation_x:
1812 case IST_MaterialOrientation_y:
1813 case IST_MaterialOrientation_z:
1817 if ( type == IST_MaterialOrientation_x ) {
1819 }
else if ( type == IST_MaterialOrientation_y ) {
1821 }
else if ( type == IST_MaterialOrientation_z ) {
1848 }
else if ( ncomponents != answer.
giveSize() ) {
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++ ) {
1874 for (
int i = 1; i <= ncomponents; ++i ) {
1875 cellVarsArray->SetComponent( ielem - 1, i - 1, valueArray.
at(i) );
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++ ) {
1904 gptot += ip->giveWeight();
1905 answer.
add(ip->giveWeight(), temp);
1908 answer.
times(1. / gptot);
1919 current = localtime(& now);
1921 std :: string fname;
1929 std :: ofstream outfile( fname.c_str() );
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);
1934 outfile <<
"<?xml version=\"1.0\"?>\n<VTKFile type=\"Collection\" version=\"0.1\">\n<Collection>\n";
1936 outfile << pvd <<
"\n";
1939 outfile <<
"</Collection>\n</VTKFile>";
1950 current = localtime(& now);
1952 std :: string fname;
1960 std :: ofstream outfile( fname.c_str() );
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);
1965 outfile <<
"<?xml version=\"1.0\"?>\n<VTKFile type=\"Collection\" version=\"0.1\">\n<Collection>\n";
1967 outfile << pvd <<
"\n";
1970 outfile <<
"</Collection>\n</VTKFile>";
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();
2054 std :: string scalars, vectors, tensors;
2060 if ( ( stream = fopen(outputFileName.c_str(),
"w") ) == NULL ) {
2061 OOFEM_ERROR(
"failed to open file %s", outputFileName.c_str() );
2064 fprintf(stream,
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n");
2065 fprintf(stream,
"<UnstructuredGrid>\n");
2068 for (
int ireg = 1; ireg <= nregions; ireg++ ) {
2071 for (
int i = 1; i <= elements.
giveSize(); i++ ) {
2072 nip += d->
giveElement( elements.
at(i) )->giveDefaultIntegrationRulePtr()->giveNumberOfIntegrationPoints();
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);
2083 for (
double c : gc ) {
2084 fprintf(stream,
"%e ", c);
2087 for (
int k = gc.giveSize() + 1; k <= 3; k++ ) {
2088 fprintf(stream,
"%e ", 0.0);
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);
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);
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 ");
2113 fprintf(stream,
" </DataArray>\n");
2114 fprintf(stream,
"</Cells>\n");
2116 for (
int vi = 1; vi <= valIDs.
giveSize(); vi++ ) {
2122 scalars.append(
" ");
2125 vectors.append(
" ");
2128 tensors.append(
" ");
2135 fprintf( stream,
"<PointData Scalars=\"%s\" Vectors=\"%s\" Tensors=\"%s\" >\n", scalars.c_str(), vectors.c_str(), tensors.c_str() );
2141 for (
int vi = 1; vi <= valIDs.
giveSize(); vi++ ) {
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);
2164 if (isttype == IST_BeamForceMomentTensor) {
2174 for (
double v : value ) {
2175 fprintf(stream,
"%e ", v);
2180 fprintf(stream,
" </DataArray>\n");
2182 fprintf(stream,
"</PointData>\n</Piece>\n");
2185 fprintf(stream,
"</UnstructuredGrid>\n");
2186 fprintf(stream,
"</VTKFile>\n");
void setInternalVarInNode(int varNum, int nodeNum, FloatArray valueArray)
CrossSection * giveCrossSection()
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)
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.
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.
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.
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.
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).
virtual IntegrationRule * giveDefaultIntegrationRulePtr()
Access method for default integration rule.
#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.
bool hasLocalCS()
Returns nonzero if node has prescribed local coordinate system.
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.
int giveCellType(Element *element)
Returns corresponding element cell_type.
FloatMatrix * giveLocalCoordinateTriplet()
Returns pointer to local coordinate triplet in node.
bool isEmpty() const
Checks if receiver is empty (i.e., zero sized).
virtual void terminate()
Terminates the receiver.
NodalRecoveryModel * smoother
Smoother.
void setNumberOfNodes(int numNodes)
void writeVTKCellData(FloatArray &valueArray)
void zero()
Sets all component to zero.
double & at(int i)
Coefficient access function.
virtual void initialize()
InternalStateValueType giveXFEMStateValueType(XFEMStateType type)
void setNumberOfInternalVarsToExport(int numVars, int numNodes)
void clear()
Clears receiver (zero size).
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.
oofem::oofegGraphicContext gc[OOFEG_LAST_LAYER]
virtual FloatArray * giveCoordinates()
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()
double giveTargetTime()
Returns target time.
bool isParallel() const
Returns true if receiver in parallel mode.
Abstract base class for all finite elements.
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.
#define _IFT_VTKXMLExportModule_externalForces
int giveNumberOfProcesses() const
Returns the number of collaborating processes.
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)
virtual bool isActive()
Returns the activeFlag.
Represents export output module - a base class for all output modules.
Class implementing an array of integers.
int & at(int i)
Coefficient access function.
int giveNumberOfNodesPerCell(int cellType)
Returns number of nodes corresponding to cell type.
void setNumberOfCells(int numCells)
const char * __UnknownTypeToString(UnknownType _value)
int giveInternalStateTypeSize(InternalStateValueType valType)
XfemManager * giveXfemManager()
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.
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.
void setNodeCoords(int nodeNum, FloatArray &coords)
virtual int giveNumberOfNodes() const
Returns number of nodes of receiver.
FloatArray & giveLoadInNode(int varNum, int nodeNum)
void setLoadInNode(int varNum, int nodeNum, FloatArray valueArray)
int giveNumberOfEnrichmentItems() const
int giveSubStepNumber()
Returns receiver's substep number.
IntArray cellVarsToExport
List of cell data to export.
virtual int initRegionNodeNumbering(IntArray &mapG2L, IntArray &mapL2G, int ®ionDofMans, 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's number.
Element * giveElement(int n)
Service for accessing particular domain fe element.
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)
void clear()
Clears the array (zero size).
bool tstep_substeps_out_flag
Flag turning output in solution step substeps/itarations.
void setNumberOfCellVarsToExport(int numVars, int numCells)
DofIDItem
Type representing particular dof type.
FloatArray & giveInternalXFEMVarInNode(int varNum, int eiNum, int nodeNum)
EngngModel * emodel
Problem pointer.
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).
Abstract base class representing (moving) material interfaces.
bool evalLevelSetNormalInNode(double &oLevelSet, int iNodeInd, const FloatArray &iGlobalCoord) const
Set * giveRegionSet(int i)
Returns element set.
void writeIntVars(VTKPiece &vtkPiece)
virtual double giveUpdatedCoordinate(int ic, TimeStep *tStep, double scale=1.)
Returns updated ic-th coordinate of receiver.
void resizeWithValues(int s, int allocChunk=0)
Checks size of receiver towards requested bounds.
virtual int giveLocalCoordinateSystem(FloatMatrix &answer)
Returns local coordinate system of receiver Required by material models with ortho- and anisotrophy...
void resize(int n)
Checks size of receiver towards requested bounds.
NodalRecoveryModel * primVarSmoother
Smoother for primary variables.
Represents VTK (Visualization Toolkit) export module.
bool particleExportFlag
particle export flag
virtual int clear()
Clears the receiver'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)
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.
#define _IFT_VTKXMLExportModule_particleexportflag
bool writeVTKPiece(VTKPiece &vtkPiece, TimeStep *tStep)
elementParallelMode giveParallelMode() const
Return elementParallelMode of receiver.
const char * __XFEMStateTypeToString(XFEMStateType _value)
bool hasDofID(DofIDItem id) const
Checks if receiver contains dof with given ID.
Element is local, there are no contributions from other domains to this element.
Implementation of matrix containing floating point numbers.
This class manages the xfem part.
IRResultType
Type defining the return values of InputRecord reading operations.
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.
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.
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
virtual int recoverValues(Set elementSet, InternalStateType type, TimeStep *tStep)=0
Recovers the nodal values for all regions.
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.
Dof * giveDofWithID(int dofID) const
Returns DOF with given dofID; issues error if not present.
void followedBy(const IntArray &b, int allocChunk=0)
Appends array b at the end of receiver.
virtual int giveNumberOfInternalDofManagers() const
void exportPrimaryVars(VTKPiece &piece, IntArray &mapG2L, IntArray &mapL2G, int region, TimeStep *tStep)
Export primary variables.
void zero()
Zeroes all coefficients of receiver.
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)
virtual double giveNodalScalarRepresentation(int)=0
Returns scalar value representation of material Interface at given point.
virtual Interface * giveInterface(InterfaceType t)
Interface requesting service.
std::vector< VTKPiece > defaultVTKPieces
void times(double s)
Multiplies receiver with scalar.
EnrichmentItem * giveEnrichmentItem(int n)
ClassFactory & classFactory
virtual FloatArray * giveCoordinates()
FloatArray & giveCellVar(int field, int cellNum)
Particle class being used in PFEM computations.
void setConnectivity(int cellNum, IntArray &nodes)
int giveEquationNumber(const UnknownNumberingScheme &s)
Returns equation number of receiver for given equation numbering scheme.
void beUnitMatrix()
Sets receiver to unity matrix.
const char * __InternalStateTypeToString(InternalStateType _value)
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.
Abstract base class representing the "problem" under consideration.
InternalStateValueType giveInternalStateValueType(InternalStateType type)
int giveSize() const
Returns the size of receiver.
virtual void doOutput(TimeStep *tStep, bool forcedOutput=false)
Writes the output.
virtual Element_Geometry_Type giveGeometryType() const
Returns the element geometry type.
Node * giveNode(int n)
Service for accessing particular domain node.
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.
Class implementing node in finite element mesh.
int giveNumberOfRegions()
Returns number of regions (aka regionSets)
Abstract class Dof represents Degree Of Freedom in finite element mesh.
virtual bool isCast(TimeStep *tStep)
void writeVTKCollection()
Writes a VTK collection file where time step data is stored.
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.
void writeVTKPointData(FloatArray &valueArray)
std::string giveOutputBaseFileName(TimeStep *tStep)
Gives the appropriate name (minus specific file extension).
NodalRecoveryModel * givePrimVarSmoother()
Returns the smoother for primary variables (nodal averaging).
Class representing integration point in finite element program.
#define OOFEM_WARNING(...)
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...
Class representing solution step.
virtual int computeGlobalCoordinates(FloatArray &answer, const FloatArray &lcoords)
Computes the global coordinates from given element's local coordinates.
const IntArray & giveElementList()
Returns list of elements within set.
REGISTER_ExportModule(ErrorCheckingExportModule)
void add(const FloatArray &src)
Adds array src to receiver.
virtual Material * giveMaterial()
void resize(int s)
Resizes receiver towards requested size.