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
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.
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 for options.
Methods Documentation
- clear()#
Clear an options database.
Source code at petsc4py/PETSc/Options.pyx:91
- Return type:
- create()#
Create an options database.
Source code at petsc4py/PETSc/Options.pyx:79
- Return type:
- delValue(name)#
Delete an option from the database.
Logically collective.
See also
- destroy()#
Destroy an options database.
Source code at petsc4py/PETSc/Options.pyx:85
- Return type:
- getAll()#
Return all the options and their values.
Not collective.
See also
- getBool(name, default=None)#
Return the boolean value associated with the option.
Not collective.
- Parameters:
- Return type:
See also
- getBoolArray(name, default=None)#
Return the boolean values associated with the option.
Not collective.
- Parameters:
- Return type:
See also
- getInt(name, default=None)#
Return the integer value associated with the option.
Not collective.
- Parameters:
- Return type:
See also
- getIntArray(name, default=None)#
Return the integer array associated with the option.
Not collective.
- Parameters:
- Return type:
See also
- getReal(name, default=None)#
Return the real value associated with the option.
Not collective.
- Parameters:
- Return type:
See also
- getRealArray(name, default=None)#
Return the real array associated with the option.
Not collective.
- Parameters:
- Return type:
See also
- getScalar(name, default=None)#
Return the scalar value associated with the option.
Not collective.
- Parameters:
- Return type:
See also
- getScalarArray(name, default=None)#
Return the scalar array associated with the option.
Not collective.
- Parameters:
- Return type:
See also
- getString(name, default=None)#
Return the string associated with the option.
Not collective.
- Parameters:
- Return type:
See also
- hasName(name)#
Return the boolean indicating if the option is in the database.
- insertString(string)#
Insert a string in the options database.
Logically collective.
See also
- prefixPop()#
Pop a prefix for the options database.
Logically collective.
See also
Source code at petsc4py/PETSc/Options.pyx:131
- Return type:
- prefixPush(prefix)#
Push a prefix for the options database.
Logically collective.
See also
- setValue(name, value)#
Set a value for an option.
Logically collective.
- Parameters:
- Return type:
See also
- view(viewer=None)#
View the options database.
Collective.
See also
Attributes Documentation
- prefix#
Prefix for options.