PetscOptionsCreateViewer#

Creates a PetscViewer and PetscViewerFormat based on a viewer specification in the options database

Synopsis#

#include "petscviewer.h" 
PetscErrorCode PetscOptionsCreateViewer(MPI_Comm comm, PetscOptions options, const char prefix[], const char name[], PetscViewer *viewer, PetscViewerFormat *format, PetscBool *set)

Collective

Input Parameters#

  • comm - the communicator to own the viewer

  • options - options database, use NULL for default global database

  • prefix - the string to prepend to the name (may be NULL)

  • name - the options database name that will be checked for

Output Parameters#

Notes#

The Viewer specification has the following form

  ascii[:[filename][:[format][:filemode]]]   - filename defaults to stdout
  binary[:[filename][:[format][:filemode]]]  - defaults to the filename of binaryoutput
  hdf5[:[filename][:[format][:filemode]]]    - HDF5 input and output, PETSCVIEWERHDF5
  pyvista[:[filename][:[format][:filemode]]] - display the object with PyVista, PETSCVIEWERPYVISTA
  draw[:x]                                   - draw the object to X Windows
  draw[:tikz[:filename]]                     - draw the object to a TikZ file
  draw[:image[:dirname]]                     - draw the object to an image in memory that gets saved to files in a directory
  socket[:port]                              - defaults to the standard socket output port of 5005, see PetscViewerSocketOpen()
  saws[:communicatorname]                    - publishes object to the Scientific Application Webserver (SAWs)
  vtk:filename.vts                           - VTK output, PETSCVIEWERVTK

See PetscViewerType for a list of all available viewer types (the string before the first :).

See PetscViewerFormat for the possible values of format.

See PetscFileMode for the possible values of filemode.

If no viewer type is indicated before the first :, then ascii is used.

Unless filemode is append or append_update, files opened in write mode overwrite any previous file.

You can control whether calls to this function return immediately with a value of set of PETSC_FALSE using PetscOptionsPushCreateViewerOff(). This is useful if calling many small subsolves, in which case XXXViewFromOptions() calls can take an appreciable fraction of the runtime.

This routine is thread-safe for accessing predefined PetscViewers like PETSC_VIEWER_STDOUT_SELF but not for accessing files by name.

This routine is used by KSPMonitorSetFromOptions(), SNESMonitorSetFromOptions(), TSMonitorSetFromOptions(), TaoMonitorSetFromOptions(), and DMMonitorSetFromOptions(), as well as PetscObjectViewFromOptions() and all functions, such as VecViewFromOptions() that call it.

Example Usage#

  ascii:mesh.tex:ascii_latex - View a `DMPLEX` in LaTeX/TikZ
  draw:tikz:figure.tex       - View an object in the file `figure.tex` using TikZ

See Also#

Viewers: Looking at PETSc Objects, PetscViewerFormat, PetscViewerDestroy(), PetscOptionsGetReal(), PetscOptionsHasName(), PetscOptionsGetString(), PetscOptionsGetIntArray(), PetscOptionsGetRealArray(), PetscOptionsBool(), PetscOptionsInt(), PetscOptionsString(), PetscOptionsReal(), PetscOptionsName(), PetscOptionsBegin(), PetscOptionsEnd(), PetscOptionsHeadBegin(), PetscOptionsStringArray(), PetscOptionsRealArray(), PetscOptionsScalar(), PetscOptionsBoolGroupBegin(), PetscOptionsBoolGroup(), PetscOptionsBoolGroupEnd(), PetscOptionsFList(), PetscOptionsEList(), PetscOptionsPushCreateViewerOff(), PetscOptionsPopCreateViewerOff(), KSPMonitorSetFromOptions(), SNESMonitorSetFromOptions(), TSMonitorSetFromOptions(), TaoMonitorSetFromOptions(), DMMonitorSetFromOptions(), PetscObjectViewFromOptions(), VecViewFromOptions()

Level#

intermediate

Location#

src/sys/classes/viewer/interface/viewreg.c

Examples#

src/ts/tutorials/ex53.c
src/snes/tutorials/ex34.c
src/sys/classes/viewer/tutorials/ex2.c
src/snes/tutorials/ex17.c
src/snes/tutorials/ex62.c
src/snes/tutorials/ex36.c
src/vec/vec/utils/tagger/tutorials/ex1.c
src/snes/tutorials/ex56.c
src/dm/impls/plex/tutorials/ex19.c


Index of all Viewer routines
Table of Contents for all manual pages
Index of all manual pages