Chapter 26 Quiz: Visualization Output

Twenty questions to check that you can write a valid VTK file, open it, and reason about the pipeline. Aim for 16/20; below that, reread the section named in the "Topics to review" map at the end. Answers and one-line rationales are in the Answer Key.


1. (MC) A VTK visualization file primarily stores:

  • A. a rendered bitmap image of the field
  • B. the grid geometry and the field values living on it
  • C. compiled rendering instructions for the GPU
  • D. a screenshot plus camera settings

2. (MC) For a uniform 2-D grid like the heat plate, the least data you must write corresponds to which VTK dataset type?

  • A. UNSTRUCTURED_GRID
  • B. STRUCTURED_GRID
  • C. RECTILINEAR_GRID
  • D. STRUCTURED_POINTS (ImageData)

3. (T/F, justify) In a legacy VTK file the very first line may be any comment describing the run.

4. (MC) A field is nx = 50, ny = 40, nz = 1. What must follow POINT_DATA?

  • A. 2000
  • B. 1960
  • C. 90
  • D. 2040

5. (Code) What are the first two lines of the file this writes, exactly?

write(iu, '(a)')     '# vtk DataFile Version 3.0'
write(iu, '(a, i0)') 'heat solver output, step ', 7

6. (MC) VTK stores structured-points values with which index varying fastest?

  • A. the last (z)
  • B. the middle (y)
  • C. the first (x)
  • D. the order is unspecified

7. (T/F, justify) Writing the value loop as do j; do i; write u(i,j) both satisfies VTK's ordering and walks the Fortran array in column-major (cache-friendly) order.

8. (Short answer) Your POINT_DATA says 6000 but your loop writes 6001 values. Name the two ways this can fail in ParaView.

9. (MC) In a VTK XML .vti file, the WholeExtent for 100 points along x is written as:

  • A. 1 100
  • B. 0 100
  • C. 0 99
  • D. 1 99

10. (Code) What does write(buf, '(a, i6.6, a)') 'heat_', 42, '.vtk' place in buf (before trailing blanks)?

11. (T/F, justify) Naming frames heat_1.vtk, heat_2.vtk, …, heat_10.vtk is fine because ParaView sorts filenames numerically.

12. (MC) A .pvd collection file exists mainly to:

  • A. compress the frames
  • B. attach a physical time value to each frame
  • C. store the colormap
  • D. record the camera angle

13. (Short answer) In ParaView, you open a .vtk file and see a flat gray rectangle with no color. What two-step action turns it into a colored temperature map?

14. (MC) NumPy's numpy.loadtxt('heat.dat') reads the matrix format from §26.4 into an array of shape:

  • A. (nx*ny,)
  • B. (ny, nx)
  • C. (nx, ny)
  • D. (3,)

15. (T/F, justify) In the 3-column gnuplot grid format, the blank line between scans is optional whitespace you can omit.

16. (Code) Predict the exact text write(iu, '(a, 1x, i0)') 'POINT_DATA', 100*80 writes.

17. (MC) Which matplotlib colormap should you avoid for scientific heat maps because it invents false edges?

  • A. viridis
  • B. inferno
  • C. jet (rainbow)
  • D. magma

18. (Short answer) Why does plot_heat.py write the field at 300 DPI rather than the default?

19. (T/F, justify) ParaView and VisIt both read legacy VTK files, so a .vtk written for one will open in the other.

20. (Code) This line is meant to be the VTK magic string. Will ParaView accept the resulting file? Why or why not?

write(iu, '(a)') '# VTK DataFile Version 3.0'

Answer Key

# Answer Rationale
1 B A visualization file holds data (grid + values); the picture is made by the viewer on demand.
2 D STRUCTURED_POINTS/ImageData implies point positions from origin+spacing+dimensions — you write only the values.
3 False The first line must be the exact magic string # vtk DataFile Version 3.0; the second line is the free comment.
4 A POINT_DATA = nx*ny*nz = 50*40*1 = 2000.
5 # vtk DataFile Version 3.0 then heat solver output, step 7 (i0 writes 7 with no padding).
6 C Structured points are stored x-index fastest, then y, then z.
7 True Mapping i→x makes VTK's x-fastest order the do j; do i loop, which is exactly Fortran's first-index-fastest memory order.
8 Too many values → reader hits EOF mid-array and errors; too few → it reads a shifted field and shows the wrong picture.
9 C XML extent uses 0-based inclusive point indices: 100 points are 0..99.
10 heat_000042.vtki6.6 zero-pads 42 to six digits.
11 False ParaView sorts filenames lexically; unpadded, heat_10.vtk sorts before heat_2.vtk. Zero-pad (heat_000010.vtk).
12 B A .pvd maps each data file to a physical timestep, so the slider shows real time, not frame index.
13 In the coloring dropdown change Solid Color to temperature, and press Apply (nothing renders until Apply).
14 B loadtxt reads ny lines of nx values into shape (ny, nx).
15 False The blank line is a structural row-separator gnuplot requires to build the surface; omit it and the grid breaks.
16 POINT_DATA 8000 (a writes the label, 1x a space, i0 writes 8000).
17 C jet/rainbow creates false boundaries at its color bands and hides detail; use a perceptually uniform map.
18 300 DPI is the raster resolution journals require for figures; the default (typically 100) looks soft in print.
19 True Both tools are built on VTK and read the legacy format; the file is portable between them.
20 No — the magic string is case-sensitive: # vtk (lowercase) is required, # VTK is rejected.

Topics to review by question

Questions Review
1, 2 §26.1 (the VTK data model; choosing a dataset type)
3, 5, 6, 8, 16, 20 §26.2 (the legacy VTK header, exactly; the value ordering)
4 §26.2 (POINT_DATA = nx*ny*nz)
7 §26.2 Performance Note (column-major write order)
9 §26.2 (.vti extent, 0-based)
10, 11 §26.3 + Chapter 12 (frame_name, zero-padding)
12, 13, 19 §26.3 (ParaView/VisIt; time series; .pvd)
14, 15 §26.4 (matrix and gnuplot formats)
17, 18 §26.5 (publication figures; colormaps; DPI)