Write RMODFLOW objects to VTK files

rmf_write_vtk(...)

# S3 method for rmf_2d_array
rmf_write_vtk(
  array,
  dis,
  file,
  mask = array * 0 + 1,
  title = "array",
  as_points = FALSE,
  vertices = FALSE,
  as_3d = FALSE,
  ijk = FALSE,
  na_value = NULL,
  binary = FALSE,
  prj = rmf_get_prj(dis),
  endian = .Platform$endian
)

# S3 method for rmf_3d_array
rmf_write_vtk(
  array,
  dis,
  file,
  mask = array * 0 + 1,
  title = "array",
  as_points = FALSE,
  vertices = FALSE,
  ijk = FALSE,
  na_value = NULL,
  binary = FALSE,
  prj = rmf_get_prj(dis),
  endian = .Platform$endian
)

# S3 method for rmf_4d_array
rmf_write_vtk(
  array,
  dis,
  file,
  mask = array(1, dim = c(dis$nrow, dis$ncol, dis$nlay)),
  ...
)

# S3 method for rmf_list
rmf_write_vtk(obj, dis, file, ...)

Arguments

...

arguments passed to rmf_write_vtk.rmf_3d_array or rmf_as_array

array

rmf_2d/3d/4d_array

dis

RMODFLOW dis object

file

file to write to

mask

a 2d array when array is 2d or a 3d array when array is 3d or 4d that can be coerced to logical. Used to set inactive cells to NA. Defaults to all cells active.

title

character; title of the dataset in the VTK file. Defaults to 'array'.

as_points

logical; should cell-centered nodal values be written to the VTK file as points or rectilinear cells as voxels with a single value per cell (default).

vertices

logical; should values at the corner nodes of the cells be written to the VTK file as points? Defaults to FALSE. See details.

as_3d

logical; should the 2d surface be represented as 3d? Defaults to FALSE. See details.

ijk

logical; should the ijk indices of the cells be included in the dataset? Defaults to FALSE. See details.

na_value

numeric value to which NA values should be set. Defaults to to NULL which omits cells/points with NA values. ASCII Legacy VTK files do not support Na or NaN values.

binary

logical; should the VTK file be written in binary? Defaults to FALSE.

prj

RMODFLOW prj object

endian

See writeBin. Only applicable when binary = TRUE.

obj

rmf_list object

Value

NULL

Details

rmf_write_vtk writes a Legacy VTK file.

A Legacy VTK file is written. If as_points is TRUE, the cell-centered nodal values are written as points (POLYDATA point structure in VTK). If FALSE, the cell geometry is written with a single array value per cell (UNSTRUCTURED_GRID in VTK using cell type 8 (Pixel) for 2d and 11 (Voxel) for 3d). If vertices is TRUE (only applicable when as_points = FALSE), the values at the cell corners are written as point values as well. Their values are determined using bi/trilinear interpolation and by applying a very small perturbation to the corner node coordinates in order to prevent out-of-bound errors. This option is useful if contours are to be displayed in post-processing, which is not feasible when only cells are written using this function. Note that the interpolation can be very slow, especially for 3d and 4d arrays. When as_3d is TRUE, the 2d array is written as a 3d cell/point type with the vertical coordinate set equal to the array value. This is useful if a topography needs to be displayed, e.g. a water-table. If ijk is TRUE, the ijk indices of the cells are also written to the data set as point values for the cell-centered nodes. This is useful for e.g. conversion to Explicit Structured Grids. rmf_write_vtk was tested using Paraview.

Writing a 4d array to a VTK file loops over all time steps in the array and writes 3d arrays for time step l to file paste(l, basename(file), sep = '_'). This format is recognized as a time-varying array by most software supporting VTK files.

Examples

dis <- rmf_example_file('example-model.dis') %>% rmf_read_dis() file <- tempfile() dis <- rmf_set_prj(dis, NULL)
#> Warning: Overwriting existing prj object in dis object
rmf_write_vtk(dis$top, dis, file = file, as_points = TRUE) rmf_write_vtk(dis$top, dis, file = file, as_3d = TRUE) rmf_write_vtk(dis$top, dis, file = file, as_points = FALSE, vertices = TRUE) rmf_write_vtk(dis$botm, dis, file = file, ijk = TRUE)