| 1430 | |
| 1431 | |
| 1432 | int VTKHDF_Recorder::writeMesh() { |
| 1433 | // 1) Check domain |
| 1434 | if (theDomain == nullptr) { |
| 1435 | opserr << "WARNING: No domain found -- VTKHDF_Recorder::writeMesh\n"; |
| 1436 | return -1; |
| 1437 | } |
| 1438 | |
| 1439 | // Clear old data structures (if you store them as class members) |
| 1440 | theNodeMapping.clear(); |
| 1441 | theEleMapping.clear(); |
| 1442 | theNodeTags.clear(); |
| 1443 | theEleTags.clear(); |
| 1444 | theEleClassTags.clear(); |
| 1445 | theEleVtkTags.clear(); |
| 1446 | theEleVtkOffsets.clear(); |
| 1447 | |
| 1448 | // 2) Gather node info |
| 1449 | NodeIter &theNodes = theDomain->getNodes(); |
| 1450 | Node *theNode; |
| 1451 | numNode = 0; |
| 1452 | maxNDM = 0; // max spatial dimension |
| 1453 | maxNDF = 0; // max degrees of freedom |
| 1454 | |
| 1455 | while ((theNode = theNodes()) != nullptr) { |
| 1456 | int nodeTag = theNode->getTag(); |
| 1457 | |
| 1458 | const Vector &crd = theNode->getCrds(); |
| 1459 | if (crd.Size() > maxNDM) { |
| 1460 | maxNDM = crd.Size(); |
| 1461 | } |
| 1462 | |
| 1463 | const Vector &disp = theNode->getTrialDisp(); |
| 1464 | if (disp.Size() > maxNDF) { |
| 1465 | maxNDF = disp.Size(); |
| 1466 | } |
| 1467 | |
| 1468 | // Build mapping (nodeTag -> index) |
| 1469 | theNodeMapping[nodeTag] = numNode; |
| 1470 | theNodeTags.push_back(nodeTag); |
| 1471 | numNode++; |
| 1472 | } |
| 1473 | |
| 1474 | // 3) Gather element info |
| 1475 | ElementIter &theElements = theDomain->getElements(); |
| 1476 | Element *theElement; |
| 1477 | numElement = 0; |
| 1478 | numConnectivityIds = 0; |
| 1479 | |
| 1480 | theEleVtkOffsets.push_back(numConnectivityIds); |
| 1481 | while ((theElement = theElements()) != nullptr) { |
| 1482 | int eleTag = theElement->getTag(); |
| 1483 | int classTag = theElement->getClassTag(); |
| 1484 | |
| 1485 | // Check if recognized by our VTK type map |
| 1486 | auto it = vtktypes.find(classTag); |
| 1487 | if (it != vtktypes.end()) { |
| 1488 | int vtkType = it->second; |
| 1489 |
no test coverage detected