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

Method EliminateXWrap

IO/NetCDF/vtkMPASReader.cxx:2049–2203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2047//------------------------------------------------------------------------------
2048
2049int vtkMPASReader::EliminateXWrap()
2050{
2051 if (this->NumberOfPoints == 0)
2052 {
2053 return 1;
2054 }
2055
2056 double xLength;
2057 double xCenter;
2058 switch (this->Geometry)
2059 {
2060 case vtkMPASReader::Spherical:
2061 vtkErrorMacro("EliminateXWrap called for spherical geometry.");
2062 return 0;
2063
2064 case vtkMPASReader::Projected:
2065 xLength = 2 * vtkMath::Pi();
2066 xCenter = this->CenterRad;
2067 break;
2068
2069 case vtkMPASReader::Planar:
2070 {
2071 // Determine the bounds in the x-dimension
2072 double xRange[2] = { this->PointX[this->PointOffset], this->PointX[this->PointOffset] };
2073 for (size_t i = 1; i < this->NumberOfPoints; ++i)
2074 {
2075 double x = this->PointX[this->PointOffset + i];
2076 xRange[0] = std::min(xRange[0], x);
2077 xRange[1] = std::max(xRange[1], x);
2078 }
2079
2080 xLength = xRange[1] - xRange[0];
2081 xCenter = (xRange[0] + xRange[1]) * 0.5;
2082 }
2083 break;
2084
2085 default:
2086 vtkErrorMacro("Unrecognized geometry type (" << this->Geometry << ").");
2087 return 0;
2088 }
2089
2090 constexpr double tolerance = 5.5;
2091
2092 // For each cell, examine vertices
2093 // Add new points and cells where needed to account for wraparound.
2094 for (size_t j = this->CellOffset; j < this->NumberOfCells + this->CellOffset; j++)
2095 {
2096 int* conns = this->OrigConnections + (j * this->PointsPerCell);
2097 int* modConns = this->ModConnections + (j * this->PointsPerCell);
2098
2099 // Determine if we are wrapping in X direction
2100 size_t lastk = this->PointsPerCell - 1;
2101 bool xWrap = false;
2102 for (size_t k = 0; k < this->PointsPerCell; k++)
2103 {
2104 if (std::abs(this->PointX[conns[k]] - this->PointX[conns[lastk]]) > tolerance)
2105 {
2106 xWrap = true;

Callers 1

ReadAndOutputGridMethod · 0.95

Calls 5

AddMirrorPointMethod · 0.95
PiFunction · 0.85
minFunction · 0.50
maxFunction · 0.50
absFunction · 0.50

Tested by

no test coverage detected