MCPcopy Create free account
hub / github.com/Kitware/VTK / ReadMidpointCoordinates

Method ReadMidpointCoordinates

IO/ParallelNetCDF/vtkPSLACReader.cxx:947–1119  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

945
946//------------------------------------------------------------------------------
947int vtkPSLACReader::ReadMidpointCoordinates(
948 int meshFD, vtkMultiBlockDataSet* vtkNotUsed(output), vtkSLACReader::MidpointCoordinateMap& map)
949{
950 // Get the number of midpoints.
951 int midpointsVar;
952 CALL_NETCDF_INT(nc_inq_varid(meshFD, "surface_midpoint", &midpointsVar));
953 this->NumberOfGlobalMidpoints = this->GetNumTuplesInVariable(meshFD, midpointsVar, 5);
954 if (this->NumberOfGlobalMidpoints < 1)
955 return 0;
956
957 vtkIdType numMidpointsPerPiece = this->NumberOfGlobalMidpoints / this->NumberOfPieces + 1;
958 vtkIdType startMidpoint = this->RequestedPiece * numMidpointsPerPiece;
959 vtkIdType endMidpoint = startMidpoint + numMidpointsPerPiece;
960 endMidpoint = std::min(endMidpoint, this->NumberOfGlobalMidpoints);
961
962 size_t starts[2];
963 size_t counts[2];
964
965 starts[0] = startMidpoint;
966 counts[0] = endMidpoint - startMidpoint;
967 starts[1] = 0;
968 counts[1] = 5;
969
970 vtkNew<vtkDoubleArray> midpointData;
971 midpointData->SetNumberOfComponents(static_cast<int>(counts[1]));
972 midpointData->SetNumberOfTuples(static_cast<vtkIdType>(counts[0]));
973 CALL_NETCDF_INT(
974 nc_get_vars_double(meshFD, midpointsVar, starts, counts, nullptr, midpointData->GetPointer(0)));
975
976 // Collect the midpoints we've read on the processes that originally read the
977 // corresponding main points (the edge the midpoint is on). These original
978 // processes are aware of who requested hose original points. Thus they can
979 // redistribute the midpoints that correspond to those processes that
980 // requested the original points.
981 std::vector<midpointListsType> midpointsToDistribute(this->NumberOfPieces);
982
983 int pointsPerProcess = this->NumberOfGlobalPoints / this->NumberOfPieces + 1;
984 for (vtkIdType i = 0; i < midpointData->GetNumberOfTuples(); i++)
985 {
986 double* mp = midpointData->GetPointer(i * 5);
987
988 midpointPositionType position;
989 position.coord[0] = mp[2];
990 position.coord[1] = mp[3];
991 position.coord[2] = mp[4];
992
993 midpointTopologyType topology;
994 topology.minEdgePoint = static_cast<vtkIdType>(vtkMath::Min(mp[0], mp[1]));
995 topology.maxEdgePoint = static_cast<vtkIdType>(vtkMath::Max(mp[0], mp[1]));
996 topology.globalId = i + startMidpoint + this->NumberOfGlobalPoints;
997
998 // find the processor the minimum edge point belongs to (by global id)
999 vtkIdType process = topology.minEdgePoint / pointsPerProcess;
1000
1001 // insert the midpoint's global point id into the data
1002 midpointsToDistribute[process].position.push_back(position);
1003 midpointsToDistribute[process].topology.push_back(topology);
1004 }

Callers

nothing calls this directly

Calls 15

nc_inq_varidFunction · 0.85
nc_get_vars_doubleFunction · 0.85
MinFunction · 0.85
GatherMidpointsFunction · 0.85
MidpointCoordinatesFunction · 0.85
AddMidpointMethod · 0.80
minFunction · 0.50
MaxFunction · 0.50
EdgeEndpointsFunction · 0.50
SetNumberOfComponentsMethod · 0.45
SetNumberOfTuplesMethod · 0.45

Tested by

no test coverage detected