| 742 | } |
| 743 | |
| 744 | bool vtkIOSSReaderInternal::UpdateAssembly(vtkIOSSReader* self, int* tag) |
| 745 | { |
| 746 | if (this->AssemblyMTime > this->DatabaseNamesMTime) |
| 747 | { |
| 748 | return true; |
| 749 | } |
| 750 | |
| 751 | vtkLogScopeF(TRACE, "UpdateAssembly"); |
| 752 | this->AssemblyMTime.Modified(); |
| 753 | |
| 754 | auto controller = self->GetController(); |
| 755 | const auto rank = controller ? controller->GetLocalProcessId() : 0; |
| 756 | const auto numRanks = controller ? controller->GetNumberOfProcesses() : 1; |
| 757 | |
| 758 | if (rank == 0) |
| 759 | { |
| 760 | // it's unclear how assemblies in Ioss are distributed across partitioned |
| 761 | // files. so we assume they are duplicated on all only read it from root node. |
| 762 | const auto handle = this->GetDatabaseHandles(rank, numRanks, 0).front(); |
| 763 | auto region = this->GetRegion(handle); |
| 764 | |
| 765 | this->Assembly = vtk::TakeSmartPointer(vtkDataAssembly::New()); |
| 766 | this->Assembly->SetRootNodeName("Assemblies"); |
| 767 | const auto status = this->BuildAssembly(region, this->Assembly, 0, /*add_leaves=*/true); |
| 768 | *tag = status ? static_cast<int>(this->AssemblyMTime.GetMTime()) : 0; |
| 769 | if (numRanks > 1) |
| 770 | { |
| 771 | vtkMultiProcessStream stream; |
| 772 | |
| 773 | stream << (*tag); |
| 774 | stream << this->Assembly->SerializeToXML(vtkIndent()); |
| 775 | controller->Broadcast(stream, 0); |
| 776 | } |
| 777 | if (!status) |
| 778 | { |
| 779 | this->Assembly = nullptr; |
| 780 | } |
| 781 | } |
| 782 | else |
| 783 | { |
| 784 | vtkMultiProcessStream stream; |
| 785 | controller->Broadcast(stream, 0); |
| 786 | |
| 787 | std::string data; |
| 788 | stream >> (*tag) >> data; |
| 789 | |
| 790 | if ((*tag) != 0) |
| 791 | { |
| 792 | this->Assembly = vtk::TakeSmartPointer(vtkDataAssembly::New()); |
| 793 | this->Assembly->InitializeFromXML(data.c_str()); |
| 794 | } |
| 795 | else |
| 796 | { |
| 797 | this->Assembly = nullptr; |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | return true; |
no test coverage detected