------------------------------------------------------------------------------
| 1378 | |
| 1379 | //------------------------------------------------------------------------------ |
| 1380 | int vtkSLACReader::ReadFieldData( |
| 1381 | const int* modeFDArray, int numModeFDs, vtkMultiBlockDataSet* output) |
| 1382 | { |
| 1383 | assert(numModeFDs > 0); |
| 1384 | assert(!this->FrequencyModes || |
| 1385 | (static_cast<size_t>(numModeFDs) <= this->Internal->Frequencies.size())); |
| 1386 | assert( |
| 1387 | !this->FrequencyModes || (static_cast<size_t>(numModeFDs) <= this->Internal->Phases.size())); |
| 1388 | |
| 1389 | vtkPointData* pd = |
| 1390 | vtkPointData::SafeDownCast(output->GetInformation()->Get(vtkSLACReader::POINT_DATA())); |
| 1391 | |
| 1392 | // Get the number of coordinates (which determines how many items are read |
| 1393 | // per variable). |
| 1394 | int ncoordDim; |
| 1395 | CALL_NETCDF_INT(nc_inq_dimid(modeFDArray[0], "ncoord", &ncoordDim)); |
| 1396 | size_t numCoords; |
| 1397 | CALL_NETCDF_INT(nc_inq_dimlen(modeFDArray[0], ncoordDim, &numCoords)); |
| 1398 | |
| 1399 | int numArrays = this->Internal->VariableArraySelection->GetNumberOfArrays(); |
| 1400 | for (int arrayIndex = 0; arrayIndex < numArrays; arrayIndex++) |
| 1401 | { |
| 1402 | // skip array if not enabled |
| 1403 | if (!this->Internal->VariableArraySelection->GetArraySetting(arrayIndex)) |
| 1404 | { |
| 1405 | continue; |
| 1406 | } |
| 1407 | |
| 1408 | // from the variable name, get the variable id |
| 1409 | const char* cname = this->Internal->VariableArraySelection->GetArrayName(arrayIndex); |
| 1410 | int varId; |
| 1411 | CALL_NETCDF_INT(nc_inq_varid(modeFDArray[0], cname, &varId)); |
| 1412 | |
| 1413 | std::string name(cname); |
| 1414 | |
| 1415 | // if this variable isn't 1d or 2d array, skip it. |
| 1416 | int numDims; |
| 1417 | CALL_NETCDF_INT(nc_inq_varndims(modeFDArray[0], varId, &numDims)); |
| 1418 | if (numDims < 1 || numDims > 2) |
| 1419 | { |
| 1420 | vtkWarningMacro(<< "Encountered invalid variable dimensions."); |
| 1421 | continue; |
| 1422 | } |
| 1423 | |
| 1424 | // Handle the imaginary component of mode data: |
| 1425 | // If simulation is purely real, all imaginary components would be zero. |
| 1426 | // Saving all the zeroes would waste space, so they aren't saved. So |
| 1427 | // missing imaginary components in the file means we should know to use |
| 1428 | // zeroes. |
| 1429 | // |
| 1430 | // Because we can't know whether a fieldname (without a corresponding |
| 1431 | // fieldname_image) is complex or not, we only do this for "efield" and |
| 1432 | // "bfield. |
| 1433 | // |
| 1434 | // (TLDR: for efield and bfield, load imaginary components if provided, |
| 1435 | // otherwise use zeroes.) |
| 1436 | if (this->FrequencyModes && (name == "efield" || name == "bfield")) |
| 1437 | { |
no test coverage detected