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

Method GetAMRGrid

IO/AMR/vtkAMReXGridReader.cxx:196–240  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

194
195//------------------------------------------------------------------------------
196vtkUniformGrid* vtkAMReXGridReader::GetAMRGrid(int blockIdx)
197{
198 if (!this->Internal->headersAreRead)
199 {
200 // Error: failed to read header files
201 return nullptr;
202 }
203
204 int dimension = this->GetDimension();
205 int level = this->GetBlockLevel(blockIdx);
206 int blockID = this->GetLevelBlockID(blockIdx);
207
208 // TODO: Need to handle Ghost Cells - Patrick O'Leary
209 // int ghostCells = this->Internal->LevelHeader[level]->levelNumberOfGhostCells;
210
211 // The vtkUniformGrid always has 3 dimensions
212 double spacing[3] = { 0.0, 0.0, 0.0 };
213 for (int i = 0; i < dimension; ++i)
214 {
215 spacing[i] = this->Internal->Header->cellSize[level][i];
216 }
217 if (dimension == 2)
218 spacing[2] = spacing[1]; // Add spacing for the 3rd dimension
219
220 vtkAMRBox block = this->Metadata->GetAMRBox(level, blockID);
221 int boxLo[3];
222 int boxHi[3];
223 block.GetDimensions(boxLo, boxHi);
224 int dimensions[3] = { 1, 1, 1 };
225 for (int i = 0; i < dimension; ++i)
226 {
227 dimensions[i] = ((boxHi[i] - boxLo[i]) + 1) +
228 1; // block dimension - '(hi - lo + 1)' is the number of cells '+ 1' is the number of points
229 }
230 vtkUniformGrid* uniformGrid = vtkUniformGrid::New();
231 uniformGrid->Initialize();
232
233 double origin[3] = { 0.0, 0.0, 0.0 };
234 vtkAMRBox::GetBoxOrigin(block, this->Metadata->GetOrigin(), spacing, origin);
235 uniformGrid->SetOrigin(origin);
236 uniformGrid->SetSpacing(spacing);
237 uniformGrid->SetDimensions(dimensions);
238 return (uniformGrid);
239 // TODO: Need to handle Ghost Cells - Patrick O'Leary
240}
241
242//------------------------------------------------------------------------------
243int vtkAMReXGridReader::GetDimension()

Callers

nothing calls this directly

Calls 11

GetDimensionMethod · 0.95
GetBlockLevelMethod · 0.95
GetLevelBlockIDMethod · 0.95
GetAMRBoxMethod · 0.80
NewFunction · 0.50
GetDimensionsMethod · 0.45
InitializeMethod · 0.45
GetOriginMethod · 0.45
SetOriginMethod · 0.45
SetSpacingMethod · 0.45
SetDimensionsMethod · 0.45

Tested by

no test coverage detected