------------------------------------------------------------------------------
| 807 | |
| 808 | //------------------------------------------------------------------------------ |
| 809 | vtkSmartPointer<vtkDataArray> vtkPSLACReader::ReadPointDataArray(int ncFD, int varId) |
| 810 | { |
| 811 | // Get the dimension info. We should only need to worry about 1 or 2D arrays. |
| 812 | int numDims; |
| 813 | CALL_NETCDF_PTR(nc_inq_varndims(ncFD, varId, &numDims)); |
| 814 | if (numDims > 2) |
| 815 | { |
| 816 | vtkErrorMacro(<< "Sanity check failed. " |
| 817 | << "Encountered array with too many dimensions."); |
| 818 | return nullptr; |
| 819 | } |
| 820 | if (numDims < 1) |
| 821 | { |
| 822 | vtkErrorMacro(<< "Sanity check failed. " |
| 823 | << "Encountered array with *no* dimensions."); |
| 824 | return nullptr; |
| 825 | } |
| 826 | int dimIds[2]; |
| 827 | CALL_NETCDF_PTR(nc_inq_vardimid(ncFD, varId, dimIds)); |
| 828 | size_t numCoords; |
| 829 | CALL_NETCDF_PTR(nc_inq_dimlen(ncFD, dimIds[0], &numCoords)); |
| 830 | if (numCoords != static_cast<size_t>(this->NumberOfGlobalPoints)) |
| 831 | { |
| 832 | vtkErrorMacro(<< "Encountered inconsistent number of coordinates."); |
| 833 | return nullptr; |
| 834 | } |
| 835 | size_t numComponents = 1; |
| 836 | if (numDims > 1) |
| 837 | { |
| 838 | CALL_NETCDF_PTR(nc_inq_dimlen(ncFD, dimIds[1], &numComponents)); |
| 839 | } |
| 840 | |
| 841 | // Allocate an array of the right type. |
| 842 | nc_type ncType; |
| 843 | CALL_NETCDF_PTR(nc_inq_vartype(ncFD, varId, &ncType)); |
| 844 | int vtkType = NetCDFTypeToVTKType(ncType); |
| 845 | if (vtkType < 1) |
| 846 | { |
| 847 | return nullptr; |
| 848 | } |
| 849 | auto dataArray = vtk::TakeSmartPointer(vtkDataArray::CreateDataArray(vtkType)); |
| 850 | assert(dataArray->HasStandardMemoryLayout() && "Array must have standard memory layout"); |
| 851 | |
| 852 | // Read the data from the file. |
| 853 | size_t start[2], count[2]; |
| 854 | start[0] = this->StartPointRead(this->RequestedPiece); |
| 855 | count[0] = this->EndPointRead(this->RequestedPiece) - start[0]; |
| 856 | start[1] = 0; |
| 857 | count[1] = numComponents; |
| 858 | dataArray->SetNumberOfComponents(static_cast<int>(count[1])); |
| 859 | dataArray->SetNumberOfTuples(static_cast<vtkIdType>(count[0])); |
| 860 | // NOLINTNEXTLINE(bugprone-unsafe-functions) |
| 861 | CALL_NETCDF_PTR(nc_get_vars(ncFD, varId, start, count, nullptr, dataArray->GetVoidPointer(0))); |
| 862 | |
| 863 | // We now need to redistribute the data. Allocate an array to store the final |
| 864 | // point data and a buffer to send data to the rest of the processes. |
| 865 | auto finalDataArray = vtk::TakeSmartPointer(vtkDataArray::CreateDataArray(vtkType)); |
| 866 | assert(finalDataArray->HasStandardMemoryLayout() && "Array must have standard memory layout"); |
nothing calls this directly
no test coverage detected