| 136 | } |
| 137 | |
| 138 | void vtkUnstructuredGridFieldAnnotations::FetchAnnotations( |
| 139 | vtkFieldData* fieldData, vtkDataAssembly* assembly) |
| 140 | { |
| 141 | if (!fieldData || !assembly) |
| 142 | { |
| 143 | return; |
| 144 | } |
| 145 | static constexpr char iossAnnotations[] = "Information Records"; |
| 146 | auto* infoRecords = vtkStringArray::SafeDownCast(fieldData->GetAbstractArray(iossAnnotations)); |
| 147 | if (!infoRecords) |
| 148 | { |
| 149 | return; |
| 150 | } |
| 151 | |
| 152 | std::unordered_set<std::string> elementBlockNames; |
| 153 | for (vtkIdType i = 0; i < infoRecords->GetNumberOfValues(); ++i) |
| 154 | { |
| 155 | const auto& record = infoRecords->GetValue(i); |
| 156 | const std::vector<std::string> data = ::split(record, "::"); |
| 157 | // Examples: |
| 158 | // "HDIV::eblock-0_0_0::CG::basis::Intrepid2_HDIV_HEX_I1_FEM" |
| 159 | // "HGRAD::eblock-0_0::DG::basis::Intrepid2_HGRAD_QUAD_C2_FEM" |
| 160 | // "HCURL::eblock-0_0_0::CG::basis::Intrepid2_HCURL_HEX_I1_FEM" |
| 161 | // "HCURL::eblock-0_0_0::CG::field::E_Field" |
| 162 | if (data.size() != 5) |
| 163 | { |
| 164 | continue; |
| 165 | } |
| 166 | |
| 167 | // TODO: Test whether function space is supported. |
| 168 | |
| 169 | // Find the datasets mentioned in the label. |
| 170 | // Currently, we only parse annotations for element blocks. |
| 171 | std::vector<std::string> queries; |
| 172 | queries.push_back("/IOSS/element_blocks/*[@label=\"" + escape(data[1]) + "\"]"); |
| 173 | auto nodeIds = assembly->SelectNodes(queries); |
| 174 | if (nodeIds.empty()) |
| 175 | { |
| 176 | vtkWarningMacro("Unmatched block \"" << escape(data[1]) << "\" in \"" << record << "\"."); |
| 177 | continue; |
| 178 | } |
| 179 | for (const auto& nodeId : nodeIds) |
| 180 | { |
| 181 | auto dataIds = assembly->GetDataSetIndices(nodeId, true); |
| 182 | // NB: It is not an error for dataIds to be empty. (In that case, we presume the data |
| 183 | // is distributed and other ranks may have non-empty partitions of the node.) |
| 184 | for (const auto& dataId : dataIds) |
| 185 | { |
| 186 | auto& blockData = this->Data[dataId]; |
| 187 | vtkStringToken recordType(data[3]); |
| 188 | vtkStringToken recordFunctionSpace(data[0]); |
| 189 | vtkStringToken recordDOFSharing(data[2]); |
| 190 | BlockAttributesKey key{ recordDOFSharing, recordFunctionSpace }; |
| 191 | auto& blockRecord(blockData[key]); |
| 192 | blockRecord.NodeIds.insert(nodeId); |
| 193 | // Insert this record into the metadata for the corresponding dataset. |
| 194 | switch (recordType.GetId()) |
| 195 | { |
no test coverage detected