Skip to main content
`Ctrl`+`K`

# petsc4py.PETSc.Viewer

class petsc4py.PETSc.Viewer

  Bases: `Object`

  Viewer object.

  Viewer is described in the `PETSc manual`.

  Viewers can be called as functions where the argument specified is the PETSc object to be viewed. See the example below.

  Examples

      >>> from petsc4py import PETSc
      >>> u = PETSc.Vec().createWithArray([1,2])
      >>> v = PETSc.Viewer()
      >>> v(u)
      Vec Object: 1 MPI process
        type: seq
      1.
      2.

  See also

  `PetscViewer`

  Enumerations

  `DrawSize` | Window size.
  `FileMode` | Viewer file mode.
  `Format` | Viewer format.
  `Type` | Viewer type.

  Methods Summary

  `ASCII`(name[, comm]) | Return an ASCII viewer associated with the communicator.
  `BINARY`([comm]) | Return the default `Type.BINARY` viewer associated with the communicator.
  `DRAW`([comm]) | Return the default `Type.DRAW` viewer associated with the communicator.
  `STDERR`([comm]) | Return the standard error viewer associated with the communicator.
  `STDOUT`([comm]) | Return the standard output viewer associated with the communicator.
  `addASCIITab`(tabs) | Increment the ASCII tab level.
  `clearDraw`() | Reset graphics.
  `create`([comm]) | Create a viewer.
  `createASCII`(name[, mode, comm]) | Create a viewer of type `Type.ASCII`.
  `createBinary`(name[, mode, comm]) | Create a viewer of type `Type.BINARY`.
  `createDraw`([display, title, position, size, ...]) | Create a `Type.DRAW` viewer.
  `createHDF5`(name[, mode, comm]) | Create a viewer of type `Type.HDF5`.
  `createMPIIO`(name[, mode, comm]) | Create a viewer of type `Type.BINARY` supporting MPI-IO.
  `createPython`([context, comm]) | Create a `Type.PYTHON` viewer.
  `createVTK`(name[, mode, comm]) | Create a viewer of type `Type.VTK`.
  `destroy`() | Destroy the viewer.
  `flush`() | Flush the viewer.
  `getASCIITab`() | Return the ASCII tab level.
  `getFileMode`() | Return the file mode.
  `getFileName`() | Return file name.
  `getFormat`() | Return the format of the viewer.
  `getPythonContext`() | Return the instance of the class implementing the required Python methods.
  `getPythonType`() | Return the fully qualified Python name of the class used by the viewer.
  `getSubViewer`([comm]) | Return a viewer defined on a subcommunicator.
  `getType`() | Return the type of the viewer.
  `popASCIISynchronized`() | Disallow ASCII synchronized calls.
  `popASCIITab`() | Pop an additional tab level pushed via `pushASCIITab`.
  `popFormat`() | Pop format from the viewer.
  `printfASCII`(msg) | Print a message.
  `printfASCIISynchronized`(msg) | Print a synchronized message.
  `pushASCIISynchronized`() | Allow ASCII synchronized calls.
  `pushASCIITab`() | Push an additional tab level.
  `pushFormat`(format) | Push format to the viewer.
  `restoreSubViewer`(sub) | Restore a viewer defined on a subcommunicator.
  `setASCIITab`(tabs) | Set ASCII tab level.
  `setDrawInfo`([display, title, position, size]) | Set window information for a `Type.DRAW` viewer.
  `setFileMode`(mode) | Set file mode.
  `setFileName`(name) | Set file name.
  `setFromOptions`() | Configure the object from the options database.
  `setPythonContext`(context) | Set the instance of the class implementing the required Python methods.
  `setPythonType`(py_type) | Set the fully qualified Python name of the class to be used.
  `setType`(vwr_type) | Set the type of the viewer.
  `setUp`() | Set up the internal data structures for using the viewer.
  `subtractASCIITab`(tabs) | Decrement the ASCII tab level.
  `useASCIITabs`(flag) | Enable/disable the use of ASCII tabs.
  `view`([obj]) | View the viewer.
  `viewObjectPython`(obj) | View a generic `Object`.

  Methods Documentation

  classmethod ASCII(name, comm=None)

    Return an ASCII viewer associated with the communicator.

    Collective.

    Parameters:

      - name (str) – The filename.

      - comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      Viewer

    Source code at petsc4py/PETSc/Viewer.pyx:604

  classmethod BINARY(comm=None)

    Return the default `Type.BINARY` viewer associated with the communicator.

    Collective.

    Parameters:

      comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      Viewer

    Source code at petsc4py/PETSc/Viewer.pyx:625

  classmethod DRAW(comm=None)

    Return the default `Type.DRAW` viewer associated with the communicator.

    Collective.

    Parameters:

      comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      Viewer

    Source code at petsc4py/PETSc/Viewer.pyx:643

  classmethod STDERR(comm=None)

    Return the standard error viewer associated with the communicator.

    Collective.

    Parameters:

      comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      Viewer

    Source code at petsc4py/PETSc/Viewer.pyx:586

  classmethod STDOUT(comm=None)

    Return the standard output viewer associated with the communicator.

    Collective.

    Parameters:

      comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      Viewer

    Source code at petsc4py/PETSc/Viewer.pyx:568

  addASCIITab(tabs)

    Increment the ASCII tab level.

    Collective.

    See also

    `PetscViewerASCIIAddTab`

    Source code at petsc4py/PETSc/Viewer.pyx:690

    Parameters:

      tabs (int)

    Return type:

      None

  clearDraw()

    Reset graphics.

    Not collective.

    See also

    `PetscViewerDrawClear`

    Source code at petsc4py/PETSc/Viewer.pyx:921

    Return type:

      None

  create(comm=None)

    Create a viewer.

    Collective.

    Parameters:

      comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      Self

    See also

    `Sys.getDefaultComm`, `PetscViewerCreate`

    Source code at petsc4py/PETSc/Viewer.pyx:179

  createASCII(name, mode=None, comm=None)

    Create a viewer of type `Type.ASCII`.

    Collective.

    Parameters:

      - name (str) – The filename associated with the viewer.

      - mode (FileMode | str | None) – The mode type.

      - comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      Self

    See also

    `create`, `setType`, `setFileMode`, `setFileName`, `Sys.getDefaultComm`, `setASCIITab`, `addASCIITab`, `subtractASCIITab`, `getASCIITab`

    Source code at petsc4py/PETSc/Viewer.pyx:200

  createBinary(name, mode=None, comm=None)

    Create a viewer of type `Type.BINARY`.

    Collective.

    Parameters:

      - name (str) – The filename associated with the viewer.

      - mode (FileMode | str | None) – The mode type.

      - comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      Self

    See also

    `create`, `setType`, `setFileMode`, `setFileName`, `Sys.getDefaultComm`

    Source code at petsc4py/PETSc/Viewer.pyx:238

  createDraw(display=None, title=None, position=None, size=None, comm=None)

    Create a `Type.DRAW` viewer.

    Collective.

    Parameters:

      - display (str | None) – The X display to use or `None` for the local machine.

      - title (str | None) – The window title or `None` for no title.

      - position (tuple[int, int] | None) – Screen coordinates of the upper left corner, or `None` for default.

      - size (tuple[int, int] | int | None) – Window size or `None` for default.

      - comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      Self

    See also

    `Sys.getDefaultComm`, `PetscViewerDrawOpen`

    Source code at petsc4py/PETSc/Viewer.pyx:380

  createHDF5(name, mode=None, comm=None)

    Create a viewer of type `Type.HDF5`.

    Collective.

    Parameters:

      - name (str) – The filename associated with the viewer.

      - mode (FileMode | str | None) – The mode type.

      - comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      Self

    See also

    `create`, `setType`, `setFileMode`, `setFileName`, `Sys.getDefaultComm`

    Source code at petsc4py/PETSc/Viewer.pyx:344

  createMPIIO(name, mode=None, comm=None)

    Create a viewer of type `Type.BINARY` supporting MPI-IO.

    Collective.

    Parameters:

      - name (str) – The filename associated with the viewer.

      - mode (FileMode | str | None) – The mode type.

      - comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      Self

    See also

    `create`, `setType`, `setFileMode`, `setFileName`, `Sys.getDefaultComm`

    Source code at petsc4py/PETSc/Viewer.pyx:271

  createPython(context=None, comm=None)

    Create a `Type.PYTHON` viewer.

    Collective.

    Parameters:

      - context (Any) – An instance of the Python class implementing the required methods.

      - comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      Self

    See also

    PETSc Python viewer, `setType`, `setPythonContext`, `Type.PYTHON`

    Source code at petsc4py/PETSc/Viewer.pyx:933

  createVTK(name, mode=None, comm=None)

    Create a viewer of type `Type.VTK`.

    Collective.

    Parameters:

      - name (str) – The filename associated with the viewer.

      - mode (FileMode | str | None) – The mode type.

      - comm (Comm | None) – MPI communicator, defaults to `Sys.getDefaultComm`.

    Return type:

      Self

    See also

    `create`, `setType`, `setFileMode`, `setFileName`, `Sys.getDefaultComm`

    Source code at petsc4py/PETSc/Viewer.pyx:308

  destroy()

    Destroy the viewer.

    Collective.

    See also

    `PetscViewerDestroy`

    Source code at petsc4py/PETSc/Viewer.pyx:166

    Return type:

      Self

  flush()

    Flush the viewer.

    Collective.

    See also

    `PetscViewerFlush`

    Source code at petsc4py/PETSc/Viewer.pyx:809

    Return type:

      None

  getASCIITab()

    Return the ASCII tab level.

    Not collective.

    See also

    `setASCIITab`, `PetscViewerASCIIGetTab`

    Source code at petsc4py/PETSc/Viewer.pyx:676

    Return type:

      int

  getFileMode()

    Return the file mode.

    Not collective.

    See also

    `setFileMode`, `PetscViewerFileGetMode`

    Source code at petsc4py/PETSc/Viewer.pyx:833

    Return type:

      FileMode

  getFileName()

    Return file name.

    Not collective.

    See also

    `setFileName`, `PetscViewerFileGetName`

    Source code at petsc4py/PETSc/Viewer.pyx:861

    Return type:

      str

  getFormat()

    Return the format of the viewer.

    Not collective.

    See also

    `pushFormat`, `popFormat`, `PetscViewerGetFormat`

    Source code at petsc4py/PETSc/Viewer.pyx:488

    Return type:

      Format

  getPythonContext()

    Return the instance of the class implementing the required Python methods.

    Not collective.

    See also

    PETSc Python viewer, `setPythonContext`

    Source code at petsc4py/PETSc/Viewer.pyx:973

    Return type:

      Any

  getPythonType()

    Return the fully qualified Python name of the class used by the viewer.

    Not collective.

    See also

    PETSc Python viewer, `setPythonContext`, `setPythonType`, `PetscViewerPythonGetType`

    Source code at petsc4py/PETSc/Viewer.pyx:1003

    Return type:

      str

  getSubViewer(comm=None)

    Return a viewer defined on a subcommunicator.

    Collective.

    Parameters:

      comm (Comm | None) – The subcommunicator. If `None`, uses `COMM_SELF`.

    Return type:

      Viewer

    Notes

    Users must call `restoreSubViewer` when done.

    See also

    `restoreSubViewer`, `PetscViewerGetSubViewer`

    Source code at petsc4py/PETSc/Viewer.pyx:526

  getType()

    Return the type of the viewer.

    Not collective.

    See also

    `setType`, `PetscViewerGetType`

    Source code at petsc4py/PETSc/Viewer.pyx:449

    Return type:

      str

  popASCIISynchronized()

    Disallow ASCII synchronized calls.

    Collective.

    See also

    `printfASCIISynchronized`, `pushASCIISynchronized`, `PetscViewerASCIIPopSynchronized`

    Source code at petsc4py/PETSc/Viewer.pyx:729

    Return type:

      None

  popASCIITab()

    Pop an additional tab level pushed via `pushASCIITab`.

    Collective.

    See also

    `pushASCIITab`, `PetscViewerASCIIPopTab`

    Source code at petsc4py/PETSc/Viewer.pyx:754

    Return type:

      None

  popFormat()

    Pop format from the viewer.

    Collective.

    See also

    `pushFormat`, `PetscViewerPopFormat`

    Source code at petsc4py/PETSc/Viewer.pyx:514

    Return type:

      None

  printfASCII(msg)

    Print a message.

    Collective.

    See also

    `PetscViewerASCIIPrintf`

    Source code at petsc4py/PETSc/Viewer.pyx:779

    Parameters:

      msg (str)

    Return type:

      None

  printfASCIISynchronized(msg)

    Print a synchronized message.

    Collective.

    See also

    `pushASCIISynchronized`, `PetscViewerASCIISynchronizedPrintf`

    Source code at petsc4py/PETSc/Viewer.pyx:793

    Parameters:

      msg (str)

    Return type:

      None

  pushASCIISynchronized()

    Allow ASCII synchronized calls.

    Collective.

    See also

    `printfASCIISynchronized`, `popASCIISynchronized`, `PetscViewerASCIIPushSynchronized`

    Source code at petsc4py/PETSc/Viewer.pyx:716

    Return type:

      None

  pushASCIITab()

    Push an additional tab level.

    Collective.

    See also

    `popASCIITab`, `PetscViewerASCIIPushTab`

    Source code at petsc4py/PETSc/Viewer.pyx:742

    Return type:

      None

  pushFormat(format)

    Push format to the viewer.

    Collective.

    See also

    `popFormat`, `PetscViewerPushFormat`

    Source code at petsc4py/PETSc/Viewer.pyx:502

    Parameters:

      format (Format)

    Return type:

      None

  restoreSubViewer(sub)

    Restore a viewer defined on a subcommunicator.

    Collective.

    Parameters:

      sub (Viewer) – The subviewer obtained from `getSubViewer`.

    Return type:

      None

    See also

    `getSubViewer`, `PetscViewerRestoreSubViewer`

    Source code at petsc4py/PETSc/Viewer.pyx:550

  setASCIITab(tabs)

    Set ASCII tab level.

    Collective.

    See also

    `getASCIITab`, `PetscViewerASCIISetTab`

    Source code at petsc4py/PETSc/Viewer.pyx:663

    Parameters:

      tabs (int)

    Return type:

      None

  setDrawInfo(display=None, title=None, position=None, size=None)

    Set window information for a `Type.DRAW` viewer.

    Collective.

    Parameters:

      - display (str | None) – The X display to use or `None` for the local machine.

      - title (str | None) – The window title or `None` for no title.

      - position (tuple[int, int] | None) – Screen coordinates of the upper left corner, or `None` for default.

      - size (tuple[int, int] | int | None) – Window size or `None` for default.

    Return type:

      None

    Source code at petsc4py/PETSc/Viewer.pyx:877

  setFileMode(mode)

    Set file mode.

    Collective.

    See also

    `getFileMode`, `PetscViewerFileSetMode`

    Source code at petsc4py/PETSc/Viewer.pyx:821

    Parameters:

      mode (FileMode | str)

    Return type:

      None

  setFileName(name)

    Set file name.

    Collective.

    See also

    `getFileName`, `PetscViewerFileSetName`

    Source code at petsc4py/PETSc/Viewer.pyx:847

    Parameters:

      name (str)

    Return type:

      None

  setFromOptions()

    Configure the object from the options database.

    Collective.

    See also

    Working with PETSc options, `PetscViewerSetFromOptions`

    Source code at petsc4py/PETSc/Viewer.pyx:463

    Return type:

      None

  setPythonContext(context)

    Set the instance of the class implementing the required Python methods.

    Logically collective.

    See also

    PETSc Python viewer, `getPythonContext`, `setPythonType`

    Source code at petsc4py/PETSc/Viewer.pyx:961

    Parameters:

      context (Any)

    Return type:

      None

  setPythonType(py_type)

    Set the fully qualified Python name of the class to be used.

    Collective.

    See also

    PETSc Python viewer, `setPythonContext`, `getPythonType`, `PetscViewerPythonSetType`

    Source code at petsc4py/PETSc/Viewer.pyx:988

    Parameters:

      py_type (str)

    Return type:

      None

  setType(vwr_type)

    Set the type of the viewer.

    Logically collective.

    Parameters:

      vwr_type (Type | str) – The type of the viewer.

    Return type:

      None

    See also

    `getType`, `PetscViewerSetType`

    Source code at petsc4py/PETSc/Viewer.pyx:430

  setUp()

    Set up the internal data structures for using the viewer.

    Collective.

    See also

    `PetscViewerSetUp`

    Source code at petsc4py/PETSc/Viewer.pyx:475

    Return type:

      Self

  subtractASCIITab(tabs)

    Decrement the ASCII tab level.

    Collective.

    See also

    `PetscViewerASCIISubtractTab`

    Source code at petsc4py/PETSc/Viewer.pyx:703

    Parameters:

      tabs (int)

    Return type:

      None

  useASCIITabs(flag)

    Enable/disable the use of ASCII tabs.

    Collective.

    See also

    `PetscViewerASCIIUseTabs`

    Source code at petsc4py/PETSc/Viewer.pyx:766

    Parameters:

      flag (bool)

    Return type:

      None

  view(obj=None)

    View the viewer.

    Collective.

    Parameters:

      obj (Viewer | Object | None) – A `Viewer` instance or `None` for the default viewer. If none of the above applies, it assumes `obj` is an instance of `Object` and it calls the generic view for `obj`.

    Return type:

      None

    Notes

    See also

    `PetscViewerView`

    Source code at petsc4py/PETSc/Viewer.pyx:138

  viewObjectPython(obj)

    View a generic `Object`.

    Collective.

    See also

    PETSc Python viewer, `setPythonContext`, `setPythonType`, `PetscViewerPythonViewObject`

    Source code at petsc4py/PETSc/Viewer.pyx:1018

    Parameters:

      obj (Object)

    Return type:

      None