| 1421 | } |
| 1422 | |
| 1423 | void Model(Ioss::Region& region) const override |
| 1424 | { |
| 1425 | for (const auto& element : this->ElementCounts) |
| 1426 | { |
| 1427 | const int64_t elementCount = element.second; |
| 1428 | const unsigned char vtk_cell_type = element.first; |
| 1429 | |
| 1430 | const Ioss::ElementTopology* elementTopology = nullptr; |
| 1431 | try |
| 1432 | { |
| 1433 | elementTopology = vtkIOSSUtilities::GetElementTopology(vtk_cell_type); |
| 1434 | } |
| 1435 | catch (std::runtime_error&) |
| 1436 | { |
| 1437 | continue; |
| 1438 | } |
| 1439 | const auto& elementType = elementTopology->name(); |
| 1440 | const int nodeCount = elementTopology->number_nodes(); |
| 1441 | const auto blockName = this->GetSubElementBlockInfo(vtk_cell_type, elementType).second; |
| 1442 | |
| 1443 | auto* entityBlock = this->GetEntity(region, blockName); |
| 1444 | |
| 1445 | std::vector<int> orderingTransformation; |
| 1446 | const bool needsIdsTransformation = |
| 1447 | NeedsIdsTransformation(vtk_cell_type, orderingTransformation); |
| 1448 | // populate ids. |
| 1449 | std::vector<int32_t> elementIds; // these are global IDs. |
| 1450 | elementIds.reserve(elementCount); |
| 1451 | |
| 1452 | std::vector<int32_t> connectivity; |
| 1453 | connectivity.reserve(elementCount * nodeCount); |
| 1454 | |
| 1455 | const int32_t gidOffset = this->Writer->GetOffsetGlobalIds() ? 1 : 0; |
| 1456 | const bool removeGhosts = this->Writer->GetRemoveGhosts(); |
| 1457 | for (auto& ds : this->DataSets) |
| 1458 | { |
| 1459 | vtkUnsignedCharArray* ghost = ds->GetCellGhostArray(); |
| 1460 | auto* gids = vtkIdTypeArray::SafeDownCast(ds->GetCellData()->GetGlobalIds()); |
| 1461 | auto* pointGIDs = vtkIdTypeArray::SafeDownCast(ds->GetPointData()->GetGlobalIds()); |
| 1462 | |
| 1463 | vtkNew<vtkIdList> tempCellPointIds; |
| 1464 | for (vtkIdType cc = 0, max = ds->GetNumberOfCells(); cc < max; ++cc) |
| 1465 | { |
| 1466 | const bool process = !removeGhosts || !ghost || ghost->GetValue(cc) == 0; |
| 1467 | if (process && ds->GetCellType(cc) == vtk_cell_type) |
| 1468 | { |
| 1469 | elementIds.push_back(gidOffset + gids->GetValue(cc)); |
| 1470 | |
| 1471 | vtkIdType numPts; |
| 1472 | vtkIdType const* cellPoints; |
| 1473 | ds->GetCellPoints(cc, numPts, cellPoints, tempCellPointIds); |
| 1474 | assert(numPts == nodeCount); |
| 1475 | |
| 1476 | if (!needsIdsTransformation) |
| 1477 | { |
| 1478 | // map cell's point to global IDs for those points. |
| 1479 | std::transform(cellPoints, cellPoints + numPts, std::back_inserter(connectivity), |
| 1480 | [&](vtkIdType ptid) { return gidOffset + pointGIDs->GetValue(ptid); }); |
nothing calls this directly
no test coverage detected