# petsc4py.PETSc.Options

class petsc4py.PETSc.Options

  Bases: `object`

  The options database object.

  A dictionary-like object to store and operate with command line options.

  Parameters:

    prefix (`str`, optional) – Optional string to prepend to all the options.

  Examples

  Create an option database and operate with it.

      >>> from petsc4py import PETSc
      >>> opts = PETSc.Options()
      >>> opts['a'] = 1 # insert the command-line option '-a 1'
      >>> if 'a' in opts: # if the option is present
      >>>     val = opts['a'] # return the option value as 'str'
      >>> a_int = opts.getInt('a') # return the option value as 'int'
      >>> a_bool = opts.getBool('a') # return the option value as 'bool'

  Read command line and use default values.

      >>> from petsc4py import PETSc
      >>> opts = PETSc.Options()
      >>> b_float = opts.getReal('b', 1) # return the value or 1.0 if not present

  Read command line options prepended with a prefix.

      >>> from petsc4py import PETSc
      >>> opts = PETSc.Options('prefix_')
      >>> opts.getString('b', 'some_default_string') # read -prefix_b xxx

  See also

  Working with PETSc options

  Methods Summary

  `clear`() | Clear an options database.
  `create`() | Create an options database.
  `delValue`(name) | Delete an option from the database.
  `destroy`() | Destroy an options database.
  `getAll`() | Return all the options and their values.
  `getBool`(name[, default]) | Return the boolean value associated with the option.
  `getBoolArray`(name[, default]) | Return the boolean values associated with the option.
  `getInt`(name[, default]) | Return the integer value associated with the option.
  `getIntArray`(name[, default]) | Return the integer array associated with the option.
  `getReal`(name[, default]) | Return the real value associated with the option.
  `getRealArray`(name[, default]) | Return the real array associated with the option.
  `getScalar`(name[, default]) | Return the scalar value associated with the option.
  `getScalarArray`(name[, default]) | Return the scalar array associated with the option.
  `getString`(name[, default]) | Return the string associated with the option.
  `hasName`(name) | Return the boolean indicating if the option is in the database.
  `insertString`(string) | Insert a string in the options database.
  `prefixPop`() | Pop a prefix for the options database.
  `prefixPush`(prefix) | Push a prefix for the options database.
  `setValue`(name, value) | Set a value for an option.
  `view`([viewer]) | View the options database.

  Attributes Summary

  `prefix` | Prefix for options.

  Methods Documentation

  clear()

    Clear an options database.

    Source code at petsc4py/PETSc/Options.pyx:91

    Return type:

      Self

  create()

    Create an options database.

    Source code at petsc4py/PETSc/Options.pyx:79

    Return type:

      Self

  delValue(name)

    Delete an option from the database.

    Logically collective.

    See also

    `setValue`, `PetscOptionsClearValue`

    Source code at petsc4py/PETSc/Options.pyx:195

    Parameters:

      name (str)

    Return type:

      None

  destroy()

    Destroy an options database.

    Source code at petsc4py/PETSc/Options.pyx:85

    Return type:

      Self

  getAll()

    Return all the options and their values.

    Not collective.

    See also

    `PetscOptionsGetAll`

    Source code at petsc4py/PETSc/Options.pyx:414

    Return type:

      dict[str, str]

  getBool(name, default=None)

    Return the boolean value associated with the option.

    Not collective.

    Parameters:

      - name (str) – The option name.

      - default – The default value. If `None`, it raises a `KeyError` if the option is not found.

    Return type:

      bool

    See also

    `getBoolArray`, `PetscOptionsGetBool`

    Source code at petsc4py/PETSc/Options.pyx:218

  getBoolArray(name, default=None)

    Return the boolean values associated with the option.

    Not collective.

    Parameters:

      - name (str) – The option name.

      - default – The default value. If `None`, it raises a `KeyError` if the option is not found.

    Return type:

      ArrayBool

    See also

    `getBool`, `PetscOptionsGetBoolArray`

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

  getInt(name, default=None)

    Return the integer value associated with the option.

    Not collective.

    Parameters:

      - name (str) – The option name.

      - default – The default value. If `None`, it raises a `KeyError` if the option is not found.

    Return type:

      int

    See also

    `getIntArray`, `PetscOptionsGetInt`

    Source code at petsc4py/PETSc/Options.pyx:258

  getIntArray(name, default=None)

    Return the integer array associated with the option.

    Not collective.

    Parameters:

      - name (str) – The option name.

      - default – The default value. If `None`, it raises a `KeyError` if the option is not found.

    Return type:

      ArrayInt

    See also

    `getInt`, `PetscOptionsGetIntArray`

    Source code at petsc4py/PETSc/Options.pyx:278

  getReal(name, default=None)

    Return the real value associated with the option.

    Not collective.

    Parameters:

      - name (str) – The option name.

      - default – The default value. If `None`, it raises a `KeyError` if the option is not found.

    Return type:

      float

    See also

    `getRealArray`, `PetscOptionsGetReal`

    Source code at petsc4py/PETSc/Options.pyx:298

  getRealArray(name, default=None)

    Return the real array associated with the option.

    Not collective.

    Parameters:

      - name (str) – The option name.

      - default – The default value. If `None`, it raises a `KeyError` if the option is not found.

    Return type:

      ArrayReal

    See also

    `getReal`, `PetscOptionsGetRealArray`

    Source code at petsc4py/PETSc/Options.pyx:318

  getScalar(name, default=None)

    Return the scalar value associated with the option.

    Not collective.

    Parameters:

      - name (str) – The option name.

      - default – The default value. If `None`, it raises a `KeyError` if the option is not found.

    Return type:

      Scalar

    See also

    `getScalarArray`, `PetscOptionsGetScalar`

    Source code at petsc4py/PETSc/Options.pyx:338

  getScalarArray(name, default=None)

    Return the scalar array associated with the option.

    Not collective.

    Parameters:

      - name (str) – The option name.

      - default – The default value. If `None`, it raises a `KeyError` if the option is not found.

    Return type:

      ArrayScalar

    See also

    `getScalar`, `PetscOptionsGetScalarArray`

    Source code at petsc4py/PETSc/Options.pyx:358

  getString(name, default=None)

    Return the string associated with the option.

    Not collective.

    Parameters:

      - name (str) – The option name.

      - default – The default value. If `None`, it raises a `KeyError` if the option is not found.

    Return type:

      str

    See also

    `PetscOptionsGetString`

    Source code at petsc4py/PETSc/Options.pyx:378

  hasName(name)

    Return the boolean indicating if the option is in the database.

    Source code at petsc4py/PETSc/Options.pyx:144

    Parameters:

      name (str)

    Return type:

      bool

  insertString(string)

    Insert a string in the options database.

    Logically collective.

    See also

    `PetscOptionsInsertString`

    Source code at petsc4py/PETSc/Options.pyx:400

    Parameters:

      string (str)

    Return type:

      None

  prefixPop()

    Pop a prefix for the options database.

    Logically collective.

    See also

    `prefixPush`, `PetscOptionsPrefixPop`

    Source code at petsc4py/PETSc/Options.pyx:131

    Return type:

      None

  prefixPush(prefix)

    Push a prefix for the options database.

    Logically collective.

    See also

    `prefixPop`, `PetscOptionsPrefixPush`

    Source code at petsc4py/PETSc/Options.pyx:116

    Parameters:

      prefix (str | Options | Object | None)

    Return type:

      None

  setValue(name, value)

    Set a value for an option.

    Logically collective.

    Parameters:

      - name (str) – The string identifying the option.

      - value (bool | int | float | Scalar | Sequence[bool] | Sequence[int] | Sequence[float] | Sequence[Scalar] | str) – The option value.

    Return type:

      None

    See also

    `delValue`, `PetscOptionsSetValue`

    Source code at petsc4py/PETSc/Options.pyx:153

  view(viewer=None)

    View the options database.

    Collective.

    Parameters:

      viewer (Viewer | None) – A `Viewer` instance or `None` for the default viewer.

    Return type:

      None

    See also

    `Viewer`, `PetscOptionsView`

    Source code at petsc4py/PETSc/Options.pyx:97

  Attributes Documentation

  prefix

    Prefix for options.

    Source code at petsc4py/PETSc/Options.pyx:67