Scroll to navigation

PETSC4PY(3) PETSc for Python PETSC4PY(3)

NAME

petsc4py - PETSc for Python

Lisandro Dalcin
dalcinl@gmail.com
https://gitlab.com/petsc/petsc
Mar 14, 2024

Abstract

This document describes petsc4py, a Python wrapper to the PETSc libraries.

PETSc (the Portable, Extensible Toolkit for Scientific Computation) is a suite of data structures and routines for the scalable (parallel) solution of scientific applications modeled by partial differential equations. It employs the MPI standard for all message-passing communication.

This package provides an important subset of PETSc functionalities and uses NumPy to efficiently manage input and output of array data.

A good friend of petsc4py is:

mpi4py: Python bindings for MPI, the Message Passing Interface.



Other projects depends on petsc4py:

slepc4py: Python bindings for SLEPc, the Scalable Library for Eigenvalue Problem Computations.



OVERVIEW

PETSc is a suite of data structures and routines for the scalable (parallel) solution of scientific applications modeled by partial differential equations. It employs the MPI standard for all message-passing communication.

PETSc is intended for use in large-scale application projects [petsc-efficient], and several ongoing computational science projects are built around the PETSc libraries. With strict attention to component interoperability, PETSc facilitates the integration of independently developed application modules, which often most naturally employ different coding styles and data structures.

PETSc is easy to use for beginners [petsc-user-ref]. Moreover, its careful design allows advanced users to have detailed control over the solution process. PETSc includes an expanding suite of parallel linear and nonlinear equation solvers that are easily used in application codes written in C, C++, and Fortran. PETSc provides many of the mechanisms needed within parallel application codes, such as simple parallel matrix and vector assembly routines that allow the overlap of communication and computation.

[petsc-user-ref]
S. Balay, S. Abhyankar, M. Adams, S. Benson, J. Brown, P. Brune, K. Buschelman, E. Constantinescu, L. Dalcin, A. Dener, V. Eijkhout, J. Faibussowitsch, W. Gropp, V. Hapla, T. Isaac, P. Jolivet, D. Karpeyev, D. Kaushik, M. Knepley, F. Kong, S. Kruger, D. May, L. Curfman McInnes, R. Mills, L. Mitchell, T. Munson, J. Roman, K. Rupp, P. Sanan, J Sarich, B. Smith, S. Zampini, H. Zhang, and H. Zhang, J. Zhang, PETSc/TAO Users Manual, ANL-21/39 - Revision 3.20, 2023. http://dx.doi.org/10.2172/2205494, https://petsc.org/release/docs/manual/manual.pdf
[petsc-efficient]
Satish Balay, Victor Eijkhout, William D. Gropp, Lois Curfman McInnes and Barry F. Smith. Efficient Management of Parallelism in Object Oriented Numerical Software Libraries. Modern Software Tools in Scientific Computing. E. Arge, A. M. Bruaset and H. P. Langtangen, editors. 163--202. Birkhauser Press. 1997.

Components

PETSc is designed with an object-oriented style. Almost all user-visible types are abstract interfaces with implementations that may be chosen at runtime. Those objects are managed through handles to opaque data structures which are created, accessed and destroyed by calling appropriate library routines.

PETSc consists of a variety of components. Each component manipulates a particular family of objects and the operations one would like to perform on these objects. These components provide the functionality required for many parallel solutions of PDEs.

Provides the vector operations required for setting up and solving large-scale linear and nonlinear problems. Includes easy-to-use parallel scatter and gather operations, as well as special-purpose code for handling ghost points for regular data structures.
A large suite of data structures and code for the manipulation of parallel sparse matrices. Includes four different parallel matrix data structures, each appropriate for a different class of problems.
A collection of sequential and parallel preconditioners, including (sequential) ILU(k), LU, and (both sequential and parallel) block Jacobi, overlapping additive Schwarz methods and (through BlockSolve95) ILU(0) and ICC(0).
Parallel implementations of many popular Krylov subspace iterative methods, including GMRES, CG, CGS, Bi-CG-Stab, two variants of TFQMR, CR, and LSQR. All are coded so that they are immediately usable with any preconditioners and any matrix data structures, including matrix-free methods.
Data-structure-neutral implementations of Newton-like methods for nonlinear systems. Includes both line search and trust region techniques with a single interface. Employs by default the above data structures and linear solvers. Users can set custom monitoring routines, convergence criteria, etc.
Code for the time evolution of solutions of PDEs. In addition, provides pseudo-transient continuation techniques for computing steady-state solutions.

INSTALLATION

Install from PyPI using pip

You can use pip to install petsc4py and its dependencies (mpi4py is optional but highly recommended):

$ python -m pip install mpi4py petsc petsc4py


Install from the PETSc source tree

First build PETSc. Next cd to the top of the PETSc source tree and set the PETSC_DIR and PETSC_ARCH environment variables. Run:

$ python -m pip install src/binding/petsc4py


The installation of petsc4py supports multiple PETSC_ARCH in the the form of colon separated list:

$ PETSC_ARCH='arch-0:...:arch-N' python -m pip install src/binding/petsc4py


If you are cross-compiling, and the numpy module cannot be loaded on your build host, then before invoking pip, set the NUMPY_INCLUDE environment variable to the path that would be returned by import numpy; numpy.get_include():

$ export NUMPY_INCLUDE=/usr/lib/pythonX/site-packages/numpy/core/include


Building the documentation

Install the documentation dependencies using the [doc] extra:

$ python -m pip install "src/binding/petsc4py[doc]"


Then:

$ cd src/binding/petsc4py/docs/source
$ make html


The resulting HTML files will be in _build/html.

NOTE:

Building the documentation requires Python 3.11 or later.


NOTE:

All new code must include documentation in accordance with the documentation standard


CITATIONS

If PETSc for Python been significant to a project that leads to an academic publication, please acknowledge that fact by citing the project.

  • L. Dalcin, P. Kler, R. Paz, and A. Cosimo, Parallel Distributed Computing using Python, Advances in Water Resources, 34(9):1124-1139, 2011. http://dx.doi.org/10.1016/j.advwatres.2011.04.013
  • S. Balay, S. Abhyankar, M. Adams, S. Benson, J. Brown, P. Brune, K. Buschelman, E. Constantinescu, L. Dalcin, A. Dener, V. Eijkhout, J. Faibussowitsch, W. Gropp, V. Hapla, T. Isaac, P. Jolivet, D. Karpeyev, D. Kaushik, M. Knepley, F. Kong, S. Kruger, D. May, L. Curfman McInnes, R. Mills, L. Mitchell, T. Munson, J. Roman, K. Rupp, P. Sanan, J Sarich, B. Smith, S. Zampini, H. Zhang, and H. Zhang, J. Zhang, PETSc/TAO Users Manual, ANL-21/39 - Revision 3.20, 2023. http://dx.doi.org/10.2172/2205494, https://petsc.org/release/docs/manual/manual.pdf

REFERENCE

petsc4py The PETSc for Python package.
petsc4py.typing Typing support.
petsc4py.PETSc Portable, Extensible Toolkit for Scientific Computation.

petsc4py

The PETSc for Python package.

This package is an interface to PETSc libraries.

PETSc (the Portable, Extensible Toolkit for Scientific Computation) is a suite of data structures and routines for the scalable (parallel) solution of scientific applications modeled by partial differential equations. It employs the MPI standard for all message-passing communications.

Functions

get_config() Return a dictionary with information about PETSc.
get_include() Return the directory in the package that contains header files.
init([args, arch, comm]) Initialize PETSc.

petsc4py.get_config

Return a dictionary with information about PETSc.
dict[str, str]


petsc4py.get_include

Return the directory in the package that contains header files.

Extension modules that need to compile against petsc4py should use this function to locate the appropriate include directory.

Example

Using Python distutils or NumPy distutils:

import petsc4py
Extension('extension_name', ...

include_dirs=[..., petsc4py.get_include()])




petsc4py.init

Initialize PETSc.
  • args (str | list[str] | None) -- Command-line arguments, usually the sys.argv list
  • arch (str | None) -- Specific configuration to use
  • comm (Intracomm | None) -- MPI commmunicator

None

Notes

This function should be called only once, typically at the very beginning of the bootstrap script of an application.


petsc4py.typing

Typing support.

Attributes

Scalar Scalar type.
ArrayInt Array of int.
ArrayReal Array of float.
ArrayComplex Array of complex.
ArrayScalar Array of Scalar numbers.
DimsSpec Dimensions specification.
AccessModeSpec Access mode specification.
InsertModeSpec Insertion mode specification.
ScatterModeSpec Scatter mode specification.
LayoutSizeSpec int or 2-tuple of int describing the layout sizes.
NormTypeSpec Norm type specification.
MatAssemblySpec Matrix assembly specification.
MatSizeSpec int or (nested) tuple of int describing the matrix sizes.
MatBlockSizeSpec The row and column block sizes.
CSRIndicesSpec CSR indices format specification.
CSRSpec CSR format specification.
NNZSpec Nonzero pattern specification.
MatNullFunction PETSc.NullSpace callback.
DMCoarsenHookFunction PETSc.DM coarsening hook callback.
DMRestrictHookFunction PETSc.DM restriction hook callback.
KSPRHSFunction PETSc.KSP right hand side function callback.
KSPOperatorsFunction PETSc.KSP operators function callback.
KSPConvergenceTestFunction PETSc.KSP convergence test callback.
KSPMonitorFunction PETSc.KSP monitor callback.
SNESMonitorFunction SNES monitor callback.
SNESObjFunction SNES objective function callback.
SNESFunction SNES residual function callback.
SNESJacobianFunction SNES Jacobian callback.
SNESGuessFunction SNES initial guess callback.
SNESUpdateFunction SNES step update callback.
SNESLSPreFunction SNES linesearch pre-check update callback.
SNESNGSFunction SNES nonlinear Gauss-Seidel callback.
SNESConvergedFunction SNES convergence test callback.
TSRHSFunction TS right hand side function callback.
TSRHSJacobian TS right hand side Jacobian callback.
TSRHSJacobianP TS right hand side parameter Jacobian callback.
TSIFunction TS implicit function callback.
TSIJacobian TS implicit Jacobian callback.
TSIJacobianP TS implicit parameter Jacobian callback.
TSI2Function TS implicit 2nd order function callback.
TSI2Jacobian TS implicit 2nd order Jacobian callback.
TSI2JacobianP TS implicit 2nd order parameter Jacobian callback.
TSMonitorFunction TS monitor callback.
TSPreStepFunction TS pre-step callback.
TSPostStepFunction TS post-step callback.
TSEventHandlerFunction TS event handler callback.
TSPostEventFunction TS post-event handler callback.
TAOObjectiveFunction TAO objective function callback.
TAOGradientFunction TAO objective gradient callback.
TAOObjectiveGradientFunction TAO objective function and gradient callback.
TAOHessianFunction TAO objective Hessian callback.
TAOUpdateFunction TAO update callback.
TAOMonitorFunction TAO monitor callback.
TAOConvergedFunction TAO convergence test callback.
TAOJacobianFunction TAO Jacobian callback.
TAOResidualFunction TAO residual callback.
TAOJacobianResidualFunction TAO Jacobian residual callback.
TAOVariableBoundsFunction TAO variable bounds callback.
TAOConstraintsFunction TAO constraints callback.
TAOLSObjectiveFunction TAOLineSearch objective function callback.
TAOLSGradientFunction TAOLineSearch objective gradient callback.
TAOLSObjectiveGradientFunction TAOLineSearch objective function and gradient callback.

petsc4py.typing.Scalar

petsc4py.typing.Scalar = float | complex
Scalar type.

Scalars can be either float or complex (but not both) depending on how PETSc was configured (./configure --with-scalar-type=real|complex).


petsc4py.typing.ArrayInt

Array of int.

alias of ndarray[Any, dtype[int]]


petsc4py.typing.ArrayReal

Array of float.

alias of ndarray[Any, dtype[float]]


petsc4py.typing.ArrayComplex

Array of complex.

alias of ndarray[Any, dtype[complex]]


petsc4py.typing.ArrayScalar

Array of Scalar numbers.

alias of ndarray[Any, dtype[float | complex]]


petsc4py.typing.DimsSpec

Dimensions specification.

N-tuples indicates N-dimensional grid sizes.

alias of tuple[int, ...]


petsc4py.typing.AccessModeSpec

Access mode specification.
  • 'rw' Read-Write mode.
  • 'r' Read-only mode.
  • 'w' Write-only mode.
  • None as 'rw'.


alias of Optional[Literal['rw', 'r', 'w']]


petsc4py.typing.InsertModeSpec

petsc4py.typing.InsertModeSpec = petsc4py.PETSc.InsertMode | bool | None
Insertion mode specification.
  • InsertMode.ADD_VALUES Add new value to existing one.
  • InsertMode.INSERT_VALUES Replace existing entry with new value.
  • None as InsertMode.INSERT_VALUES.
  • False as InsertMode.INSERT_VALUES.
  • True as InsertMode.ADD_VALUES.


SEE ALSO:

InsertMode



petsc4py.typing.ScatterModeSpec

petsc4py.typing.ScatterModeSpec = petsc4py.PETSc.ScatterMode | bool | str | None
Scatter mode specification.
  • ScatterMode.FORWARD Forward mode.
  • ScatterMode.REVERSE Reverse mode.
  • None as ScatterMode.FORWARD.
  • False as ScatterMode.FORWARD.
  • True as ScatterMode.REVERSE.
  • 'forward' as ScatterMode.FORWARD.
  • 'reverse' as ScatterMode.REVERSE.


SEE ALSO:

ScatterMode



petsc4py.typing.LayoutSizeSpec

petsc4py.typing.LayoutSizeSpec = int | tuple[int, int]
int or 2-tuple of int describing the layout sizes.

A single int indicates global size. A tuple of int indicates (local_size, global_size).

SEE ALSO:

Sys.splitOwnership



petsc4py.typing.NormTypeSpec

petsc4py.typing.NormTypeSpec = petsc4py.PETSc.NormType | None
Norm type specification.

Possible values include:

  • NormType.NORM_1 The 1-norm: Σₙ abs(xₙ) for vectors, maxₙ (Σᵢ abs(xₙᵢ)) for matrices.
  • NormType.NORM_2 The 2-norm: √(Σₙ xₙ²) for vectors, largest singular values for matrices.
  • NormType.NORM_INFINITY The ∞-norm: maxₙ abs(xₙ) for vectors, maxᵢ (Σₙ abs(xₙᵢ)) for matrices.
  • NormType.NORM_FROBENIUS The Frobenius norm: same as 2-norm for vectors, √(Σₙᵢ xₙᵢ²) for matrices.
  • NormType.NORM_1_AND_2 Compute both NormType.NORM_1 and NormType.NORM_2.
  • None as NormType.NORM_2 for vectors, NormType.NORM_FROBENIUS for matrices.

SEE ALSO:

PETSc.NormType, petsc.NormType



petsc4py.typing.MatAssemblySpec

petsc4py.typing.MatAssemblySpec = petsc4py.PETSc.Mat.AssemblyType | bool | None
Matrix assembly specification.
  • Mat.AssemblyType.FINAL
  • Mat.AssemblyType.FLUSH
  • None as Mat.AssemblyType.FINAL
  • False as Mat.AssemblyType.FINAL
  • True as Mat.AssemblyType.FLUSH


SEE ALSO:

petsc.MatAssemblyType



petsc4py.typing.MatSizeSpec

petsc4py.typing.MatSizeSpec = int | tuple[int, int] | tuple[tuple[int, int], tuple[int, int]]
int or (nested) tuple of int describing the matrix sizes.

If int then rows = columns. A single tuple of int indicates (rows, columns). A nested tuple of int indicates ((local_rows, rows), (local_columns, columns)).

SEE ALSO:

Sys.splitOwnership



petsc4py.typing.MatBlockSizeSpec

petsc4py.typing.MatBlockSizeSpec = int | tuple[int, int]
The row and column block sizes.

If a single int is provided then rows and columns share the same block size.


petsc4py.typing.CSRIndicesSpec

CSR indices format specification.

A 2-tuple carrying the (row_start, col_indices) information.

alias of tuple[Sequence[int], Sequence[int]]


petsc4py.typing.CSRSpec

CSR format specification.

A 3-tuple carrying the (row_start, col_indices, values) information.

alias of tuple[Sequence[int], Sequence[int], Sequence[float | complex]]


petsc4py.typing.NNZSpec

Nonzero pattern specification.

A single int corresponds to fixed number of non-zeros per row. A Sequence of int indicates different non-zeros per row. If a 2-tuple is used, the elements of the tuple corresponds to the on-process and off-process parts of the matrix.

SEE ALSO:

petsc.MatSeqAIJSetPreallocation, petsc.MatMPIAIJSetPreallocation


alias of Union[int, Sequence[int], tuple[Sequence[int], Sequence[int]]]


petsc4py.typing.MatNullFunction

PETSc.NullSpace callback.

alias of Callable[[NullSpace, Vec], None]


petsc4py.typing.DMCoarsenHookFunction

PETSc.DM coarsening hook callback.

alias of Callable[[DM, DM], None]


petsc4py.typing.DMRestrictHookFunction

PETSc.DM restriction hook callback.

alias of Callable[[DM, Mat, Vec, Mat, DM], None]


petsc4py.typing.KSPRHSFunction

PETSc.KSP right hand side function callback.

alias of Callable[[KSP, Vec], None]


petsc4py.typing.KSPOperatorsFunction

PETSc.KSP operators function callback.

alias of Callable[[KSP, Mat, Mat], None]


petsc4py.typing.KSPConvergenceTestFunction

PETSc.KSP convergence test callback.

alias of Callable[[KSP, int, float], ConvergedReason]


petsc4py.typing.KSPMonitorFunction

PETSc.KSP monitor callback.

alias of Callable[[KSP, int, float], None]


petsc4py.typing.SNESMonitorFunction

SNES monitor callback.

alias of Callable[[SNES, int, float], None]


petsc4py.typing.SNESObjFunction

SNES objective function callback.

alias of Callable[[SNES, Vec], None]


petsc4py.typing.SNESFunction

SNES residual function callback.

alias of Callable[[SNES, Vec, Vec], None]


petsc4py.typing.SNESJacobianFunction

SNES Jacobian callback.

alias of Callable[[SNES, Vec, Mat, Mat], None]


petsc4py.typing.SNESGuessFunction

SNES initial guess callback.

alias of Callable[[SNES, Vec], None]


petsc4py.typing.SNESUpdateFunction

SNES step update callback.

alias of Callable[[SNES, int], None]


petsc4py.typing.SNESLSPreFunction

SNES linesearch pre-check update callback.

alias of Callable[[Vec, Vec], None]


petsc4py.typing.SNESNGSFunction

SNES nonlinear Gauss-Seidel callback.

alias of Callable[[SNES, Vec, Vec], None]


petsc4py.typing.SNESConvergedFunction

SNES convergence test callback.

alias of Callable[[SNES, int, tuple[float, float, float]], ConvergedReason]


petsc4py.typing.TSRHSFunction

TS right hand side function callback.

alias of Callable[[TS, float, Vec, Vec], None]


petsc4py.typing.TSRHSJacobian

TS right hand side Jacobian callback.

alias of Callable[[TS, float, Vec, Mat, Mat], None]


petsc4py.typing.TSRHSJacobianP

TS right hand side parameter Jacobian callback.

alias of Callable[[TS, float, Vec, Mat], None]


petsc4py.typing.TSIFunction

TS implicit function callback.

alias of Callable[[TS, float, Vec, Vec, Vec], None]


petsc4py.typing.TSIJacobian

TS implicit Jacobian callback.

alias of Callable[[TS, float, Vec, Vec, float, Mat, Mat], None]


petsc4py.typing.TSIJacobianP

TS implicit parameter Jacobian callback.

alias of Callable[[TS, float, Vec, Vec, float, Mat], None]


petsc4py.typing.TSI2Function

TS implicit 2nd order function callback.

alias of Callable[[TS, float, Vec, Vec, Vec, Vec], None]


petsc4py.typing.TSI2Jacobian

TS implicit 2nd order Jacobian callback.

alias of Callable[[TS, float, Vec, Vec, Vec, float, float, Mat, Mat], None]


petsc4py.typing.TSI2JacobianP

TS implicit 2nd order parameter Jacobian callback.

alias of Callable[[TS, float, Vec, Vec, Vec, float, float, Mat], None]


petsc4py.typing.TSMonitorFunction

TS monitor callback.

alias of Callable[[TS, int, float, Vec], None]


petsc4py.typing.TSPreStepFunction

TS pre-step callback.

alias of Callable[[TS], None]


petsc4py.typing.TSPostStepFunction

TS post-step callback.

alias of Callable[[TS], None]


petsc4py.typing.TSEventHandlerFunction

TS event handler callback.

alias of Callable[[TS, float, Vec, ndarray[Any, dtype[float | complex]]], None]


petsc4py.typing.TSPostEventFunction

TS post-event handler callback.

alias of Callable[[TS, ndarray[Any, dtype[int]], float, Vec, bool], None]


petsc4py.typing.TAOObjectiveFunction

TAO objective function callback.

alias of Callable[[TAO, Vec], float]


petsc4py.typing.TAOGradientFunction

TAO objective gradient callback.

alias of Callable[[TAO, Vec, Vec], None]


petsc4py.typing.TAOObjectiveGradientFunction

TAO objective function and gradient callback.

alias of Callable[[TAO, Vec, Vec], float]


petsc4py.typing.TAOHessianFunction

TAO objective Hessian callback.

alias of Callable[[TAO, Vec, Mat, Mat], None]


petsc4py.typing.TAOUpdateFunction

TAO update callback.

alias of Callable[[TAO, int], None]


petsc4py.typing.TAOMonitorFunction

TAO monitor callback.

alias of Callable[[TAO], None]


petsc4py.typing.TAOConvergedFunction

TAO convergence test callback.

alias of Callable[[TAO], None]


petsc4py.typing.TAOJacobianFunction

TAO Jacobian callback.

alias of Callable[[TAO, Vec, Mat, Mat], None]


petsc4py.typing.TAOResidualFunction

TAO residual callback.

alias of Callable[[TAO, Vec, Vec], None]


petsc4py.typing.TAOJacobianResidualFunction

TAO Jacobian residual callback.

alias of Callable[[TAO, Vec, Mat, Mat], None]


petsc4py.typing.TAOVariableBoundsFunction

TAO variable bounds callback.

alias of Callable[[TAO, Vec, Vec], None]


petsc4py.typing.TAOConstraintsFunction

TAO constraints callback.

alias of Callable[[TAO, Vec, Vec], None]


petsc4py.typing.TAOLSObjectiveFunction

TAOLineSearch objective function callback.

alias of Callable[[TAOLineSearch, Vec], float]


petsc4py.typing.TAOLSGradientFunction

TAOLineSearch objective gradient callback.

alias of Callable[[TAOLineSearch, Vec, Vec], None]


petsc4py.typing.TAOLSObjectiveGradientFunction

TAOLineSearch objective function and gradient callback.

alias of Callable[[TAOLineSearch, Vec, Vec], float]


petsc4py.PETSc

Portable, Extensible Toolkit for Scientific Computation.

Basic constants:

Use a default value for an int or float parameter.
Use a default value for an int or float parameter.
Compute a default value for an int or float parameter.

More constants:

Very large real value.
Very large negative real value.
Very large positive real value, same as INFINITY.

Classes

AO Application ordering object.
Comm Communicator object.
DM An object describing a computational grid or mesh.
DMComposite A DM object that is used to manage data for a collection of DMs.
DMDA A DM object that is used to manage data for a structured grid.
DMInterpolation Interpolation on a mesh.
DMLabel An object representing a subset of mesh entities from a DM.
DMPlex Encapsulate an unstructured mesh.
DMPlexTransform
DMPlexTransformType
DMShell A shell DM object, used to manage user-defined problem data.
DMStag A DM object representing a "staggered grid" or a structured cell complex.
DMSwarm A DM object used to represent arrays of data (fields) of arbitrary type.
DS Discrete System object.
Device The device object.
DeviceContext DeviceContext object.
DualSpace Dual space to a linear space.
FE A PETSc object that manages a finite element space.
IS A collection of indices.
InsertMode Insertion mode.
KSP Abstract PETSc object that manages all Krylov methods.
LGMap Mapping from an arbitrary local ordering from 0 to n-1 to a global PETSc ordering used by a vector or matrix.
Log Logging support.
LogClass
LogEvent
LogStage Logging support for different stages.
Mat Matrix object.
MatPartitioning Object for managing the partitioning of a matrix or graph.
NormType Norm type.
NullSpace Nullspace object.
Object
Options Options(prefix=None)
PC Preconditioners.
Partitioner A graph partitioner.
Quad Quadrature rule for integration.
Random The random number generator object.
SF Star Forest object for communication.
SNES Nonlinear equations solver.
Scatter Scatter object.
ScatterMode Scatter mode.
Section Mapping from integers in a range to unstructured set of integers.
Space Linear space object.
Sys System utilities.
TAO Optimization solver.
TAOLineSearch TAO Line Search.
TS ODE integrator.
Vec A vector object.
Viewer Viewer object.
ViewerHDF5

petsc4py.PETSc.AO

Bases: Object

Application ordering object.

Enumerations

Type

petsc4py.PETSc.AO.Type

Bases: object

Attributes Summary

ADVANCED Object ADVANCED of type str
BASIC Object BASIC of type str
MAPPING Object MAPPING of type str
MEMORYSCALABLE Object MEMORYSCALABLE of type str

Attributes Documentation

Object ADVANCED of type str

Object BASIC of type str

Object MAPPING of type str

Object MEMORYSCALABLE of type str


Methods Summary

app2petsc(indices) Map an application-defined ordering to the PETSc ordering.
createBasic(app[, petsc, comm]) Return a basic application ordering using two orderings.
createMapping(app[, petsc, comm]) Return an application mapping using two orderings.
createMemoryScalable(app[, petsc, comm]) Return a memory scalable application ordering using two orderings.
destroy() Destroy the application ordering.
getType() Return the application ordering type.
petsc2app(indices) Map a PETSc ordering to the application-defined ordering.
view([viewer]) Display the application ordering.

Methods Documentation

Map an application-defined ordering to the PETSc ordering.

Collective.

Any integers in indices that are negative are left unchanged. This allows one to convert, for example, neighbor lists that use negative entries to indicate nonexistent neighbors due to boundary conditions, etc.

Integers that are out of range are mapped to -1.

If IS is used, it cannot be of type stride or block.

indices (Sequence[int] | IS) -- The indices; to be replaced with their mapped values.
Sequence[int] | IS

SEE ALSO:

petsc2app, petsc.AOApplicationToPetscIS, petsc.AOApplicationToPetsc


Source code at petsc4py/PETSc/AO.pyx:215


Return a basic application ordering using two orderings.

Collective.

The arrays/indices app and petsc must contain all the integers 0 to len(app)-1 with no duplicates; that is there cannot be any "holes" in the indices. Use createMapping if you wish to have "holes" in the indices.

  • app (Sequence[int] | IS) -- The application ordering.
  • petsc (Sequence[int] | IS | None) -- Another ordering (may be None to indicate the natural ordering, that is 0, 1, 2, 3, ...).
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

createMemoryScalable, createMapping, petsc.AOCreateBasicIS, petsc.AOCreateBasic


Source code at petsc4py/PETSc/AO.pyx:51


Return an application mapping using two orderings.

Collective.

The arrays app and petsc need NOT contain all the integers 0 to len(app)-1, that is there CAN be "holes" in the indices. Use createBasic if they do not have holes for better performance.

  • app (Sequence[int] | IS) -- The application ordering.
  • petsc (Sequence[int] | IS | None) -- Another ordering. May be None to indicate the identity ordering.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

createBasic, petsc.AOCreateMappingIS, petsc.AOCreateMapping


Source code at petsc4py/PETSc/AO.pyx:154


Return a memory scalable application ordering using two orderings.

Collective.

The arrays/indices app and petsc must contain all the integers 0 to len(app)-1 with no duplicates; that is there cannot be any "holes" in the indices. Use createMapping if you wish to have "holes" in the indices.

Comparing with createBasic, this routine trades memory with message communication.

  • app (Sequence[int] | IS) -- The application ordering.
  • petsc (Sequence[int] | IS | None) -- Another ordering (may be None to indicate the natural ordering, that is 0, 1, 2, 3, ...).
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

createBasic, createMapping, petsc.AOCreateMemoryScalableIS, petsc.AOCreateMemoryScalable


Source code at petsc4py/PETSc/AO.pyx:101


Destroy the application ordering.

Collective.

SEE ALSO:

petsc.AODestroy


Source code at petsc4py/PETSc/AO.pyx:38



Return the application ordering type.

Not collective.

SEE ALSO:

petsc.AOGetType


Source code at petsc4py/PETSc/AO.pyx:201



Map a PETSc ordering to the application-defined ordering.

Collective.

Any integers in indices that are negative are left unchanged. This allows one to convert, for example, neighbor lists that use negative entries to indicate nonexistent neighbors due to boundary conditions, etc.

Integers that are out of range are mapped to -1.

If IS is used, it cannot be of type stride or block.

indices (Sequence[int] | IS) -- The indices; to be replaced with their mapped values.
Sequence[int] | IS

SEE ALSO:

app2petsc, petsc.AOPetscToApplicationIS, petsc.AOPetscToApplication


Source code at petsc4py/PETSc/AO.pyx:249


Display the application ordering.

Collective.

viewer (Viewer | None) -- A Viewer to display the ordering.
None

SEE ALSO:

petsc.AOView


Source code at petsc4py/PETSc/AO.pyx:19




petsc4py.PETSc.Comm

Bases: object

Communicator object.

Predefined instances:

The null (or invalid) communicator.
The self communicator.
The world communicator.

SEE ALSO:

Sys.setDefaultComm, Sys.getDefaultComm


Methods Summary

barrier() Barrier synchronization.
destroy() Destroy the communicator.
duplicate() Duplicate the communicator.
getRank() Return the rank of the calling processes in the communicator.
getSize() Return the number of processes in the communicator.
tompi4py() Convert communicator to mpi4py.

Attributes Summary

fortran Fortran handle.
rank Communicator rank.
size Communicator size.

Methods Documentation

Barrier synchronization.

Collective.

Source code at petsc4py/PETSc/Comm.pyx:123



Destroy the communicator.

Collective.

SEE ALSO:

petsc.PetscCommDestroy


Source code at petsc4py/PETSc/Comm.pyx:61



Duplicate the communicator.

Collective.

SEE ALSO:

petsc.PetscCommDuplicate


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



Return the rank of the calling processes in the communicator.

Not collective.

Source code at petsc4py/PETSc/Comm.pyx:111



Return the number of processes in the communicator.

Not collective.

Source code at petsc4py/PETSc/Comm.pyx:99



Convert communicator to mpi4py.

Not collective.

SEE ALSO:

mpi4py.MPI.Comm, mpi4py.MPI.Intracomm


Source code at petsc4py/PETSc/Comm.pyx:155

Intracomm


Attributes Documentation

Fortran handle.

Source code at petsc4py/PETSc/Comm.pyx:147


Communicator rank.

Source code at petsc4py/PETSc/Comm.pyx:140


Communicator size.

Source code at petsc4py/PETSc/Comm.pyx:135



petsc4py.PETSc.DM

Bases: Object

An object describing a computational grid or mesh.

Enumerations

BoundaryType DM Boundary types.
PolytopeType
Type DM types.

petsc4py.PETSc.DM.BoundaryType

Bases: object

DM Boundary types.

Attributes Summary

GHOSTED Constant GHOSTED of type int
MIRROR Constant MIRROR of type int
NONE Constant NONE of type int
PERIODIC Constant PERIODIC of type int
TWIST Constant TWIST of type int

Attributes Documentation

Constant GHOSTED of type int

Constant MIRROR of type int

Constant NONE of type int

Constant PERIODIC of type int

Constant TWIST of type int


petsc4py.PETSc.DM.PolytopeType

Bases: object

Attributes Summary

FV_GHOST Constant FV_GHOST of type int
HEXAHEDRON Constant HEXAHEDRON of type int
INTERIOR_GHOST Constant INTERIOR_GHOST of type int
POINT Constant POINT of type int
POINT_PRISM_TENSOR Constant POINT_PRISM_TENSOR of type int
PYRAMID Constant PYRAMID of type int
QUADRILATERAL Constant QUADRILATERAL of type int
QUAD_PRISM_TENSOR Constant QUAD_PRISM_TENSOR of type int
SEGMENT Constant SEGMENT of type int
SEG_PRISM_TENSOR Constant SEG_PRISM_TENSOR of type int
TETRAHEDRON Constant TETRAHEDRON of type int
TRIANGLE Constant TRIANGLE of type int
TRI_PRISM Constant TRI_PRISM of type int
TRI_PRISM_TENSOR Constant TRI_PRISM_TENSOR of type int
UNKNOWN Constant UNKNOWN of type int

Attributes Documentation

Constant FV_GHOST of type int

Constant HEXAHEDRON of type int

Constant INTERIOR_GHOST of type int

Constant POINT of type int

Constant POINT_PRISM_TENSOR of type int

Constant PYRAMID of type int

Constant QUADRILATERAL of type int

Constant QUAD_PRISM_TENSOR of type int

Constant SEGMENT of type int

Constant SEG_PRISM_TENSOR of type int

Constant TETRAHEDRON of type int

Constant TRIANGLE of type int

Constant TRI_PRISM of type int

Constant TRI_PRISM_TENSOR of type int

Constant UNKNOWN of type int


petsc4py.PETSc.DM.Type

Bases: object

DM types.

Attributes Summary

COMPOSITE Object COMPOSITE of type str
DA Object DA of type str
FOREST Object FOREST of type str
MOAB Object MOAB of type str
NETWORK Object NETWORK of type str
P4EST Object P4EST of type str
P8EST Object P8EST of type str
PATCH Object PATCH of type str
PLEX Object PLEX of type str
PRODUCT Object PRODUCT of type str
REDUNDANT Object REDUNDANT of type str
SHELL Object SHELL of type str
SLICED Object SLICED of type str
STAG Object STAG of type str
SWARM Object SWARM of type str

Attributes Documentation

Object COMPOSITE of type str

Object DA of type str

Object FOREST of type str

Object MOAB of type str

Object NETWORK of type str

Object P4EST of type str

Object P8EST of type str

Object PATCH of type str

Object PLEX of type str

Object PRODUCT of type str

Object REDUNDANT of type str

Object SHELL of type str

Object SLICED of type str

Object STAG of type str

Object SWARM of type str


Methods Summary

adaptLabel(label) Adapt a DM based on a DMLabel.
adaptMetric(metric[, bdLabel, rgLabel]) Return a mesh adapted to the specified metric field.
addCoarsenHook(coarsenhook, restricthook[, ...]) Add a callback to be executed when restricting to a coarser grid.
addField(field[, label]) Add a field to a DM object.
appendOptionsPrefix(prefix) Append to the prefix used for searching for options in the database.
clearDS() Remove all discrete systems from the DM.
clearFields() Remove all fields from the DM.
clearLabelStratum(name, value) Remove all points from a stratum.
clearLabelValue(name, point, value) Remove a point from a DMLabel with given value.
clone() Return the cloned DM .
coarsen([comm]) Return a coarsened DM object.
coarsenHierarchy(nlevels) Coarsen this DM and return the coarsened DM hierarchy.
convert(dm_type) Return a DM converted to another DM.
copyDS(dm) Copy the discrete systems for this DM into another DM.
copyDisc(dm) Copy fields and discrete systems of a DM into another DM.
copyFields(dm) Copy the discretizations of this DM into another DM.
create([comm]) Return an empty DM.
createDS() Create discrete systems.
createFieldDecomposition() Return a list of IS objects.
createGlobalVec() Return a global vector.
createInjection(dm) Return the injection matrix into a finer DM.
createInterpolation(dm) Return the interpolation matrix to a finer DM.
createLabel(name) Create a label of the given name if it does not already exist.
createLocalVec() Return a local vector.
createMassMatrix(dmf) Return the mass matrix between this DM and the given DM.
createMat() Return an empty matrix.
createRestriction(dm) Return the restriction matrix between this DM and the given DM.
createSectionSF(localsec, globalsec) Create the SF encoding the parallel DOF overlap for the DM.
createSubDM(fields) Return IS and DM encapsulating a subproblem.
destroy() Destroy the object.
getAppCtx() Source code at petsc4py/PETSc/DM.pyx:352
getAuxiliaryVec([label, value, part]) Return an auxiliary vector for region.
getBasicAdjacency() Return the flags for determining variable influence.
getBlockSize() Return the inherent block size associated with a DM.
getBoundingBox() Return the dimension of embedding space for coordinates values.
getCoarseDM() Return the coarse DM.
getCoarsenLevel() Return the number of coarsenings.
getCoordinateDM() Return the coordinate DM.
getCoordinateDim() Return the dimension of embedding space for coordinates values.
getCoordinateSection() Return coordinate values layout over the mesh.
getCoordinates() Return a global vector with the coordinates associated.
getCoordinatesLocal() Return a local vector with the coordinates associated.
getDS() Return default DS.
getDimension() Return the topological dimension of the DM.
getField(index) Return the discretization object for a given DM field.
getFieldAdjacency(field) Return the flags for determining variable influence.
getGlobalSection() Return the Section encoding the global data layout for the DM.
getGlobalVec() Return a global vector.
getLGMap() Return local mapping to global mapping.
getLabel(name) Return the label of a given name.
getLabelIdIS(name) Return an IS of all values that the DMLabel takes.
getLabelName(index) Return the name of nth label.
getLabelOutput(name) Return the output flag for a given label.
getLabelSize(name) Return the number of values that the DMLabel takes.
getLabelValue(name, point) Return the value in DMLabel for the given point.
getLocalBoundingBox() Return the bounding box for the piece of the DM.
getLocalSection() Return the Section encoding the local data layout for the DM.
getLocalVec() Return a local vector.
getNumFields() Return the number of fields in the DM.
getNumLabels() Return the number of labels defined by on the DM.
getOptionsPrefix() Return the prefix used for searching for options in the database.
getPointSF() Return the SF encoding the parallel DOF overlap for the DM.
getRefineLevel() Return the refinement level.
getSectionSF() Return the Section encoding the parallel DOF overlap.
getStratumIS(name, value) Return the points in a label stratum.
getStratumSize(name, value) Return the number of points in a label stratum.
getType() Return the DM type name.
globalToLocal(vg, vl[, addv]) Update local vectors from global vector.
hasLabel(name) Determine whether the DM has a label.
load(viewer) Return a DM stored in binary.
localToGlobal(vl, vg[, addv]) Update global vectors from local vector.
localToLocal(vl, vlg[, addv]) Map the values from a local vector to another local vector.
localizeCoordinates() Create local coordinates for cells having periodic faces.
projectCoordinates(disc) Project coordinates to a different space.
refine([comm]) Return a refined DM object.
refineHierarchy(nlevels) Refine this DM and return the refined DM hierarchy.
removeLabel(name) Remove and destroy the label by name.
restoreGlobalVec(vg) Restore a global vector.
restoreLocalVec(vl) Restore a local vector.
setAppCtx(appctx) Source code at petsc4py/PETSc/DM.pyx:349
setAuxiliaryVec(aux, label[, value, part]) Set an auxiliary vector for a specific region.
setBasicAdjacency(useCone, useClosure) Set the flags for determining variable influence.
setCoarseDM(dm) Set the coarse DM.
setCoordinateDim(dim) Set the dimension of embedding space for coordinates values.
setCoordinates(c) Set a global vector that holds the coordinates.
setCoordinatesLocal(c) Set a local vector with the ghost point holding the coordinates.
setDimension(dim) Set the topological dimension of the DM.
setField(index, field[, label]) Set the discretization object for a given DM field.
setFieldAdjacency(field, useCone, useClosure) Set the flags for determining variable influence.
setFromOptions() Configure the object from the options database.
setGlobalSection(sec) Set the Section encoding the global data layout for the DM.
setKSPComputeOperators(operators[, args, kargs]) Matrix associated with the linear system.
setLabelOutput(name, output) Set if a given label should be saved to a view.
setLabelValue(name, point, value) Set a point to a DMLabel with a given value.
setLocalSection(sec) Set the Section encoding the local data layout for the DM.
setMatType(mat_type) Set matrix type to be used by DM.createMat.
setNumFields(numFields) Set the number of fields in the DM.
setOptionsPrefix(prefix) Set the prefix used for searching for options in the database.
setPointSF(sf) Set the SF encoding the parallel DOF overlap for the DM.
setRefineLevel(level) Set the number of refinements.
setSNESFunction(function[, args, kargs]) Set SNES residual evaluation function.
setSNESJacobian(jacobian[, args, kargs]) Set the SNES Jacobian evaluation function.
setSectionSF(sf) Set the Section encoding the parallel DOF overlap for the DM.
setType(dm_type) Build a DM.
setUp() Return the data structure.
setVecType(vec_type) Set the type of vector.
view([viewer]) View the DM.
viewFromOptions(name[, obj]) View a DM based in the options.

Attributes Summary

appctx
ds

Methods Documentation

Adapt a DM based on a DMLabel.

Collective.

label (str) -- The name of the DMLabel.
DM

SEE ALSO:

petsc.DMAdaptLabel


Source code at petsc4py/PETSc/DM.pyx:1431


Return a mesh adapted to the specified metric field.
  • metric (Vec) -- The metric to which the mesh is adapted, defined vertex-wise.
  • bdLabel (str | None) -- Label for boundary tags.
  • rgLabel (str | None) -- Label for cell tag.

DM

SEE ALSO:

petsc.DMAdaptMetric


Source code at petsc4py/PETSc/DM.pyx:1454


Add a callback to be executed when restricting to a coarser grid.

Logically collective.

  • coarsenhook (DMCoarsenHookFunction) -- The coarsen hook function.
  • restricthook (DMRestrictHookFunction) -- The restrict hook function.
  • args (tuple[Any, ...] | None) -- Positional arguments for the hooks.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the hooks.

None

SEE ALSO:

petsc.DMCoarsenHookAdd


Source code at petsc4py/PETSc/DM.pyx:2103


Add a field to a DM object.

Logically collective.

  • field (Object) -- The discretization object.
  • label (str | None) -- The name of the label indicating the support of the field, or None for the entire mesh.

None

SEE ALSO:

petsc.DMAddField


Source code at petsc4py/PETSc/DM.pyx:619


Append to the prefix used for searching for options in the database.

Logically collective.

SEE ALSO:

Working with PETSc options (TODO), setOptionsPrefix, petsc.DMAppendOptionsPrefix


Source code at petsc4py/PETSc/DM.pyx:285

prefix (str) --
None


Remove all discrete systems from the DM.

Logically collective.

SEE ALSO:

petsc.DMClearDS


Source code at petsc4py/PETSc/DM.pyx:683



Remove all fields from the DM.

Logically collective.

SEE ALSO:

petsc.DMClearFields


Source code at petsc4py/PETSc/DM.pyx:642



Remove all points from a stratum.

Not collective.

  • name (str) -- The label name.
  • value (int) -- The stratum value.

None

SEE ALSO:

petsc.DMClearLabelStratum


Source code at petsc4py/PETSc/DM.pyx:1891


Remove a point from a DMLabel with given value.

Not collective.

  • name (str) -- The label name.
  • point (int) -- The mesh point.
  • value (int) -- The label value for the point.

None

SEE ALSO:

petsc.DMClearLabelValue


Source code at petsc4py/PETSc/DM.pyx:1777


Return the cloned DM .

Collective.

SEE ALSO:

petsc.DMClone


Source code at petsc4py/PETSc/DM.pyx:142



Return a coarsened DM object.

Collective.

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

SEE ALSO:

petsc.DMCoarsen


Source code at petsc4py/PETSc/DM.pyx:1305


Coarsen this DM and return the coarsened DM hierarchy.

Collective.

nlevels (int) -- The number of levels of coarsening.
list

SEE ALSO:

petsc.DMCoarsenHierarchy


Source code at petsc4py/PETSc/DM.pyx:1356


Return a DM converted to another DM.

Collective.

dm_type (Type | str) -- The new DM.Type, use “same” for the same type.
DM

SEE ALSO:

DM.Type, petsc.DMConvert


Source code at petsc4py/PETSc/DM.pyx:1258


Copy the discrete systems for this DM into another DM.

Collective.

dm (DM) -- The DM that the discrete fields are copied into.
None

SEE ALSO:

petsc.DMCopyDS


Source code at petsc4py/PETSc/DM.pyx:710


Copy fields and discrete systems of a DM into another DM.

Collective.

dm (DM) -- The DM that the fields and discrete systems are copied into.
None

SEE ALSO:

petsc.DMCopyDisc


Source code at petsc4py/PETSc/DM.pyx:727


Copy the discretizations of this DM into another DM.

Collective.

dm (DM) -- The DM that the fields are copied into.
None

SEE ALSO:

petsc.DMCopyFields


Source code at petsc4py/PETSc/DM.pyx:654


Return an empty DM.

Collective.

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

SEE ALSO:

petsc.DMCreate


Source code at petsc4py/PETSc/DM.pyx:121


Create discrete systems.

Collective.

SEE ALSO:

petsc.DMCreateDS


Source code at petsc4py/PETSc/DM.pyx:671



Return a list of IS objects.

Not collective.

Notes

The user is responsible for freeing all requested arrays.

SEE ALSO:

petsc.DMCreateFieldDecomposition


Source code at petsc4py/PETSc/DM.pyx:1990

tuple[list, list, list]


Return a global vector.

Collective.

SEE ALSO:

petsc.DMCreateGlobalVector


Source code at petsc4py/PETSc/DM.pyx:774



Return the injection matrix into a finer DM.

Collective.

dm (DM) -- The second, finer DM object.
Mat

SEE ALSO:

petsc.DMCreateInjection


Source code at petsc4py/PETSc/DM.pyx:1220


Return the interpolation matrix to a finer DM.

Collective.

dm (DM) -- The second, finer DM.
tuple[Mat, Vec]

SEE ALSO:

petsc.DMCreateInterpolation


Source code at petsc4py/PETSc/DM.pyx:1199


Create a label of the given name if it does not already exist.

Not collective.

name (str) -- The label name.
None

SEE ALSO:

petsc.DMCreateLabel


Source code at petsc4py/PETSc/DM.pyx:1689


Return a local vector.

Not collective.

SEE ALSO:

petsc.DMCreateLocalVector


Source code at petsc4py/PETSc/DM.pyx:788



Return the mass matrix between this DM and the given DM.

Collective.

dmf (DM) -- The second DM.
Mat

SEE ALSO:

petsc.DMCreateMassMatrix


Source code at petsc4py/PETSc/DM.pyx:1180


Return an empty matrix.

Collective.

SEE ALSO:

petsc.DMCreateMatrix


Source code at petsc4py/PETSc/DM.pyx:1166



Return the restriction matrix between this DM and the given DM.

Collective.

dm (DM) -- The second, finer DM object.
Mat

SEE ALSO:

petsc.DMCreateRestriction


Source code at petsc4py/PETSc/DM.pyx:1239


Create the SF encoding the parallel DOF overlap for the DM.
  • localsec (Section) -- Describe the local data layout.
  • globalsec (Section) -- Describe the global data layout.

None

Notes

Encoding based on the Section describing the data layout.

SEE ALSO:

DM.getSectionSF, petsc.DMCreateSectionSF


Source code at petsc4py/PETSc/DM.pyx:1563


Return IS and DM encapsulating a subproblem.

Not collective.

  • iset (IS) -- The global indices for all the degrees of freedom.
  • subdm (DM) -- The DM for the subproblem.

fields (Sequence[int]) --
tuple[IS, DM]

SEE ALSO:

petsc.DMCreateSubDM


Source code at petsc4py/PETSc/DM.pyx:454


Destroy the object.

Collective.

SEE ALSO:

petsc.DMDestroy


Source code at petsc4py/PETSc/DM.pyx:108



Source code at petsc4py/PETSc/DM.pyx:352

Return an auxiliary vector for region.

Not collective.

  • label (str | None) -- The name of the DMLabel.
  • value (int | None) -- Indicate the region.
  • part (int | None) -- The equation part, or 0 is unused.

Vec

SEE ALSO:

DM.getLabel, petsc.DMGetAuxiliaryVec


Source code at petsc4py/PETSc/DM.pyx:511


Return the flags for determining variable influence.

Not collective.

  • useCone (bool) -- Whether adjacency uses cone information.
  • useClosure (bool) -- Whether adjacency is computed using full closure information.

tuple[bool, bool]

SEE ALSO:

petsc.DMGetBasicAdjacency


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


Return the inherent block size associated with a DM.

Not collective.

SEE ALSO:

petsc.DMGetBlockSize


Source code at petsc4py/PETSc/DM.pyx:746



Return the dimension of embedding space for coordinates values.

Not collective.

SEE ALSO:

petsc.DMGetBoundingBox


Source code at petsc4py/PETSc/DM.pyx:1092

tuple[tuple[float, float], ...]


Return the coarse DM.

Collective.

SEE ALSO:

petsc.DMGetCoarseDM


Source code at petsc4py/PETSc/DM.pyx:954



Return the number of coarsenings.

Not collective.

SEE ALSO:

petsc.DMGetCoarsenLevel


Source code at petsc4py/PETSc/DM.pyx:1415



Return the coordinate DM.

Collective.

SEE ALSO:

petsc.DMGetCoordinateDM


Source code at petsc4py/PETSc/DM.pyx:982



Return the dimension of embedding space for coordinates values.

Not collective.

SEE ALSO:

petsc.DMGetCoordinateDim


Source code at petsc4py/PETSc/DM.pyx:225



Return coordinate values layout over the mesh.

Collective.

SEE ALSO:

petsc.DMGetCoordinateSection


Source code at petsc4py/PETSc/DM.pyx:997

Section


Return a global vector with the coordinates associated.

Collective.

SEE ALSO:

petsc.DMGetCoordinates


Source code at petsc4py/PETSc/DM.pyx:1029



Return a local vector with the coordinates associated.

Collective the first time it is called.

SEE ALSO:

petsc.DMGetCoordinatesLocal


Source code at petsc4py/PETSc/DM.pyx:1061



Return default DS.

Not collective.

SEE ALSO:

petsc.DMGetDS


Source code at petsc4py/PETSc/DM.pyx:695



Return the topological dimension of the DM.

Not collective.

SEE ALSO:

petsc.DMGetDimension


Source code at petsc4py/PETSc/DM.pyx:193



Return the discretization object for a given DM field.

Not collective.

index (int) -- The field number.
tuple[Object, None]

SEE ALSO:

petsc.DMGetField


Source code at petsc4py/PETSc/DM.pyx:594


Return the flags for determining variable influence.

Not collective.

field (int) -- The field number.
  • useCone (bool) -- Whether adjacency uses cone information.
  • useClosure (bool) -- Whether adjacency is computed using full closure information.

tuple[bool, bool]

SEE ALSO:

petsc.DMGetAdjacency


Source code at petsc4py/PETSc/DM.pyx:424


Return the Section encoding the global data layout for the DM.

SEE ALSO:

petsc.DMGetGlobalSection


Source code at petsc4py/PETSc/DM.pyx:1541

Section


Return a global vector.

Collective.

SEE ALSO:

petsc.DMGetGlobalVector


Source code at petsc4py/PETSc/DM.pyx:802



Return local mapping to global mapping.

Collective.

SEE ALSO:

petsc.DMGetLocalToGlobalMapping


Source code at petsc4py/PETSc/DM.pyx:937

LGMap


Return the label of a given name.

Not collective.

SEE ALSO:

petsc.DMGetLabel


Source code at petsc4py/PETSc/DM.pyx:1489

name (str) --
DMLabel


Return an IS of all values that the DMLabel takes.

Not collective.

name (str) -- The label name.
IS

SEE ALSO:

petsc.DMLabelGetValueIS, petsc.DMGetLabelIdIS


Source code at petsc4py/PETSc/DM.pyx:1822


Return the name of nth label.

Not collective.

index (int) -- The label number.
str

SEE ALSO:

petsc.DMGetLabelName


Source code at petsc4py/PETSc/DM.pyx:1648


Return the output flag for a given label.

Not collective.

name (str) -- The label name.
bool

SEE ALSO:

petsc.DMGetLabelOutput


Source code at petsc4py/PETSc/DM.pyx:1935


Return the number of values that the DMLabel takes.

Not collective.

name (str) -- The label name.
int

SEE ALSO:

petsc.DMLabelGetNumValues, petsc.DMGetLabelSize


Source code at petsc4py/PETSc/DM.pyx:1801


Return the value in DMLabel for the given point.

Not collective.

  • name (str) -- The label name.
  • point (int) -- The mesh point

int

SEE ALSO:

petsc.DMGetLabelValue


Source code at petsc4py/PETSc/DM.pyx:1730


Return the bounding box for the piece of the DM.

Not collective.

SEE ALSO:

petsc.DMGetLocalBoundingBox


Source code at petsc4py/PETSc/DM.pyx:1109

tuple[tuple[float, float], ...]


Return the Section encoding the local data layout for the DM.

SEE ALSO:

petsc.DMGetGlobalSection


Source code at petsc4py/PETSc/DM.pyx:1518

Section


Return a local vector.

Not collective.

SEE ALSO:

petsc.DMGetLocalVector


Source code at petsc4py/PETSc/DM.pyx:835



Return the number of fields in the DM.

Not collective.

SEE ALSO:

petsc.DMGetNumFields


Source code at petsc4py/PETSc/DM.pyx:554



Return the number of labels defined by on the DM.

Not collective.

SEE ALSO:

petsc.DMGetNumLabels


Source code at petsc4py/PETSc/DM.pyx:1634



Return the prefix used for searching for options in the database.

Not collective.

SEE ALSO:

Working with PETSc options (TODO), setOptionsPrefix, petsc.DMGetOptionsPrefix


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



Return the SF encoding the parallel DOF overlap for the DM.

SEE ALSO:

petsc.DMGetPointSF


Source code at petsc4py/PETSc/DM.pyx:1611



Return the refinement level.

Not collective.

SEE ALSO:

petsc.DMGetRefineLevel


Source code at petsc4py/PETSc/DM.pyx:1383



Return the Section encoding the parallel DOF overlap.

SEE ALSO:

petsc.DMGetSectionSF


Source code at petsc4py/PETSc/DM.pyx:1584



Return the points in a label stratum.

Not collective.

  • name (str) -- The label name.
  • value (int) -- The stratum value.

IS

SEE ALSO:

petsc.DMGetStratumIS


Source code at petsc4py/PETSc/DM.pyx:1867


Return the number of points in a label stratum.

Not collective.

  • name (str) -- The label name.
  • value (int) -- The stratum value.

int

SEE ALSO:

petsc.DMGetStratumSize


Source code at petsc4py/PETSc/DM.pyx:1843


Return the DM type name.

Not collective.

SEE ALSO:

petsc.DMGetType


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



Update local vectors from global vector.

Neighborwise collective.

  • vg (Vec) -- The global vector.
  • vl (Vec) -- The local vector.
  • addv (InsertModeSpec | None) -- Insertion mode.

None

SEE ALSO:

petsc.DMGlobalToLocalBegin, petsc.DMGlobalToLocalEnd


Source code at petsc4py/PETSc/DM.pyx:868


Determine whether the DM has a label.

Not collective.

name (str) -- The label name.
bool

SEE ALSO:

petsc.DMHasLabel


Source code at petsc4py/PETSc/DM.pyx:1668


Return a DM stored in binary.

Collective.

viewer (Viewer) -- Viewer used to store the DM, like Viewer.Type.BINARY or Viewer.Type.HDF5.
Self

Notes

When using Viewer.Type.HDF5 format, one can save multiple DMPlex meshes in a single HDF5 files. This in turn requires one to name the DMPlex object with Object.setName before saving it with DM.view and before loading it with DM.load for identification of the mesh object.

SEE ALSO:

DM.view, DM.load, Object.setName, petsc.DMLoad


Source code at petsc4py/PETSc/DM.pyx:82


Update global vectors from local vector.

Neighborwise collective.

  • vl (Vec) -- The local vector.
  • vg (Vec) -- The global vector.
  • addv (InsertModeSpec | None) -- Insertion mode.

None

SEE ALSO:

petsc.DMLocalToGlobalBegin, petsc.DMLocalToGlobalEnd


Source code at petsc4py/PETSc/DM.pyx:891


Map the values from a local vector to another local vector.

Neighborwise collective.

  • vl (Vec) -- The local vector.
  • vlg (Vec) -- The global vector.
  • addv (InsertModeSpec | None) -- Insertion mode.

None

SEE ALSO:

petsc.DMLocalToLocalBegin, petsc.DMLocalToLocalEnd


Source code at petsc4py/PETSc/DM.pyx:914


Create local coordinates for cells having periodic faces.

Collective.

Notes

Used if the mesh is periodic.

SEE ALSO:

petsc.DMLocalizeCoordinates


Source code at petsc4py/PETSc/DM.pyx:1126



Project coordinates to a different space.
disc (FE) -- The new coordinates discretization.
Self

SEE ALSO:

petsc.DMProjectCoordinates


Source code at petsc4py/PETSc/DM.pyx:1076


Return a refined DM object.

Collective.

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

SEE ALSO:

petsc.DMRefine


Source code at petsc4py/PETSc/DM.pyx:1281


Refine this DM and return the refined DM hierarchy.

Collective.

nlevels (int) -- The number of levels of refinement.
list

SEE ALSO:

petsc.DMRefineHierarchy


Source code at petsc4py/PETSc/DM.pyx:1329


Remove and destroy the label by name.

Not collective.

name (str) -- The label name.
None

SEE ALSO:

petsc.DMRemoveLabel


Source code at petsc4py/PETSc/DM.pyx:1708


Restore a global vector.

Not collective.

vg (Vec) -- The global vector.
None

SEE ALSO:

petsc.DMRestoreGlobalVector


Source code at petsc4py/PETSc/DM.pyx:817


Restore a local vector.

Not collective.

vl (Vec) -- The local vector.
None

SEE ALSO:

petsc.DMRestoreLocalVector


Source code at petsc4py/PETSc/DM.pyx:850


Source code at petsc4py/PETSc/DM.pyx:349

Set an auxiliary vector for a specific region.

Not collective.

  • aux (Vec) -- The auxiliary vector.
  • label (DMLabel | None) -- The name of the DMLabel.
  • value -- Indicate the region.
  • part -- The equation part, or 0 is unused.

None

SEE ALSO:

petsc.DMGetLabel, petsc.DMSetAuxiliaryVec


Source code at petsc4py/PETSc/DM.pyx:481


Set the flags for determining variable influence.

Not collective.

  • useCone (bool) -- Whether adjacency uses cone information.
  • useClosure (bool) -- Whether adjacency is computed using full closure information.

None

SEE ALSO:

petsc.DMSetBasicAdjacency


Source code at petsc4py/PETSc/DM.pyx:357


Set the coarse DM.

Collective.

SEE ALSO:

petsc.DMSetCoarseDM


Source code at petsc4py/PETSc/DM.pyx:969

dm (DM) --
None


Set the dimension of embedding space for coordinates values.

Not collective.

dim (int) -- The embedding dimension.
None

SEE ALSO:

petsc.DMSetCoordinateDim


Source code at petsc4py/PETSc/DM.pyx:239


Set a global vector that holds the coordinates.

Collective.

c (Vec) -- Coordinate Vector.
None

SEE ALSO:

petsc.DMSetCoordinates


Source code at petsc4py/PETSc/DM.pyx:1012


Set a local vector with the ghost point holding the coordinates.

Not collective.

c (Vec) -- Coordinate Vector.
None

SEE ALSO:

petsc.DMSetCoordinatesLocal


Source code at petsc4py/PETSc/DM.pyx:1044


Set the topological dimension of the DM.

Collective.

dim (int) -- Topological dimension.
None

SEE ALSO:

petsc.DMSetDimension


Source code at petsc4py/PETSc/DM.pyx:207


Set the discretization object for a given DM field.

Logically collective.

  • index (int) -- The field number.
  • field (Object) -- The discretization object.
  • label (str | None) -- The name of the label indicating the support of the field, or None for the entire mesh.

None

SEE ALSO:

petsc.DMSetField


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


Set the flags for determining variable influence.

Not collective.

  • field (int) -- The field number.
  • useCone (bool) -- Whether adjacency uses cone information.
  • useClosure (bool) -- Whether adjacency is computed using full closure information.

None

SEE ALSO:

petsc.DMSetAdjacency


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


Configure the object from the options database.

Collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.DMSetFromOptions


Source code at petsc4py/PETSc/DM.pyx:299



Set the Section encoding the global data layout for the DM.

SEE ALSO:

petsc.DMSetGlobalSection


Source code at petsc4py/PETSc/DM.pyx:1531

sec (Section) --
None


Matrix associated with the linear system.

Collective.

  • operator -- Callback function to compute the operators.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

petsc.DMKSPSetComputeOperators


Source code at petsc4py/PETSc/DM.pyx:1961


Set if a given label should be saved to a view.

Not collective.

  • name (str) -- The label name.
  • output (bool) -- If True, the label is saved to the viewer.

None

SEE ALSO:

petsc.DMSetLabelOutput


Source code at petsc4py/PETSc/DM.pyx:1913


Set a point to a DMLabel with a given value.

Not collective.

  • name (str) -- The label name.
  • point (int) -- The mesh point.
  • value (int) -- The label value for the point.

None

SEE ALSO:

petsc.DMSetLabelValue


Source code at petsc4py/PETSc/DM.pyx:1753


Set the Section encoding the local data layout for the DM.

SEE ALSO:

petsc.DMSetLocalSection


Source code at petsc4py/PETSc/DM.pyx:1508

sec (Section) --
None


Set matrix type to be used by DM.createMat.

Logically collective.

mat_type (Type | str) -- The matrix type.
None

Notes

The option -dm_mat_type is used to set the matrix type.

SEE ALSO:

Working with PETSc options (TODO), petsc.DMSetMatType


Source code at petsc4py/PETSc/DM.pyx:1143


Set the number of fields in the DM.

Logically collective.

SEE ALSO:

petsc.DMSetNumFields


Source code at petsc4py/PETSc/DM.pyx:541

numFields (int) --
None


Set the prefix used for searching for options in the database.

Logically collective.

SEE ALSO:

Working with PETSc options (TODO), getOptionsPrefix, petsc.DMSetOptionsPrefix


Source code at petsc4py/PETSc/DM.pyx:257

prefix (str) --
None


Set the SF encoding the parallel DOF overlap for the DM.

SEE ALSO:

petsc.DMSetPointSF


Source code at petsc4py/PETSc/DM.pyx:1624

sf (SF) --
None


Set the number of refinements.

Not collective.

  • nlevels -- The number of refinement.
  • level (int) --

None

SEE ALSO:

petsc.DMSetRefineLevel


Source code at petsc4py/PETSc/DM.pyx:1397


Set SNES residual evaluation function.

Not collective.

  • function (SNESFunction) -- The callback.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

SNES.setFunction, petsc.DMSNESSetFunction


Source code at petsc4py/PETSc/DM.pyx:2038


Set the SNES Jacobian evaluation function.

Not collective.

  • jacobian (SNESJacobianFunction) -- The Jacobian callback.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

SNES.setJacobian, petsc.DMSNESSetJacobian


Source code at petsc4py/PETSc/DM.pyx:2071


Set the Section encoding the parallel DOF overlap for the DM.

SEE ALSO:

petsc.DMSetSectionSF


Source code at petsc4py/PETSc/DM.pyx:1597

sf (SF) --
None


Build a DM.

Collective.

dm_type (Type | str) -- The type of DM.
None

Notes

DM types are available in DM.Type class.

SEE ALSO:

DM.Type, petsc.DMSetType


Source code at petsc4py/PETSc/DM.pyx:156


Return the data structure.

Collective.

SEE ALSO:

petsc.DMSetUp


Source code at petsc4py/PETSc/DM.pyx:334



Set the type of vector.

Logically collective.

SEE ALSO:

Vec.Type, petsc.DMSetVecType


Source code at petsc4py/PETSc/DM.pyx:760

vec_type (Type | str) --
None


View the DM.

Collective.

viewer (Viewer | None) -- The DM viewer.
None

SEE ALSO:

petsc.DMView


Source code at petsc4py/PETSc/DM.pyx:63


View a DM based in the options.

Collective.

  • name (str) -- Name used to activate the viewing.
  • obj (Object | None) -- Object provides the prefix for the options database.

None

SEE ALSO:

petsc.DMViewFromOptions


Source code at petsc4py/PETSc/DM.pyx:311


Attributes Documentation





petsc4py.PETSc.DMComposite

Bases: DM

A DM object that is used to manage data for a collection of DMs.

Methods Summary

addDM(dm, *args) Add a DM vector to the composite.
create([comm]) Create a composite object.
gather(gvec, imode, lvecs) Gather split local vectors into a coupled global vector.
getAccess(gvec[, locs]) Get access to the individual vectors from the global vector.
getEntries() Return sub-DMs contained in the composite.
getGlobalISs() Return the index sets for each composed object in the composite.
getLGMaps() Return a local-to-global mapping for each DM in the composite.
getLocalISs() Return index sets for each component of a composite local vector.
getNumber() Get number of sub-DMs contained in the composite.
scatter(gvec, lvecs) Scatter coupled global vector into split local vectors.

Methods Documentation

Add a DM vector to the composite.

Collective.

  • dm (DM) -- The DM object.
  • *args (DM) -- Additional DM objects.

None

SEE ALSO:

petsc.DMCompositeAddDM


Source code at petsc4py/PETSc/DMComposite.pyx:27


Create a composite object.

Collective.

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

SEE ALSO:

petsc.DMCompositeCreate


Source code at petsc4py/PETSc/DMComposite.pyx:6


Gather split local vectors into a coupled global vector.

Collective.

  • gvec (Vec) -- The global vector.
  • imode (InsertModeSpec) -- The insertion mode.
  • lvecs (Sequence[Vec]) -- The individual sequential vectors.

None

SEE ALSO:

scatter, petsc.DMCompositeGatherArray


Source code at petsc4py/PETSc/DMComposite.pyx:114


Get access to the individual vectors from the global vector.

Not collective.

Use via The with statement context manager (PEP 343).

  • gvec (Vec) -- The global vector.
  • locs (Sequence[int] | None) -- Indices of vectors wanted, or None to get all vectors.

Any

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


Return sub-DMs contained in the composite.

Not collective.

SEE ALSO:

petsc.DMCompositeGetEntriesArray


Source code at petsc4py/PETSc/DMComposite.pyx:65

list[DM]


Return the index sets for each composed object in the composite.

Collective.

These could be used to extract a subset of vector entries for a "multi-physics" preconditioner.

Use getLocalISs for index sets in the packed local numbering, and getLGMaps for to map local sub-DM (including ghost) indices to packed global indices.

SEE ALSO:

petsc.DMCompositeGetGlobalISs


Source code at petsc4py/PETSc/DMComposite.pyx:142

list[IS]


Return a local-to-global mapping for each DM in the composite.

Collective.

Note that this includes all the ghost points that individual ghosted DMDA may have.

SEE ALSO:

petsc.DMCompositeGetISLocalToGlobalMappings


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

list[LGMap]


Return index sets for each component of a composite local vector.

Not collective.

To get the composite global indices at all local points (including ghosts), use getLGMaps.

To get index sets for pieces of the composite global vector, use getGlobalISs.

SEE ALSO:

petsc.DMCompositeGetLocalISs


Source code at petsc4py/PETSc/DMComposite.pyx:169

list[IS]


Get number of sub-DMs contained in the composite.

Not collective.

SEE ALSO:

petsc.DMCompositeGetNumberDM


Source code at petsc4py/PETSc/DMComposite.pyx:50



Scatter coupled global vector into split local vectors.

Collective.

  • gvec (Vec) -- The global vector.
  • lvecs (Sequence[Vec]) -- Array of local vectors.

None

SEE ALSO:

gather, petsc.DMCompositeScatterArray


Source code at petsc4py/PETSc/DMComposite.pyx:89



petsc4py.PETSc.DMDA

Bases: DM

A DM object that is used to manage data for a structured grid.

Enumerations

ElementType
InterpolationType
StencilType

petsc4py.PETSc.DMDA.ElementType

Bases: object

Attributes Summary

P1 Constant P1 of type int
Q1 Constant Q1 of type int

Attributes Documentation

Constant P1 of type int

Constant Q1 of type int


petsc4py.PETSc.DMDA.InterpolationType

Bases: object

Attributes Summary

Q0 Constant Q0 of type int
Q1 Constant Q1 of type int

Attributes Documentation

Constant Q0 of type int

Constant Q1 of type int


petsc4py.PETSc.DMDA.StencilType

Bases: object

Attributes Summary

BOX Constant BOX of type int
STAR Constant STAR of type int

Attributes Documentation

Constant BOX of type int

Constant STAR of type int


Methods Summary

create([dim, dof, sizes, proc_sizes, ...]) Create a DMDA object.
createNaturalVec() Create a vector that will hold values in the natural numbering.
duplicate([dof, boundary_type, ...]) Duplicate a DMDA.
getAO() Return the application ordering context for a distributed array.
getBoundaryType() Return the type of ghost nodes at boundary in each dimension.
getCoordinateName(index) Return the name of a coordinate dimension.
getCorners() Return the lower left corner and the sizes of the owned local region.
getDim() Return the topological dimension.
getDof() Return the number of degrees of freedom per node.
getElementType() Return the element type to be returned by getElements.
getElements([elem_type]) Return an array containing the indices of all the local elements.
getFieldName(field) Return the name of an individual field component.
getGhostCorners() Return the lower left corner and the size of the ghosted local region.
getGhostRanges() Return the ranges of the local region in each dimension, including ghost nodes.
getInterpolationType() Return the type of interpolation.
getOwnershipRanges() Return the ranges of indices in each dimension owned by each process.
getProcSizes() Return the number of processes in each dimension.
getRanges() Return the ranges of the owned local region in each dimension.
getRefinementFactor() Return the ratios that the DMDA grid is refined in each dimension.
getScatter() Return the global-to-local, and local-to-local scatter contexts.
getSizes() Return the number of grid points in each dimension.
getStencil() Return the stencil type and width.
getStencilType() Return the stencil type.
getStencilWidth() Return the stencil width.
getVecArray(vec) Get access to the vector.
globalToNatural(vg, vn[, addv]) Map values to the "natural" grid ordering.
naturalToGlobal(vn, vg[, addv]) Map values the to grid ordering.
setBoundaryType(boundary_type) Set the type of ghost nodes on domain boundaries.
setCoordinateName(index, name) Set the name of the coordinate dimension.
setDim(dim) Set the topological dimension.
setDof(dof) Set the number of degrees of freedom per vertex.
setElementType(elem_type) Set the element type to be returned by getElements.
setFieldName(field, name) Set the name of individual field components.
setInterpolationType(interp_type) Set the type of interpolation.
setProcSizes(proc_sizes) Set the number of processes in each dimension.
setRefinementFactor([refine_x, refine_y, ...]) Set the ratios for the DMDA grid refinement.
setSizes(sizes) Set the number of grid points in each dimension.
setStencil(stencil_type, stencil_width) Set the stencil type and width.
setStencilType(stencil_type) Set the stencil type.
setStencilWidth(stencil_width) Set the stencil width.
setUniformCoordinates([xmin, xmax, ymin, ...]) Set the DMDA coordinates to be a uniform grid.

Attributes Summary

boundary_type Boundary types in each dimension.
corners The lower left corner and size of local region in each dimension.
dim The grid dimension.
dof The number of DOFs associated with each stratum of the grid.
ghost_corners The lower left corner and size of local region in each dimension.
ghost_ranges Ranges of local region, including ghost nodes.
proc_sizes The number of processes in each dimension in the global decomposition.
ranges Ranges of the local region in each dimension.
sizes The global dimension.
stencil Stencil type and width.
stencil_type Stencil type.
stencil_width Elementwise stencil width.

Methods Documentation

Create a DMDA object.

Collective.

This routine performs the following steps of the C API: - petsc.DMDACreate - petsc.DMSetDimension - petsc.DMDASetDof - petsc.DMDASetSizes - petsc.DMDASetNumProcs - petsc.DMDASetOwnershipRanges - petsc.DMDASetBoundaryType - petsc.DMDASetStencilType - petsc.DMDASetStencilWidth - petsc.DMSetUp (optionally)

  • dim (int | None) -- The number of dimensions.
  • dof (int | None) -- The number of degrees of freedom.
  • sizes (DimsSpec | None) -- The number of elements in each dimension.
  • proc_sizes (DimsSpec | None) -- The number of processes in x, y, z dimensions.
  • boundary_type (tuple[DM.BoundaryType | int | str | bool, ...] | None) -- The boundary types.
  • stencil_type (StencilType | None) -- The ghost/halo stencil type.
  • stencil_width (int | None) -- The width of the ghost/halo region.
  • setup (bool) -- Whether to call the setup routine after creating the object.
  • ownership_ranges (tuple[Sequence[int], ...] | None) -- Local x, y, z element counts, of length equal to proc_sizes, summing to sizes.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.DMDACreate, petsc.DMSetDimension, petsc.DMDASetDof, petsc.DMDASetSizes, petsc.DMDASetNumProcs, petsc.DMDASetOwnershipRanges, petsc.DMDASetBoundaryType, petsc.DMDASetStencilType, petsc.DMDASetStencilWidth, petsc.DMSetUp


Source code at petsc4py/PETSc/DMDA.pyx:26


Create a vector that will hold values in the natural numbering.

Collective.

The number of local entries in the vector on each process is the same as in a vector created with DM.createGlobalVec.

SEE ALSO:

petsc.DMDACreateNaturalVector


Source code at petsc4py/PETSc/DMDA.pyx:827



Duplicate a DMDA.

Collective.

This routine retrieves the information from the DMDA and recreates it. Parameters dof, boundary_type, stencil_type, stencil_width will be overwritten, if provided.

  • dof (int | None) -- The number of degrees of freedom.
  • boundary_type (tuple[DM.BoundaryType | int | str | bool, ...] | None) -- Boundary types.
  • stencil_type (StencilType | None) -- The ghost/halo stencil type.
  • stencil_width (int | None) -- The width of the ghost/halo region.

DMDA

SEE ALSO:

create, petsc.DMDAGetInfo, petsc.DMSetUp


Source code at petsc4py/PETSc/DMDA.pyx:143


Return the application ordering context for a distributed array.

Collective.

The returned AO maps to the natural grid ordering that would be used for the DMDA if only 1 processor were employed (ordering most rapidly in the x-dimension, then y, then z). Multiple degrees of freedom are numbered for each node (rather than 1 component for the whole grid, then the next component, etc.).

SEE ALSO:

petsc.DMDAGetAO


Source code at petsc4py/PETSc/DMDA.pyx:906



Return the type of ghost nodes at boundary in each dimension.

Not collective.

SEE ALSO:

setBoundaryType


Source code at petsc4py/PETSc/DMDA.pyx:404

tuple[BoundaryType, ...]


Return the name of a coordinate dimension.

Not collective.

index (int) -- The coordinate number for the DMDA (0, 1, ..., dim-1).
str

SEE ALSO:

setCoordinateName, petsc.DMDAGetCoordinateName


Source code at petsc4py/PETSc/DMDA.pyx:805


Return the lower left corner and the sizes of the owned local region.

Not collective.

Returns the global (x,y,z) indices of the lower left corner (first tuple) and size of the local region (second tuple).

Excluding ghost points.

The corner information is independent of the number of degrees of freedom per node. Thus the returned values can be thought of as coordinates on a logical grid, where each grid point has (potentially) several degrees of freedom.

SEE ALSO:

getRanges, getGhostRanges, getOwnershipRanges, getGhostCorners, petsc.DMDAGetCorners


Source code at petsc4py/PETSc/DMDA.pyx:620

tuple[tuple[int, ...], tuple[int, ...]]


Return the topological dimension.

Not collective.

SEE ALSO:

setDim, petsc.DMGetDimension


Source code at petsc4py/PETSc/DMDA.pyx:230



Return the number of degrees of freedom per node.

Not collective.

SEE ALSO:

setDof, petsc.DMDAGetInfo


Source code at petsc4py/PETSc/DMDA.pyx:260



Return the element type to be returned by getElements.

Not collective.

SEE ALSO:

setElementType, petsc.DMDAGetElementType


Source code at petsc4py/PETSc/DMDA.pyx:1048

ElementType


Return an array containing the indices of all the local elements.

Not collective.

The elements are in local coordinates.

Each process uniquely owns a subset of the elements. That is, no element is owned by two or more processes.

elem_type (ElementType | None) -- The element type.
ArrayInt

SEE ALSO:

petsc.DMDAGetElements


Source code at petsc4py/PETSc/DMDA.pyx:1062


Return the name of an individual field component.

Not collective.

field (int) -- The field number for the DMDA (0, 1, ..., dof-1), where dof indicates the number of degrees of freedom per node within the DMDA.
str

SEE ALSO:

setFieldName, petsc.DMDAGetFieldName


Source code at petsc4py/PETSc/DMDA.pyx:697


Return the lower left corner and the size of the ghosted local region.

Not collective.

Returns the global (x,y,z) indices of the lower left corner (first tuple) and size of the local region (second tuple).

SEE ALSO:

getRanges, getGhostRanges, getOwnershipRanges, getCorners, petsc.DMDAGetGhostCorners


Source code at petsc4py/PETSc/DMDA.pyx:649

tuple[tuple[int, ...], tuple[int, ...]]


Return the ranges of the local region in each dimension, including ghost nodes.

Not collective.

SEE ALSO:

getRanges, getOwnershipRanges, getCorners, getGhostCorners, petsc.DMDAGetGhostCorners


Source code at petsc4py/PETSc/DMDA.pyx:575

tuple[tuple[int, int], ...]


Return the type of interpolation.

Not collective.

SEE ALSO:

setInterpolationType, petsc.DMDAGetInterpolationType


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

InterpolationType


Return the ranges of indices in each dimension owned by each process.

Not collective.

These numbers are not multiplied by the number of DOFs per node.

SEE ALSO:

getRanges, getGhostRanges, getCorners, getGhostCorners, petsc.DMDAGetOwnershipRanges


Source code at petsc4py/PETSc/DMDA.pyx:595

tuple[ArrayInt, ...]


Return the number of processes in each dimension.

Not collective.

SEE ALSO:

setProcSizes, petsc.DMDAGetInfo


Source code at petsc4py/PETSc/DMDA.pyx:357

tuple[int, ...]


Return the ranges of the owned local region in each dimension.

Not collective.

Excluding ghost nodes.

SEE ALSO:

getGhostRanges, getOwnershipRanges, getCorners, getGhostCorners, petsc.DMDAGetCorners


Source code at petsc4py/PETSc/DMDA.pyx:553

tuple[tuple[int, int], ...]


Return the ratios that the DMDA grid is refined in each dimension.

Not collective.

SEE ALSO:

setRefinementFactor, petsc.DMDAGetRefinementFactor


Source code at petsc4py/PETSc/DMDA.pyx:979

tuple[int, ...]


Return the global-to-local, and local-to-local scatter contexts.

Collective.

SEE ALSO:

petsc.DMDAGetScatter


Source code at petsc4py/PETSc/DMDA.pyx:927

tuple[Scatter, Scatter]


Return the number of grid points in each dimension.

Not collective.

SEE ALSO:

setSizes, petsc.DMDAGetInfo


Source code at petsc4py/PETSc/DMDA.pyx:307

tuple[int, ...]


Return the stencil type and width.

Not collective.

SEE ALSO:

getStencilType, getStencilWidth


Source code at petsc4py/PETSc/DMDA.pyx:530

tuple[StencilType, int]


Return the stencil type.

Not collective.

SEE ALSO:

setStencilType, petsc.DMDAGetInfo


Source code at petsc4py/PETSc/DMDA.pyx:445

StencilType


Return the stencil width.

Not collective.

SEE ALSO:

setStencilWidth


Source code at petsc4py/PETSc/DMDA.pyx:483



Get access to the vector.

Not collective.

Use via The with statement context manager (PEP 343).

vec (Vec) -- The vector to which access is being requested.
Any

Source code at petsc4py/PETSc/DMDA.pyx:721


Map values to the "natural" grid ordering.

Neighborwise collective.

You must call createNaturalVec before using this routine.

  • vg (Vec) -- The global vector in a grid ordering.
  • vn (Vec) -- The global vector in a "natural" ordering.
  • addv (InsertMode | None) -- The insertion mode.

None

SEE ALSO:

naturalToGlobal, petsc.DMDAGlobalToNaturalBegin, petsc.DMDAGlobalToNaturalEnd


Source code at petsc4py/PETSc/DMDA.pyx:844


Map values the to grid ordering.

Neighborwise collective.

  • vn (Vec) -- The global vector in a natural ordering.
  • vg (Vec) -- the global vector in a grid ordering.
  • addv (InsertMode | None) -- The insertion mode.

None

SEE ALSO:

globalToNatural, petsc.DMDANaturalToGlobalBegin, petsc.DMDANaturalToGlobalEnd


Source code at petsc4py/PETSc/DMDA.pyx:875


Set the type of ghost nodes on domain boundaries.

Not collective.

boundary_type (tuple[BoundaryType | int | str | bool, ...]) -- The boundary type in (x), (x, y), or (x, y, z) dimensions.
None

SEE ALSO:

getBoundaryType, petsc.DMDASetBoundaryType


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


Set the name of the coordinate dimension.

Logically collective.

  • index (int) -- The coordinate number for the DMDA (0, 1, ..., dim-1).
  • name (str) -- The name of the coordinate.

None

SEE ALSO:

getCoordinateName, petsc.DMDASetCoordinateName


Source code at petsc4py/PETSc/DMDA.pyx:783


Set the topological dimension.

Collective.

dim (int) -- Topological dimension.
None

SEE ALSO:

getDim, petsc.DMSetDimension


Source code at petsc4py/PETSc/DMDA.pyx:213


Set the number of degrees of freedom per vertex.

Not collective.

dof (int) -- The number of degrees of freedom.
None

SEE ALSO:

getDof, petsc.DMDASetDof


Source code at petsc4py/PETSc/DMDA.pyx:242


Set the element type to be returned by getElements.

Not collective.

SEE ALSO:

getElementType, petsc.DMDASetElementType


Source code at petsc4py/PETSc/DMDA.pyx:1034

elem_type (ElementType | str) --
None


Set the name of individual field components.

Logically collective.

  • field (int) -- The field number for the DMDA (0, 1, ..., dof-1), where dof indicates the number of degrees of freedom per node within the DMDA.
  • name (str) -- The name of the field (component).

None

SEE ALSO:

getFieldName, petsc.DMDASetFieldName


Source code at petsc4py/PETSc/DMDA.pyx:673


Set the type of interpolation.

Logically collective.

You should call this on the coarser of the two DMDAs you pass to DM.createInterpolation.

interp_type (InterpolationType) -- The interpolation type.
None

SEE ALSO:

getInterpolationType, petsc.DMDASetInterpolationType


Source code at petsc4py/PETSc/DMDA.pyx:997


Set the number of processes in each dimension.

Logically collective.

proc_sizes (DimsSpec) -- The number of processes in (x,), (x, y), or (x, y, z) dimensions.
None

SEE ALSO:

getProcSizes, petsc.DMDASetNumProcs


Source code at petsc4py/PETSc/DMDA.pyx:330


Set the ratios for the DMDA grid refinement.

Logically collective.

  • refine_x (int) -- Ratio of fine grid to coarse in x dimension.
  • refine_y (int) -- Ratio of fine grid to coarse in y dimension.
  • refine_z (int) -- Ratio of fine grid to coarse in z dimension.

None

SEE ALSO:

getRefinementFactor, petsc.DMDASetRefinementFactor


Source code at petsc4py/PETSc/DMDA.pyx:946


Set the number of grid points in each dimension.

Logically collective.

sizes (DimsSpec) -- The global (x,), (x, y), or (x, y, z) size.
None

SEE ALSO:

getSizes, petsc.DMDASetSizes


Source code at petsc4py/PETSc/DMDA.pyx:280


Set the stencil type and width.

Not collective.

  • stencil_type (StencilType) -- The stencil type.
  • stencil_width (int) -- The stencil width.

None

SEE ALSO:

setStencilWidth, setStencilType, petsc.DMDASetStencilType, petsc.DMDASetStencilWidth


Source code at petsc4py/PETSc/DMDA.pyx:503


Set the stencil type.

Logically collective.

  • stype -- The stencil type.
  • stencil_type (StencilType) --

None

SEE ALSO:

getStencilType, setStencil, petsc.DMDASetStencilType


Source code at petsc4py/PETSc/DMDA.pyx:427


Set the stencil width.

Logically collective.

stencil_width (int) -- The stencil width.
None

SEE ALSO:

getStencilWidth, setStencil, petsc.DMDASetStencilWidth


Source code at petsc4py/PETSc/DMDA.pyx:465


Set the DMDA coordinates to be a uniform grid.

Collective.

  • xmin (float) -- The minimum in the x dimension.
  • xmax (float) -- The maximum in the x dimension.
  • ymin (float) -- The minimum in the y dimension (value ignored for 1 dimensional problems).
  • ymax (float) -- The maximum in the y dimension (value ignored for 1 dimensional problems).
  • zmin (float) -- The minimum in the z dimension (value ignored for 1 or 2 dimensional problems).
  • zmax (float) -- The maximum in the z dimension (value ignored for 1 or 2 dimensional problems).

None

SEE ALSO:

petsc.DMDASetUniformCoordinates


Source code at petsc4py/PETSc/DMDA.pyx:738


Attributes Documentation

Boundary types in each dimension.

Source code at petsc4py/PETSc/DMDA.pyx:1121


The lower left corner and size of local region in each dimension.

Source code at petsc4py/PETSc/DMDA.pyx:1151


The grid dimension.

Source code at petsc4py/PETSc/DMDA.pyx:1101


The number of DOFs associated with each stratum of the grid.

Source code at petsc4py/PETSc/DMDA.pyx:1106


The lower left corner and size of local region in each dimension.

Source code at petsc4py/PETSc/DMDA.pyx:1156


Ranges of local region, including ghost nodes.

Source code at petsc4py/PETSc/DMDA.pyx:1146


The number of processes in each dimension in the global decomposition.

Source code at petsc4py/PETSc/DMDA.pyx:1116


Ranges of the local region in each dimension.

Source code at petsc4py/PETSc/DMDA.pyx:1141


The global dimension.

Source code at petsc4py/PETSc/DMDA.pyx:1111


Stencil type and width.

Source code at petsc4py/PETSc/DMDA.pyx:1126


Stencil type.

Source code at petsc4py/PETSc/DMDA.pyx:1131


Elementwise stencil width.

Source code at petsc4py/PETSc/DMDA.pyx:1136




petsc4py.PETSc.DMInterpolation

Bases: object

Interpolation on a mesh.

Methods Summary

create([comm]) Create a DMInterpolation context.
destroy() Destroy the DMInterpolation context.
evaluate(dm, x[, v]) Calculate interpolated field values at the interpolation points.
getCoordinates() Return the coordinates of each interpolation point.
getDim() Return the spatial dimension of the interpolation context.
getDof() Return the number of fields interpolated at a point.
getVector() Return a Vec which can hold all the interpolated field values.
restoreVector(vec) Restore a Vec which can hold all the interpolated field values.
setDim(dim) Set the spatial dimension for the interpolation context.
setDof(dof) Set the number of fields interpolated at a point.
setUp(dm[, redundantPoints, ignoreOutsideDomain]) Compute spatial indices for point location during interpolation.

Methods Documentation

Create a DMInterpolation context.

Collective.

comm (Comm | None) -- MPI communicator, defaults to COMM_SELF.
Self

SEE ALSO:

destroy, petsc.DMInterpolationCreate


Source code at petsc4py/PETSc/DMUtils.pyx:13


Destroy the DMInterpolation context.

Collective.

SEE ALSO:

create, petsc.DMInterpolationDestroy


Source code at petsc4py/PETSc/DMUtils.pyx:35



Calculate interpolated field values at the interpolation points.

Collective.

  • dm (DM) -- The DM.
  • x (Vec) -- The local vector containing the field to be interpolated.
  • v (Vec | None) -- A vector capable of holding the interpolated field values.

Vec

SEE ALSO:

petsc.DMInterpolationEvaluate


Source code at petsc4py/PETSc/DMUtils.pyx:48


Return the coordinates of each interpolation point.

Collective.

The local vector entries correspond to interpolation points lying on this process, according to the associated DM.

SEE ALSO:

petsc.DMInterpolationGetCoordinates


Source code at petsc4py/PETSc/DMUtils.pyx:74



Return the spatial dimension of the interpolation context.

Not collective.

SEE ALSO:

setDim, petsc.DMInterpolationGetDim


Source code at petsc4py/PETSc/DMUtils.pyx:92



Return the number of fields interpolated at a point.

Not collective.

SEE ALSO:

setDof, petsc.DMInterpolationGetDof


Source code at petsc4py/PETSc/DMUtils.pyx:106



Return a Vec which can hold all the interpolated field values.

Collective.

This vector should be returned using restoreVector.

SEE ALSO:

restoreVector, petsc.DMInterpolationGetVector


Source code at petsc4py/PETSc/DMUtils.pyx:186



Restore a Vec which can hold all the interpolated field values.

Collective.

vec (Vec) -- A vector capable of holding the interpolated field values.
None

SEE ALSO:

getVector, petsc.DMInterpolationRestoreVector


Source code at petsc4py/PETSc/DMUtils.pyx:202


Set the spatial dimension for the interpolation context.

Not collective.

dim (int) -- The spatial dimension.
None

SEE ALSO:

getDim, petsc.DMInterpolationSetDim


Source code at petsc4py/PETSc/DMUtils.pyx:120


Set the number of fields interpolated at a point.

Not collective.

dof (int) -- The number of fields.
None

SEE ALSO:

getDof, petsc.DMInterpolationSetDof


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


Compute spatial indices for point location during interpolation.

Collective.

  • dm (DM) -- The DM for the function space used for interpolation.
  • redundantPoints (bool) -- If True, all processes are passing in the same array of points. Otherwise, points need to be communicated among processes.
  • ignoreOutsideDomain (bool) -- Ignore points outside of the domain if True; otherwise, return an error.

None

SEE ALSO:

petsc.DMInterpolationSetUp


Source code at petsc4py/PETSc/DMUtils.pyx:156



petsc4py.PETSc.DMLabel

Bases: Object

An object representing a subset of mesh entities from a DM.

Methods Summary

addStrata(strata) Add new stratum values in a DMLabel.
addStrataIS(iset) Add new stratum values in a DMLabel.
addStratum(value) Add a new stratum value in a DMLabel.
clearStratum(stratum) Remove a stratum.
clearValue(point, value) Clear the value a label assigns to a point.
computeIndex() Create an index structure for membership determination.
convertToSection() Return a Section and IS that encode the label.
create(name[, comm]) Create a DMLabel object, which is a multimap.
createIndex(pStart, pEnd) Create an index structure for membership determination.
destroy() Destroy the label.
destroyIndex() Destroy the index structure.
distribute(sf) Create a new label pushed forward over the SF.
duplicate() Duplicate the DMLabel.
filter(start, end) Remove all points outside of [start, end).
gather(sf) Gather all label values from leaves into roots.
getBounds() Return the smallest and largest point in the label.
getDefaultValue() Return the default value returned by getValue.
getNonEmptyStratumValuesIS() Return an IS of all values that the DMLabel takes.
getNumValues() Return the number of values that the DMLabel takes.
getStratumIS(stratum) Return an IS with the stratum points.
getStratumSize(stratum) Return the size of a stratum.
getValue(point) Return the value a label assigns to a point.
getValueIS() Return an IS of all values that the DMLabel takes.
hasPoint(point) Determine whether the label contains a point.
hasStratum(value) Determine whether points exist with the given value.
hasValue(value) Determine whether a label assigns the value to any point.
insertIS(iset, value) Set all points in the IS to a value.
permute(permutation) Create a new label with permuted points.
reset() Destroy internal data structures in the DMLabel.
setDefaultValue(value) Set the default value returned by getValue.
setStratumIS(stratum, iset) Set the stratum points using an IS.
setValue(point, value) Set the value a label assigns to a point.
stratumHasPoint(value, point) Return whether the stratum contains a point.
view([viewer]) View the label.

Methods Documentation

Add new stratum values in a DMLabel.

Not collective.

strata (Sequence[int]) -- The stratum values.
None

SEE ALSO:

addStrataIS, addStratum, petsc.DMLabelAddStrata


Source code at petsc4py/PETSc/DMLabel.pyx:236


Add new stratum values in a DMLabel.

Not collective.

iset (IS) -- Index set with stratum values.
None

SEE ALSO:

addStrata, addStratum, petsc.DMLabelAddStrataIS


Source code at petsc4py/PETSc/DMLabel.pyx:256


Add a new stratum value in a DMLabel.
value (int) -- The stratum value.
None

SEE ALSO:

addStrata, addStrataIS, petsc.DMLabelAddStratum


Source code at petsc4py/PETSc/DMLabel.pyx:220


Remove a stratum.

Not collective.

stratum (int) -- The stratum value.
None

SEE ALSO:

petsc.DMLabelClearStratum


Source code at petsc4py/PETSc/DMLabel.pyx:404


Clear the value a label assigns to a point.

Not collective.

  • point (int) -- The point.
  • value (int) -- The point value.

None

SEE ALSO:

petsc.DMLabelClearValue


Source code at petsc4py/PETSc/DMLabel.pyx:199


Create an index structure for membership determination.

Not collective.

Automatically determines the bounds.

SEE ALSO:

petsc.DMLabelComputeIndex


Source code at petsc4py/PETSc/DMLabel.pyx:422



Return a Section and IS that encode the label.

Not collective.

SEE ALSO:

petsc.DMLabelConvertToSection


Source code at petsc4py/PETSc/DMLabel.pyx:605

tuple[Section, IS]


Create a DMLabel object, which is a multimap.

Collective.

  • name (str) -- The label name.
  • comm (Comm | None) -- MPI communicator, defaults to COMM_SELF.

Self

SEE ALSO:

petsc.DMLabelCreate


Source code at petsc4py/PETSc/DMLabel.pyx:40


Create an index structure for membership determination.

Not collective.

  • pStart (int) -- The smallest point.
  • pEnd (int) -- The largest point + 1.

None

SEE ALSO:

destroyIndex, petsc.DMLabelCreateIndex


Source code at petsc4py/PETSc/DMLabel.pyx:436


Destroy the label.

Collective.

SEE ALSO:

petsc.DMLabelDestroy


Source code at petsc4py/PETSc/DMLabel.pyx:8



Destroy the index structure.

Not collective.

SEE ALSO:

createIndex, petsc.DMLabelDestroyIndex


Source code at petsc4py/PETSc/DMLabel.pyx:456



Create a new label pushed forward over the SF.

Collective.

sf (SF) -- The map from old to new distribution.
DMLabel

SEE ALSO:

gather, petsc.DMLabelDistribute


Source code at petsc4py/PETSc/DMLabel.pyx:565


Duplicate the DMLabel.

Collective.

SEE ALSO:

petsc.DMLabelDuplicate


Source code at petsc4py/PETSc/DMLabel.pyx:65

DMLabel


Remove all points outside of [start, end).

Not collective.

  • start (int) -- The first point kept.
  • end (int) -- One more than the last point kept.

None

SEE ALSO:

petsc.DMLabelFilter


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


Gather all label values from leaves into roots.

Collective.

This is the inverse operation to distribute.

sf (SF) -- The SF communication map.
DMLabel

SEE ALSO:

distribute, petsc.DMLabelGather


Source code at petsc4py/PETSc/DMLabel.pyx:584


Return the smallest and largest point in the label.

Not collective.

The returned values are the smallest point and the largest point + 1.

SEE ALSO:

petsc.DMLabelGetBounds


Source code at petsc4py/PETSc/DMLabel.pyx:510

tuple[int, int]


Return the default value returned by getValue.

Not collective.

The default value is returned if a point has not been explicitly given a value. When a label is created, it is initialized to -1.

SEE ALSO:

setDefaultValue, petsc.DMLabelGetDefaultValue


Source code at petsc4py/PETSc/DMLabel.pyx:161



Return an IS of all values that the DMLabel takes.

Not collective.

SEE ALSO:

petsc.DMLabelGetNonEmptyStratumValuesIS


Source code at petsc4py/PETSc/DMLabel.pyx:620



Return the number of values that the DMLabel takes.

Not collective.

SEE ALSO:

petsc.DMLabelGetNumValues


Source code at petsc4py/PETSc/DMLabel.pyx:273



Return an IS with the stratum points.

Not collective.

stratum (int) -- The stratum value.
IS

SEE ALSO:

setStratumIS, petsc.DMLabelGetStratumIS


Source code at petsc4py/PETSc/DMLabel.pyx:364


Return the size of a stratum.

Not collective.

stratum (int) -- The stratum value.
int

SEE ALSO:

petsc.DMLabelGetStratumSize


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


Return the value a label assigns to a point.

Not collective.

If no value was assigned, a default value will be returned The default value, initially -1, can be changed with setDefaultValue.

point (int) -- The point.
int

SEE ALSO:

setValue, setDefaultValue, petsc.DMLabelGetValue


Source code at petsc4py/PETSc/DMLabel.pyx:137


Return an IS of all values that the DMLabel takes.

Not collective.

SEE ALSO:

petsc.DMLabelGetValueIS


Source code at petsc4py/PETSc/DMLabel.pyx:287



Determine whether the label contains a point.

Not collective.

The user must call createIndex before this function.

point (int) -- The point.
bool

SEE ALSO:

hasValue, petsc.DMLabelHasPoint


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


Determine whether points exist with the given value.

Not collective.

value (int) -- The stratum value.
bool

SEE ALSO:

petsc.DMLabelHasStratum


Source code at petsc4py/PETSc/DMLabel.pyx:324


Determine whether a label assigns the value to any point.

Not collective.

value (int) -- The value.
bool

SEE ALSO:

hasPoint, petsc.DMLabelHasValue


Source code at petsc4py/PETSc/DMLabel.pyx:468


Set all points in the IS to a value.

Not collective.

  • iset (IS) -- The point IS.
  • value (int) -- The point value.

Self

SEE ALSO:

petsc.DMLabelInsertIS


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


Create a new label with permuted points.

Not collective.

permutation (IS) -- The point permutation.
DMLabel

SEE ALSO:

petsc.DMLabelPermute


Source code at petsc4py/PETSc/DMLabel.pyx:546


Destroy internal data structures in the DMLabel.

Not collective.

SEE ALSO:

petsc.DMLabelReset


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



Set the default value returned by getValue.

Not collective.

The value is used if a point has not been explicitly given a value. When a label is created, the default value is initialized to -1.

value (int) -- The default value.
None

SEE ALSO:

getDefaultValue, petsc.DMLabelSetDefaultValue


Source code at petsc4py/PETSc/DMLabel.pyx:178


Set the stratum points using an IS.

Not collective.

  • stratum (int) -- The stratum value.
  • iset (IS) -- The stratum points.

None

SEE ALSO:

getStratumIS, petsc.DMLabelSetStratumIS


Source code at petsc4py/PETSc/DMLabel.pyx:384


Set the value a label assigns to a point.

Not collective.

If the value is the same as the label's default value (which is initially -1, and can be changed with setDefaultValue), this function will do nothing.

  • point (int) -- The point.
  • value (int) -- The point value.

None

SEE ALSO:

getValue, setDefaultValue, petsc.DMLabelSetValue


Source code at petsc4py/PETSc/DMLabel.pyx:112


Return whether the stratum contains a point.

Not collective.

  • value (int) -- The stratum value.
  • point (int) -- The point.

bool

SEE ALSO:

petsc.DMLabelStratumHasPoint


Source code at petsc4py/PETSc/DMLabel.pyx:301


View the label.

Collective.

viewer (Viewer | None) -- A Viewer to display the graph.
None

SEE ALSO:

petsc.DMLabelView


Source code at petsc4py/PETSc/DMLabel.pyx:21



petsc4py.PETSc.DMPlex

Bases: DM

Encapsulate an unstructured mesh.

DMPlex encapsulates both topology and geometry. It is capable of parallel refinement and coarsening (using Pragmatic or ParMmg) and parallel redistribution for load balancing. It is designed to interface with the FE and FV trial discretization objects.

Enumerations

ReorderDefaultFlag

petsc4py.PETSc.DMPlex.ReorderDefaultFlag

Bases: object

Attributes Summary

FALSE Constant FALSE of type int
NOTSET Constant NOTSET of type int
TRUE Constant TRUE of type int

Attributes Documentation

Constant FALSE of type int

Constant NOTSET of type int

Constant TRUE of type int


Methods Summary

computeCellGeometryFVM(cell) Compute the volume for a given cell.
computeGradientClementInterpolant(locX, locC) Return the L2 projection of the cellwise gradient of a function onto P1.
constructGhostCells([labelName]) Construct ghost cells which connect to every boundary face.
coordinatesLoad(viewer, sfxc) Load coordinates into this DMPlex object.
coordinatesView(viewer) Save DMPlex coordinates into a file.
create([comm]) Create a DMPlex object, which encapsulates an unstructured mesh.
createBoxMesh(faces[, lower, upper, ...]) Create a mesh on the tensor product of intervals.
createBoxSurfaceMesh(faces[, lower, upper, ...]) Create a mesh on the surface of a box mesh using tensor cells.
createCGNS(cgid[, interpolate, comm]) Create a DMPlex mesh from a CGNS file.
createCGNSFromFile(filename[, interpolate, comm]) "Create a DMPlex mesh from a CGNS file.
createClosureIndex(sec) Calculate an index for sec for the closure operation.
createCoarsePointIS() Create an IS covering the coarse DMPlex chart with the fine points as data.
createCohesiveSubmesh(hasLagrange, value) Extract the hypersurface defined by one face of the cohesive cells.
createExodus(exoid[, interpolate, comm]) Create a DMPlex mesh from an ExodusII file ID.
createExodusFromFile(filename[, ...]) Create a DMPlex mesh from an ExodusII file.
createFromCellList(dim, cells, coords[, ...]) Create a DMPlex from a list of vertices for each cell on process 0.
createFromFile(filename[, plexname, ...]) Create DMPlex from a file.
createGmsh(viewer[, interpolate, comm]) Create a DMPlex mesh from a Gmsh file viewer.
createPointNumbering() Create a global numbering for all points.
createSection(numComp, numDof[, bcField, ...]) Create a Section based upon the DOF layout specification provided.
distribute([overlap]) Distribute the mesh and any associated sections.
distributeField(sf, sec, vec[, newsec, newvec]) Distribute field data with a with a given SF.
distributeGetDefault() Return a flag indicating whether the DM should be distributed by default.
distributeOverlap([overlap]) Add partition overlap to a distributed non-overlapping DMPlex.
distributeSetDefault(flag) Set flag indicating whether the DMPlex should be distributed by default.
distributionGetName() Retrieve the name of the specific parallel distribution.
distributionSetName(name) Set the name of the specific parallel distribution.
generate(boundary[, name, interpolate]) Generate a mesh.
getAdjacency(p) Return all points adjacent to the given point.
getAdjacencyUseAnchors() Query whether adjacency in the mesh uses the point-to-point constraints.
getCellNumbering() Return a global cell numbering for all cells on this process.
getCellType(p) Return the polytope type of a given cell.
getCellTypeLabel() Return the DMLabel recording the polytope type of each cell.
getChart() Return the interval for all mesh points [pStart, pEnd).
getCone(p) Return the points on the in-edges for this point in the DAG.
getConeOrientation(p) Return the orientations on the in-edges for this point in the DAG.
getConeSize(p) Return the number of in-edges for this point in the DAG.
getDepth() Return the depth of the DAG representing this mesh.
getDepthStratum(svalue) Return the bounds [start, end) for all points at a certain depth.
getFullJoin(points) Return an array for the join of the set of points.
getHeightStratum(svalue) Return the bounds [start, end) for all points at a certain height.
getJoin(points) Return an array for the join of the set of points.
getMaxSizes() Return the maximum number of in-edges and out-edges of the DAG.
getMeet(points) Return an array for the meet of the set of points.
getMinRadius() Return the minimum distance from any cell centroid to a face.
getOrdering(otype) Calculate a reordering of the mesh.
getPartitioner() Return the mesh partitioner.
getPointDepth(point) Return the depth of a given point.
getPointGlobal(point) Return location of point data in global Vec.
getPointGlobalField(point, field) Return location of point field data in global Vec.
getPointHeight(point) Return the height of a given point.
getPointLocal(point) Return location of point data in local Vec.
getPointLocalField(point, field) Return location of point field data in local Vec.
getRefinementLimit() Retrieve the maximum cell volume for refinement.
getRefinementUniform() Retrieve the flag for uniform refinement.
getSupport(p) Return the points on the out-edges for this point in the DAG.
getSupportSize(p) Return the number of out-edges for this point in the DAG.
getTransitiveClosure(p[, useCone]) Return the points and orientations on the transitive closure of this point.
getVecClosure(sec, vec, point) Return an array of the values on the closure of a point.
getVertexNumbering() Return a global vertex numbering for all vertices on this process.
globalVectorLoad(viewer, sectiondm, sf, vec) Load on-disk vector data into a global vector.
globalVectorView(viewer, sectiondm, vec) Save a global vector.
insertCone(p, conePos, conePoint) DMPlexInsertCone - Insert a point into the in-edges for the point p in the DAG.
insertConeOrientation(p, conePos, ...) Insert a point orientation for the in-edge for the point p in the DAG.
interpolate() Convert to a mesh with all intermediate faces, edges, etc.
isDistributed() Return the flag indicating if the mesh is distributed.
isSimplex() Return the flag indicating if the first cell is a simplex.
labelCohesiveComplete(label, bdlabel, ...) Add all other mesh pieces to complete the surface.
labelComplete(label) Add the transitive closure to the surface.
labelsLoad(viewer, sfxc) Load labels into this DMPlex object.
labelsView(viewer) Save DMPlex labels into a file.
localVectorLoad(viewer, sectiondm, sf, vec) Load on-disk vector data into a local vector.
localVectorView(viewer, sectiondm, vec) Save a local vector.
markBoundaryFaces(label[, value]) Mark all faces on the boundary.
metricAverage2(metric1, metric2, metricAvg) Compute and return the unweighted average of two metrics.
metricAverage3(metric1, metric2, metric3, ...) Compute and return the unweighted average of three metrics.
metricCreate([field]) Create a Riemannian metric field.
metricCreateIsotropic(indicator[, field]) Construct an isotropic metric from an error indicator.
metricCreateUniform(alpha[, field]) Construct a uniform isotropic metric.
metricDeterminantCreate([field]) Create the determinant field for a Riemannian metric.
metricEnforceSPD(metric, ometric, determinant) Enforce symmetric positive-definiteness of a metric.
metricGetGradationFactor() Return the metric gradation factor.
metricGetHausdorffNumber() Return the metric Hausdorff number.
metricGetMaximumAnisotropy() Return the maximum tolerated metric anisotropy.
metricGetMaximumMagnitude() Return the maximum tolerated metric magnitude.
metricGetMinimumMagnitude() Return the minimum tolerated metric magnitude.
metricGetNormalizationOrder() Return the order p for L-p normalization.
metricGetNumIterations() Return the number of parallel adaptation iterations.
metricGetTargetComplexity() Return the target metric complexity.
metricGetVerbosity() Return the verbosity of the mesh adaptation package.
metricIntersection2(metric1, metric2, metricInt) Compute and return the intersection of two metrics.
metricIntersection3(metric1, metric2, ...) Compute the intersection of three metrics.
metricIsIsotropic() Return the flag indicating whether the metric is isotropic or not.
metricIsUniform() Return the flag indicating whether the metric is uniform or not.
metricNoInsertion() Return the flag indicating whether node insertion and deletion are turned off.
metricNoMovement() Return the flag indicating whether node movement is turned off.
metricNoSurf() Return the flag indicating whether surface modification is turned off.
metricNoSwapping() Return the flag indicating whether facet swapping is turned off.
metricNormalize(metric, ometric, determinant) Apply L-p normalization to a metric.
metricRestrictAnisotropyFirst() Return true if anisotropy is restricted before normalization.
metricSetFromOptions() Source code at petsc4py/PETSc/DMPlex.pyx:2240
metricSetGradationFactor(beta) Set the metric gradation factor.
metricSetHausdorffNumber(hausd) Set the metric Hausdorff number.
metricSetIsotropic(isotropic) Record whether the metric is isotropic or not.
metricSetMaximumAnisotropy(a_max) Set the maximum tolerated metric anisotropy.
metricSetMaximumMagnitude(h_max) Set the maximum tolerated metric magnitude.
metricSetMinimumMagnitude(h_min) Set the minimum tolerated metric magnitude.
metricSetNoInsertion(noInsert) Set the flag indicating whether node insertion should be turned off.
metricSetNoMovement(noMove) Set the flag indicating whether node movement should be turned off.
metricSetNoSurf(noSurf) Set the flag indicating whether surface modification should be turned off.
metricSetNoSwapping(noSwap) Set the flag indicating whether facet swapping should be turned off.
metricSetNormalizationOrder(p) Set the order p for L-p normalization.
metricSetNumIterations(numIter) Set the number of parallel adaptation iterations.
metricSetRestrictAnisotropyFirst(...) Record whether anisotropy is be restricted before normalization or after.
metricSetTargetComplexity(targetComplexity) Set the target metric complexity.
metricSetUniform(uniform) Record whether the metric is uniform or not.
metricSetVerbosity(verbosity) Set the verbosity of the mesh adaptation package.
orient() Give a consistent orientation to the input mesh.
permute(perm) Reorder the mesh according to the input permutation.
rebalanceSharedPoints([entityDepth, ...]) Redistribute shared points in order to achieve better balancing.
reorderGetDefault() Return flag indicating whether the DMPlex should be reordered by default.
reorderSetDefault(flag) Set flag indicating whether the DM should be reordered by default.
sectionLoad(viewer, sectiondm, sfxc) Load section into a DM.
sectionView(viewer, sectiondm) Save a section associated with a DMPlex.
setAdjacencyUseAnchors([useAnchors]) Define adjacency in the mesh using the point-to-point constraints.
setCellType(p, ctype) Set the polytope type of a given cell.
setChart(pStart, pEnd) Set the interval for all mesh points [pStart, pEnd).
setCone(p, cone[, orientation]) Set the points on the in-edges for this point in the DAG.
setConeOrientation(p, orientation) Set the orientations on the in-edges for this point in the DAG.
setConeSize(p, size) Set the number of in-edges for this point in the DAG.
setMatClosure(sec, gsec, mat, point, values) Set an array of the values on the closure of point.
setPartitioner(part) Set the mesh partitioner.
setRefinementLimit(refinementLimit) Set the maximum cell volume for refinement.
setRefinementUniform([refinementUniform]) Set the flag for uniform refinement.
setSupport(p, supp) Set the points on the out-edges for this point in the DAG.
setSupportSize(p, size) Set the number of out-edges for this point in the DAG.
setTetGenOptions(opts) Set the options used for the Tetgen mesh generator.
setTriangleOptions(opts) Set the options used for the Triangle mesh generator.
setVecClosure(sec, vec, point, values[, addv]) Set an array of the values on the closure of point.
stratify() Calculate the strata of DAG.
symmetrize() Create support (out-edge) information from cone (in-edge) information.
topologyLoad(viewer) Load a topology into this DMPlex object.
topologyView(viewer) Save a DMPlex topology into a file.
uninterpolate() Convert to a mesh with only cells and vertices.
vecGetClosure(sec, vec, p) Return an array of values on the closure of p.

Methods Documentation

Compute the volume for a given cell.

Collective.

cell (int) -- The cell.
  • volume (float) -- The cell volume.
  • centroid (ArrayReal) -- The cell centroid.
  • normal (ArrayReal) -- The cell normal, if appropriate.

tuple[float, ArrayReal, ArrayReal]

SEE ALSO:

DMPlex, DM.getCoordinateSection, DM.getCoordinates, petsc.DMPlexComputeCellGeometryFVM


Source code at petsc4py/PETSc/DMPlex.pyx:2177


Return the L2 projection of the cellwise gradient of a function onto P1.

Collective.

  • locX (Vec) -- The coefficient vector of the function.
  • locC (Vec) -- The output Vec which holds the Clement interpolant of the gradient.

Vec

SEE ALSO:

DM, DMPlex, petsc.DMPlexComputeGradientClementInterpolant


Source code at petsc4py/PETSc/DMPlex.pyx:2978


Construct ghost cells which connect to every boundary face.

Collective.

labelName (str | None) -- The name of the label specifying the boundary faces. Defaults to "Face Sets".
numGhostCells -- The number of ghost cells added to the DMPlex.
int

SEE ALSO:

DM, DMPlex, DM.create, petsc.DMPlexConstructGhostCells


Source code at petsc4py/PETSc/DMPlex.pyx:2209


Load coordinates into this DMPlex object.

Collective.

  • viewer (Viewer) -- The Viewer for the saved coordinates.
  • sfxc (SF) -- The SF returned by topologyLoad.

None

SEE ALSO:

DM, DMPlex, DM.load, DMPlex.topologyLoad, DMPlex.labelsLoad, DM.view, SF, Viewer, petsc.DMPlexCoordinatesLoad


Source code at petsc4py/PETSc/DMPlex.pyx:3151


Save DMPlex coordinates into a file.

Collective.

viewer (Viewer) -- The Viewer for saving.
None

SEE ALSO:

DM, DMPlex, DM.view, DMPlex.topologyView, DMPlex.labelsView, DMPlex.coordinatesLoad, Viewer, petsc.DMPlexCoordinatesView


Source code at petsc4py/PETSc/DMPlex.pyx:3018


Create a DMPlex object, which encapsulates an unstructured mesh.

Collective.

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

SEE ALSO:

DM, DMPlex, DM.create, DM.setType, petsc.DMPlexCreate


Source code at petsc4py/PETSc/DMPlex.pyx:22


Create a mesh on the tensor product of intervals.

Collective.

  • faces (Sequence[int]) -- Number of faces per dimension, or None for the default.
  • lower (Sequence[float] | None) -- The lower left corner.
  • upper (Sequence[float] | None) -- The upper right corner.
  • simplex (bool | None) -- True for simplices, False for tensor cells.
  • periodic (Sequence | str | int | bool | None) -- The boundary type for the X,Y,Z direction, or None for DM.BoundaryType.NONE.
  • interpolate (bool | None) -- Flag to create intermediate mesh entities (edges, faces).
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

DM, DMPlex, DM.setFromOptions, DMPlex.createFromFile, DM.setType, DM.create, petsc.DMPlexCreateBoxMesh


Source code at petsc4py/PETSc/DMPlex.pyx:98


Create a mesh on the surface of a box mesh using tensor cells.

Collective.

  • faces (Sequence[int]) -- Number of faces per dimension, or None for the default.
  • lower (Sequence[float] | None) -- The lower left corner.
  • upper (Sequence[float] | None) -- The upper right corner.
  • interpolate (bool | None) -- Flag to create intermediate mesh pieces (edges, faces).
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

DM, DMPlex, DM.setFromOptions, DMPlex.createBoxMesh, DMPlex.createFromFile, DM.setType, DM.create, petsc.DMPlexCreateBoxSurfaceMesh


Source code at petsc4py/PETSc/DMPlex.pyx:149


Create a DMPlex mesh from a CGNS file.

Collective.

  • cgid (int) -- The CG id associated with a file and obtained using cg_open.
  • interpolate (bool | None) -- Create faces and edges in the mesh.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.createCGNSFromFile, DMPlex.createExodus, petsc.DMPlexCreateCGNS


Source code at petsc4py/PETSc/DMPlex.pyx:226


"Create a DMPlex mesh from a CGNS file.

Collective.

  • filename (str) -- The name of the CGNS file.
  • interpolate (bool | None) -- Create faces and edges in the mesh.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.createCGNS, DMPlex.createExodus, petsc.DMPlexCreateCGNS


Source code at petsc4py/PETSc/DMPlex.pyx:254


Calculate an index for sec for the closure operation.

Not collective.

sec (Section) -- The Section describing the layout in the local vector, or None to use the default section.
None

SEE ALSO:

DM, DMPlex, Section, DMPlex.vecGetClosure, petsc.DMPlexCreateClosureIndex


Source code at petsc4py/PETSc/DMPlex.pyx:1999


Create an IS covering the coarse DMPlex chart with the fine points as data.

Collective.

fpointIS -- The IS of all the fine points which exist in the original coarse mesh.
IS

SEE ALSO:

DM, DMPlex, IS, DM.refine, DMPlex.setRefinementUniform, petsc.DMPlexCreateCoarsePointIS


Source code at petsc4py/PETSc/DMPlex.pyx:1786


Extract the hypersurface defined by one face of the cohesive cells.
  • hasLagrange (bool) -- Flag indicating whether the mesh has Lagrange dofs in the cohesive cells.
  • value (int) -- A label value.

DMPlex

SEE ALSO:

DM, DMPlex, petsc.DMPlexCreateCohesiveSubmesh


Source code at petsc4py/PETSc/DMPlex.pyx:377


Create a DMPlex mesh from an ExodusII file ID.

Collective.

  • exoid (int) -- The ExodusII id associated with a exodus file and obtained using ex_open.
  • interpolate (bool | None) -- Create faces and edges in the mesh,
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

DM, DMPlex, DM.create, petsc.DMPlexCreateExodus


Source code at petsc4py/PETSc/DMPlex.pyx:312


Create a DMPlex mesh from an ExodusII file.

Collective.

  • filename (str) -- The name of the ExodusII file.
  • interpolate (bool | None) -- Create faces and edges in the mesh.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

DM, DMPlex, DM.create, DMPlex.createExodus, petsc.DMPlexCreateExodusFromFile


Source code at petsc4py/PETSc/DMPlex.pyx:283


Create a DMPlex from a list of vertices for each cell on process 0.

Collective.

  • dim (int) -- The topological dimension of the mesh.
  • cells (Sequence[int]) -- An array of number of cells times number of vertices on each cell.
  • coords (Sequence[float]) -- An array of number of vertices times spatial dimension for coordinates.
  • interpolate (bool | None) -- Flag to interpolate the mesh.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.interpolate, petsc.DMPlexCreateFromCellListPetsc


Source code at petsc4py/PETSc/DMPlex.pyx:43


Create DMPlex from a file.

Collective.

  • filename (str) -- A file name.
  • plexname (str | None) -- The name of the resulting DMPlex, also used for intra-datafile lookup by some formats.
  • interpolate (bool | None) -- Flag to create intermediate mesh pieces (edges, faces).
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.


SEE ALSO:

DM, DMPlex, DMPlex.createFromCellList, DMPlex.create, Object.setName, DM.view, DM.load, Working with PETSc options (TODO), petsc.DMPlexCreateFromFile


Source code at petsc4py/PETSc/DMPlex.pyx:192


Create a DMPlex mesh from a Gmsh file viewer.

Collective.

  • viewer (Viewer) -- The Viewer associated with a Gmsh file.
  • interpolate (bool | None) -- Create faces and edges in the mesh.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

Notes

-dm_plex_gmsh_hybrid forces triangular prisms to use tensor order.

-dm_plex_gmsh_periodic allows for reading Gmsh periodic section.

-dm_plex_gmsh_highorder allows for generating high-order coordinates.

-dm_plex_gmsh_project projects high-order coordinates to a different space, use the prefix -dm_plex_gmsh_project_ to define the space.

-dm_plex_gmsh_use_regions generates labels with region names.

-dm_plex_gmsh_mark_vertices adds vertices to generated labels.

-dm_plex_gmsh_multiple_tags allows multiple tags for default labels.

-dm_plex_gmsh_spacedim <d> embedding space dimension.

SEE ALSO:

DM, DMPlex, DM.create, Working with PETSc options (TODO), petsc.DMPlexCreateGmsh


Source code at petsc4py/PETSc/DMPlex.pyx:339


Create a global numbering for all points.

Collective.

SEE ALSO:

DM, DMPlex, DMPlex.getCellNumbering, petsc.DMPlexCreatePointNumbering


Source code at petsc4py/PETSc/DMPlex.pyx:907



Create a Section based upon the DOF layout specification provided.

Not collective.

  • numComp (Sequence[int]) -- An array of size numFields holding the number of components per field.
  • numDof (Sequence[int]) -- An array of size numFields*(dim+1) holding the number of DOFs per field on a mesh piece of dimension dim.
  • bcField (Sequence[int] | None) -- An array of size numBC giving the field number for each boundary condition, where numBC is the number of boundary conditions.
  • bcComps (Sequence[IS] | None) -- An array of size numBC giving an IS holding the field components to which each boundary condition applies.
  • bcPoints (Sequence[IS] | None) -- An array of size numBC giving an IS holding the DMPlex points to which each boundary condition applies.
  • perm (IS | None) -- Permutation of the chart.

Section

SEE ALSO:

DM, DMPlex, DMPlex.create, Section.create, Section.setPermutation, petsc.DMPlexCreateSection


Source code at petsc4py/PETSc/DMPlex.pyx:1806


Distribute the mesh and any associated sections.

Collective.

overlap (int | None) -- The overlap of partitions.
sf -- The SF used for point distribution, or None if not distributed.
SF or None

SEE ALSO:

DM, DMPlex, DMPlex.create, petsc.DMPlexDistribute


Source code at petsc4py/PETSc/DMPlex.pyx:1536


Distribute field data with a with a given SF.

Collective.

  • sf (SF) -- The SF describing the communication pattern.
  • sec (Section) -- The Section for existing data layout.
  • vec (Vec) -- The existing data in a local vector.
  • newsec (Section | None) -- The SF describing the new data layout.
  • newvec (Vec | None) -- The new data in a local vector.

  • newSection (Section) -- The SF describing the new data layout.
  • newVec (Vec) -- The new data in a local vector.

tuple[Section, Vec]

SEE ALSO:

DMPlex, DMPlex.distribute, petsc.DMPlexDistributeField


Source code at petsc4py/PETSc/DMPlex.pyx:1727


Return a flag indicating whether the DM should be distributed by default.

Not collective.

dist -- Flag indicating whether the DMPlex should be distributed by default.
bool

SEE ALSO:

DM, DMPlex, DMPlex.distributeSetDefault, DMPlex.distribute, petsc.DMPlexDistributeGetDefault


Source code at petsc4py/PETSc/DMPlex.pyx:1620


Add partition overlap to a distributed non-overlapping DMPlex.

Collective.

overlap (int | None) -- The overlap of partitions (the same on all ranks).
sf -- The SF used for point distribution.
SF

SEE ALSO:

DM, DMPlex, SF, DMPlex.create, DMPlex.distribute, petsc.DMPlexDistributeOverlap


Source code at petsc4py/PETSc/DMPlex.pyx:1564


Set flag indicating whether the DMPlex should be distributed by default.

Logically collective.

flag (bool) -- Flag indicating whether the DMPlex should be distributed by default.
None

SEE ALSO:

DMPlex, DMPlex.distributeGetDefault, DMPlex.distribute, petsc.DMPlexDistributeSetDefault


Source code at petsc4py/PETSc/DMPlex.pyx:1640


Retrieve the name of the specific parallel distribution.
name -- The name of the specific parallel distribution.
str

SEE ALSO:

DMPlex, DMPlex.distributionSetName, DMPlex.topologyView, DMPlex.topologyLoad, petsc.DMPlexDistributionGetName


Source code at petsc4py/PETSc/DMPlex.pyx:1679


Set the name of the specific parallel distribution.
name (str) -- The name of the specific parallel distribution.
None

SEE ALSO:

DMPlex, DMPlex.distributionGetName, DMPlex.topologyView, DMPlex.topologyLoad, petsc.DMPlexDistributionSetName


Source code at petsc4py/PETSc/DMPlex.pyx:1660


Generate a mesh.

Not collective.

  • boundary (DMPlex) -- The DMPlex boundary object.
  • name (str | None) -- The mesh generation package name.
  • interpolate (bool | None) -- Flag to create intermediate mesh elements.

Self

SEE ALSO:

DM, DMPlex, DMPlex.create, DM.refine, Working with PETSc options (TODO), petsc.DMPlexGenerate


Source code at petsc4py/PETSc/DMPlex.pyx:1276


Return all points adjacent to the given point.
p (int) -- The point.
ArrayInt

SEE ALSO:

DMPlex, DMPlex.distribute, petsc.DMPlexGetAdjacency


Source code at petsc4py/PETSc/DMPlex.pyx:1446


Query whether adjacency in the mesh uses the point-to-point constraints.

SEE ALSO:

DMPlex, DMPlex.getAdjacency, DMPlex.distribute, petsc.DMPlexGetAdjacencyUseAnchors


Source code at petsc4py/PETSc/DMPlex.pyx:1433



Return a global cell numbering for all cells on this process.

SEE ALSO:

DM, DMPlex, DMPlex.getVertexNumbering, petsc.DMPlexGetCellNumbering


Source code at petsc4py/PETSc/DMPlex.pyx:881



Return the polytope type of a given cell.

Not collective.

p (int) -- The cell.
PolytopeType

SEE ALSO:

DM, DMPlex, DM.PolytopeType, DMPlex.getCellTypeLabel, DMPlex.getDepth, petsc.DMPlexGetCellType


Source code at petsc4py/PETSc/DMPlex.pyx:683


Return the DMLabel recording the polytope type of each cell.

Not collective.

SEE ALSO:

DM, DMPlex, DMPlex.getCellType, DM.createLabel, petsc.DMPlexGetCellTypeLabel


Source code at petsc4py/PETSc/DMPlex.pyx:704

DMLabel


Return the interval for all mesh points [pStart, pEnd).

Not collective.

  • pStart (int) -- The first mesh point.
  • pEnd (int) -- The upper bound for mesh points.

tuple[int, int]

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.setChart, petsc.DMPlexGetChart


Source code at petsc4py/PETSc/DMPlex.pyx:398


Return the points on the in-edges for this point in the DAG.

Not collective.

p (int) -- The point, which must lie in the chart set with DMPlex.setChart.
ArrayInt

SEE ALSO:

DM, DMPlex, DMPlex.getConeSize, DMPlex.setCone, DMPlex.setChart, petsc.DMPlexGetCone


Source code at petsc4py/PETSc/DMPlex.pyx:489


Return the orientations on the in-edges for this point in the DAG.

Not collective.

p (int) -- The point, which must lie in the chart set with DMPlex.setChart.
ArrayInt

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.getCone, DMPlex.setCone, DMPlex.setChart, petsc.DMPlexGetConeOrientation


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


Return the number of in-edges for this point in the DAG.

Not collective.

p (int) -- The point, which must lie in the chart set with DMPlex.setChart.
int

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.setConeSize, DMPlex.setChart, petsc.DMPlexGetConeSize


Source code at petsc4py/PETSc/DMPlex.pyx:440


Return the depth of the DAG representing this mesh.

Not collective.

SEE ALSO:

DM, DMPlex, DMPlex.getDepthStratum, DMPlex.symmetrize, petsc.DMPlexGetDepth


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



Return the bounds [start, end) for all points at a certain depth.

Not collective.

svalue (int) -- The requested depth.
  • pStart (int) -- The first stratum point.
  • pEnd (int) -- The upper bound for stratum points.

tuple[int, int]

SEE ALSO:

DM, DMPlex, DMPlex.getHeightStratum, DMPlex.getDepth, DMPlex.symmetrize, DMPlex.interpolate, petsc.DMPlexGetDepthStratum


Source code at petsc4py/PETSc/DMPlex.pyx:936


Return an array for the join of the set of points.

Not collective.

points (Sequence[int]) -- The input points.
ArrayInt

SEE ALSO:

DM, DMPlex, DMPlex.getJoin, DMPlex.getMeet, petsc.DMPlexGetFullJoin


Source code at petsc4py/PETSc/DMPlex.pyx:1084


Return the bounds [start, end) for all points at a certain height.

Not collective.

svalue (int) -- The requested height.
  • pStart (int) -- The first stratum point.
  • pEnd (int) -- The upper bound for stratum points.

tuple[int, int]

SEE ALSO:

DM, DMPlex, DMPlex.getDepthStratum, DMPlex.getDepth, petsc.DMPlexGetHeightStratum


Source code at petsc4py/PETSc/DMPlex.pyx:963


Return an array for the join of the set of points.

Not collective.

points (Sequence[int]) -- The input points.
ArrayInt

SEE ALSO:

DM, DMPlex, DMPlex.getMeet, petsc.DMPlexGetJoin


Source code at petsc4py/PETSc/DMPlex.pyx:1058


Return the maximum number of in-edges and out-edges of the DAG.

Not collective.

  • maxConeSize (int) -- The maximum number of in-edges.
  • maxSupportSize (int) -- The maximum number of out-edges.

tuple[int, int]

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.setConeSize, DMPlex.setChart, petsc.DMPlexGetMaxSizes


Source code at petsc4py/PETSc/DMPlex.pyx:824


Return an array for the meet of the set of points.

Not collective.

points (Sequence[int]) -- The input points.
ArrayInt

SEE ALSO:

DM, DMPlex, DMPlex.getJoin, petsc.DMPlexGetMeet


Source code at petsc4py/PETSc/DMPlex.pyx:1032


Return the minimum distance from any cell centroid to a face.

Not collective.

SEE ALSO:

DMPlex, DM.getCoordinates, petsc.DMPlexGetMinRadius


Source code at petsc4py/PETSc/DMPlex.pyx:1772

float


Calculate a reordering of the mesh.

Collective.

otype (OrderingType) -- Type of reordering, see Mat.OrderingType.
perm -- The point permutation.
IS

SEE ALSO:

DMPlex, DMPlex.permute, Mat.OrderingType, Mat.getOrdering, petsc.DMPlexGetOrdering


Source code at petsc4py/PETSc/DMPlex.pyx:2090


Return the mesh partitioner.

Not collective.

SEE ALSO:

DM, DMPlex, Partitioner, Section, DMPlex.distribute, DMPlex.setPartitioner, Partitioner.create, petsc.PetscPartitionerDMPlexPartition, petsc.DMPlexGetPartitioner


Source code at petsc4py/PETSc/DMPlex.pyx:1487

Partitioner


Return the depth of a given point.

Not collective.

point (int) -- The point.
int

SEE ALSO:

DM, DMPlex, DMPlex.getDepthStratum, DMPlex.getDepth, petsc.DMPlexGetPointDepth


Source code at petsc4py/PETSc/DMPlex.pyx:990


Return location of point data in global Vec.

Not collective.

point (int) -- The topological point.
  • start (int) -- Start of point data; returns -(globalStart+1) if point is not owned.
  • end (int) -- End of point data; returns -(globalEnd+1) if point is not owned.

tuple[int, int]

SEE ALSO:

DM, DMPlex, DMPlex.getPointGlobalField, Section.getOffset, Section.getDof, DMPlex.getPointLocal, petsc.DMPlexGetPointGlobal


Source code at petsc4py/PETSc/DMPlex.pyx:1940


Return location of point field data in global Vec.

Not collective.

  • point (int) -- The topological point.
  • field (int) -- The field number.

  • start (int) -- Start of point data; returns -(globalStart+1) if point is not owned.
  • end (int) -- End of point data; returns -(globalEnd+1) if point is not owned.

tuple[int, int]

SEE ALSO:

DM, DMPlex, DMPlex.getPointGlobal, Section.getOffset, Section.getDof, DMPlex.getPointLocal, petsc.DMPlexGetPointGlobalField


Source code at petsc4py/PETSc/DMPlex.pyx:1968


Return the height of a given point.

Not collective.

point (int) -- The point.
int

SEE ALSO:

DM, DMPlex, DMPlex.getHeightStratum, petsc.DMPlexGetPointHeight


Source code at petsc4py/PETSc/DMPlex.pyx:1011


Return location of point data in local Vec.

Not collective.

point (int) -- The topological point.
  • start (int) -- Start of point data.
  • end (int) -- End of point data.

tuple[int, int]

SEE ALSO:

DM, DMPlex, DMPlex.getPointLocalField, Section.getOffset, Section.getDof, petsc.DMPlexGetPointLocal


Source code at petsc4py/PETSc/DMPlex.pyx:1881


Return location of point field data in local Vec.

Not collective.

  • point (int) -- The topological point.
  • field (int) -- The field number.

  • start (int) -- Start of point data.
  • end (int) -- End of point data.

tuple[int, int]

SEE ALSO:

DM, DMPlex, DMPlex.getPointLocal, Section.getOffset, petsc.DMPlexGetPointLocalField


Source code at petsc4py/PETSc/DMPlex.pyx:1909


Retrieve the maximum cell volume for refinement.

SEE ALSO:

DM, DMPlex, DM.refine, DMPlex.setRefinementLimit, DMPlex.getRefinementUniform, DMPlex.setRefinementUniform, petsc.DMPlexGetRefinementLimit


Source code at petsc4py/PETSc/DMPlex.pyx:2076

float


Retrieve the flag for uniform refinement.
refinementUniform -- The flag for uniform refinement.
bool

SEE ALSO:

DM, DMPlex, DM.refine, DMPlex.setRefinementUniform, DMPlex.getRefinementLimit, DMPlex.setRefinementLimit, petsc.DMPlexGetRefinementUniform


Source code at petsc4py/PETSc/DMPlex.pyx:2039


Return the points on the out-edges for this point in the DAG.

Not collective.

p (int) -- The point, which must lie in the chart set with DMPlex.setChart.
ArrayInt

SEE ALSO:

DM, DMPlex, DMPlex.getSupportSize, DMPlex.setSupport, DMPlex.getCone, DMPlex.setChart, petsc.DMPlexGetSupport


Source code at petsc4py/PETSc/DMPlex.pyx:769


Return the number of out-edges for this point in the DAG.

Not collective.

p (int) -- The point, which must lie in the chart set with DMPlex.setChart.
int

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.setConeSize, DMPlex.setChart, DMPlex.getConeSize, petsc.DMPlexGetSupportSize


Source code at petsc4py/PETSc/DMPlex.pyx:720


Return the points and orientations on the transitive closure of this point.

Not collective.

  • p (int) -- The mesh point.
  • useCone (bool | None) -- True for the closure, otherwise return the star.

  • points (ArrayInt) -- The points.
  • orientations (ArrayInt) -- The orientations.

tuple[ArrayInt, ArrayInt]

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.setCone, DMPlex.setChart, DMPlex.getCone, petsc.DMPlexGetTransitiveClosure


Source code at petsc4py/PETSc/DMPlex.pyx:1110


Return an array of the values on the closure of a point.

Not collective.

  • sec (Section) -- The Section describing the layout in vec or None to use the default section.
  • vec (Vec) -- The local vector.
  • point (int) -- The point in the DMPlex.

ArrayScalar

SEE ALSO:

DM, DMPlex, petsc.DMPlexVecRestoreClosure


Source code at petsc4py/PETSc/DMPlex.pyx:1177


Return a global vertex numbering for all vertices on this process.

SEE ALSO:

DM, DMPlex, DMPlex.getCellNumbering, petsc.DMPlexGetVertexNumbering


Source code at petsc4py/PETSc/DMPlex.pyx:894



Load on-disk vector data into a global vector.

Collective.

  • viewer (Viewer) -- The Viewer that represents the on-disk vector data.
  • sectiondm (DM) -- The DM that contains the global section on which vec is defined.
  • sf (SF) -- The SF that migrates the on-disk vector data into vec.
  • vec (Vec) -- The global vector to set values of.

None

SEE ALSO:

DM, DMPlex, DMPlex.topologyLoad, DMPlex.sectionLoad, DMPlex.localVectorLoad, DMPlex.globalVectorView, DMPlex.localVectorView, SF, Viewer, petsc.DMPlexGlobalVectorLoad


Source code at petsc4py/PETSc/DMPlex.pyx:3228


Save a global vector.

Collective.

  • viewer (Viewer) -- The Viewer to save data with.
  • sectiondm (DM) -- The DM containing the global section on which vec is defined; may be the same as this DMPlex object.
  • vec (Vec) -- The global vector to be saved.

None

SEE ALSO:

DM, DMPlex, DMPlex.topologyView, DMPlex.sectionView, DMPlex.localVectorView, DMPlex.globalVectorLoad, DMPlex.localVectorLoad, petsc.DMPlexGlobalVectorView


Source code at petsc4py/PETSc/DMPlex.pyx:3075


DMPlexInsertCone - Insert a point into the in-edges for the point p in the DAG.

Not collective.

  • p (int) -- The point, which must lie in the chart set with DMPlex.setChart.
  • conePos (int) -- The local index in the cone where the point should be put.
  • conePoint (int) -- The mesh point to insert.

None

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.getCone, DMPlex.setChart, DMPlex.setConeSize, DM.setUp, petsc.DMPlexInsertCone


Source code at petsc4py/PETSc/DMPlex.pyx:554


Insert a point orientation for the in-edge for the point p in the DAG.

Not collective.

  • p (int) -- The point, which must lie in the chart set with DMPlex.setChart
  • conePos (int) -- The local index in the cone where the point should be put.
  • coneOrientation (int) -- The point orientation to insert.

None

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.getCone, DMPlex.setChart, DMPlex.setConeSize, DM.setUp, petsc.DMPlexInsertConeOrientation


Source code at petsc4py/PETSc/DMPlex.pyx:579


Convert to a mesh with all intermediate faces, edges, etc.

Collective.

SEE ALSO:

DMPlex, DMPlex.uninterpolate, DMPlex.createFromCellList, petsc.DMPlexInterpolate


Source code at petsc4py/PETSc/DMPlex.pyx:1697



Return the flag indicating if the mesh is distributed.

Collective.

SEE ALSO:

DM, DMPlex, DMPlex.distribute, petsc.DMPlexIsDistributed


Source code at petsc4py/PETSc/DMPlex.pyx:1593



Return the flag indicating if the first cell is a simplex.

SEE ALSO:

DM, DMPlex, DMPlex.getCellType, DMPlex.getHeightStratum, petsc.DMPlexIsSimplex


Source code at petsc4py/PETSc/DMPlex.pyx:1607



Add all other mesh pieces to complete the surface.
  • label (DMLabel) -- A DMLabel marking the surface.
  • bdlabel (DMLabel) -- A DMLabel marking the vertices on the boundary which will not be duplicated.
  • bdvalue (int) -- Value of DMLabel marking the vertices on the boundary.
  • flip (bool) -- Flag to flip the submesh normal and replace points on the other side.
  • subdm (DMPlex) -- The DMPlex associated with the label.

None

SEE ALSO:

DM, DMPlex, DMPlex.labelComplete, petsc.DMPlexLabelCohesiveComplete


Source code at petsc4py/PETSc/DMPlex.pyx:1386


Add the transitive closure to the surface.
label (DMLabel) -- A DMLabel marking the surface points.
None

SEE ALSO:

DM, DMPlex, DMPlex.labelCohesiveComplete, petsc.DMPlexLabelComplete


Source code at petsc4py/PETSc/DMPlex.pyx:1371


Load labels into this DMPlex object.

Collective.

  • viewer (Viewer) -- The Viewer for the saved labels.
  • sfxc (SF) -- The SF returned by topologyLoad.

None

SEE ALSO:

DM, DMPlex, DM.load, DMPlex.topologyLoad, DMPlex.coordinatesLoad, DM.view, SF, Viewer, petsc.DMPlexLabelsLoad


Source code at petsc4py/PETSc/DMPlex.pyx:3171


Save DMPlex labels into a file.

Collective.

viewer (Viewer) -- The Viewer for saving.
None

SEE ALSO:

DM, DMPlex, DM.view, DMPlex.topologyView, DMPlex.coordinatesView, DMPlex.labelsLoad, Viewer, petsc.DMPlexLabelsView


Source code at petsc4py/PETSc/DMPlex.pyx:3036


Load on-disk vector data into a local vector.

Collective.

  • viewer (Viewer) -- The Viewer that represents the on-disk vector data.
  • sectiondm (DM) -- The DM that contains the local section on which vec is defined.
  • sf (SF) -- The SF that migrates the on-disk vector data into vec.
  • vec (Vec) -- The local vector to set values of.

None

SEE ALSO:

DM, DMPlex, DMPlex.topologyLoad, DMPlex.sectionLoad, DMPlex.globalVectorLoad, DMPlex.globalVectorView, DMPlex.localVectorView, SF, Viewer, petsc.DMPlexLocalVectorLoad


Source code at petsc4py/PETSc/DMPlex.pyx:3253


Save a local vector.

Collective.

  • viewer (Viewer) -- The Viewer to save data with.
  • sectiondm (DM) -- The DM that contains the local section on which vec is defined; may be the same as this DMPlex object.
  • vec (Vec) -- The local vector to be saved.

None

SEE ALSO:

DM, DMPlex, DMPlex.topologyView, DMPlex.sectionView, DMPlex.globalVectorView, DMPlex.globalVectorLoad, DMPlex.localVectorLoad, petsc.DMPlexLocalVectorView


Source code at petsc4py/PETSc/DMPlex.pyx:3099


Mark all faces on the boundary.

Not collective.

  • value (int | None) -- The marker value, or DETERMINE or None to use some value in the closure (or 1 if none are found).
  • label (str) --

DMLabel

SEE ALSO:

DM, DMPlex, DMLabel.create, DM.createLabel, petsc.DMPlexMarkBoundaryFaces


Source code at petsc4py/PETSc/DMPlex.pyx:1344


Compute and return the unweighted average of two metrics.
  • metric1 (Vec) -- The first metric to be averaged.
  • metric2 (Vec) -- The second metric to be averaged.
  • metricAvg (Vec) -- The output averaged metric.

Vec

SEE ALSO:

DMPlex.metricAverage3, petsc.DMPlexMetricAverage2


Source code at petsc4py/PETSc/DMPlex.pyx:2894


Compute and return the unweighted average of three metrics.
  • metric1 (Vec) -- The first metric to be averaged.
  • metric2 (Vec) -- The second metric to be averaged.
  • metric3 (Vec) -- The third metric to be averaged.
  • metricAvg (Vec) -- The output averaged metric.

Vec

SEE ALSO:

DMPlex.metricAverage2, petsc.DMPlexMetricAverage3


Source code at petsc4py/PETSc/DMPlex.pyx:2914


Create a Riemannian metric field.
field (int | None) -- The field number to use.
Vec

SEE ALSO:

DMPlex.metricCreateUniform, DMPlex.metricCreateIsotropic, Working with PETSc options (TODO), petsc.DMPlexMetricCreate


Source code at petsc4py/PETSc/DMPlex.pyx:2736


Construct an isotropic metric from an error indicator.
  • indicator (Vec) -- The error indicator.
  • field (int | None) -- The field number to use.

Vec

SEE ALSO:

DMPlex.metricCreate, DMPlex.metricCreateUniform, petsc.DMPlexMetricCreateIsotropic


Source code at petsc4py/PETSc/DMPlex.pyx:2777


Construct a uniform isotropic metric.
  • alpha (float) -- Scaling parameter for the diagonal.
  • field (int | None) -- The field number to use.

Vec

SEE ALSO:

DMPlex.metricCreate, DMPlex.metricCreateIsotropic, petsc.DMPlexMetricCreateUniform


Source code at petsc4py/PETSc/DMPlex.pyx:2755


Create the determinant field for a Riemannian metric.
field (int | None) -- The field number to use.
  • determinant (Vec) -- The determinant field.
  • dmDet (DM) -- The corresponding DM

tuple[Vec, DM]

SEE ALSO:

DMPlex.metricCreateUniform, DMPlex.metricCreateIsotropic, DMPlex.metricCreate, petsc.DMPlexMetricDeterminantCreate


Source code at petsc4py/PETSc/DMPlex.pyx:2798


Enforce symmetric positive-definiteness of a metric.
  • metric (Vec) -- The metric.
  • ometric (Vec) -- The output metric.
  • determinant (Vec) -- The output determinant.
  • restrictSizes (bool | None) -- Flag indicating whether maximum/minimum magnitudes should be enforced.
  • restrictAnisotropy (bool | None) -- Flag indicating whether maximum anisotropy should be enforced.

  • ometric (Vec) -- The output metric.
  • determinant (Vec) -- The output determinant.

tuple[Vec, Vec]

SEE ALSO:

DMPlex.metricNormalize, DMPlex.metricIntersection2, DMPlex.metricIntersection3, Working with PETSc options (TODO), petsc.DMPlexMetricEnforceSPD


Source code at petsc4py/PETSc/DMPlex.pyx:2825


Return the metric gradation factor.

SEE ALSO:

DMPlex.metricSetGradationFactor, DMPlex.metricGetHausdorffNumber, petsc.DMPlexMetricGetGradationFactor


Source code at petsc4py/PETSc/DMPlex.pyx:2693

float


Return the metric Hausdorff number.

SEE ALSO:

DMPlex.metricGetGradationFactor, DMPlex.metricSetHausdorffNumber, petsc.DMPlexMetricGetHausdorffNumber


Source code at petsc4py/PETSc/DMPlex.pyx:2723

float


Return the maximum tolerated metric anisotropy.

SEE ALSO:

DMPlex.metricSetMaximumAnisotropy, DMPlex.metricGetMaximumMagnitude, petsc.DMPlexMetricGetMaximumAnisotropy


Source code at petsc4py/PETSc/DMPlex.pyx:2603

float


Return the maximum tolerated metric magnitude.

SEE ALSO:

DMPlex.metricSetMaximumMagnitude, DMPlex.metricGetMinimumMagnitude, petsc.DMPlexMetricGetMaximumMagnitude


Source code at petsc4py/PETSc/DMPlex.pyx:2573

float


Return the minimum tolerated metric magnitude.

SEE ALSO:

DMPlex.metricSetMinimumMagnitude, DMPlex.metricGetMaximumMagnitude, petsc.DMPlexMetricGetMinimumMagnitude


Source code at petsc4py/PETSc/DMPlex.pyx:2543

float


Return the order p for L-p normalization.

SEE ALSO:

DMPlex.metricSetNormalizationOrder, DMPlex.metricGetTargetComplexity, petsc.DMPlexMetricGetNormalizationOrder


Source code at petsc4py/PETSc/DMPlex.pyx:2663

float


Return the number of parallel adaptation iterations.

SEE ALSO:

DMPlex.metricSetNumIterations, DMPlex.metricGetVerbosity, petsc.DMPlexMetricGetNumIterations


Source code at petsc4py/PETSc/DMPlex.pyx:2513



Return the target metric complexity.

SEE ALSO:

DMPlex.metricSetTargetComplexity, DMPlex.metricGetNormalizationOrder, petsc.DMPlexMetricGetTargetComplexity


Source code at petsc4py/PETSc/DMPlex.pyx:2633

float


Return the verbosity of the mesh adaptation package.
verbosity -- The verbosity, where -1 is silent and 10 is maximum.
int

SEE ALSO:

DMPlex.metricSetVerbosity, DMPlex.metricGetNumIterations, petsc.DMPlexMetricGetVerbosity


Source code at petsc4py/PETSc/DMPlex.pyx:2478


Compute and return the intersection of two metrics.
  • metric1 (Vec) -- The first metric to be intersected.
  • metric2 (Vec) -- The second metric to be intersected.
  • metricInt (Vec) -- The output intersected metric.

Vec

SEE ALSO:

DMPlex.metricIntersection3, petsc.DMPlexMetricIntersection2


Source code at petsc4py/PETSc/DMPlex.pyx:2936


Compute the intersection of three metrics.
  • metric1 (Vec) -- The first metric to be intersected.
  • metric2 (Vec) -- The second metric to be intersected.
  • metric3 (Vec) -- The third metric to be intersected.
  • metricInt (Vec) -- The output intersected metric.

Vec

SEE ALSO:

DMPlex.metricIntersection2, petsc.DMPlexMetricIntersection3


Source code at petsc4py/PETSc/DMPlex.pyx:2956


Return the flag indicating whether the metric is isotropic or not.

SEE ALSO:

DMPlex.metricSetIsotropic, DMPlex.metricIsUniform, DMPlex.metricRestrictAnisotropyFirst, petsc.DMPlexMetricIsIsotropic


Source code at petsc4py/PETSc/DMPlex.pyx:2290



Return the flag indicating whether the metric is uniform or not.

SEE ALSO:

DMPlex.metricSetUniform, DMPlex.metricRestrictAnisotropyFirst, petsc.DMPlexMetricIsUniform


Source code at petsc4py/PETSc/DMPlex.pyx:2260



Return the flag indicating whether node insertion and deletion are turned off.

SEE ALSO:

DMPlex.metricSetNoInsertion, DMPlex.metricNoSwapping, DMPlex.metricNoMovement, DMPlex.metricNoSurf, petsc.DMPlexMetricNoInsertion


Source code at petsc4py/PETSc/DMPlex.pyx:2351



Return the flag indicating whether node movement is turned off.

SEE ALSO:

DMPlex.metricSetNoMovement, DMPlex.metricNoInsertion, DMPlex.metricNoSwapping, DMPlex.metricNoSurf, petsc.DMPlexMetricNoMovement


Source code at petsc4py/PETSc/DMPlex.pyx:2415



Return the flag indicating whether surface modification is turned off.

SEE ALSO:

DMPlex.metricSetNoSurf, DMPlex.metricNoMovement, DMPlex.metricNoInsertion, DMPlex.metricNoSwapping, petsc.DMPlexMetricNoSurf


Source code at petsc4py/PETSc/DMPlex.pyx:2447



Return the flag indicating whether facet swapping is turned off.

SEE ALSO:

DMPlex.metricSetNoSwapping, DMPlex.metricNoInsertion, DMPlex.metricNoMovement, DMPlex.metricNoSurf, petsc.DMPlexMetricNoSwapping


Source code at petsc4py/PETSc/DMPlex.pyx:2383



Apply L-p normalization to a metric.
  • metric (Vec) -- The metric.
  • ometric (Vec) -- The output metric.
  • determinant (Vec) -- The output determinant.
  • restrictSizes (bool | None) -- Flag indicating whether maximum/minimum magnitudes should be enforced.
  • restrictAnisotropy (bool | None) -- Flag indicating whether maximum anisotropy should be enforced.

  • ometric (Vec) -- The output normalized metric.
  • determinant (Vec) -- The output determinant.

tuple[Vec, Vec]

SEE ALSO:

DMPlex.metricEnforceSPD, DMPlex.metricIntersection2, DMPlex.metricIntersection3, Working with PETSc options (TODO), petsc.DMPlexMetricNormalize


Source code at petsc4py/PETSc/DMPlex.pyx:2860


Return true if anisotropy is restricted before normalization.

SEE ALSO:

DMPlex.metricIsIsotropic, DMPlex.metricSetRestrictAnisotropyFirst, petsc.DMPlexMetricRestrictAnisotropyFirst


Source code at petsc4py/PETSc/DMPlex.pyx:2320



Source code at petsc4py/PETSc/DMPlex.pyx:2240


Set the metric gradation factor.
beta (float) -- The metric gradation factor.
None

SEE ALSO:

DMPlex.metricGetGradationFactor, DMPlex.metricSetHausdorffNumber, petsc.DMPlexMetricSetGradationFactor


Source code at petsc4py/PETSc/DMPlex.pyx:2676


Set the metric Hausdorff number.
hausd (float) -- The metric Hausdorff number.
None

SEE ALSO:

DMPlex.metricSetGradationFactor, DMPlex.metricGetHausdorffNumber, petsc.DMPlexMetricSetHausdorffNumber


Source code at petsc4py/PETSc/DMPlex.pyx:2706


Record whether the metric is isotropic or not.
isotropic (bool) -- Flag indicating whether the metric is isotropic or not.
None

SEE ALSO:

DMPlex.metricIsIsotropic, DMPlex.metricSetUniform, DMPlex.metricSetRestrictAnisotropyFirst, petsc.DMPlexMetricSetIsotropic


Source code at petsc4py/PETSc/DMPlex.pyx:2273


Set the maximum tolerated metric anisotropy.
a_max (float) -- The maximum tolerated metric anisotropy.
None

SEE ALSO:

DMPlex.metricGetMaximumAnisotropy, DMPlex.metricSetMaximumMagnitude, petsc.DMPlexMetricSetMaximumAnisotropy


Source code at petsc4py/PETSc/DMPlex.pyx:2586


Set the maximum tolerated metric magnitude.
h_max (float) -- The maximum tolerated metric magnitude.
None

SEE ALSO:

DMPlex.metricGetMaximumMagnitude, DMPlex.metricSetMinimumMagnitude, petsc.DMPlexMetricSetMaximumMagnitude


Source code at petsc4py/PETSc/DMPlex.pyx:2556


Set the minimum tolerated metric magnitude.
h_min (float) -- The minimum tolerated metric magnitude.
None

SEE ALSO:

DMPlex.metricGetMinimumMagnitude, DMPlex.metricSetMaximumMagnitude, petsc.DMPlexMetricSetMinimumMagnitude


Source code at petsc4py/PETSc/DMPlex.pyx:2526


Set the flag indicating whether node insertion should be turned off.
noInsert (bool) -- Flag indicating whether node insertion and deletion should be turned off.
None

SEE ALSO:

DMPlex.metricNoInsertion, DMPlex.metricSetNoSwapping, DMPlex.metricSetNoMovement, DMPlex.metricSetNoSurf, petsc.DMPlexMetricSetNoInsertion


Source code at petsc4py/PETSc/DMPlex.pyx:2333


Set the flag indicating whether node movement should be turned off.
noMove (bool) -- Flag indicating whether node movement should be turned off.
None

SEE ALSO:

DMPlex.metricNoMovement, DMPlex.metricSetNoInsertion, DMPlex.metricSetNoSwapping, DMPlex.metricSetNoSurf, petsc.DMPlexMetricSetNoMovement


Source code at petsc4py/PETSc/DMPlex.pyx:2397


Set the flag indicating whether surface modification should be turned off.
noSurf (bool) -- Flag indicating whether surface modification should be turned off.
None

SEE ALSO:

DMPlex.metricNoSurf, DMPlex.metricSetNoMovement, DMPlex.metricSetNoInsertion, DMPlex.metricSetNoSwapping, petsc.DMPlexMetricSetNoSurf


Source code at petsc4py/PETSc/DMPlex.pyx:2429


Set the flag indicating whether facet swapping should be turned off.
noSwap (bool) -- Flag indicating whether facet swapping should be turned off.
None

SEE ALSO:

DMPlex.metricNoSwapping, DMPlex.metricSetNoInsertion, DMPlex.metricSetNoMovement, DMPlex.metricSetNoSurf, petsc.DMPlexMetricSetNoSwapping


Source code at petsc4py/PETSc/DMPlex.pyx:2365


Set the order p for L-p normalization.
p (float) -- The normalization order.
None

SEE ALSO:

DMPlex.metricGetNormalizationOrder, DMPlex.metricSetTargetComplexity, petsc.DMPlexMetricSetNormalizationOrder


Source code at petsc4py/PETSc/DMPlex.pyx:2646


Set the number of parallel adaptation iterations.
numIter (int) -- The number of parallel adaptation iterations.
None

SEE ALSO:

DMPlex.metricSetVerbosity, DMPlex.metricGetNumIterations, petsc.DMPlexMetricSetNumIterations


Source code at petsc4py/PETSc/DMPlex.pyx:2496


Record whether anisotropy is be restricted before normalization or after.
restrictAnisotropyFirst (bool) -- Flag indicating if anisotropy is restricted before normalization or after.
None

SEE ALSO:

DMPlex.metricSetIsotropic, DMPlex.metricRestrictAnisotropyFirst, petsc.DMPlexMetricSetRestrictAnisotropyFirst


Source code at petsc4py/PETSc/DMPlex.pyx:2303


Set the target metric complexity.
targetComplexity (float) -- The target metric complexity.
None

SEE ALSO:

DMPlex.metricGetTargetComplexity, DMPlex.metricSetNormalizationOrder, petsc.DMPlexMetricSetTargetComplexity


Source code at petsc4py/PETSc/DMPlex.pyx:2616


Record whether the metric is uniform or not.
uniform (bool) -- Flag indicating whether the metric is uniform or not.
None

SEE ALSO:

DMPlex.metricIsUniform, DMPlex.metricSetIsotropic, DMPlex.metricSetRestrictAnisotropyFirst, petsc.DMPlexMetricSetUniform


Source code at petsc4py/PETSc/DMPlex.pyx:2243


Set the verbosity of the mesh adaptation package.
verbosity (int) -- The verbosity, where -1 is silent and 10 is maximum.
None

SEE ALSO:

DMPlex.metricGetVerbosity, DMPlex.metricSetNumIterations, petsc.DMPlexMetricSetVerbosity


Source code at petsc4py/PETSc/DMPlex.pyx:2461


Give a consistent orientation to the input mesh.

SEE ALSO:

DM, DMPlex, DM.create, petsc.DMPlexOrient


Source code at petsc4py/PETSc/DMPlex.pyx:871



Reorder the mesh according to the input permutation.

Collective.

perm (IS) -- The point permutation, perm[old point number] = new point number.
pdm -- The permuted DMPlex.
DMPlex

SEE ALSO:

DMPlex, Mat.permute, petsc.DMPlexPermute


Source code at petsc4py/PETSc/DMPlex.pyx:2118


Redistribute shared points in order to achieve better balancing.
  • entityDepth (int | None) -- Depth of the entity to balance (e.g., 0 -> balance vertices).
  • useInitialGuess (bool | None) -- Whether to use the current distribution as initial guess.
  • parallel (bool | None) -- Whether to use ParMETIS and do the partition in parallel or gather the graph onto a single process.

success -- Whether the graph partitioning was successful or not. Unsuccessful simply means no change to the partitioning.
bool

SEE ALSO:

DM, DMPlex, DMPlex.distribute, Working with PETSc options (TODO), petsc.DMPlexRebalanceSharedPoints


Source code at petsc4py/PETSc/DMPlex.pyx:1504


Return flag indicating whether the DMPlex should be reordered by default.

Not collective.

SEE ALSO:

None, petsc.DMPlexReorderGetDefault


Source code at petsc4py/PETSc/DMPlex.pyx:2142

ReorderDefaultFlag


Set flag indicating whether the DM should be reordered by default.

Logically collective.

  • reorder -- Flag for reordering.
  • flag (ReorderDefaultFlag) --


SEE ALSO:

DMPlex.reorderGetDefault, petsc.DMPlexReorderSetDefault


Source code at petsc4py/PETSc/DMPlex.pyx:2156


Load section into a DM.

Collective.

  • viewer (Viewer) -- The Viewer that represents the on-disk section (sectionA).
  • sectiondm (DM) -- The DM into which the on-disk section (sectionA) is migrated.
  • sfxc (SF) -- The SF returned by topologyLoad.

  • gsf (SF) -- The SF that migrates any on-disk Vec data associated with sectionA into a global Vec associated with the sectiondm's global section (None if not needed).
  • lsf (SF) -- The SF that migrates any on-disk Vec data associated with sectionA into a local Vec associated with the sectiondm's local section (None if not needed).

tuple[SF, SF]

SEE ALSO:

DM, DMPlex, DM.load, DMPlex.topologyLoad, DMPlex.coordinatesLoad, DMPlex.labelsLoad, DMPlex.globalVectorLoad, DMPlex.localVectorLoad, DMPlex.sectionView, SF, Viewer, petsc.DMPlexSectionLoad


Source code at petsc4py/PETSc/DMPlex.pyx:3191


Save a section associated with a DMPlex.

Collective.

  • viewer (Viewer) -- The Viewer for saving.
  • sectiondm (DM) -- The DM that contains the section to be saved.

None

SEE ALSO:

DM, DMPlex, DM.view, DMPlex.topologyView, DMPlex.coordinatesView, DMPlex.labelsView, DMPlex.globalVectorView, DMPlex.localVectorView, DMPlex.sectionLoad, Viewer, petsc.DMPlexSectionView


Source code at petsc4py/PETSc/DMPlex.pyx:3054


Define adjacency in the mesh using the point-to-point constraints.
useAnchors (bool) -- Flag to use the constraints. If True, then constrained points are omitted from DMPlex.getAdjacency, and their anchor points appear in their place.
None

SEE ALSO:

DMPlex, DMPlex.getAdjacency, DMPlex.distribute, petsc.DMPlexSetAdjacencyUseAnchors


Source code at petsc4py/PETSc/DMPlex.pyx:1414


Set the polytope type of a given cell.

Not collective.

  • p (int) -- The cell.
  • ctype (PolytopeType) -- The polytope type of the cell.

None

SEE ALSO:

DM, DMPlex, DMPlex.getCellTypeLabel, DMPlex.getDepth, DM.createLabel, petsc.DMPlexSetCellType


Source code at petsc4py/PETSc/DMPlex.pyx:661


Set the interval for all mesh points [pStart, pEnd).

Not collective.

  • pStart (int) -- The first mesh point.
  • pEnd (int) -- The upper bound for mesh points.

None

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.getChart, petsc.DMPlexSetChart


Source code at petsc4py/PETSc/DMPlex.pyx:419


Set the points on the in-edges for this point in the DAG.

Not collective.

  • p (int) -- The point, which must lie in the chart set with DMPlex.setChart.
  • cone (Sequence[int]) -- An array of points which are on the in-edges for point p.
  • orientation (Sequence[int] | None) -- An array of orientations, defaults to None.

None

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.getCone, DMPlex.setChart, DMPlex.setConeSize, DM.setUp, DMPlex.setSupport, DMPlex.setSupportSize, petsc.DMPlexSetCone


Source code at petsc4py/PETSc/DMPlex.pyx:515


Set the orientations on the in-edges for this point in the DAG.

Not collective.

  • p (int) -- The point, which must lie in the chart set with DMPlex.setChart.
  • orientation (Sequence[int]) -- An array of orientations.

None

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.getConeOrientation, DMPlex.setCone, DMPlex.setChart, DMPlex.setConeSize, DM.setUp, petsc.DMPlexSetConeOrientation


Source code at petsc4py/PETSc/DMPlex.pyx:630


Set the number of in-edges for this point in the DAG.

Not collective.

  • p (int) -- The point, which must lie in the chart set with DMPlex.setChart.
  • size (int) -- The cone size for point p.

None

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.getConeSize, DMPlex.setChart, petsc.DMPlexSetConeSize


Source code at petsc4py/PETSc/DMPlex.pyx:464


Set an array of the values on the closure of point.

Not collective.

  • sec (Section) -- The section describing the layout in mat, or None to use the default section.
  • gsec (Section) -- The section describing the layout in mat, or None to use the default global section.
  • mat (Mat) -- The matrix.
  • point (int) -- The point in the DMPlex.
  • values (Sequence[Scalar]) -- The array of values.
  • mode -- The insertion mode.
  • addv (InsertModeSpec | None) --

None

SEE ALSO:

DM, DMPlex, petsc.DMPlexMatSetClosure


Source code at petsc4py/PETSc/DMPlex.pyx:1239


Set the mesh partitioner.

Logically collective.

part (Partitioner) -- The partitioner.

SEE ALSO:

DM, DMPlex, Partitioner, DMPlex.distribute, DMPlex.getPartitioner, Partitioner.create, petsc.DMPlexSetPartitioner


Source code at petsc4py/PETSc/DMPlex.pyx:1469


Set the maximum cell volume for refinement.
refinementLimit (float) -- The maximum cell volume in the refined mesh.
None

SEE ALSO:

DM, DMPlex, DM.refine, DMPlex.getRefinementLimit, DMPlex.getRefinementUniform, DMPlex.setRefinementUniform, petsc.DMPlexSetRefinementLimit


Source code at petsc4py/PETSc/DMPlex.pyx:2058


Set the flag for uniform refinement.
refinementUniform (bool | None) -- The flag for uniform refinement.
None

SEE ALSO:

DM, DMPlex, DM.refine, DMPlex.getRefinementUniform, DMPlex.getRefinementLimit, DMPlex.setRefinementLimit, petsc.DMPlexSetRefinementUniform


Source code at petsc4py/PETSc/DMPlex.pyx:2021


Set the points on the out-edges for this point in the DAG.

Not collective.

  • p (int) -- The point, which must lie in the chart set with DMPlex.setChart.
  • supp (Sequence[int]) -- An array of points which are on the out-edges for point p.

None

SEE ALSO:

DM, DMPlex, DMPlex.setCone, DMPlex.setConeSize, DMPlex.create, DMPlex.getSupport, DMPlex.setChart, DMPlex.setSupportSize, DM.setUp, petsc.DMPlexSetSupport


Source code at petsc4py/PETSc/DMPlex.pyx:795


Set the number of out-edges for this point in the DAG.

Not collective.

  • p (int) -- The point, which must lie in the chart set with DMPlex.setChart.
  • size (int) -- The support size for point p.

None

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.getSupportSize, DMPlex.setChart, petsc.DMPlexSetSupportSize


Source code at petsc4py/PETSc/DMPlex.pyx:744


Set the options used for the Tetgen mesh generator.

Not collective.

opts (str) -- The command line options.
None

SEE ALSO:

Working with PETSc options (TODO), DM, DMPlex, DMPlex.setTriangleOptions, DMPlex.generate, petsc.DMPlexTetgenSetOptions


Source code at petsc4py/PETSc/DMPlex.pyx:1324


Set the options used for the Triangle mesh generator.

Not collective.

opts (str) -- The command line options.
None

SEE ALSO:

Working with PETSc options (TODO), DM, DMPlex, DMPlex.setTetGenOptions, DMPlex.generate, petsc.DMPlexTriangleSetOptions


Source code at petsc4py/PETSc/DMPlex.pyx:1304


Set an array of the values on the closure of point.

Not collective.

  • sec (Section) -- The section describing the layout in vec, or None to use the default section.
  • vec (Vec) -- The local vector.
  • point (int) -- The point in the DMPlex.
  • values (Sequence[Scalar]) -- The array of values.
  • mode -- The insertion mode.
  • addv (InsertModeSpec | None) --

None

SEE ALSO:

DM, DMPlex, petsc.DMPlexVecSetClosure


Source code at petsc4py/PETSc/DMPlex.pyx:1207


Calculate the strata of DAG.

Collective.

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.symmetrize, petsc.DMPlexStratify


Source code at petsc4py/PETSc/DMPlex.pyx:859



Create support (out-edge) information from cone (in-edge) information.

Not collective.

SEE ALSO:

DM, DMPlex, DMPlex.create, DMPlex.setChart, DMPlex.setConeSize, DMPlex.setCone, petsc.DMPlexSymmetrize


Source code at petsc4py/PETSc/DMPlex.pyx:846



Load a topology into this DMPlex object.

Collective.

viewer (Viewer) -- The Viewer for the saved topology
sfxc -- The SF that pushes points in [0, N) to the associated points in the loaded DMPlex, where N is the global number of points.
SF

SEE ALSO:

DM, DMPlex, DM.load, DMPlex.coordinatesLoad, DMPlex.labelsLoad, DM.view, SF, Viewer, petsc.DMPlexTopologyLoad


Source code at petsc4py/PETSc/DMPlex.pyx:3125


Save a DMPlex topology into a file.

Collective.

viewer (Viewer) -- The Viewer for saving.
None

SEE ALSO:

DM, DMPlex, DM.view, DMPlex.coordinatesView, DMPlex.labelsView, DMPlex.topologyLoad, Viewer, petsc.DMPlexTopologyView


Source code at petsc4py/PETSc/DMPlex.pyx:3000


Convert to a mesh with only cells and vertices.

Collective.

SEE ALSO:

DMPlex, DMPlex.interpolate, DMPlex.createFromCellList, petsc.DMPlexUninterpolate


Source code at petsc4py/PETSc/DMPlex.pyx:1712



Return an array of values on the closure of p.

Not collective.

  • sec (Section) -- The section describing the layout in vec.
  • vec (Vec) -- The local vector.
  • p (int) -- The point in the DMPlex.

ArrayScalar

SEE ALSO:

DM, DMPlex, petsc.DMPlexVecRestoreClosure


Source code at petsc4py/PETSc/DMPlex.pyx:1149




petsc4py.PETSc.DMPlexTransform

Bases: Object

Methods Summary

apply(dm) Source code at petsc4py/PETSc/DMPlex.pyx:3301
create([comm]) Source code at petsc4py/PETSc/DMPlex.pyx:3306
destroy() Source code at petsc4py/PETSc/DMPlex.pyx:3314
getType() Source code at petsc4py/PETSc/DMPlex.pyx:3318
setDM(dm) Source code at petsc4py/PETSc/DMPlex.pyx:3332
setFromOptions() Source code at petsc4py/PETSc/DMPlex.pyx:3335
setType(tr_type) Source code at petsc4py/PETSc/DMPlex.pyx:3327
setUp() Source code at petsc4py/PETSc/DMPlex.pyx:3323
view([viewer]) Source code at petsc4py/PETSc/DMPlex.pyx:3338

Methods Documentation

Source code at petsc4py/PETSc/DMPlex.pyx:3301
dm (DM) --


Source code at petsc4py/PETSc/DMPlex.pyx:3306

Source code at petsc4py/PETSc/DMPlex.pyx:3314

Source code at petsc4py/PETSc/DMPlex.pyx:3318

Source code at petsc4py/PETSc/DMPlex.pyx:3332
dm (DM) --


Source code at petsc4py/PETSc/DMPlex.pyx:3335

Source code at petsc4py/PETSc/DMPlex.pyx:3327

Source code at petsc4py/PETSc/DMPlex.pyx:3323

Source code at petsc4py/PETSc/DMPlex.pyx:3338
viewer (Viewer | None) --



petsc4py.PETSc.DMPlexTransformType

Bases: object

Attributes Summary

EXTRUDE Object EXTRUDE of type str
REFINE1D Object REFINE1D of type str
REFINEALFELD Object REFINEALFELD of type str
REFINEBOUNDARYLAYER Object REFINEBOUNDARYLAYER of type str
REFINEPOWELLSABIN Object REFINEPOWELLSABIN of type str
REFINEREGULAR Object REFINEREGULAR of type str
REFINESBR Object REFINESBR of type str
REFINETOBOX Object REFINETOBOX of type str
REFINETOSIMPLEX Object REFINETOSIMPLEX of type str
TRANSFORMFILTER Object TRANSFORMFILTER of type str

Attributes Documentation

Object EXTRUDE of type str

Object REFINE1D of type str

Object REFINEALFELD of type str

Object REFINEBOUNDARYLAYER of type str

Object REFINEPOWELLSABIN of type str

Object REFINEREGULAR of type str

Object REFINESBR of type str

Object REFINETOBOX of type str

Object REFINETOSIMPLEX of type str

Object TRANSFORMFILTER of type str


petsc4py.PETSc.DMShell

Bases: DM

A shell DM object, used to manage user-defined problem data.

Methods Summary

create([comm]) Creates a shell DM object.
setCoarsen(coarsen[, args, kargs]) Set the routine used to coarsen the DMShell.
setCreateDomainDecomposition(decomp[, args, ...]) Set the routine used to create a domain decomposition.
setCreateDomainDecompositionScatters(scatter) Set the routine used to create the scatter contexts for domain decomposition.
setCreateFieldDecomposition(decomp[, args, ...]) Set the routine used to create a field decomposition.
setCreateGlobalVector(create_gvec[, args, kargs]) Set the routine to create a global vector.
setCreateInjection(create_injection[, args, ...]) Set the routine used to create the injection operator.
setCreateInterpolation(create_interpolation) Set the routine used to create the interpolation operator.
setCreateLocalVector(create_lvec[, args, kargs]) Set the routine to create a local vector.
setCreateMatrix(create_matrix[, args, kargs]) Set the routine to create a matrix.
setCreateRestriction(create_restriction[, ...]) Set the routine used to create the restriction operator.
setCreateSubDM(create_subdm[, args, kargs]) Set the routine used to create a sub DM from the DMShell.
setGlobalToLocal(begin, end[, begin_args, ...]) Set the routines used to perform a global to local scatter.
setGlobalToLocalVecScatter(gtol) Set a Scatter context for global to local communication.
setGlobalVector(gv) Set a template global vector.
setLocalToGlobal(begin, end[, begin_args, ...]) Set the routines used to perform a local to global scatter.
setLocalToGlobalVecScatter(ltog) Set a Scatter context for local to global communication.
setLocalToLocal(begin, end[, begin_args, ...]) Set the routines used to perform a local to local scatter.
setLocalToLocalVecScatter(ltol) Set a Scatter context for local to local communication.
setLocalVector(lv) Set a template local vector.
setMatrix(mat) Set a template matrix.
setRefine(refine[, args, kargs]) Set the routine used to refine the DMShell.

Methods Documentation

Creates a shell DM object.

Collective.

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

SEE ALSO:

petsc.DMShellCreate


Source code at petsc4py/PETSc/DMShell.pyx:4


Set the routine used to coarsen the DMShell.

Logically collective.

  • coarsen (Callable[[DM, Comm], DM] | None) -- The routine which coarsens the DM.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for coarsen.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for coarsen.

None

SEE ALSO:

setRefine, petsc.DMShellSetCoarsen


Source code at petsc4py/PETSc/DMShell.pyx:374


Set the routine used to create a domain decomposition.

Logically collective.

  • decomp (Callable[[DM], tuple[list[str] | None, list[IS] | None, list[IS] | None, list[DM] | None]] | None) -- The routine to create the decomposition.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for decomp.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for decomp.

None

SEE ALSO:

petsc.DMShellSetCreateDomainDecomposition


Source code at petsc4py/PETSc/DMShell.pyx:572


Set the routine used to create the scatter contexts for domain decomposition.

Logically collective.

  • scatter (Callable[[DM, list[DM]], tuple[list[Scatter], list[Scatter], list[Scatter]]] | None) -- The routine to create the scatters.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for scatter.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for scatter.

None

SEE ALSO:

petsc.DMShellSetCreateDomainDecompositionScatters


Source code at petsc4py/PETSc/DMShell.pyx:605


Set the routine used to create a field decomposition.

Logically collective.

  • decomp (Callable[[DM], tuple[list[str] | None, list[IS] | None, list[DM] | None]] | None) -- The routine to create the decomposition.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for decomp.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for decomp.

None

SEE ALSO:

petsc.DMShellSetCreateFieldDecomposition


Source code at petsc4py/PETSc/DMShell.pyx:539


Set the routine to create a global vector.

Logically collective.

  • create_gvec (Callable[[DM], Vec] | None) -- The creation routine.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for create_gvec.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for create_gvec.

None

SEE ALSO:

setCreateLocalVector, petsc.DMShellSetCreateGlobalVector


Source code at petsc4py/PETSc/DMShell.pyx:76


Set the routine used to create the injection operator.

Logically collective.

  • create_injection (Callable[[DM, DM], Mat] | None) -- The routine to create the injection.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for create_injection.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for create_injection.

None

SEE ALSO:

petsc.DMShellSetCreateInjection


Source code at petsc4py/PETSc/DMShell.pyx:473


Set the routine used to create the interpolation operator.

Logically collective.

  • create_interpolation (Callable[[DM, DM], tuple[Mat, Vec]] | None) -- The routine to create the interpolation.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for create_interpolation.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for create_interpolation.

None

SEE ALSO:

petsc.DMShellSetCreateInterpolation


Source code at petsc4py/PETSc/DMShell.pyx:440


Set the routine to create a local vector.

Logically collective.

  • create_lvec (Callable[[DM], Vec] | None) -- The creation routine.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for create_lvec.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for create_lvec.

None

SEE ALSO:

setCreateGlobalVector, petsc.DMShellSetCreateLocalVector


Source code at petsc4py/PETSc/DMShell.pyx:109


Set the routine to create a matrix.

Logically collective.

  • create_matrix (Callable[[DM], Mat] | None) -- The function to create a matrix.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for create_matrix.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for create_matrix.

None

SEE ALSO:

petsc.DMShellSetCreateMatrix


Source code at petsc4py/PETSc/DMShell.pyx:341


Set the routine used to create the restriction operator.

Logically collective.

  • create_restriction (Callable[[DM, DM], Mat] | None) -- The routine to create the restriction
  • args (tuple[Any, ...] | None) -- Additional positional arguments for create_restriction.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for create_restriction.

None

SEE ALSO:

petsc.DMShellSetCreateRestriction


Source code at petsc4py/PETSc/DMShell.pyx:506


Set the routine used to create a sub DM from the DMShell.

Logically collective.

  • subdm -- The routine to create the decomposition.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for subdm.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for subdm.
  • create_subdm (Callable[[DM, Sequence[int]], tuple[IS, DM]] | None) --

None

SEE ALSO:

petsc.DMShellSetCreateSubDM


Source code at petsc4py/PETSc/DMShell.pyx:638


Set the routines used to perform a global to local scatter.

Logically collective.

  • dm -- The DMShell.
  • begin (Callable[[DM, Vec, InsertMode, Vec], None] | None) -- The routine which begins the global to local scatter.
  • end (Callable[[DM, Vec, InsertMode, Vec], None] | None) -- The routine which ends the global to local scatter.
  • begin_args (tuple[Any, ...] | None) -- Additional positional arguments for begin.
  • begin_kargs (dict[str, Any] | None) -- Additional keyword arguments for begin.
  • end_args (tuple[Any, ...] | None) -- Additional positional arguments for end.
  • end_kargs (dict[str, Any] | None) -- Additional keyword arguments for end.

None

SEE ALSO:

petsc.DMShellSetGlobalToLocal


Source code at petsc4py/PETSc/DMShell.pyx:142


Set a Scatter context for global to local communication.

Logically collective.

gtol (Scatter) -- The global to local Scatter context.
None

SEE ALSO:

petsc.DMShellSetGlobalToLocalVecScatter


Source code at petsc4py/PETSc/DMShell.pyx:192


Set a template global vector.

Logically collective.

gv (Vec) -- Template vector.
None

SEE ALSO:

setLocalVector, petsc.DMShellSetGlobalVector


Source code at petsc4py/PETSc/DMShell.pyx:42


Set the routines used to perform a local to global scatter.

Logically collective.

  • begin (Callable[[DM, Vec, InsertMode, Vec], None] | None) -- The routine which begins the local to global scatter.
  • end (Callable[[DM, Vec, InsertMode, Vec], None] | None) -- The routine which ends the local to global scatter.
  • begin_args (tuple[Any, ...] | None) -- Additional positional arguments for begin.
  • begin_kargs (dict[str, Any] | None) -- Additional keyword arguments for begin.
  • end_args (tuple[Any, ...] | None) -- Additional positional arguments for end.
  • end_kargs (dict[str, Any] | None) -- Additional keyword arguments for end.

None

SEE ALSO:

petsc.DMShellSetLocalToGlobal


Source code at petsc4py/PETSc/DMShell.pyx:209


Set a Scatter context for local to global communication.

Logically collective.

ltog (Scatter) -- The local to global Scatter context.
None

SEE ALSO:

petsc.DMShellSetLocalToGlobalVecScatter


Source code at petsc4py/PETSc/DMShell.pyx:257


Set the routines used to perform a local to local scatter.

Logically collective.

  • begin (Callable[[DM, Vec, InsertMode, Vec], None] | None) -- The routine which begins the local to local scatter.
  • end (Callable[[DM, Vec, InsertMode, Vec], None] | None) -- The routine which ends the local to local scatter.
  • begin_args (tuple[Any, ...] | None) -- Additional positional arguments for begin.
  • begin_kargs (dict[str, Any] | None) -- Additional keyword arguments for begin.
  • end_args (tuple[Any, ...] | None) -- Additional positional arguments for end.
  • end_kargs (dict[str, Any] | None) -- Additional keyword arguments for end.

None

SEE ALSO:

petsc.DMShellSetLocalToLocal


Source code at petsc4py/PETSc/DMShell.pyx:274


Set a Scatter context for local to local communication.

Logically collective.

ltol (Scatter) -- The local to local Scatter context.
None

SEE ALSO:

petsc.DMShellSetLocalToLocalVecScatter


Source code at petsc4py/PETSc/DMShell.pyx:324


Set a template local vector.

Logically collective.

lv (Vec) -- Template vector.
None

SEE ALSO:

setGlobalVector, petsc.DMShellSetLocalVector


Source code at petsc4py/PETSc/DMShell.pyx:59


Set a template matrix.

Collective.

mat (Mat) -- The template matrix.
None

SEE ALSO:

petsc.DMShellSetMatrix


Source code at petsc4py/PETSc/DMShell.pyx:25


Set the routine used to refine the DMShell.

Logically collective.

  • refine (Callable[[DM, Comm], DM] | None) -- The routine which refines the DM.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for refine.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for refine.

None

SEE ALSO:

setCoarsen, petsc.DMShellSetRefine


Source code at petsc4py/PETSc/DMShell.pyx:407



petsc4py.PETSc.DMStag

Bases: DM

A DM object representing a "staggered grid" or a structured cell complex.

Enumerations

StencilLocation
StencilType

petsc4py.PETSc.DMStag.StencilLocation

Bases: object

Attributes Summary

BACK Constant BACK of type int
BACK_DOWN Constant BACK_DOWN of type int
BACK_DOWN_LEFT Constant BACK_DOWN_LEFT of type int
BACK_DOWN_RIGHT Constant BACK_DOWN_RIGHT of type int
BACK_LEFT Constant BACK_LEFT of type int
BACK_RIGHT Constant BACK_RIGHT of type int
BACK_UP Constant BACK_UP of type int
BACK_UP_LEFT Constant BACK_UP_LEFT of type int
BACK_UP_RIGHT Constant BACK_UP_RIGHT of type int
DOWN Constant DOWN of type int
DOWN_LEFT Constant DOWN_LEFT of type int
DOWN_RIGHT Constant DOWN_RIGHT of type int
ELEMENT Constant ELEMENT of type int
FRONT Constant FRONT of type int
FRONT_DOWN Constant FRONT_DOWN of type int
FRONT_DOWN_LEFT Constant FRONT_DOWN_LEFT of type int
FRONT_DOWN_RIGHT Constant FRONT_DOWN_RIGHT of type int
FRONT_LEFT Constant FRONT_LEFT of type int
FRONT_RIGHT Constant FRONT_RIGHT of type int
FRONT_UP Constant FRONT_UP of type int
FRONT_UP_LEFT Constant FRONT_UP_LEFT of type int
FRONT_UP_RIGHT Constant FRONT_UP_RIGHT of type int
LEFT Constant LEFT of type int
NULLLOC Constant NULLLOC of type int
RIGHT Constant RIGHT of type int
UP Constant UP of type int
UP_LEFT Constant UP_LEFT of type int
UP_RIGHT Constant UP_RIGHT of type int

Attributes Documentation

Constant BACK of type int

Constant BACK_DOWN of type int

Constant BACK_DOWN_LEFT of type int

Constant BACK_DOWN_RIGHT of type int

Constant BACK_LEFT of type int

Constant BACK_RIGHT of type int

Constant BACK_UP of type int

Constant BACK_UP_LEFT of type int

Constant BACK_UP_RIGHT of type int

Constant DOWN of type int

Constant DOWN_LEFT of type int

Constant DOWN_RIGHT of type int

Constant ELEMENT of type int

Constant FRONT of type int

Constant FRONT_DOWN of type int

Constant FRONT_DOWN_LEFT of type int

Constant FRONT_DOWN_RIGHT of type int

Constant FRONT_LEFT of type int

Constant FRONT_RIGHT of type int

Constant FRONT_UP of type int

Constant FRONT_UP_LEFT of type int

Constant FRONT_UP_RIGHT of type int

Constant LEFT of type int

Constant NULLLOC of type int

Constant RIGHT of type int

Constant UP of type int

Constant UP_LEFT of type int

Constant UP_RIGHT of type int


petsc4py.PETSc.DMStag.StencilType

Bases: object

Attributes Summary

BOX Constant BOX of type int
NONE Constant NONE of type int
STAR Constant STAR of type int

Attributes Documentation

Constant BOX of type int

Constant NONE of type int

Constant STAR of type int


Methods Summary

VecSplitToDMDA(vec, loc, c) Return DMDA, Vec from a subgrid of a DMStag, its Vec.
create(dim[, dofs, sizes, boundary_types, ...]) Create a DMDA object.
createCompatibleDMStag(dofs) Create a compatible DMStag with different DOFs/stratum.
get1dCoordinatecArrays() Not implemented in petsc4py.
getBoundaryTypes() Return boundary types in each dimension.
getCorners() Return starting element index, width and number of partial elements.
getDim() Return the number of dimensions.
getDof() Get number of DOFs associated with each stratum of the grid.
getEntriesPerElement() Return the number of entries per element in the local representation.
getGhostCorners() Return starting element index and width of local region.
getGlobalSizes() Return global element counts in each dimension.
getIsFirstRank() Return whether this process is first in each dimension in the process grid.
getIsLastRank() Return whether this process is last in each dimension in the process grid.
getLocalSizes() Return local elementwise sizes in each dimension.
getLocationDof(loc) Return number of DOFs associated with a given point on the grid.
getLocationSlot(loc, c) Return index to use in accessing raw local arrays.
getOwnershipRanges() Return elements per process in each dimension.
getProcSizes() Return number of processes in each dimension.
getProductCoordinateLocationSlot(loc) Return slot for use with local product coordinate arrays.
getStencilType() Return elementwise ghost/halo stencil type.
getStencilWidth() Return elementwise stencil width.
getVecArray(vec) Not implemented in petsc4py.
migrateVec(vec, dmTo, vecTo) Transfer a vector between two DMStag objects.
setBoundaryTypes(boundary_types) Set the boundary types.
setCoordinateDMType(dmtype) Set the type to store coordinates.
setDof(dofs) Set DOFs/stratum.
setGlobalSizes(sizes) Set global element counts in each dimension.
setOwnershipRanges(ranges) Set elements per process in each dimension.
setProcSizes(sizes) Set the number of processes in each dimension in the global process grid.
setStencilType(stenciltype) Set elementwise ghost/halo stencil type.
setStencilWidth(swidth) Set elementwise stencil width.
setUniformCoordinates([xmin, xmax, ymin, ...]) Set the coordinates to be a uniform grid..
setUniformCoordinatesExplicit([xmin, xmax, ...]) Set coordinates to be a uniform grid, storing all values.
setUniformCoordinatesProduct([xmin, xmax, ...]) Create uniform coordinates, as a product of 1D arrays.

Attributes Summary

boundary_types Boundary types in each dimension.
corners The lower left corner and size of local region in each dimension.
dim The dimension.
dofs The number of DOFs associated with each stratum of the grid.
entries_per_element The number of entries per element in the local representation.
ghost_corners The lower left corner and size of local region in each dimension.
global_sizes Global element counts in each dimension.
local_sizes Local elementwise sizes in each dimension.
proc_sizes The number of processes in each dimension in the global decomposition.
stencil_type Stencil type.
stencil_width Elementwise stencil width.

Methods Documentation

Return DMDA, Vec from a subgrid of a DMStag, its Vec.

Collective.

If a c value of -k is provided, the first k DOFs for that position are extracted, padding with zero values if needed. If a non-negative value is provided, a single DOF is extracted.

  • vec (Vec) -- The Vec object.
  • loc (StencilLocation) -- Which subgrid to extract.
  • c (int) -- Which component to extract.

tuple[DMDA, Vec]

SEE ALSO:

petsc.DMStagVecSplitToDMDA


Source code at petsc4py/PETSc/DMStag.pyx:791


Create a DMDA object.

Collective.

Creates an object to manage data living on the elements and vertices / the elements, faces, and vertices / the elements, faces, edges, and vertices of a parallelized regular 1D / 2D / 3D grid.

  • dim (int) -- The number of dimensions.
  • dofs (tuple[int, ...] | None) -- The number of degrees of freedom per vertex, element (1D); vertex, face, element (2D); or vertex, edge, face, element (3D).
  • sizes (tuple[int, ...] | None) -- The number of elements in each dimension.
  • boundary_types (tuple[DM.BoundaryType | int | str | bool, ...] | None) -- The boundary types.
  • stencil_type (StencilType | None) -- The ghost/halo stencil type.
  • stencil_width (int | None) -- The width of the ghost/halo region.
  • proc_sizes (tuple[int, ...] | None) -- The number of processes in x, y, z dimensions.
  • ownership_ranges (tuple[Sequence[int], ...] | None) -- Local x, y, z element counts, of length equal to proc_sizes, summing to sizes.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.
  • setUp (bool | None) -- Whether to call the setup routine after creating the object.

Self

SEE ALSO:

petsc.DMStagCreate1d, petsc.DMStagCreate2d, petsc.DMStagCreate3d, petsc.DMSetUp


Source code at petsc4py/PETSc/DMStag.pyx:46


Create a compatible DMStag with different DOFs/stratum.

Collective.

dofs (tuple[int, ...]) -- The number of DOFs on the strata in the new DMStag.
DM

SEE ALSO:

petsc.DMStagCreateCompatibleDMStag


Source code at petsc4py/PETSc/DMStag.pyx:767


Not implemented in petsc4py.

Source code at petsc4py/PETSc/DMStag.pyx:834



Return boundary types in each dimension.

Not collective.

SEE ALSO:

setBoundaryTypes, petsc.DMStagGetBoundaryTypes


Source code at petsc4py/PETSc/DMStag.pyx:476

tuple[str, ...]


Return starting element index, width and number of partial elements.

Not collective.

The returned value is calculated excluding ghost points.

The number of extra partial elements is either 1 or 0. The value is 1 on right, top, and front non-periodic domain ("physical") boundaries, in the x, y, and z dimensions respectively, and otherwise 0.

SEE ALSO:

getGhostCorners, petsc.DMStagGetCorners, petsc.DMGetDimension


Source code at petsc4py/PETSc/DMStag.pyx:361

tuple[tuple[int, ...], tuple[int, ...], tuple[int, ...]]


Return the number of dimensions.

Not collective.

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



Get number of DOFs associated with each stratum of the grid.

Not collective.

SEE ALSO:

petsc.DMStagGetDOF


Source code at petsc4py/PETSc/DMStag.pyx:346

tuple[int, ...]


Return the number of entries per element in the local representation.

Not collective.

This is the natural block size for most local operations.

SEE ALSO:

petsc.DMStagGetEntriesPerElement


Source code at petsc4py/PETSc/DMStag.pyx:316



Return starting element index and width of local region.

Not collective.

SEE ALSO:

getCorners, petsc.DMStagGetGhostCorners


Source code at petsc4py/PETSc/DMStag.pyx:383

tuple[tuple[int, ...], tuple[int, ...]]


Return global element counts in each dimension.

Not collective.

SEE ALSO:

getLocalSizes, petsc.DMStagGetGlobalSizes


Source code at petsc4py/PETSc/DMStag.pyx:415

tuple[int, ...]


Return whether this process is first in each dimension in the process grid.

Not collective.

SEE ALSO:

petsc.DMStagGetIsFirstRank


Source code at petsc4py/PETSc/DMStag.pyx:494

tuple[int, ...]


Return whether this process is last in each dimension in the process grid.

Not collective.

SEE ALSO:

petsc.DMStagGetIsLastRank


Source code at petsc4py/PETSc/DMStag.pyx:510

tuple[int, ...]


Return local elementwise sizes in each dimension.

Not collective.

The returned value is calculated excluding ghost points.

SEE ALSO:

getGlobalSizes, petsc.DMStagGetLocalSizes


Source code at petsc4py/PETSc/DMStag.pyx:398

tuple[int, ...]


Return number of DOFs associated with a given point on the grid.

Not collective.

loc (StencilLocation) -- The grid point.
int

SEE ALSO:

petsc.DMStagGetLocationDOF


Source code at petsc4py/PETSc/DMStag.pyx:722


Return index to use in accessing raw local arrays.

Not collective.

  • loc (StencilLocation) -- Location relative to an element.
  • c (int) -- Component.

int

SEE ALSO:

petsc.DMStagGetLocationSlot


Source code at petsc4py/PETSc/DMStag.pyx:679


Return elements per process in each dimension.

Not collective.

SEE ALSO:

setOwnershipRanges, petsc.DMStagGetOwnershipRanges


Source code at petsc4py/PETSc/DMStag.pyx:459

tuple[Sequence[int], ...]


Return number of processes in each dimension.

Not collective.

SEE ALSO:

petsc.DMStagGetNumRanks


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

tuple[int, ...]


Return slot for use with local product coordinate arrays.

Not collective.

loc (StencilLocation) -- The grid location.
None

SEE ALSO:

petsc.DMStagGetProductCoordinateLocationSlot


Source code at petsc4py/PETSc/DMStag.pyx:702


Return elementwise ghost/halo stencil type.

Not collective.

SEE ALSO:

setStencilType, petsc.DMStagGetStencilType


Source code at petsc4py/PETSc/DMStag.pyx:445



Return elementwise stencil width.

Not collective.

SEE ALSO:

petsc.DMStagGetStencilWidth


Source code at petsc4py/PETSc/DMStag.pyx:332



Not implemented in petsc4py.

Source code at petsc4py/PETSc/DMStag.pyx:830

vec (Vec) --
None


Transfer a vector between two DMStag objects.

Collective.

Currently only implemented to migrate global vectors to global vectors.

  • vec (Vec) -- The source vector.
  • dmTo (DM) -- The compatible destination object.
  • vecTo (Vec) -- The destination vector.

None

SEE ALSO:

petsc.DMStagMigrateVec


Source code at petsc4py/PETSc/DMStag.pyx:744


Set the boundary types.

Logically collective.

boundary_types (tuple[BoundaryType | int | str | bool, ...]) -- Boundary types for one/two/three dimensions.
None

SEE ALSO:

getBoundaryTypes, petsc.DMStagSetBoundaryTypes


Source code at petsc4py/PETSc/DMStag.pyx:198


Set the type to store coordinates.

Logically collective.

dmtype (Type) -- The type to store coordinates.
None

SEE ALSO:

petsc.DMStagSetCoordinateDMType


Source code at petsc4py/PETSc/DMStag.pyx:658


Set DOFs/stratum.

Logically collective.

dofs (tuple[int, ...]) -- The number of points per 0-cell (vertex/node), 1-cell (element in 1D, edge in 2D and 3D), 2-cell (element in 2D, face in 3D), or 3-cell (element in 3D).
None

SEE ALSO:

petsc.DMStagSetDOF


Source code at petsc4py/PETSc/DMStag.pyx:222


Set global element counts in each dimension.

Logically collective.

sizes (tuple[int, ...]) -- Global elementwise size in the one/two/three dimensions.
None

SEE ALSO:

petsc.DMStagSetGlobalSizes


Source code at petsc4py/PETSc/DMStag.pyx:244


Set elements per process in each dimension.

Logically collective.

ranges (tuple[Sequence[int], ...]) -- Element counts for each process in one/two/three dimensions.
None

SEE ALSO:

getOwnershipRanges, petsc.DMStagSetOwnershipRanges


Source code at petsc4py/PETSc/DMStag.pyx:284


Set the number of processes in each dimension in the global process grid.

Logically collective.

sizes (tuple[int, ...]) -- Number of processes in one/two/three dimensions.
None

SEE ALSO:

petsc.DMStagSetNumRanks


Source code at petsc4py/PETSc/DMStag.pyx:264


Set elementwise ghost/halo stencil type.

Logically collective.

stenciltype (StencilType | str) -- The elementwise ghost stencil type.
None

SEE ALSO:

getStencilType, petsc.DMStagSetStencilType


Source code at petsc4py/PETSc/DMStag.pyx:180


Set elementwise stencil width.

Logically collective.

The width value is not used when StencilType.NONE is specified.

swidth (int) -- Stencil/halo/ghost width in elements.
None

SEE ALSO:

petsc.DMStagSetStencilWidth


Source code at petsc4py/PETSc/DMStag.pyx:160


Set the coordinates to be a uniform grid..

Collective.

Local coordinates are populated, linearly extrapolated to ghost cells, including those outside the physical domain. This is also done in case of periodic boundaries, meaning that the same global point may have different coordinates in different local representations, which are equivalent assuming a periodicity implied by the arguments to this function, i.e., two points are equivalent if their difference is a multiple of xmax-xmin in the x dimension, ymax-ymin in the y dimension, and zmax-zmin in the z dimension.

  • xmin (float) -- The minimum global coordinate value in the x dimension.
  • xmax (float) -- The maximum global coordinate value in the x dimension.
  • ymin (float) -- The minimum global coordinate value in the y dimension.
  • ymax (float) -- The maximum global coordinate value in the y dimension.
  • zmin (float) -- The minimum global coordinate value in the z dimension.
  • zmax (float) -- The maximum global coordinate value in the z dimension.

None

SEE ALSO:

setUniformCoordinatesExplicit, setUniformCoordinatesProduct, petsc.DMStagSetUniformCoordinates


Source code at petsc4py/PETSc/DMStag.pyx:610


Set coordinates to be a uniform grid, storing all values.

Collective.

  • xmin (float) -- The minimum global coordinate value in the x dimension.
  • xmax (float) -- The maximum global coordinate value in the x dimension.
  • ymin (float) -- The minimum global coordinate value in the y dimension.
  • ymax (float) -- The maximum global coordinate value in the y dimension.
  • zmin (float) -- The minimum global coordinate value in the z dimension.
  • zmax (float) -- The maximum global coordinate value in the z dimension.

None

SEE ALSO:

setUniformCoordinatesProduct, setUniformCoordinates, petsc.DMStagSetUniformCoordinatesExplicit


Source code at petsc4py/PETSc/DMStag.pyx:528


Create uniform coordinates, as a product of 1D arrays.

Collective.

The per-dimension 1-dimensional DMStag objects that comprise the product always have active 0-cells (vertices, element boundaries) and 1-cells (element centers).

  • xmin (float) -- The minimum global coordinate value in the x dimension.
  • xmax (float) -- The maximum global coordinate value in the x dimension.
  • ymin (float) -- The minimum global coordinate value in the y dimension.
  • ymax (float) -- The maximum global coordinate value in the y dimension.
  • zmin (float) -- The minimum global coordinate value in the z dimension.
  • zmax (float) -- The maximum global coordinate value in the z dimension.

None

SEE ALSO:

setUniformCoordinatesExplicit, setUniformCoordinates, petsc.DMStagSetUniformCoordinatesProduct


Source code at petsc4py/PETSc/DMStag.pyx:567


Attributes Documentation

Boundary types in each dimension.

Source code at petsc4py/PETSc/DMStag.pyx:868


The lower left corner and size of local region in each dimension.

Source code at petsc4py/PETSc/DMStag.pyx:883


The dimension.

Source code at petsc4py/PETSc/DMStag.pyx:838


The number of DOFs associated with each stratum of the grid.

Source code at petsc4py/PETSc/DMStag.pyx:843


The number of entries per element in the local representation.

Source code at petsc4py/PETSc/DMStag.pyx:848


The lower left corner and size of local region in each dimension.

Source code at petsc4py/PETSc/DMStag.pyx:888


Global element counts in each dimension.

Source code at petsc4py/PETSc/DMStag.pyx:853


Local elementwise sizes in each dimension.

Source code at petsc4py/PETSc/DMStag.pyx:858


The number of processes in each dimension in the global decomposition.

Source code at petsc4py/PETSc/DMStag.pyx:863


Stencil type.

Source code at petsc4py/PETSc/DMStag.pyx:873


Elementwise stencil width.

Source code at petsc4py/PETSc/DMStag.pyx:878




petsc4py.PETSc.DMSwarm

Bases: DM

A DM object used to represent arrays of data (fields) of arbitrary type.

Enumerations

CollectType
MigrateType
PICLayoutType
Type

petsc4py.PETSc.DMSwarm.CollectType

Bases: object

Attributes Summary

COLLECT_BASIC Constant COLLECT_BASIC of type int
COLLECT_DMDABOUNDINGBOX Constant COLLECT_DMDABOUNDINGBOX of type int
COLLECT_GENERAL Constant COLLECT_GENERAL of type int
COLLECT_USER Constant COLLECT_USER of type int

Attributes Documentation

Constant COLLECT_BASIC of type int

Constant COLLECT_DMDABOUNDINGBOX of type int

Constant COLLECT_GENERAL of type int

Constant COLLECT_USER of type int


petsc4py.PETSc.DMSwarm.MigrateType

Bases: object

Attributes Summary

MIGRATE_BASIC Constant MIGRATE_BASIC of type int
MIGRATE_DMCELLEXACT Constant MIGRATE_DMCELLEXACT of type int
MIGRATE_DMCELLNSCATTER Constant MIGRATE_DMCELLNSCATTER of type int
MIGRATE_USER Constant MIGRATE_USER of type int

Attributes Documentation

Constant MIGRATE_BASIC of type int

Constant MIGRATE_DMCELLEXACT of type int

Constant MIGRATE_DMCELLNSCATTER of type int

Constant MIGRATE_USER of type int


petsc4py.PETSc.DMSwarm.PICLayoutType

Bases: object

Attributes Summary

LAYOUT_GAUSS Constant LAYOUT_GAUSS of type int
LAYOUT_REGULAR Constant LAYOUT_REGULAR of type int
LAYOUT_SUBDIVISION Constant LAYOUT_SUBDIVISION of type int

Attributes Documentation

Constant LAYOUT_GAUSS of type int

Constant LAYOUT_REGULAR of type int

Constant LAYOUT_SUBDIVISION of type int


petsc4py.PETSc.DMSwarm.Type

Bases: object

Attributes Summary

BASIC Constant BASIC of type int
PIC Constant PIC of type int

Attributes Documentation

Constant BASIC of type int

Constant PIC of type int


Methods Summary

addNPoints(npoints) Add space for a number of new points in the DMSwarm.
addPoint() Add space for one new point in the DMSwarm.
collectViewCreate() Apply a collection method and gather points in neighbor ranks.
collectViewDestroy() Reset the DMSwarm to the size prior to calling collectViewCreate.
copyPoint(pi, pj) Copy point pi to point pj in the DMSwarm.
create([comm]) Create an empty DM object and set its type to DM.Type.SWARM.
createGlobalVectorFromField(fieldname) Create a global Vec object associated with a given field.
createLocalVectorFromField(fieldname) Create a local Vec object associated with a given field.
destroyGlobalVectorFromField(fieldname) Destroy the global Vec object associated with a given field.
destroyLocalVectorFromField(fieldname) Destroy the local Vec object associated with a given field.
finalizeFieldRegister() Finalize the registration of fields to a DMSwarm.
getCellDM() Return DM cell attached to DMSwarm.
getField(fieldname) Return arrays storing all entries associated with a field.
getLocalSize() Return the local length of fields registered.
getSize() Return the total length of fields registered.
initializeFieldRegister() Initiate the registration of fields to a DMSwarm.
insertPointUsingCellDM(layoutType, fill_param) Insert point coordinates within each cell.
migrate([remove_sent_points]) Relocate points defined in the DMSwarm to other MPI ranks.
projectFields(fieldnames, vecs[, mode]) Project a set of DMSwarm fields onto the cell DM.
registerField(fieldname, blocksize[, dtype]) Register a field to a DMSwarm with a native PETSc data type.
removePoint() Remove the last point from the DMSwarm.
removePointAtIndex(index) Remove a specific point from the DMSwarm.
restoreField(fieldname) Restore accesses associated with a registered field.
setCellDM(dm) Attach a DM to a DMSwarm.
setLocalSizes(nlocal, buffer) Set the length of all registered fields on the DMSwarm.
setPointCoordinates(coordinates[, ...]) Set point coordinates in a DMSwarm from a user-defined list.
setPointCoordinatesCellwise(coordinates) Insert point coordinates within each cell.
setPointsUniformCoordinates(min, max, npoints) Set point coordinates in a DMSwarm on a regular (ijk) grid.
setType(dmswarm_type) Set particular flavor of DMSwarm.
sortGetAccess() Setup up a DMSwarm point sort context.
sortGetIsValid() Return whether the sort context is up-to-date.
sortGetNumberOfPointsPerCell(e) Return the number of points in a cell.
sortGetPointsPerCell(e) Create an array of point indices for all points in a cell.
sortGetSizes() Return the sizes associated with a DMSwarm point sorting context.
sortRestoreAccess() Invalidate the DMSwarm point sorting context.
vectorDefineField(fieldname) Set the field from which to define a Vec object.
viewFieldsXDMF(filename, fieldnames) Write a selection of DMSwarm fields to an XDMF3 file.
viewXDMF(filename) Write this DMSwarm fields to an XDMF3 file.

Methods Documentation

Add space for a number of new points in the DMSwarm.

Not collective.

npoints (int) -- The number of new points to add.
None

SEE ALSO:

petsc.DMSwarmAddNPoints


Source code at petsc4py/PETSc/DMSwarm.pyx:322


Add space for one new point in the DMSwarm.

Not collective.

SEE ALSO:

petsc.DMSwarmAddPoint


Source code at petsc4py/PETSc/DMSwarm.pyx:310



Apply a collection method and gather points in neighbor ranks.

Collective.

SEE ALSO:

collectViewDestroy, petsc.DMSwarmCollectViewCreate


Source code at petsc4py/PETSc/DMSwarm.pyx:438



Reset the DMSwarm to the size prior to calling collectViewCreate.

Collective.

SEE ALSO:

collectViewCreate, petsc.DMSwarmCollectViewDestroy


Source code at petsc4py/PETSc/DMSwarm.pyx:450



Copy point pi to point pj in the DMSwarm.

Not collective.

  • pi (int) -- The index of the point to copy (source).
  • pj (int) -- The point index where the copy should be located (destination).

None

SEE ALSO:

petsc.DMSwarmCopyPoint


Source code at petsc4py/PETSc/DMSwarm.pyx:370


Create an empty DM object and set its type to DM.Type.SWARM.

Collective.

DMs are the abstract objects in PETSc that mediate between meshes and discretizations and the algebraic solvers, time integrators, and optimization algorithms.

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

SEE ALSO:

petsc.DMCreate, petsc.DMSetType


Source code at petsc4py/PETSc/DMSwarm.pyx:32


Create a global Vec object associated with a given field.

Collective.

The vector must be returned to the DMSwarm using a matching call to destroyGlobalVectorFromField.

fieldname (str) -- The textual name given to a registered field.
Vec

SEE ALSO:

destroyGlobalVectorFromField, petsc.DMSwarmCreateGlobalVectorFromField


Source code at petsc4py/PETSc/DMSwarm.pyx:58


Create a local Vec object associated with a given field.

Collective.

The vector must be returned to the DMSwarm using a matching call to destroyLocalVectorFromField.

fieldname (str) -- The textual name given to a registered field.
Vec

SEE ALSO:

destroyLocalVectorFromField, petsc.DMSwarmCreateLocalVectorFromField


Source code at petsc4py/PETSc/DMSwarm.pyx:102


Destroy the global Vec object associated with a given field.

Collective.

fieldname (str) -- The textual name given to a registered field.
None

SEE ALSO:

createGlobalVectorFromField, petsc.DMSwarmDestroyGlobalVectorFromField


Source code at petsc4py/PETSc/DMSwarm.pyx:82


Destroy the local Vec object associated with a given field.

Collective.

fieldname (str) -- The textual name given to a registered field.
None

SEE ALSO:

createLocalVectorFromField, petsc.DMSwarmDestroyLocalVectorFromField


Source code at petsc4py/PETSc/DMSwarm.pyx:126


Finalize the registration of fields to a DMSwarm.

Collective.

SEE ALSO:

initializeFieldRegister, petsc.DMSwarmFinalizeFieldRegister


Source code at petsc4py/PETSc/DMSwarm.pyx:160



Return DM cell attached to DMSwarm.

Collective.

SEE ALSO:

setCellDM, petsc.DMSwarmGetCellDM


Source code at petsc4py/PETSc/DMSwarm.pyx:479



Return arrays storing all entries associated with a field.

Not collective.

The returned array contains underlying values of the field.

The array must be returned to the DMSwarm using a matching call to restoreField.

fieldname (str) -- The textual name to identify this field.
The type of the entries in the array will match the type of the field.
numpy.ndarray

SEE ALSO:

restoreField, petsc.DMSwarmGetField


Source code at petsc4py/PETSc/DMSwarm.pyx:224


Return the local length of fields registered.

Not collective.

SEE ALSO:

petsc.DMSwarmGetLocalSize


Source code at petsc4py/PETSc/DMSwarm.pyx:391



Return the total length of fields registered.

Collective.

SEE ALSO:

petsc.DMSwarmGetSize


Source code at petsc4py/PETSc/DMSwarm.pyx:405



Initiate the registration of fields to a DMSwarm.

Collective.

After all fields have been registered, you must call finalizeFieldRegister.

SEE ALSO:

finalizeFieldRegister, petsc.DMSwarmInitializeFieldRegister


Source code at petsc4py/PETSc/DMSwarm.pyx:146



Insert point coordinates within each cell.

Not collective.

  • layout_type -- Method used to fill each cell with the cell DM.
  • fill_param (int) -- Parameter controlling how many points per cell are added (the meaning of this parameter is dependent on the layout type).
  • layoutType (PICLayoutType) --

None

SEE ALSO:

petsc.DMSwarmInsertPointsUsingCellDM


Source code at petsc4py/PETSc/DMSwarm.pyx:596


Relocate points defined in the DMSwarm to other MPI ranks.

Collective.

remove_sent_points (bool) -- Flag indicating if sent points should be removed from the current MPI rank.
None

SEE ALSO:

petsc.DMSwarmMigrate


Source code at petsc4py/PETSc/DMSwarm.pyx:419


Project a set of DMSwarm fields onto the cell DM.

Collective.

  • fieldnames (Sequence[str]) -- The textual names of the swarm fields to project.
  • vecs (Sequence[Vec]) --
  • mode (ScatterModeSpec) --

None

SEE ALSO:

petsc.DMSwarmProjectFields


Source code at petsc4py/PETSc/DMSwarm.pyx:805


Register a field to a DMSwarm with a native PETSc data type.

Collective.

  • fieldname (str) -- The textual name to identify this field.
  • blocksize (int) -- The number of each data type.
  • dtype (dtype) -- A valid PETSc data type.

None

SEE ALSO:

petsc.DMSwarmRegisterPetscDatatypeField


Source code at petsc4py/PETSc/DMSwarm.pyx:194


Remove the last point from the DMSwarm.

Not collective.

SEE ALSO:

petsc.DMSwarmRemovePoint


Source code at petsc4py/PETSc/DMSwarm.pyx:340



Remove a specific point from the DMSwarm.

Not collective.

index (int) -- Index of point to remove
None

SEE ALSO:

petsc.DMSwarmRemovePointAtIndex


Source code at petsc4py/PETSc/DMSwarm.pyx:352


Restore accesses associated with a registered field.

Not collective.

fieldname (str) -- The textual name to identify this field.
None

SEE ALSO:

getField, petsc.DMSwarmRestoreField


Source code at petsc4py/PETSc/DMSwarm.pyx:267


Attach a DM to a DMSwarm.

Collective.

dm (DM) -- The DM to attach to the DMSwarm.
None

SEE ALSO:

getCellDM, petsc.DMSwarmSetCellDM


Source code at petsc4py/PETSc/DMSwarm.pyx:462


Set the length of all registered fields on the DMSwarm.

Not collective.

  • nlocal (int) -- The length of each registered field.
  • buffer (int) -- The length of the buffer used for efficient dynamic resizing.

Self

SEE ALSO:

petsc.DMSwarmSetLocalSizes


Source code at petsc4py/PETSc/DMSwarm.pyx:172


Set point coordinates in a DMSwarm from a user-defined list.

Collective.

  • coordinates (Sequence[float]) -- The coordinate values.
  • redundant (bool) -- If set to True, it is assumed that coordinates are only valid on rank 0 and should be broadcast to other ranks.
  • mode (InsertMode | None) -- Indicates whether to append points to the swarm (InsertMode.ADD), or override existing points (InsertMode.INSERT).

None

SEE ALSO:

petsc.DMSwarmSetPointCoordinates


Source code at petsc4py/PETSc/DMSwarm.pyx:559


Insert point coordinates within each cell.

Not collective.

Point coordinates are defined over the reference cell.

coordinates (Sequence[float]) -- The coordinates (defined in the local coordinate system for each cell) to insert.
None

SEE ALSO:

petsc.DMSwarmSetPointCoordinatesCellwise


Source code at petsc4py/PETSc/DMSwarm.pyx:618


Set point coordinates in a DMSwarm on a regular (ijk) grid.

Collective.

  • min (Sequence[float]) -- Minimum coordinate values in the x, y, z directions (array of length dim).
  • max (Sequence[float]) -- Maximum coordinate values in the x, y, z directions (array of length dim).
  • npoints (Sequence[int]) -- Number of points in each spatial direction (array of length dim).
  • mode (InsertMode | None) -- Indicates whether to append points to the swarm (InsertMode.ADD), or override existing points (InsertMode.INSERT).

Self

SEE ALSO:

petsc.DMSwarmSetPointsUniformCoordinates


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


Set particular flavor of DMSwarm.

Collective.

dmswarm_type (Type | str) -- The DMSwarm type.
None

SEE ALSO:

petsc.DMSwarmSetType


Source code at petsc4py/PETSc/DMSwarm.pyx:496


Setup up a DMSwarm point sort context.

Not collective.

The point sort context is used for efficient traversal of points within a cell.

You must call sortRestoreAccess when you no longer need access to the sort context.

SEE ALSO:

sortRestoreAccess, petsc.DMSwarmSortGetAccess


Source code at petsc4py/PETSc/DMSwarm.pyx:693



Return whether the sort context is up-to-date.

Not collective.

Returns the flag associated with a DMSwarm point sorting context.

SEE ALSO:

petsc.DMSwarmSortGetIsValid


Source code at petsc4py/PETSc/DMSwarm.pyx:767



Return the number of points in a cell.

Not collective.

e (int) -- The index of the cell.
int

SEE ALSO:

petsc.DMSwarmSortGetNumberOfPointsPerCell


Source code at petsc4py/PETSc/DMSwarm.pyx:747


Create an array of point indices for all points in a cell.

Not collective.

e (int) -- The index of the cell.
list[int]

SEE ALSO:

petsc.DMSwarmSortGetPointsPerCell


Source code at petsc4py/PETSc/DMSwarm.pyx:723


Return the sizes associated with a DMSwarm point sorting context.

Not collective.

  • ncells (int) -- Number of cells within the sort context.
  • npoints (int) -- Number of points used to create the sort context.

tuple[int, int]

SEE ALSO:

petsc.DMSwarmSortGetSizes


Source code at petsc4py/PETSc/DMSwarm.pyx:783


Invalidate the DMSwarm point sorting context.

Not collective.

SEE ALSO:

sortGetAccess, petsc.DMSwarmSortRestoreAccess


Source code at petsc4py/PETSc/DMSwarm.pyx:711



Set the field from which to define a Vec object.

Collective.

The field will be used when DM.createLocalVec, or DM.createGlobalVec is called.

fieldname (str) -- The textual name given to a registered field.
None

SEE ALSO:

petsc.DMSwarmVectorDefineField


Source code at petsc4py/PETSc/DMSwarm.pyx:288


Write a selection of DMSwarm fields to an XDMF3 file.

Collective.

  • filename (str) -- The file name of the XDMF file (must have the extension .xmf).
  • fieldnames (Sequence[str]) -- Array containing the textual names of fields to write.

None

SEE ALSO:

petsc.DMSwarmViewFieldsXDMF


Source code at petsc4py/PETSc/DMSwarm.pyx:645


Write this DMSwarm fields to an XDMF3 file.

Collective.

filename (str) -- The file name of the XDMF file (must have the extension .xmf).
None

SEE ALSO:

petsc.DMSwarmViewXDMF


Source code at petsc4py/PETSc/DMSwarm.pyx:674




petsc4py.PETSc.DS

Bases: Object

Discrete System object.

Enumerations

Type

petsc4py.PETSc.DS.Type

Bases: object

Attributes Summary

BASIC Object BASIC of type str

Attributes Documentation

Object BASIC of type str


Methods Summary

create([comm]) Create an empty DS.
destroy() Destroy the discrete system.
getComponents() Return the number of components for each field on an evaluation point.
getCoordinateDimension() Return the coordinate dimension of the DS.
getDimensions() Return the size of the space for each field on an evaluation point.
getFieldIndex(disc) Return the index of the given field.
getNumFields() Return the number of fields in the DS.
getSpatialDimension() Return the spatial dimension of the DS.
getTotalComponents() Return the total number of components in this system.
getTotalDimensions() Return the total size of the approximation space for this system.
getType() Return the type of the discrete system.
setDiscretisation(f, disc) Set the discretization object for the given field.
setFromOptions() Set parameters in a DS from the options database.
setType(ds_type) Build a particular type of a discrete system.
setUp() Construct data structures for the discrete system.
view([viewer]) View a discrete system.

Methods Documentation

Create an empty DS.

Collective.

The type can then be set with setType.

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

SEE ALSO:

setType, destroy, petsc.PetscDSCreate


Source code at petsc4py/PETSc/DS.pyx:51


Destroy the discrete system.

Collective.

SEE ALSO:

create, petsc.PetscDSDestroy


Source code at petsc4py/PETSc/DS.pyx:38



Return the number of components for each field on an evaluation point.

Not collective.

SEE ALSO:

petsc.PetscDSGetComponents


Source code at petsc4py/PETSc/DS.pyx:244

ArrayInt


Return the coordinate dimension of the DS.

Not collective.

The coordinate dimension of the DS is the dimension of the space into which the discretiaztions are embedded.

SEE ALSO:

petsc.PetscDSGetCoordinateDimension


Source code at petsc4py/PETSc/DS.pyx:151



Return the size of the space for each field on an evaluation point.

Not collective.

SEE ALSO:

petsc.PetscDSGetDimensions


Source code at petsc4py/PETSc/DS.pyx:229

ArrayInt


Return the index of the given field.

Not collective.

disc (Object) -- The discretization object.
int

SEE ALSO:

petsc.PetscDSGetFieldIndex


Source code at petsc4py/PETSc/DS.pyx:182


Return the number of fields in the DS.

Not collective.

SEE ALSO:

petsc.PetscDSGetNumFields


Source code at petsc4py/PETSc/DS.pyx:168



Return the spatial dimension of the DS.

Not collective.

The spatial dimension of the DS is the topological dimension of the discretizations.

SEE ALSO:

petsc.PetscDSGetSpatialDimension


Source code at petsc4py/PETSc/DS.pyx:134



Return the total number of components in this system.

Not collective.

SEE ALSO:

petsc.PetscDSGetTotalComponents


Source code at petsc4py/PETSc/DS.pyx:215



Return the total size of the approximation space for this system.

Not collective.

SEE ALSO:

petsc.PetscDSGetTotalDimension


Source code at petsc4py/PETSc/DS.pyx:201



Return the type of the discrete system.

Not collective.

SEE ALSO:

setType, petsc.PetscDSGetType


Source code at petsc4py/PETSc/DS.pyx:93



Set the discretization object for the given field.

Not collective.

  • f (int) -- The field number.
  • disc (Object) -- The discretization object.

None

SEE ALSO:

petsc.PetscDSSetDiscretization


Source code at petsc4py/PETSc/DS.pyx:259


Set parameters in a DS from the options database.

Collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.PetscDSSetFromOptions


Source code at petsc4py/PETSc/DS.pyx:107



Build a particular type of a discrete system.

Collective.

ds_type (Type | str) -- The type of the discrete system.
None

SEE ALSO:

getType, petsc.PetscDSSetType


Source code at petsc4py/PETSc/DS.pyx:74


Construct data structures for the discrete system.

Collective.

SEE ALSO:

petsc.PetscDSSetUp


Source code at petsc4py/PETSc/DS.pyx:119



View a discrete system.

Collective.

viewer (Viewer | None) -- A Viewer to display the system.
None

SEE ALSO:

petsc.PetscDSView


Source code at petsc4py/PETSc/DS.pyx:19




petsc4py.PETSc.Device

Bases: object

The device object.

Represents a handle to an accelerator (which may be the host).

SEE ALSO:

DeviceContext, petsc.PetscDevice


Enumerations

Type The type of device.

petsc4py.PETSc.Device.Type

Bases: object

The type of device.

SEE ALSO:

Device, Device.create, Device.getDeviceType, Device.type, petsc.PetscDeviceType


Attributes Summary

CUDA Constant CUDA of type int
DEFAULT Constant DEFAULT of type int
HIP Constant HIP of type int
HOST Constant HOST of type int
SYCL Constant SYCL of type int

Attributes Documentation

Constant CUDA of type int

Constant DEFAULT of type int

Constant HIP of type int

Constant HOST of type int

Constant SYCL of type int


Methods Summary

configure() Configure and setup a device object.
create([dtype, device_id]) Create a device object.
destroy() Destroy a device object.
getDeviceId() Return the device id.
getDeviceType() Return the type of the device.
setDefaultType(device_type) Set the device type to be used as the default in subsequent calls to create.
view([viewer]) View a device object.

Attributes Summary

device_id The device id.
type The device type.

Methods Documentation

Configure and setup a device object.

Not collective.

SEE ALSO:

create, petsc.PetscDeviceConfigure


Source code at petsc4py/PETSc/Device.pyx:128



Create a device object.

Not collective.

  • dtype (Type | None) -- The type of device to create (or None for the default).
  • device_id (int) -- The numeric id of the device to create.

Device

SEE ALSO:

destroy, petsc.PetscDeviceCreate


Source code at petsc4py/PETSc/Device.pyx:90


Destroy a device object.

Not collective.

SEE ALSO:

create, petsc.PetscDeviceDestroy


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



Return the device id.

Not collective.

SEE ALSO:

create, petsc.PetscDeviceGetDeviceId


Source code at petsc4py/PETSc/Device.pyx:176



Return the type of the device.

Not collective.

SEE ALSO:

type, petsc.PetscDeviceGetType


Source code at petsc4py/PETSc/Device.pyx:161



Set the device type to be used as the default in subsequent calls to create.

Not collective.

SEE ALSO:

create, petsc.PetscDeviceSetDefaultDeviceType


Source code at petsc4py/PETSc/Device.pyx:191

device_type (Type | str) --
None


View a device object.

Collective.

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

SEE ALSO:

petsc.PetscDeviceView


Source code at petsc4py/PETSc/Device.pyx:140


Attributes Documentation

The device id.

Source code at petsc4py/PETSc/Device.pyx:211


The device type.

Source code at petsc4py/PETSc/Device.pyx:206




petsc4py.PETSc.DeviceContext

Bases: Object

DeviceContext object.

Represents an abstract handle to a device context.

SEE ALSO:

Device, petsc.PetscDeviceContext


Enumerations

DeviceJoinMode The type of join to perform.
StreamType The type of stream.

petsc4py.PETSc.DeviceContext.DeviceJoinMode

Bases: object

The type of join to perform.

SEE ALSO:

DeviceContext, DeviceContext.join, DeviceContext.fork, petsc.PetscDeviceContextJoinMode


Attributes Summary

DESTROY Constant DESTROY of type int
NO_SYNC Constant NO_SYNC of type int
SYNC Constant SYNC of type int

Attributes Documentation

Constant DESTROY of type int

Constant NO_SYNC of type int

Constant SYNC of type int


petsc4py.PETSc.DeviceContext.StreamType

Bases: object

The type of stream.

SEE ALSO:

DeviceContext, DeviceContext.getStreamType, DeviceContext.setStreamType, petsc.PetscStreamType


Attributes Summary

DEFAULT_BLOCKING Constant DEFAULT_BLOCKING of type int
GLOBAL_BLOCKING Constant GLOBAL_BLOCKING of type int
GLOBAL_NONBLOCKING Constant GLOBAL_NONBLOCKING of type int

Attributes Documentation

Constant DEFAULT_BLOCKING of type int

Constant GLOBAL_BLOCKING of type int

Constant GLOBAL_NONBLOCKING of type int


Methods Summary

create() Create an empty DeviceContext.
duplicate() Duplicate a the device context.
fork(n[, stream_type]) Create multiple device contexts which are all logically dependent on this one.
getCurrent() Return the current device context.
getDevice() Get the Device which this instance is attached to.
getStreamType() Return the StreamType.
idle() Return whether the underlying stream for the device context is idle.
join(join_mode, py_sub_ctxs) Join a set of device contexts on this one.
setCurrent(dctx) Set the current device context.
setDevice(device) Set the Device which this DeviceContext is attached to.
setFromOptions([comm]) Configure the DeviceContext from the options database.
setStreamType(stream_type) Set the StreamType.
setUp() Set up the internal data structures for using the device context.
synchronize() Synchronize a device context.
waitFor(other) Make this instance wait for other.

Attributes Summary

current The current global device context.
device The device associated to the device context.
stream_type The stream type.

Methods Documentation

Create an empty DeviceContext.

Not collective.

SEE ALSO:

Device, petsc.PetscDeviceContextCreate


Source code at petsc4py/PETSc/Device.pyx:239

DeviceContext


Duplicate a the device context.

Not collective.

SEE ALSO:

create, petsc.PetscDeviceContextDuplicate


Source code at petsc4py/PETSc/Device.pyx:336

DeviceContext


Create multiple device contexts which are all logically dependent on this one.

Not collective.

  • n (int) -- The number of device contexts to create.
  • stream_type (StreamType | str | None) -- The type of stream of the forked device context.

list[DeviceContext]

SEE ALSO:

join, waitFor, petsc.PetscDeviceContextFork


Source code at petsc4py/PETSc/Device.pyx:387


Return the current device context.

Not collective.

SEE ALSO:

current, setCurrent, petsc.PetscDeviceContextGetCurrentContext


Source code at petsc4py/PETSc/Device.pyx:487

DeviceContext


Get the Device which this instance is attached to.

Not collective.

SEE ALSO:

setDevice, device, Device, petsc.PetscDeviceContextGetDevice


Source code at petsc4py/PETSc/Device.pyx:289

Device


Return the StreamType.

Not collective.

SEE ALSO:

stream_type, setStreamType, petsc.PetscDeviceContextGetStreamType


Source code at petsc4py/PETSc/Device.pyx:255



Return whether the underlying stream for the device context is idle.

Not collective.

SEE ALSO:

synchronize, petsc.PetscDeviceContextQueryIdle


Source code at petsc4py/PETSc/Device.pyx:351



Join a set of device contexts on this one.

Not collective.

  • join_mode (DeviceJoinMode | str) -- The type of join to perform.
  • py_sub_ctxs (list[DeviceContext]) -- The list of device contexts to join.

None

SEE ALSO:

fork, waitFor, petsc.PetscDeviceContextJoin


Source code at petsc4py/PETSc/Device.pyx:417


Set the current device context.

Not collective.

dctx (DeviceContext | None) -- The DeviceContext to set as current (or None to use the default context).
None

SEE ALSO:

current, getCurrent, petsc.PetscDeviceContextSetCurrentContext


Source code at petsc4py/PETSc/Device.pyx:503


Set the Device which this DeviceContext is attached to.

Collective.

device (Device) -- The Device to which this instance is attached to.
None

SEE ALSO:

getDevice, device, Device, petsc.PetscDeviceContextSetDevice


Source code at petsc4py/PETSc/Device.pyx:304


Configure the DeviceContext from the options database.

Collective.

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

SEE ALSO:

Sys.getDefaultComm, petsc.PetscDeviceContextSetFromOptions


Source code at petsc4py/PETSc/Device.pyx:468


Set the StreamType.

Not collective.

stream_type (StreamType | str) -- The type of stream to set
None

SEE ALSO:

stream_type, getStreamType, petsc.PetscDeviceContextSetStreamType


Source code at petsc4py/PETSc/Device.pyx:270


Set up the internal data structures for using the device context.

Not collective.

SEE ALSO:

create, petsc.PetscDeviceContextSetUp


Source code at petsc4py/PETSc/Device.pyx:324



Synchronize a device context.

Not collective.

Notes

The underlying stream is considered idle after this routine returns, i.e. idle will return True.

SEE ALSO:

idle, petsc.PetscDeviceContextSynchronize


Source code at petsc4py/PETSc/Device.pyx:451



Make this instance wait for other.

Not collective.

other (DeviceContext | None) -- The other DeviceContext to wait for
None

SEE ALSO:

fork, join, petsc.PetscDeviceContextWaitForContext


Source code at petsc4py/PETSc/Device.pyx:366


Attributes Documentation

The current global device context.

Source code at petsc4py/PETSc/Device.pyx:540


The device associated to the device context.

Source code at petsc4py/PETSc/Device.pyx:533


The stream type.

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




petsc4py.PETSc.DualSpace

Bases: Object

Dual space to a linear space.

Enumerations

Type

petsc4py.PETSc.DualSpace.Type

Bases: object

Attributes Summary

BDM Object BDM of type str
LAGRANGE Object LAGRANGE of type str
REFINED Object REFINED of type str
SIMPLE Object SIMPLE of type str

Attributes Documentation

Object BDM of type str

Object LAGRANGE of type str

Object REFINED of type str

Object SIMPLE of type str


Methods Summary

create([comm]) Create an empty DualSpace object.
destroy() Destroy the DualSpace object.
duplicate() Create a duplicate DualSpace object that is not set up.
getDM() Return the DM representing the reference cell of a DualSpace.
getDimension() Return the dimension of the dual space.
getFunctional(i) Return the i-th basis functional in the dual space.
getInteriorDimension() Return the interior dimension of the dual space.
getLagrangeContinuity() Return whether the element is continuous.
getLagrangeTensor() Return the tensor nature of the dual space.
getLagrangeTrimmed() Return the trimmed nature of the dual space.
getNumComponents() Return the number of components for this space.
getNumDof() Return the number of degrees of freedom for each spatial dimension.
getOrder() Return the order of the dual space.
getType() Return the type of the dual space object.
setDM(dm) Set the DM representing the reference cell.
setLagrangeContinuity(continuous) Indicate whether the element is continuous.
setLagrangeTensor(tensor) Set the tensor nature of the dual space.
setLagrangeTrimmed(trimmed) Set the trimmed nature of the dual space.
setNumComponents(nc) Set the number of components for this space.
setOrder(order) Set the order of the dual space.
setSimpleDimension(dim) Set the number of functionals in the dual space basis.
setSimpleFunctional(func, functional) Set the given basis element for this dual space.
setType(dualspace_type) Build a particular type of dual space.
setUp() Construct a basis for a DualSpace.
view([viewer]) View a DualSpace.
viewFromOptions(name[, obj]) View a DualSpace based on values in the options database.

Methods Documentation

Create an empty DualSpace object.

Collective.

The type can then be set with setType.

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

SEE ALSO:

petsc.PetscDualSpaceCreate


Source code at petsc4py/PETSc/Space.pyx:581


Destroy the DualSpace object.

Collective.

SEE ALSO:

petsc.PetscDualSpaceDestroy


Source code at petsc4py/PETSc/Space.pyx:623



Create a duplicate DualSpace object that is not set up.

Collective.

SEE ALSO:

petsc.PetscDualSpaceDuplicate


Source code at petsc4py/PETSc/Space.pyx:636

DualSpace


Return the DM representing the reference cell of a DualSpace.

Not collective.

SEE ALSO:

setDM, petsc.PetscDualSpaceGetDM


Source code at petsc4py/PETSc/Space.pyx:649



Return the dimension of the dual space.

Not collective.

The dimension of the dual space, i.e. the number of basis functionals.

SEE ALSO:

petsc.PetscDualSpaceGetDimension


Source code at petsc4py/PETSc/Space.pyx:680



Return the i-th basis functional in the dual space.

Not collective.

i (int) -- The basis number.
Quad

SEE ALSO:

petsc.PetscDualSpaceGetFunctional


Source code at petsc4py/PETSc/Space.pyx:806


Return the interior dimension of the dual space.

Not collective.

The interior dimension of the dual space, i.e. the number of basis functionals assigned to the interior of the reference domain.

SEE ALSO:

petsc.PetscDualSpaceGetInteriorDimension


Source code at petsc4py/PETSc/Space.pyx:826



Return whether the element is continuous.

Not collective.

SEE ALSO:

setLagrangeContinuity, petsc.PetscDualSpaceLagrangeGetContinuity


Source code at petsc4py/PETSc/Space.pyx:843



Return the tensor nature of the dual space.

Not collective.

SEE ALSO:

setLagrangeTensor, petsc.PetscDualSpaceLagrangeGetTensor


Source code at petsc4py/PETSc/Space.pyx:875



Return the trimmed nature of the dual space.

Not collective.

SEE ALSO:

setLagrangeTrimmed, petsc.PetscDualSpaceLagrangeGetTrimmed


Source code at petsc4py/PETSc/Space.pyx:907



Return the number of components for this space.

SEE ALSO:

setNumComponents, petsc.PetscDualSpaceGetNumComponents


Source code at petsc4py/PETSc/Space.pyx:696



Return the number of degrees of freedom for each spatial dimension.

Not collective.

SEE ALSO:

petsc.PetscDualSpaceGetNumDof


Source code at petsc4py/PETSc/Space.pyx:790

ArrayInt


Return the order of the dual space.

Not collective.

SEE ALSO:

setOrder, petsc.PetscDualSpaceGetOrder


Source code at petsc4py/PETSc/Space.pyx:758



Return the type of the dual space object.

Not collective.

SEE ALSO:

setType, petsc.PetscDualSpaceGetType


Source code at petsc4py/PETSc/Space.pyx:724



Set the DM representing the reference cell.

Not collective.

dm (DM) -- The reference cell.
None

SEE ALSO:

getDM, petsc.PetscDualSpaceSetDM


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


Indicate whether the element is continuous.

Not collective.

continuous (bool) -- The flag for element continuity.
None

SEE ALSO:

getLagrangeContinuity, petsc.PetscDualSpaceLagrangeSetContinuity


Source code at petsc4py/PETSc/Space.pyx:857


Set the tensor nature of the dual space.

Not collective.

tensor (bool) -- Whether the dual space has tensor layout (vs. simplicial).
None

SEE ALSO:

getLagrangeTensor, petsc.PetscDualSpaceLagrangeSetTensor


Source code at petsc4py/PETSc/Space.pyx:889


Set the trimmed nature of the dual space.

Not collective.

trimmed (bool) -- Whether the dual space represents to dual basis of a trimmed polynomial space (e.g. Raviart-Thomas and higher order / other form degree variants).
None

SEE ALSO:

getLagrangeTrimmed, petsc.PetscDualSpaceLagrangeSetTrimmed


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


Set the number of components for this space.
nc (int) -- The number of components
None

SEE ALSO:

getNumComponents, petsc.PetscDualSpaceSetNumComponents


Source code at petsc4py/PETSc/Space.pyx:708


Set the order of the dual space.

Not collective.

order (int) -- The order.
None

SEE ALSO:

getOrder, petsc.PetscDualSpaceSetOrder


Source code at petsc4py/PETSc/Space.pyx:772


Set the number of functionals in the dual space basis.

Logically collective.

dim (int) -- The basis dimension.
None

SEE ALSO:

petsc.PetscDualSpaceSimpleSetDimension


Source code at petsc4py/PETSc/Space.pyx:964


Set the given basis element for this dual space.

Not collective.

  • func (int) -- The basis index.
  • functional (Quad) -- The basis functional.

None

SEE ALSO:

petsc.PetscDualSpaceSimpleSetFunctional


Source code at petsc4py/PETSc/Space.pyx:982


Build a particular type of dual space.

Collective.

dualspace_type (Type | str) -- The kind of space.
Self

SEE ALSO:

getType, petsc.PetscDualSpaceSetType


Source code at petsc4py/PETSc/Space.pyx:738


Construct a basis for a DualSpace.

Collective.

SEE ALSO:

petsc.PetscDualSpaceSetUp


Source code at petsc4py/PETSc/Space.pyx:569



View a DualSpace.

Collective.

viewer (Viewer | None) -- A Viewer to display the DualSpace.
None

SEE ALSO:

petsc.PetscDualSpaceView


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


View a DualSpace based on values in the options database.

Collective.

  • name (str) -- Command line option name.
  • obj (Object | None) -- Optional object that provides the options prefix.

None

SEE ALSO:

Working with PETSc options (TODO), petsc.PetscSpaceViewFromOptions


Source code at petsc4py/PETSc/Space.pyx:941




petsc4py.PETSc.FE

Bases: Object

A PETSc object that manages a finite element space.

Enumerations

Type

petsc4py.PETSc.FE.Type

Bases: object

Attributes Summary

BASIC Object BASIC of type str
COMPOSITE Object COMPOSITE of type str
OPENCL Object OPENCL of type str

Attributes Documentation

Object BASIC of type str

Object COMPOSITE of type str

Object OPENCL of type str


Methods Summary

create([comm]) Create an empty FE object.
createDefault(dim, nc, isSimplex[, qorder, ...]) Create a FE for basic FEM computation.
createLagrange(dim, nc, isSimplex, k[, ...]) Create a FE for the basic Lagrange space of degree k.
destroy() Destroy the FE object.
getBasisSpace() Return the Space used for the approximation of the FE solution.
getDimension() Return the dimension of the finite element space on a cell.
getDualSpace() Return the DualSpace used to define the inner product for the FE.
getFaceQuadrature() Return the Quad used to calculate inner products on faces.
getNumComponents() Return the number of components in the element.
getNumDof() Return the number of DOFs.
getQuadrature() Return the Quad used to calculate inner products.
getSpatialDimension() Return the spatial dimension of the element.
getTileSizes() Return the tile sizes for evaluation.
setBasisSpace(sp) Set the Space used for the approximation of the solution.
setDualSpace(dspace) Set the DualSpace used to define the inner product.
setFaceQuadrature(quad) Set the Quad used to calculate inner products on faces.
setFromOptions() Set parameters in a FE from the options database.
setNumComponents(comp) Set the number of field components in the element.
setQuadrature(quad) Set the Quad used to calculate inner products.
setTileSizes(blockSize, numBlocks, ...) Set the tile sizes for evaluation.
setType(fe_type) Build a particular FE.
setUp() Construct data structures for the FE after the Type has been set.
view([viewer]) View a FE object.
viewFromOptions(name[, obj]) View from a FE based on values in the options database.

Methods Documentation

Create an empty FE object.

Collective.

The type can then be set with setType.

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

SEE ALSO:

setType, petsc.PetscFECreate


Source code at petsc4py/PETSc/FE.pyx:51


Create a FE for basic FEM computation.

Collective.

  • dim (int) -- The spatial dimension.
  • nc (int) -- The number of components.
  • isSimplex (bool) -- Flag for simplex reference cell, otherwise it's a tensor product.
  • qorder (int) -- The quadrature order or DETERMINE to use Space polynomial degree.
  • prefix (str) -- The options prefix, or None.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.PetscFECreateDefault


Source code at petsc4py/PETSc/FE.pyx:74


Create a FE for the basic Lagrange space of degree k.

Collective.

  • dim (int) -- The spatial dimension.
  • nc (int) -- The number of components.
  • isSimplex (bool) -- Flag for simplex reference cell, otherwise it's a tensor product.
  • k (int) -- The degree of the space.
  • qorder (int) -- The quadrature order or DETERMINE to use Space polynomial degree.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.PetscFECreateLagrange


Source code at petsc4py/PETSc/FE.pyx:121


Destroy the FE object.

Collective.

SEE ALSO:

petsc.PetscFEDestroy


Source code at petsc4py/PETSc/FE.pyx:38



Return the Space used for the approximation of the FE solution.

Not collective.

SEE ALSO:

setBasisSpace, petsc.PetscFEGetBasisSpace


Source code at petsc4py/PETSc/FE.pyx:386

Space


Return the dimension of the finite element space on a cell.

Not collective.

SEE ALSO:

petsc.PetscFEGetDimension


Source code at petsc4py/PETSc/FE.pyx:180



Return the DualSpace used to define the inner product for the FE.

Not collective.

SEE ALSO:

setDualSpace, DualSpace, petsc.PetscFEGetDualSpace


Source code at petsc4py/PETSc/FE.pyx:441

DualSpace


Return the Quad used to calculate inner products on faces.

Not collective.

SEE ALSO:

setFaceQuadrature, petsc.PetscFEGetFaceQuadrature


Source code at petsc4py/PETSc/FE.pyx:316



Return the number of components in the element.

Not collective.

SEE ALSO:

setNumComponents, petsc.PetscFEGetNumComponents


Source code at petsc4py/PETSc/FE.pyx:208



Return the number of DOFs.

Not collective.

Return the number of DOFs (dual basis vectors) associated with mesh points on the reference cell of a given dimension.

SEE ALSO:

petsc.PetscFEGetNumDof


Source code at petsc4py/PETSc/FE.pyx:240

ndarray


Return the Quad used to calculate inner products.

Not collective.

SEE ALSO:

setQuadrature, petsc.PetscFEGetQuadrature


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



Return the spatial dimension of the element.

Not collective.

SEE ALSO:

petsc.PetscFEGetSpatialDimension


Source code at petsc4py/PETSc/FE.pyx:194



Return the tile sizes for evaluation.

Not collective.

  • blockSize (int) -- The number of elements in a block.
  • numBlocks (int) -- The number of blocks in a batch.
  • batchSize (int) -- The number of elements in a batch.
  • numBatches (int) -- The number of batches in a chunk.

tuple(int, int, int, int)

SEE ALSO:

setTileSizes, petsc.PetscFEGetTileSizes


Source code at petsc4py/PETSc/FE.pyx:259


Set the Space used for the approximation of the solution.

Not collective.

sp (Space) -- The Space object.
None

SEE ALSO:

getBasisSpace, petsc.PetscFESetBasisSpace


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


Set the DualSpace used to define the inner product.

Not collective.

dspace (DualSpace) -- The DualSpace object.
None

SEE ALSO:

getDualSpace, DualSpace, petsc.PetscFESetDualSpace


Source code at petsc4py/PETSc/FE.pyx:455


Set the Quad used to calculate inner products on faces.

Not collective.

quad (Quad) -- The Quad object.
Quad

SEE ALSO:

getFaceQuadrature, petsc.PetscFESetFaceQuadrature


Source code at petsc4py/PETSc/FE.pyx:348


Set parameters in a FE from the options database.

Collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.PetscFESetFromOptions


Source code at petsc4py/PETSc/FE.pyx:417



Set the number of field components in the element.

Not collective.

comp (int) -- The number of field components.
None

SEE ALSO:

getNumComponents, petsc.PetscFESetNumComponents


Source code at petsc4py/PETSc/FE.pyx:222


Set the Quad used to calculate inner products.

Not collective.

quad (Quad) -- The Quad object.
Self

SEE ALSO:

getQuadrature, petsc.PetscFESetQuadrature


Source code at petsc4py/PETSc/FE.pyx:330


Set the tile sizes for evaluation.

Not collective.

  • blockSize (int) -- The number of elements in a block.
  • numBlocks (int) -- The number of blocks in a batch.
  • batchSize (int) -- The number of elements in a batch.
  • numBatches (int) -- The number of batches in a chunk.

None

SEE ALSO:

getTileSizes, petsc.PetscFESetTileSizes


Source code at petsc4py/PETSc/FE.pyx:285


Build a particular FE.

Collective.

fe_type (Type | str) -- The kind of FEM space.
Self

SEE ALSO:

petsc.PetscFESetType


Source code at petsc4py/PETSc/FE.pyx:366


Construct data structures for the FE after the Type has been set.

Collective.

SEE ALSO:

petsc.PetscFESetUp


Source code at petsc4py/PETSc/FE.pyx:429



View a FE object.

Collective.

viewer (Viewer | None) -- A Viewer to display the graph.
None

SEE ALSO:

petsc.PetscFEView


Source code at petsc4py/PETSc/FE.pyx:19


View from a FE based on values in the options database.

Collective.

  • name (str) -- Command line option name.
  • obj (Object | None) -- Optional object that provides the options prefix.

None

SEE ALSO:

Working with PETSc options (TODO), petsc.PetscFEViewFromOptions


Source code at petsc4py/PETSc/FE.pyx:472




petsc4py.PETSc.IS

Bases: Object

A collection of indices.

IS objects are used to index into vectors and matrices and to set up vector scatters.

SEE ALSO:

petsc.IS


Enumerations

Type

petsc4py.PETSc.IS.Type

Bases: object

Attributes Summary

BLOCK Object BLOCK of type str
GENERAL Object GENERAL of type str
STRIDE Object STRIDE of type str

Attributes Documentation

Object BLOCK of type str

Object GENERAL of type str

Object STRIDE of type str


Methods Summary

allGather() Concatenate index sets stored across processors.
buildTwoSided([toindx]) Create an index set describing a global mapping.
complement(nmin, nmax) Create a complement index set.
copy([result]) Copy the contents of the index set into another.
create([comm]) Create an IS.
createBlock(bsize, indices[, comm]) Create a blocked index set.
createGeneral(indices[, comm]) Create an IS with indices.
createStride(size[, first, step, comm]) Create an index set consisting of evenly spaced values.
destroy() Destroy the index set.
difference(iset) Return the difference between two index sets.
duplicate() Create a copy of the index set.
embed(iset, drop) Embed self into iset.
equal(iset) Return whether the index sets have the same set of indices or not.
expand(iset) Return the union of two (possibly unsorted) index sets.
getBlockIndices() Return the indices of an index set with type IS.Type.BLOCK.
getBlockSize() Return the number of elements in a block.
getIndices() Return the indices of the index set.
getInfo() Return stride information for an index set with type IS.Type.STRIDE.
getLocalSize() Return the process-local length of the index set.
getSize() Return the global length of an index set.
getSizes() Return the local and global sizes of the index set.
getStride() Return size and stride information.
getType() Return the index set type associated with the IS.
invertPermutation([nlocal]) Invert the index set.
isIdentity() Return whether the index set has been declared as an identity.
isPermutation() Return whether an index set has been declared to be a permutation.
isSorted() Return whether the indices have been sorted.
load(viewer) Load a stored index set.
renumber([mult]) Renumber the non-negative entries of an index set, starting from 0.
setBlockIndices(bsize, indices) Set the indices for an index set with type IS.Type.BLOCK.
setBlockSize(bs) Set the block size of the index set.
setIdentity() Mark the index set as being an identity.
setIndices(indices) Set the indices of an index set.
setPermutation() Mark the index set as being a permutation.
setStride(size[, first, step]) Set the stride information for an index set with type IS.Type.STRIDE.
setType(is_type) Set the type of the index set.
sort() Sort the indices of an index set.
sum(iset) Return the union of two (sorted) index sets.
toGeneral() Convert the index set type to IS.Type.GENERAL.
union(iset) Return the union of two (possibly unsorted) index sets.
view([viewer]) Display the index set.

Attributes Summary

array View of the index set as an array of integers.
block_size The number of elements in a block.
identity True if index set is an identity, False otherwise.
indices The indices of the index set.
local_size The local size of the index set.
permutation True if index set is a permutation, False otherwise.
size The global size of the index set.
sizes The local and global sizes of the index set.
sorted True if index set is sorted, False otherwise.

Methods Documentation

Concatenate index sets stored across processors.

Collective.

The returned index set will be the same on every processor.

SEE ALSO:

petsc.ISAllGather


Source code at petsc4py/PETSc/IS.pyx:306



Create an index set describing a global mapping.

Collective.

This function generates an index set that contains new numbers from remote or local on the index set.

toindx (IS | None) -- Index set describing which indices to send, default is to send natural numbering.
New index set containing the new numbers from remote or local.
IS

SEE ALSO:

petsc.ISBuildTwoSided


Source code at petsc4py/PETSc/IS.pyx:335


Create a complement index set.

Collective.

The complement set of indices is all indices that are not in the provided set (and within the provided bounds).

  • nmin (int) -- Minimum index that can be found in the local part of the complement index set.
  • nmax (int) -- One greater than the maximum index that can be found in the local part of the complement index set.

IS

Notes

For a parallel index set, this will generate the local part of the complement on each process.

To generate the entire complement (on each process) of a parallel index set, first call IS.allGather and then call this method.

SEE ALSO:

IS.allGather, petsc.ISComplement


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


Copy the contents of the index set into another.

Collective.

result (IS | None) -- The target index set. If None then IS.duplicate is called first.
The copied index set. If result is not None then this is returned here.
IS

SEE ALSO:

IS.duplicate, petsc.ISCopy


Source code at petsc4py/PETSc/IS.pyx:255


Create an IS.

Collective.

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

SEE ALSO:

petsc.ISCreate


Source code at petsc4py/PETSc/IS.pyx:87


Create a blocked index set.

Collective.

  • bsize (int) -- Block size.
  • indices (Sequence[int]) -- Integer array of indices.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.ISCreateBlock


Source code at petsc4py/PETSc/IS.pyx:171


Create an IS with indices.

Collective.

  • indices (Sequence[int]) -- Integer array.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.ISCreateGeneral


Source code at petsc4py/PETSc/IS.pyx:141


Create an index set consisting of evenly spaced values.

Collective.

  • size (int) -- The length of the locally owned portion of the index set.
  • first (int) -- The first element of the index set.
  • step (int) -- The difference between adjacent indices.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.ISCreateStride


Source code at petsc4py/PETSc/IS.pyx:205


Destroy the index set.

Collective.

SEE ALSO:

petsc.ISDestroy


Source code at petsc4py/PETSc/IS.pyx:74



Return the difference between two index sets.

Collective.

iset (IS) -- Index set to compute the difference with.
Index set representing the difference between self and iset.
IS

SEE ALSO:

petsc.ISDifference


Source code at petsc4py/PETSc/IS.pyx:652


Create a copy of the index set.

Collective.

SEE ALSO:

IS.copy, petsc.ISDuplicate


Source code at petsc4py/PETSc/IS.pyx:241



Embed self into iset.

Not collective.

The embedding is performed by finding the locations in iset that have the same indices as self.

  • iset (IS) -- The index set to embed into.
  • drop (bool) -- Flag indicating whether to drop indices from self that are not in iset.

The embedded index set.
IS

SEE ALSO:

petsc.ISEmbed


Source code at petsc4py/PETSc/IS.pyx:712


Return whether the index sets have the same set of indices or not.

Collective.

iset (IS) -- The index set to compare indices with.
bool

SEE ALSO:

petsc.ISEqual


Source code at petsc4py/PETSc/IS.pyx:552


Return the union of two (possibly unsorted) index sets.

Collective.

To compute the union, expand concatenates the two index sets and removes any duplicates.

iset (IS) -- Index set to compute the union with.
The new, combined, index set.
IS

SEE ALSO:

petsc.ISExpand


Source code at petsc4py/PETSc/IS.pyx:590


Return the indices of an index set with type IS.Type.BLOCK.

Not collective.

SEE ALSO:

petsc.ISBlockGetIndices


Source code at petsc4py/PETSc/IS.pyx:835

ArrayInt


Return the number of elements in a block.

Not collective.

SEE ALSO:

petsc.ISGetBlockSize


Source code at petsc4py/PETSc/IS.pyx:439



Return the indices of the index set.

Not collective.

SEE ALSO:

petsc.ISGetIndices


Source code at petsc4py/PETSc/IS.pyx:791

ArrayInt


Return stride information for an index set with type IS.Type.STRIDE.

Not collective.

  • first (int) -- First element of the index set.
  • step (int) -- Difference between adjacent indices.

tuple[int, int]

SEE ALSO:

IS.getStride, petsc.ISStrideGetInfo


Source code at petsc4py/PETSc/IS.pyx:905


Return the process-local length of the index set.

Not collective.

SEE ALSO:

petsc.ISGetLocalSize


Source code at petsc4py/PETSc/IS.pyx:403



Return the global length of an index set.

Not collective.

SEE ALSO:

petsc.ISGetSize


Source code at petsc4py/PETSc/IS.pyx:389



Return the local and global sizes of the index set.

Not collective.

  • local_size (int) -- The local size.
  • global_size (int) -- The global size.

tuple[int, int]

SEE ALSO:

IS.getLocalSize, IS.getSize


Source code at petsc4py/PETSc/IS.pyx:417


Return size and stride information.

Not collective.

  • size (int) -- Length of the locally owned portion of the index set.
  • first (int) -- First element of the index set.
  • step (int) -- Difference between adjacent indices.

tuple[int, int, int]

SEE ALSO:

petsc.ISGetLocalSize, petsc.ISStrideGetInfo


Source code at petsc4py/PETSc/IS.pyx:881


Return the index set type associated with the IS.

Not collective.

SEE ALSO:

petsc.ISGetType


Source code at petsc4py/PETSc/IS.pyx:127



Invert the index set.

Collective.

For this to be correct the index set must be a permutation.

nlocal (int | None) -- The number of indices on this processor in the resulting index set, defaults to PETSC_DECIDE.
IS

SEE ALSO:

petsc.ISInvertPermutation


Source code at petsc4py/PETSc/IS.pyx:365


Return whether the index set has been declared as an identity.

Collective.

SEE ALSO:

petsc.ISIdentity


Source code at petsc4py/PETSc/IS.pyx:538



Return whether an index set has been declared to be a permutation.

Logically collective.

SEE ALSO:

petsc.ISPermutation


Source code at petsc4py/PETSc/IS.pyx:511



Return whether the indices have been sorted.

Collective.

SEE ALSO:

petsc.ISSorted


Source code at petsc4py/PETSc/IS.pyx:484



Load a stored index set.

Collective.

viewer (Viewer) -- Binary file viewer, either Viewer.Type.BINARY or Viewer.Type.HDF5.
Self

SEE ALSO:

petsc.ISLoad


Source code at petsc4py/PETSc/IS.pyx:283


Renumber the non-negative entries of an index set, starting from 0.

Collective.

mult (IS | None) -- The multiplicity of each entry in self, default implies a multiplicity of 1.
  • int -- One past the largest entry of the new index set.
  • IS -- The renumbered index set.

tuple[int, IS]

SEE ALSO:

petsc.ISRenumber


Source code at petsc4py/PETSc/IS.pyx:743


Set the indices for an index set with type IS.Type.BLOCK.

Collective.

  • bsize (int) -- Number of elements in each block.
  • indices (Sequence[int]) -- List of integers.

None

SEE ALSO:

petsc.ISBlockSetIndices


Source code at petsc4py/PETSc/IS.pyx:812


Set the block size of the index set.

Logically collective.

bs (int) -- Block size.
None

SEE ALSO:

petsc.ISSetBlockSize


Source code at petsc4py/PETSc/IS.pyx:453


Mark the index set as being an identity.

Logically collective.

SEE ALSO:

petsc.ISSetIdentity


Source code at petsc4py/PETSc/IS.pyx:525



Set the indices of an index set.

Logically collective.

The index set is assumed to be of type IS.Type.GENERAL.

SEE ALSO:

petsc.ISGeneralSetIndices


Source code at petsc4py/PETSc/IS.pyx:774

indices (Sequence[int]) --
None


Mark the index set as being a permutation.

Logically collective.

SEE ALSO:

petsc.ISSetPermutation


Source code at petsc4py/PETSc/IS.pyx:498



Set the stride information for an index set with type IS.Type.STRIDE.

Logically collective.

  • size (int) -- Length of the locally owned portion of the index set.
  • first (int) -- First element of the index set.
  • step (int) -- Difference between adjacent indices.

None

SEE ALSO:

petsc.ISStrideSetStride


Source code at petsc4py/PETSc/IS.pyx:857


Set the type of the index set.

Collective.

is_type (Type | str) -- The index set type.
None

SEE ALSO:

petsc.ISSetType


Source code at petsc4py/PETSc/IS.pyx:108


Sort the indices of an index set.

Collective.

SEE ALSO:

petsc.ISSort


Source code at petsc4py/PETSc/IS.pyx:471



Return the union of two (sorted) index sets.

Collective.

iset (IS) -- The index set to compute the union with.
IS

SEE ALSO:

petsc.ISSum


Source code at petsc4py/PETSc/IS.pyx:571


Convert the index set type to IS.Type.GENERAL.

Collective.

SEE ALSO:

petsc.ISToGeneral, petsc.ISType


Source code at petsc4py/PETSc/IS.pyx:322



Return the union of two (possibly unsorted) index sets.

Collective.

This function will call either petsc.ISSum or petsc.ISExpand depending on whether or not the input sets are already sorted.

Sequential only (as petsc.ISSum is sequential only).

iset (IS) -- Index set to compute the union with.
The new, combined, index set.
IS

SEE ALSO:

IS.expand, IS.sum


Source code at petsc4py/PETSc/IS.pyx:617


Display the index set.

Collective.

viewer (Viewer | None) -- Viewer used to display the IS.
None

SEE ALSO:

petsc.ISView


Source code at petsc4py/PETSc/IS.pyx:55


Attributes Documentation

View of the index set as an array of integers.

Not collective.

Source code at petsc4py/PETSc/IS.pyx:1034


The number of elements in a block.

Not collective.

SEE ALSO:

IS.getBlockSize


Source code at petsc4py/PETSc/IS.pyx:1008


True if index set is an identity, False otherwise.

Collective.

SEE ALSO:

IS.isIdentity


Source code at petsc4py/PETSc/IS.pyx:941


The indices of the index set.

Not collective.

SEE ALSO:

IS.getIndices


Source code at petsc4py/PETSc/IS.pyx:1021


The local size of the index set.

Not collective.

SEE ALSO:

IS.getLocalSize


Source code at petsc4py/PETSc/IS.pyx:995


True if index set is a permutation, False otherwise.

Logically collective.

SEE ALSO:

IS.isPermutation


Source code at petsc4py/PETSc/IS.pyx:928


The global size of the index set.

Not collective.

SEE ALSO:

IS.getSize


Source code at petsc4py/PETSc/IS.pyx:982


The local and global sizes of the index set.

Not collective.

SEE ALSO:

IS.getSizes


Source code at petsc4py/PETSc/IS.pyx:969


True if index set is sorted, False otherwise.

Collective.

SEE ALSO:

IS.isSorted


Source code at petsc4py/PETSc/IS.pyx:954




petsc4py.PETSc.InsertMode

Bases: object

Insertion mode.

Most commonly used insertion modes are:

Insert provided value/s discarding previous value/s.
Add provided value/s to current value/s.
Insert the maximum of provided value/s and current value/s.

SEE ALSO:

petsc.InsertMode


Attributes Summary

ADD Constant ADD of type int
ADD_ALL Constant ADD_ALL of type int
ADD_ALL_VALUES Constant ADD_ALL_VALUES of type int
ADD_BC Constant ADD_BC of type int
ADD_BC_VALUES Constant ADD_BC_VALUES of type int
ADD_VALUES Constant ADD_VALUES of type int
INSERT Constant INSERT of type int
INSERT_ALL Constant INSERT_ALL of type int
INSERT_ALL_VALUES Constant INSERT_ALL_VALUES of type int
INSERT_BC Constant INSERT_BC of type int
INSERT_BC_VALUES Constant INSERT_BC_VALUES of type int
INSERT_VALUES Constant INSERT_VALUES of type int
MAX Constant MAX of type int
MAX_VALUES Constant MAX_VALUES of type int
NOT_SET_VALUES Constant NOT_SET_VALUES of type int

Attributes Documentation

Constant ADD of type int

Constant ADD_ALL of type int

Constant ADD_ALL_VALUES of type int

Constant ADD_BC of type int

Constant ADD_BC_VALUES of type int

Constant ADD_VALUES of type int

Constant INSERT of type int

Constant INSERT_ALL of type int

Constant INSERT_ALL_VALUES of type int

Constant INSERT_BC of type int

Constant INSERT_BC_VALUES of type int

Constant INSERT_VALUES of type int

Constant MAX of type int

Constant MAX_VALUES of type int

Constant NOT_SET_VALUES of type int


petsc4py.PETSc.KSP

Bases: Object

Abstract PETSc object that manages all Krylov methods.

This is the object that manages the linear solves in PETSc (even those such as direct solvers that do no use Krylov accelerators).

Notes

When a direct solver is used, but no Krylov solver is used, the KSP object is still used but with a Type.PREONLY, meaning that only application of the preconditioner is used as the linear solver.

SEE ALSO:

create, setType, SNES, TS, PC, Type.CG, Type.GMRES, petsc.KSP


Enumerations

ConvergedReason KSP Converged Reason.
HPDDMType The HPDDM Krylov solver type.
NormType KSP norm type.
Type KSP Type.

petsc4py.PETSc.KSP.ConvergedReason

Bases: object

KSP Converged Reason.

Still iterating
Still iterating
Undocumented.
Undocumented.
∥r∥ <= rtolnorm(b) or rtolnorm(b - Ax₀)
∥r∥ <= atol
Used by the Type.PREONLY solver after the single iteration of the preconditioner is applied. Also used when the petsc.KSPConvergedSkip convergence test routine is set in KSP.
Undocumented.
Undocumented.
Undocumented.
Undocumented.
Ran out of iterations before any convergence criteria was reached.
norm(r) >= dtol*norm(b)
A breakdown in the Krylov method was detected so the method could not continue to enlarge the Krylov space. Could be due to a singular matrix or preconditioner. In KSPHPDDM, this is also returned when some search directions within a block are colinear.
A breakdown in the KSPBICG method was detected so the method could not continue to enlarge the Krylov space.
It appears the operator or preconditioner is not symmetric and this Krylov method (Type.CG, Type.MINRES, Type.CR) requires symmetry.
It appears the preconditioner is indefinite (has both positive and negative eigenvalues) and this Krylov method (Type.CG) requires it to be positive definite.
Undocumented.
Undocumented.
It was not possible to build or use the requested preconditioner. This is usually due to a zero pivot in a factorization. It can also result from a failure in a subpreconditioner inside a nested preconditioner such as PC.Type.FIELDSPLIT.

SEE ALSO:

None


Attributes Summary

CONVERGED_ATOL Constant CONVERGED_ATOL of type int
CONVERGED_ATOL_NORMAL Constant CONVERGED_ATOL_NORMAL of type int
CONVERGED_HAPPY_BREAKDOWN Constant CONVERGED_HAPPY_BREAKDOWN of type int
CONVERGED_ITERATING Constant CONVERGED_ITERATING of type int
CONVERGED_ITS Constant CONVERGED_ITS of type int
CONVERGED_NEG_CURVE Constant CONVERGED_NEG_CURVE of type int
CONVERGED_RTOL Constant CONVERGED_RTOL of type int
CONVERGED_RTOL_NORMAL Constant CONVERGED_RTOL_NORMAL of type int
CONVERGED_STEP_LENGTH Constant CONVERGED_STEP_LENGTH of type int
DIVERGED_BREAKDOWN Constant DIVERGED_BREAKDOWN of type int
DIVERGED_BREAKDOWN_BICG Constant DIVERGED_BREAKDOWN_BICG of type int
DIVERGED_DTOL Constant DIVERGED_DTOL of type int
DIVERGED_INDEFINITE_MAT Constant DIVERGED_INDEFINITE_MAT of type int
DIVERGED_INDEFINITE_PC Constant DIVERGED_INDEFINITE_PC of type int
DIVERGED_MAX_IT Constant DIVERGED_MAX_IT of type int
DIVERGED_NANORINF Constant DIVERGED_NANORINF of type int
DIVERGED_NONSYMMETRIC Constant DIVERGED_NONSYMMETRIC of type int
DIVERGED_NULL Constant DIVERGED_NULL of type int
DIVERGED_PCSETUP_FAILED Constant DIVERGED_PCSETUP_FAILED of type int
ITERATING Constant ITERATING of type int

Attributes Documentation

Constant CONVERGED_ATOL of type int

Constant CONVERGED_ATOL_NORMAL of type int

Constant CONVERGED_HAPPY_BREAKDOWN of type int

Constant CONVERGED_ITERATING of type int

Constant CONVERGED_ITS of type int

Constant CONVERGED_NEG_CURVE of type int

Constant CONVERGED_RTOL of type int

Constant CONVERGED_RTOL_NORMAL of type int

Constant CONVERGED_STEP_LENGTH of type int

Constant DIVERGED_BREAKDOWN of type int

Constant DIVERGED_BREAKDOWN_BICG of type int

Constant DIVERGED_DTOL of type int

Constant DIVERGED_INDEFINITE_MAT of type int

Constant DIVERGED_INDEFINITE_PC of type int

Constant DIVERGED_MAX_IT of type int

Constant DIVERGED_NANORINF of type int

Constant DIVERGED_NONSYMMETRIC of type int

Constant DIVERGED_NULL of type int

Constant DIVERGED_PCSETUP_FAILED of type int

Constant ITERATING of type int


petsc4py.PETSc.KSP.HPDDMType

Bases: object

The HPDDM Krylov solver type.

Attributes Summary

BCG Constant BCG of type int
BFBCG Constant BFBCG of type int
BGCRODR Constant BGCRODR of type int
BGMRES Constant BGMRES of type int
CG Constant CG of type int
GCRODR Constant GCRODR of type int
GMRES Constant GMRES of type int
PREONLY Constant PREONLY of type int

Attributes Documentation

Constant BCG of type int

Constant BFBCG of type int

Constant BGCRODR of type int

Constant BGMRES of type int

Constant CG of type int

Constant GCRODR of type int

Constant GMRES of type int

Constant PREONLY of type int


petsc4py.PETSc.KSP.NormType

Bases: object

KSP norm type.

The available norm types are:

Skips computing the norm, this should generally only be used if you are using the Krylov method as a smoother with a fixed small number of iterations. Implicitly sets petsc.KSPConvergedSkip as KSP convergence test. Note that certain algorithms such as Type.GMRES ALWAYS require the norm calculation, for these methods the norms are still computed, they are just not used in the convergence test.
The default for left preconditioned solves, uses the l₂ norm of the preconditioned residual P⁻¹(b - Ax).
Uses the l₂ norm of the true b - Ax residual.
Supported by Type.CG, Type.CR, Type.CGNE, Type.CGS.

Attributes Summary

DEFAULT Constant DEFAULT of type int
NATURAL Constant NATURAL of type int
NO Constant NO of type int
NONE Constant NONE of type int
NORM_DEFAULT Constant NORM_DEFAULT of type int
NORM_NATURAL Constant NORM_NATURAL of type int
NORM_NONE Constant NORM_NONE of type int
NORM_PRECONDITIONED Constant NORM_PRECONDITIONED of type int
NORM_UNPRECONDITIONED Constant NORM_UNPRECONDITIONED of type int
PRECONDITIONED Constant PRECONDITIONED of type int
UNPRECONDITIONED Constant UNPRECONDITIONED of type int

Attributes Documentation

Constant DEFAULT of type int

Constant NATURAL of type int

Constant NO of type int

Constant NONE of type int

Constant NORM_DEFAULT of type int

Constant NORM_NATURAL of type int

Constant NORM_NONE of type int

Constant NORM_PRECONDITIONED of type int

Constant NORM_UNPRECONDITIONED of type int

Constant PRECONDITIONED of type int

Constant UNPRECONDITIONED of type int


petsc4py.PETSc.KSP.Type

Bases: object

KSP Type.

The available types are:

The preconditioned Richardson iterative method petsc.KSPRICHARDSON.
The preconditioned Chebyshev iterative method. petsc.KSPCHEBYSHEV.
The Preconditioned Conjugate Gradient (PCG) iterative method. petsc.KSPCG
A pipelined conjugate gradient method (Gropp). petsc.KSPGROPPCG
A pipelined conjugate gradient method. petsc.KSPPIPECG
Pipelined Conjugate Gradients with Residual Replacement. petsc.KSPPIPECGRR
Deep pipelined (length l) Conjugate Gradient method. petsc.KSPPIPELCG
Pipelined predict-and-recompute conjugate gradient method. petsc.KSPPIPEPRCG
Pipelined conjugate gradient method with a single non-blocking reduction per two iterations. petsc.KSPPIPECG2
Applies the preconditioned conjugate gradient method to the normal equations without explicitly forming AᵀA. petsc.KSPCGNE
Conjugate gradient method subject to a constraint on the solution norm. petsc.KSPNASH
Conjugate gradient method subject to a constraint on the solution norm. petsc.KSPSTCG
Conjugate gradient method subject to a constraint on the solution norm. petsc.KSPGLTR
Flexible Conjugate Gradient method (FCG). Unlike most KSP methods this allows the preconditioner to be nonlinear. petsc.KSPFCG
Pipelined, Flexible Conjugate Gradient method. petsc.KSPPIPEFCG
Generalized Minimal Residual method with restart. petsc.KSPGMRES
Pipelined (1-stage) Flexible Generalized Minimal Residual method. petsc.KSPPIPEFGMRES
Implements the Flexible Generalized Minimal Residual method. petsc.KSPFGMRES
Augments the standard Generalized Minimal Residual method approximation space with approximations to the error from previous restart cycles. petsc.KSPLGMRES
Deflated Generalized Minimal Residual method. In this implementation, the adaptive strategy allows to switch to the deflated GMRES when the stagnation occurs. petsc.KSPDGMRES
Pipelined Generalized Minimal Residual method. petsc.KSPPGMRES
A variant of Quasi Minimal Residual (QMR). petsc.KSPTCQMR
Stabilized version of Biconjugate Gradient (BiCGStab) method. petsc.KSPBCGS
Improved Stabilized version of BiConjugate Gradient (IBiCGStab) method in an alternative form to have only a single global reduction operation instead of the usual 3 (or 4). petsc.KSPIBCGS
Quasi- Minimal Residual variant of the Bi-CGStab algorithm (QMRCGStab) method. petsc.KSPQMRCGS
Flexible Stabilized version of BiConjugate Gradient (BiCGStab) method. petsc.KSPFBCGS
A mathematically equivalent variant of flexible stabilized BiConjugate Gradient (BiCGStab). petsc.KSPFBCGSR
Variant of the L-step stabilized BiConjugate Gradient (BiCGStab(L)) algorithm. Uses "L-step" Minimal Residual (MR) polynomials. The variation concerns cases when some parameters are negative due to round-off. petsc.KSPBCGSL
Pipelined stabilized BiConjugate Gradient (BiCGStab) method. petsc.KSPPIPEBCGS
Conjugate Gradient Squared method. petsc.KSPCGS
A Transpose Tree Quasi- Minimal Residual (QMR). petsc.KSPCR
(Preconditioned) Conjugate Residuals (CR) method. petsc.KSPCR
Pipelined Conjugate Residual (CR) method. petsc.KSPPIPECR
Least squares solver. petsc.KSPLSQR
Applies ONLY the preconditioner exactly once. This may be used in inner iterations, where it is desired to allow multiple iterations as well as the "0-iteration" case. It is commonly used with the direct solver preconditioners like PCLU and PCCHOLESKY. There is an alias of KSPNONE. petsc.KSPPREONLY
No solver KSPNONE
Conjugate Gradient (CG) method subject to a constraint on the solution norm. petsc.KSPQCG
Implements the Biconjugate gradient method (BiCG). Similar to running the conjugate gradient on the normal equations. petsc.KSPBICG
Minimum Residual (MINRES) method. petsc.KSPMINRES
Symmetric LQ method (SymmLQ). Uses LQ decomposition (lower trapezoidal). petsc.KSPSYMMLQ
Left Conjugate Direction (LCD) method. petsc.KSPLCD
Python shell solver. Call Python function to implement solver. KSPPYTHON
Preconditioned flexible Generalized Conjugate Residual (GCR) method. petsc.KSPGCR
Pipelined Generalized Conjugate Residual method. petsc.KSPPIPEGCR
Two-Stage Iteration with least-squares Residual Minimization method. petsc.KSPTSIRM
Conjugate Gradient method for Least-Squares problems. Supports non-square (rectangular) matrices. petsc.KSPCGLS
Dual-Primal (DP) Finite Element Tearing and Interconnect (FETI) method. petsc.KSPFETIDP
Interface with the HPDDM library. This KSP may be used to further select methods that are currently not implemented natively in PETSc, e.g., GCRODR, a recycled Krylov method which is similar to KSPLGMRES. petsc.KSPHPDDM

Notes

KSP Type KSP Type table Pieplined KSP methods Flexible KSP methods

SEE ALSO:

Working with PETSc options (TODO), petsc.KSP


Attributes Summary

BCGS Object BCGS of type str
BCGSL Object BCGSL of type str
BICG Object BICG of type str
CG Object CG of type str
CGLS Object CGLS of type str
CGNE Object CGNE of type str
CGS Object CGS of type str
CHEBYSHEV Object CHEBYSHEV of type str
CR Object CR of type str
DGMRES Object DGMRES of type str
FBCGS Object FBCGS of type str
FBCGSR Object FBCGSR of type str
FCG Object FCG of type str
FETIDP Object FETIDP of type str
FGMRES Object FGMRES of type str
GCR Object GCR of type str
GLTR Object GLTR of type str
GMRES Object GMRES of type str
GROPPCG Object GROPPCG of type str
HPDDM Object HPDDM of type str
IBCGS Object IBCGS of type str
LCD Object LCD of type str
LGMRES Object LGMRES of type str
LSQR Object LSQR of type str
MINRES Object MINRES of type str
NASH Object NASH of type str
NONE Object NONE of type str
PGMRES Object PGMRES of type str
PIPEBCGS Object PIPEBCGS of type str
PIPECG Object PIPECG of type str
PIPECG2 Object PIPECG2 of type str
PIPECGRR Object PIPECGRR of type str
PIPECR Object PIPECR of type str
PIPEFCG Object PIPEFCG of type str
PIPEFGMRES Object PIPEFGMRES of type str
PIPEGCR Object PIPEGCR of type str
PIPELCG Object PIPELCG of type str
PIPEPRCG Object PIPEPRCG of type str
PREONLY Object PREONLY of type str
PYTHON Object PYTHON of type str
QCG Object QCG of type str
QMRCGS Object QMRCGS of type str
RICHARDSON Object RICHARDSON of type str
STCG Object STCG of type str
SYMMLQ Object SYMMLQ of type str
TCQMR Object TCQMR of type str
TFQMR Object TFQMR of type str
TSIRM Object TSIRM of type str

Attributes Documentation

Object BCGS of type str

Object BCGSL of type str

Object BICG of type str

Object CG of type str

Object CGLS of type str

Object CGNE of type str

Object CGS of type str

Object CHEBYSHEV of type str

Object CR of type str

Object DGMRES of type str

Object FBCGS of type str

Object FBCGSR of type str

Object FCG of type str

Object FETIDP of type str

Object FGMRES of type str

Object GCR of type str

Object GLTR of type str

Object GMRES of type str

Object GROPPCG of type str

Object HPDDM of type str

Object IBCGS of type str

Object LCD of type str

Object LGMRES of type str

Object LSQR of type str

Object MINRES of type str

Object NASH of type str

Object NONE of type str

Object PGMRES of type str

Object PIPEBCGS of type str

Object PIPECG of type str

Object PIPECG2 of type str

Object PIPECGRR of type str

Object PIPECR of type str

Object PIPEFCG of type str

Object PIPEFGMRES of type str

Object PIPEGCR of type str

Object PIPELCG of type str

Object PIPEPRCG of type str

Object PREONLY of type str

Object PYTHON of type str

Object QCG of type str

Object QMRCGS of type str

Object RICHARDSON of type str

Object STCG of type str

Object SYMMLQ of type str

Object TCQMR of type str

Object TFQMR of type str

Object TSIRM of type str


Methods Summary

appendOptionsPrefix(prefix) Append to prefix used for all KSP options in the database.
buildResidual([r]) Return the residual of the linear system.
buildSolution([x]) Return the solution vector.
callConvergenceTest(its, rnorm) Call the convergence test callback.
computeEigenvalues() Compute the extreme eigenvalues for the preconditioned operator.
computeExtremeSingularValues() Compute the extreme singular values for the preconditioned operator.
create([comm]) Create the KSP context.
createPython([context, comm]) Create a linear solver of Python type.
destroy() Destroy KSP context.
getAppCtx() Return the user-defined context for the linear solver.
getComputeEigenvalues() Return flag indicating whether eigenvalues will be calculated.
getComputeSingularValues() Return flag indicating whether singular values will be calculated.
getConvergedReason() Use reason property.
getConvergenceHistory() Return array containing the residual history.
getConvergenceTest() Return the function to be used to determine convergence.
getDM() Return the DM that may be used by some preconditioners.
getErrorIfNotConverged() Return the flag indicating the solver will error if divergent.
getHPDDMType() Return the Krylov solver type.
getInitialGuessKnoll() Determine whether the KSP solver is using the Knoll trick.
getInitialGuessNonzero() Determine whether the KSP solver uses a zero initial guess.
getIterationNumber() Use its property.
getMonitor() Return function used to monitor the residual.
getNormType() Return the norm that is used for convergence testing.
getOperators() Return the matrix associated with the linear system.
getOptionsPrefix() Return the prefix used for all KSP options in the database.
getPC() Return the preconditioner.
getPCSide() Return the preconditioning side.
getPythonContext() Return the instance of the class implementing Python methods.
getPythonType() Return the fully qualified Python name of the class used by the solver.
getResidualNorm() Use norm property.
getRhs() Return the right-hand side vector for the linear system.
getSolution() Return the solution for the linear system to be solved.
getTolerances() Return various tolerances used by the KSP convergence tests.
getType() Return the KSP type as a string from the KSP object.
getWorkVecs([right, left]) Create working vectors.
logConvergenceHistory(rnorm) Add residual to convergence history.
matSolve(B, X) Solve a linear system with multiple right-hand sides.
matSolveTranspose(B, X) Solve the transpose of a linear system with multiple RHS.
monitor(its, rnorm) Run the user provided monitor routines, if they exist.
monitorCancel() Clear all monitors for a KSP object.
reset() Resets a KSP context.
setAppCtx(appctx) Set the optional user-defined context for the linear solver.
setComputeEigenvalues(flag) Set a flag to compute eigenvalues.
setComputeOperators(operators[, args, kargs]) Set routine to compute the linear operators.
setComputeRHS(rhs[, args, kargs]) Set routine to compute the right-hand side of the linear system.
setComputeSingularValues(flag) Set flag to calculate singular values.
setConvergedReason(reason) Use reason property.
setConvergenceHistory([length, reset]) Set the array used to hold the residual history.
setConvergenceTest(converged[, args, kargs]) Set the function to be used to determine convergence.
setDM(dm) Set the DM that may be used by some preconditioners.
setDMActive(flag) DM should be used to generate system matrix & RHS vector.
setErrorIfNotConverged(flag) Cause solve to generate an error if not converged.
setFromOptions() Set KSP options from the options database.
setGMRESRestart(restart) Set number of iterations at which KSP restarts.
setHPDDMType(hpddm_type) Set the Krylov solver type.
setInitialGuessKnoll(flag) Tell solver to use PC.apply to compute the initial guess.
setInitialGuessNonzero(flag) Tell the iterative solver that the initial guess is nonzero.
setIterationNumber(its) Use its property.
setMonitor(monitor[, args, kargs]) Set additional function to monitor the residual.
setNormType(normtype) Set the norm that is used for convergence testing.
setOperators([A, P]) Set matrix associated with the linear system.
setOptionsPrefix(prefix) Set the prefix used for all KSP options in the database.
setPC(pc) Set the preconditioner.
setPCSide(side) Set the preconditioning side.
setPythonContext([context]) Set the instance of the class implementing Python methods.
setPythonType(py_type) Set the fully qualified Python name of the class to be used.
setResidualNorm(rnorm) Use norm property.
setTolerances([rtol, atol, divtol, max_it]) Set various tolerances used by the KSP convergence testers.
setType(ksp_type) Build the KSP data structure for a particular Type.
setUp() Set up internal data structures for an iterative solver.
setUpOnBlocks() Set up the preconditioner for each block in a block method.
setUseFischerGuess(model, size) Use the Paul Fischer algorithm to compute initial guesses.
solve(b, x) Solve the linear system.
solveTranspose(b, x) Solve the transpose of a linear system.
view([viewer]) Print the KSP data structure.

Attributes Summary

appctx The solver application context.
atol The absolute tolerance of the solver.
divtol The divergence tolerance of the solver.
dm The solver DM.
guess_knoll Whether solver uses Knoll trick.
guess_nonzero Whether guess is non-zero.
history The convergence history of the solver.
is_converged Boolean indicating if the solver has converged.
is_diverged Boolean indicating if the solver has failed.
is_iterating Boolean indicating if the solver has not converged yet.
its The current number of iterations the solver has taken.
mat_op The system matrix operator.
mat_pc The preconditioner operator.
max_it The maximum number of iteration the solver may take.
norm The norm of the residual at the current iteration.
norm_type The norm used by the solver.
pc The PC of the solver.
pc_side The side on which preconditioning is performed.
reason The converged reason.
rtol The relative tolerance of the solver.
vec_rhs The right-hand side vector.
vec_sol The solution vector.

Methods Documentation

Append to prefix used for all KSP options in the database.

Logically collective.

prefix (str) -- The options prefix to append.
None

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen.

SEE ALSO:

petsc.KSPAppendOptionsPrefix


Source code at petsc4py/PETSc/KSP.pyx:578


Return the residual of the linear system.
r (Vec | None) -- Optional vector to use for the result.
Vec

SEE ALSO:

buildSolution, petsc.KSPBuildResidual


Source code at petsc4py/PETSc/KSP.pyx:1916


Return the solution vector.
x (Vec | None) -- Optional vector to store the solution.
Vec

SEE ALSO:

buildResidual, petsc.KSPBuildSolution


Source code at petsc4py/PETSc/KSP.pyx:1896


Call the convergence test callback.
  • its (int) -- Number of iterations.
  • rnorm (float) -- The residual norm.

None

Notes

This functionality is implemented in petsc4py.

Source code at petsc4py/PETSc/KSP.pyx:1075


Compute the extreme eigenvalues for the preconditioned operator.

SEE ALSO:

petsc.KSPComputeEigenvalues


Source code at petsc4py/PETSc/KSP.pyx:1936

ArrayComplex


Compute the extreme singular values for the preconditioned operator.
  • smax (float) -- The maximum singular value.
  • smin (float) -- The minimum singular value.

tuple[float, float]

SEE ALSO:

petsc.KSPComputeExtremeSingularValues


Source code at petsc4py/PETSc/KSP.pyx:1957


Create the KSP context.

Collective.

SEE ALSO:

petsc.KSPCreate


Source code at petsc4py/PETSc/KSP.pyx:460

comm (Comm | None) --
Self


Create a linear solver of Python type.

Collective.

  • context (Any) -- An instance of the Python class implementing the required methods.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

PETSc Python linear solver type, setType, setPythonContext, Type.PYTHON


Source code at petsc4py/PETSc/KSP.pyx:1999


Destroy KSP context.

Collective.

SEE ALSO:

petsc.KSPDestroy


Source code at petsc4py/PETSc/KSP.pyx:447



Return the user-defined context for the linear solver.

Not collective.

SEE ALSO:

setAppCtx


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



Return flag indicating whether eigenvalues will be calculated.

Not collective.

Return the flag indicating that the extreme eigenvalues values will be calculated via a Lanczos or Arnoldi process as the linear system is solved.

SEE ALSO:

setComputeEigenvalues, petsc.KSPSetComputeEigenvalues


Source code at petsc4py/PETSc/KSP.pyx:1380



Return flag indicating whether singular values will be calculated.

Return the flag indicating whether the extreme singular values will be calculated via a Lanczos or Arnoldi process as the linear system is solved.

SEE ALSO:

setComputeSingularValues, petsc.KSPGetComputeSingularValues


Source code at petsc4py/PETSc/KSP.pyx:1424



Use reason property.

Source code at petsc4py/PETSc/KSP.pyx:1750

ConvergedReason


Return array containing the residual history.

Not collective.

SEE ALSO:

setConvergenceHistory, petsc.KSPGetResidualHistory


Source code at petsc4py/PETSc/KSP.pyx:1141

ArrayReal


Return the function to be used to determine convergence.

Logically collective.

SEE ALSO:

setTolerances, setConvergenceTest, petsc.KSPGetConvergenceTest, petsc.KSPConvergedDefault


Source code at petsc4py/PETSc/KSP.pyx:1062

KSPConvergenceTestFunction


Return the DM that may be used by some preconditioners.

Not collective.

SEE ALSO:

PETSc.KSP, DM, petsc.KSPGetDM


Source code at petsc4py/PETSc/KSP.pyx:657



Return the flag indicating the solver will error if divergent.

Not collective.

SEE ALSO:

petsc.KSPGetErrorIfNotConverged


Source code at petsc4py/PETSc/KSP.pyx:1804



Return the Krylov solver type.

SEE ALSO:

petsc.KSPHPDDMGetType


Source code at petsc4py/PETSc/KSP.pyx:1774

HPDDMType


Determine whether the KSP solver is using the Knoll trick.

This uses the Knoll trick; using PC.apply to compute the initial guess.

SEE ALSO:

petsc.KSPGetInitialGuessKnoll


Source code at petsc4py/PETSc/KSP.pyx:1498



Determine whether the KSP solver uses a zero initial guess.

Not collective.

SEE ALSO:

petsc.KSPGetInitialGuessNonzero


Source code at petsc4py/PETSc/KSP.pyx:1464



Use its property.

Source code at petsc4py/PETSc/KSP.pyx:1728



Return function used to monitor the residual.

Not collective.

SEE ALSO:

Working with PETSc options (TODO), setMonitor, monitor, monitorCancel, petsc.KSPGetMonitorContext


Source code at petsc4py/PETSc/KSP.pyx:1220

KSPMonitorFunction


Return the norm that is used for convergence testing.

Not collective.

SEE ALSO:

NormType, setNormType, petsc.KSPGetNormType, petsc.KSPConvergedSkip


Source code at petsc4py/PETSc/KSP.pyx:1342

NormType


Return the matrix associated with the linear system.

Collective.

Return the matrix associated with the linear system and a (possibly) different one used to construct the preconditioner.

  • A (Mat) -- Matrix that defines the linear system.
  • P (Mat) -- Matrix to be used in constructing the preconditioner, usually the same as A.

tuple[Mat, Mat]

SEE ALSO:

PETSc.KSP, solve, setOperators, petsc.KSPGetOperators


Source code at petsc4py/PETSc/KSP.pyx:855


Return the prefix used for all KSP options in the database.

Not collective.

SEE ALSO:

petsc.KSPGetOptionsPrefix


Source code at petsc4py/PETSc/KSP.pyx:564



Return the preconditioner.

Not collective.

SEE ALSO:

PETSc.KSP, setPC, petsc.KSPGetPC


Source code at petsc4py/PETSc/KSP.pyx:902



Return the preconditioning side.

Not collective.

SEE ALSO:

Working with PETSc options (TODO), setPCSide, setNormType, getNormType, petsc.KSPGetPCSide


Source code at petsc4py/PETSc/KSP.pyx:1303



Return the instance of the class implementing Python methods.

Not collective.

SEE ALSO:

PETSc Python linear solver type, setPythonContext


Source code at petsc4py/PETSc/KSP.pyx:2041



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

Not collective.

SEE ALSO:

PETSc Python linear solver type, setPythonContext, setPythonType, petsc.KSPPythonGetType


Source code at petsc4py/PETSc/KSP.pyx:2071



Use norm property.

Source code at petsc4py/PETSc/KSP.pyx:1739

float


Return the right-hand side vector for the linear system.

Not collective.

SEE ALSO:

petsc.KSPGetRhs


Source code at petsc4py/PETSc/KSP.pyx:1818



Return the solution for the linear system to be solved.

Note that this may not be the solution that is stored during the iterative process.

SEE ALSO:

petsc.KSPGetSolution


Source code at petsc4py/PETSc/KSP.pyx:1833



Return various tolerances used by the KSP convergence tests.

Not collective.

Return the relative, absolute, divergence, and maximum iteration tolerances used by the default KSP convergence tests.

  • rtol (float) -- The relative convergence tolerance
  • atol (float) -- The absolute convergence tolerance
  • dtol (float) -- The divergence tolerance
  • maxits (int) -- Maximum number of iterations

tuple[float, float, float, int]

SEE ALSO:

setTolerances, petsc.KSPGetTolerances


Source code at petsc4py/PETSc/KSP.pyx:969


Return the KSP type as a string from the KSP object.

Not collective.

SEE ALSO:

petsc.KSPGetType


Source code at petsc4py/PETSc/KSP.pyx:512



Create working vectors.
  • right (int | None) -- Number of right hand vectors to allocate.
  • left (int | None) -- Number of left hand vectors to allocate.

  • R (list of Vec) -- List of correctly allocated right hand vectors.
  • L (list of Vec) -- List of correctly allocated left hand vectors.

tuple[list[Vec], list[Vec]] | list[Vec] | None

Source code at petsc4py/PETSc/KSP.pyx:1849


Add residual to convergence history.

Logically collective.

rnorm (float) -- Residual norm to be added to convergence history.
None

Source code at petsc4py/PETSc/KSP.pyx:1156


Solve a linear system with multiple right-hand sides.

These are stored as a Mat.Type.DENSE. Unlike solve, B and X must be different matrices.

  • B (Mat) -- Block of right-hand sides.
  • X (Mat) -- Block of solutions.

None

SEE ALSO:

solve, petsc.KSPMatSolve


Source code at petsc4py/PETSc/KSP.pyx:1686


Solve the transpose of a linear system with multiple RHS.
  • B (Mat) -- Block of right-hand sides.
  • X (Mat) -- Block of solutions.

None

SEE ALSO:

solveTranspose, petsc.KSPMatSolve


Source code at petsc4py/PETSc/KSP.pyx:1706


Run the user provided monitor routines, if they exist.

Collective.

Notes

This routine is called by the KSP implementations. It does not typically need to be called by the user.

SEE ALSO:

setMonitor, petsc.KSPMonitor


Source code at petsc4py/PETSc/KSP.pyx:1248

  • its (int) --
  • rnorm (float) --

None


Clear all monitors for a KSP object.

Logically collective.

SEE ALSO:

Working with PETSc options (TODO), getMonitor, setMonitor, monitor, petsc.KSPMonitorCancel


Source code at petsc4py/PETSc/KSP.pyx:1233



Resets a KSP context.

Collective.

Resets a KSP context to the kspsetupcalled = 0 state and removes any allocated Vecs and Mats.

SEE ALSO:

petsc.KSPReset


Source code at petsc4py/PETSc/KSP.pyx:1551



Set the optional user-defined context for the linear solver.

Not collective.

appctx (Any) -- The user defined context
None

Notes

The user context is a way for users to attach any information to the KSP that they may need later when interacting with the solver.

SEE ALSO:

getAppCtx


Source code at petsc4py/PETSc/KSP.pyx:620


Set a flag to compute eigenvalues.

Set a flag so that the extreme eigenvalues values will be calculated via a Lanczos or Arnoldi process as the linear system is solved.

flag (bool) -- Boolean whether to compute eigenvalues (or not).
None

Notes

Currently this option is not valid for all iterative methods.

SEE ALSO:

getComputeEigenvalues, petsc.KSPSetComputeEigenvalues


Source code at petsc4py/PETSc/KSP.pyx:1356


Set routine to compute the linear operators.

Logically collective.

  • operators (KSPOperatorsFunction) -- Function which computes the operators.
  • args (tuple[Any, ...] | None) -- Positional arguments for callback function operators.
  • kargs (dict[str, Any] | None) -- Keyword arguments for callback function operators.

None

Notes

The user provided function Operators will be called automatically at the very next call to solve. It will NOT be called at future solve calls unless either setComputeOperators or setOperators is called before that solve is called. This allows the same system to be solved several times with different right-hand side functions, but is a confusing API since one might expect it to be called for each solve.

To reuse the same preconditioner for the next solve and not compute a new one based on the most recently computed matrix call petsc.KSPSetReusePreconditioner.

SEE ALSO:

PETSc.KSP, solve, setOperators, petsc.KSPSetComputeOperators, petsc.KSPSetReusePreconditioner


Source code at petsc4py/PETSc/KSP.pyx:768


Set routine to compute the right-hand side of the linear system.

Logically collective.

  • rhs (KSPRHSFunction) -- Function which computes the right-hand side.
  • args (tuple[Any, ...] | None) -- Positional arguments for callback function rhs.
  • kargs (dict[str, Any] | None) -- Keyword arguments for callback function rhs.

None

Notes

The routine you provide will be called each time you call solve to prepare the new right-hand side for that solve.

SEE ALSO:

PETSc.KSP, solve, petsc.KSPSetComputeRHS


Source code at petsc4py/PETSc/KSP.pyx:733


Set flag to calculate singular values.

Logically collective.

Set a flag so that the extreme singular values will be calculated via a Lanczos or Arnoldi process as the linear system is solved.

flag (bool) -- Boolean whether to compute singular values (or not).
None

Notes

Currently this option is not valid for all iterative methods.

SEE ALSO:

getComputeSingularValues, petsc.KSPSetComputeSingularValues


Source code at petsc4py/PETSc/KSP.pyx:1398


Use reason property.

Source code at petsc4py/PETSc/KSP.pyx:1745

reason (ConvergedReason) --
None


Set the array used to hold the residual history.

Not collective.

If set, this array will contain the residual norms computed at each iteration of the solver.

  • length (int | None) -- Length of array to store history in.
  • reset (bool) -- True indicates the history counter is reset to zero for each new linear solve.

None

Notes

If length is not provided or None then a default array of length 10000 is allocated.

If the array is not long enough then once the iterations is longer than the array length solve stops recording the history.

SEE ALSO:

getConvergenceHistory, petsc.KSPSetResidualHistory


Source code at petsc4py/PETSc/KSP.pyx:1096


Set the function to be used to determine convergence.

Logically collective.

  • converged (KSPConvergenceTestFunction) -- Callback which computes the convergence.
  • args (tuple[Any, ...] | None) -- Positional arguments for callback function.
  • kargs (dict[str, Any] | None) -- Keyword arguments for callback function.

None

Notes

Must be called after the KSP type has been set so put this after a call to setType, or setFromOptions.

The default convergence test, petsc.KSPConvergedDefault, aborts if the residual grows to more than 10000 times the initial residual.

The default is a combination of relative and absolute tolerances. The residual value that is tested may be an approximation; routines that need exact values should compute them.

In the default PETSc convergence test, the precise values of reason are macros such as KSP_CONVERGED_RTOL, which are defined in petsch.

SEE ALSO:

setTolerances, getConvergenceTest, petsc.KSPSetConvergenceTest, petsc.KSPConvergedDefault


Source code at petsc4py/PETSc/KSP.pyx:998


Set the DM that may be used by some preconditioners.

Logically collective.

dm (DM) -- The DM object, cannot be None.
None

Notes

If this is used then the KSP will attempt to use the DM to create the matrix and use the routine set with DM.setKSPComputeOperators. Use setDMActive(False) to instead use the matrix you have provided with setOperators.

A DM can only be used for solving one problem at a time because information about the problem is stored on the DM, even when not using interfaces like DM.setKSPComputeOperators. Use DM.clone to get a distinct DM when solving different problems using the same function space.

SEE ALSO:

PETSc.KSP, DM, DM.setKSPComputeOperators, setOperators, DM.clone, petsc.KSPSetDM


Source code at petsc4py/PETSc/KSP.pyx:674


DM should be used to generate system matrix & RHS vector.

Logically collective.

flag (bool) -- Whether to use the DM.
None

Notes

By default setDM sets the DM as active, call setDMActive(False) after setDM(dm) to not have the KSP object use the DM to generate the matrices.

SEE ALSO:

PETSc.KSP, DM, setDM, petsc.KSPSetDMActive


Source code at petsc4py/PETSc/KSP.pyx:707


Cause solve to generate an error if not converged.

Logically collective.

flag (bool) -- True enables this behavior.
None

SEE ALSO:

petsc.KSPSetErrorIfNotConverged


Source code at petsc4py/PETSc/KSP.pyx:1786


Set KSP options from the options database.

Collective.

This routine must be called before setUp if the user is to be allowed to set the Krylov type.

SEE ALSO:

Working with PETSc options (TODO), petsc.KSPSetFromOptions


Source code at petsc4py/PETSc/KSP.pyx:603



Set number of iterations at which KSP restarts.

Suitable KSPs are: KSPGMRES, KSPFGMRES and KSPLGMRES.

restart (int) -- Integer restart value.
None

SEE ALSO:

petsc.KSPGMRESSetRestart


Source code at petsc4py/PETSc/KSP.pyx:1979


Set the Krylov solver type.

Collective.

hpddm_type (HPDDMType) -- The type of Krylov solver to use.
None

SEE ALSO:

petsc.KSPHPDDMSetType


Source code at petsc4py/PETSc/KSP.pyx:1756


Tell solver to use PC.apply to compute the initial guess.

Logically collective.

This is the Knoll trick.

flag (bool) -- True uses Knoll trick.
None

SEE ALSO:

petsc.KSPSetInitialGuessKnoll


Source code at petsc4py/PETSc/KSP.pyx:1478


Tell the iterative solver that the initial guess is nonzero.

Logically collective.

Otherwise KSP assumes the initial guess is to be zero (and thus zeros it out before solving).

flag (bool) -- True indicates the guess is non-zero, False indicates the guess is zero.
None

SEE ALSO:

petsc.KSPSetInitialGuessNonzero


Source code at petsc4py/PETSc/KSP.pyx:1442


Use its property.

Source code at petsc4py/PETSc/KSP.pyx:1723

its (int) --
None


Set additional function to monitor the residual.

Logically collective.

Set an ADDITIONAL function to be called at every iteration to monitor the residual/error etc.

  • monitor (KSPMonitorFunction) -- Callback which monitors the convergence.
  • args (tuple[Any, ...] | None) -- Positional arguments for callback function.
  • kargs (dict[str, Any] | None) -- Keyword arguments for callback function.

None

Notes

The default is to do nothing. To print the residual, or preconditioned residual if setNormType(NORM_PRECONDITIONED) was called, use monitor as the monitoring routine, with a PETSc.Viewer.ASCII as the context.

Several different monitoring routines may be set by calling setMonitor multiple times; all will be called in the order in which they were set.

SEE ALSO:

Working with PETSc options (TODO), getMonitor, monitor, monitorCancel, petsc.KSPMonitorSet


Source code at petsc4py/PETSc/KSP.pyx:1172


Set the norm that is used for convergence testing.
normtype (NormType) -- The norm type to use (see NormType).
None

Notes

Not all combinations of preconditioner side (see setPCSide) and norm type are supported by all Krylov methods. If only one is set, PETSc tries to automatically change the other to find a compatible pair. If no such combination is supported, PETSc will generate an error.

SEE ALSO:

NormType, Working with PETSc options (TODO), setUp, solve, destroy, setPCSide, getPCSide, NormType, petsc.KSPSetNormType, petsc.KSPConvergedSkip, petsc.KSPSetCheckNormIteration


Source code at petsc4py/PETSc/KSP.pyx:1317


Set matrix associated with the linear system.

Collective.

Set the matrix associated with the linear system and a (possibly) different one from which the preconditioner will be built.

  • A (Mat | None) -- Matrix that defines the linear system.
  • P (Mat | None) -- Matrix to be used in constructing the preconditioner, usually the same as A.

None

Notes

If you know the operator A has a null space you can use Mat.setNullSpace and Mat.setTransposeNullSpace to supply the null space to A and the KSP solvers will automatically use that null space as needed during the solution process.

All future calls to setOperators must use the same size matrices!

Passing None for A or P removes the matrix that is currently used.

SEE ALSO:

PETSc.KSP, solve, setComputeOperators, petsc.KSPSetOperators


Source code at petsc4py/PETSc/KSP.pyx:814


Set the prefix used for all KSP options in the database.

Logically collective.

prefix (str) -- The options prefix.
None

Notes

A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. For example, to distinguish between the runtime options for two different KSP contexts, one could call ` KSPSetOptionsPrefix(ksp1, "sys1_") KSPSetOptionsPrefix(ksp2, "sys2_") `

This would enable use of different options for each system, such as ` -sys1_ksp_type gmres -sys1_ksp_rtol 1.e-3 -sys2_ksp_type bcgs -sys2_ksp_rtol 1.e-4 `

SEE ALSO:

Working with PETSc options (TODO), petsc.KSPSetOptionsPrefix


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


Set the preconditioner.

Collective.

Set the preconditioner to be used to calculate the application of the preconditioner on a vector.

pc (PC) -- The preconditioner object
None

SEE ALSO:

PETSc.KSP, getPC, petsc.KSPSetPC


Source code at petsc4py/PETSc/KSP.pyx:882


Set the preconditioning side.

Logically collective.

side (Side) -- The preconditioning side (see PC.Side).
None

Notes

Left preconditioning is used by default for most Krylov methods except Type.FGMRES which only supports right preconditioning.

For methods changing the side of the preconditioner changes the norm type that is used, see setNormType.

Symmetric preconditioning is currently available only for the Type.QCG method. Note, however, that symmetric preconditioning can be emulated by using either right or left preconditioning and a pre or post processing step.

Setting the PC side often affects the default norm type. See setNormType for details.

SEE ALSO:

PC.Side, Working with PETSc options (TODO), getPCSide, setNormType, getNormType, petsc.KSPSetPCSide


Source code at petsc4py/PETSc/KSP.pyx:1269


Set the instance of the class implementing Python methods.

Not collective.

SEE ALSO:

PETSc Python linear solver type, getPythonContext


Source code at petsc4py/PETSc/KSP.pyx:2029

context (Any | None) --
None


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

Collective.

SEE ALSO:

PETSc Python linear solver type, setPythonContext, getPythonType, petsc.KSPPythonSetType


Source code at petsc4py/PETSc/KSP.pyx:2056

py_type (str) --
None


Use norm property.

Source code at petsc4py/PETSc/KSP.pyx:1734

rnorm (float) --
None


Set various tolerances used by the KSP convergence testers.

Logically collective.

Set the relative, absolute, divergence, and maximum iteration tolerances used by the default KSP convergence testers.

  • rtol (float | None) -- The relative convergence tolerance, relative decrease in the (possibly preconditioned) residual norm.
  • atol (float | None) -- The absolute convergence tolerance absolute size of the (possibly preconditioned) residual norm.
  • dtol -- The divergence tolerance, amount (possibly preconditioned) residual norm can increase before petsc.KSPConvergedDefault concludes that the method is diverging.
  • max_it (int | None) -- Maximum number of iterations to use.
  • divtol (float | None) --

None

Notes

Use None to retain the default value of any of the tolerances.

SEE ALSO:

Working with PETSc options (TODO), getTolerances, setConvergenceTest, petsc.KSPSetTolerances, petsc.KSPConvergedDefault


Source code at petsc4py/PETSc/KSP.pyx:919


Build the KSP data structure for a particular Type.

Logically collective.

ksp_type (Type | str) -- KSP Type object
None

Notes

See Type for available methods (for instance, Type.CG or Type.GMRES).

Normally, it is best to use the setFromOptions command and then set the KSP type from the options database rather than by using this routine. Using the options database provides the user with maximum flexibility in evaluating the many different Krylov methods. This method is provided for those situations where it is necessary to set the iterative solver independently of the command line or options database. This might be the case, for example, when the choice of iterative solver changes during the execution of the program, and the user's application is taking responsibility for choosing the appropriate method. In other words, this routine is not for beginners.

SEE ALSO:

petsc.KSPSetType


Source code at petsc4py/PETSc/KSP.pyx:476


Set up internal data structures for an iterative solver.

Collective.

SEE ALSO:

petsc.KSPSetUp


Source code at petsc4py/PETSc/KSP.pyx:1539



Set up the preconditioner for each block in a block method.

Collective.

Methods include: block Jacobi, block Gauss-Seidel, and overlapping Schwarz methods.

SEE ALSO:

petsc.KSPSetUpOnBlocks


Source code at petsc4py/PETSc/KSP.pyx:1566



Use the Paul Fischer algorithm to compute initial guesses.

Use the Paul Fischer algorithm or its variants to compute initial guesses for a set of solves with related right hand sides.

  • model (int) -- Use model 1, model 2, model 3, any other number to turn it off.
  • size (int) -- Size of subspace used to generate initial guess.

None

SEE ALSO:

petsc.KSPSetUseFischerGuess


Source code at petsc4py/PETSc/KSP.pyx:1513


Solve the linear system.

Collective.

  • b (Vec) -- Right hand side vector.
  • x (Vec) -- Solution vector.

None

Notes

If one uses setDM then x or b need not be passed. Use getSolution to access the solution in this case.

The operator is specified with setOperators.

solve will normally return without generating an error regardless of whether the linear system was solved or if constructing the preconditioner failed. Call getConvergedReason to determine if the solver converged or failed and why. The option -ksp_error_if_not_converged or function setErrorIfNotConverged will cause solve to error as soon as an error occurs in the linear solver. In inner solves, DIVERGED_MAX_IT is not treated as an error because when using nested solvers it may be fine that inner solvers in the preconditioner do not converge during the solution process.

The number of iterations can be obtained from its.

If you provide a matrix that has a Mat.setNullSpace and Mat.setTransposeNullSpace this will use that information to solve singular systems in the least squares sense with a norm minimizing solution.

Ax = b where b = bₚ + bₜ where bₜ is not in the range of A (and hence by the fundamental theorem of linear algebra is in the nullspace(Aᵀ), see Mat.setNullSpace.

KSP first removes bₜ producing the linear system Ax = bₚ (which has multiple solutions) and solves this to find the ∥x∥ minimizing solution (and hence it finds the solution x orthogonal to the nullspace(A). The algorithm is simply in each iteration of the Krylov method we remove the nullspace(A) from the search direction thus the solution which is a linear combination of the search directions has no component in the nullspace(A).

We recommend always using Type.GMRES for such singular systems. If nullspace(A) = nullspace(Aᵀ) (note symmetric matrices always satisfy this property) then both left and right preconditioning will work If nullspace(A) != nullspace(Aᵀ) then left preconditioning will work but right preconditioning may not work (or it may).

If using a direct method (e.g., via the KSP solver Type.PREONLY and a preconditioner such as PC.Type.LU or PC.Type.ILU, then its=1. See setTolerances for more details.

Understanding Convergence

The routines setMonitor and computeEigenvalues provide information on additional options to monitor convergence and print eigenvalue information.

SEE ALSO:

create, setUp, destroy, setTolerances, is_converged, solveTranspose, its, Mat.setNullSpace, Mat.setTransposeNullSpace, Type, setErrorIfNotConverged, petsc.KSPSolve


Source code at petsc4py/PETSc/KSP.pyx:1581


Solve the transpose of a linear system.

Collective.

  • b (Vec) -- Right hand side vector.
  • x (Vec) -- Solution vector.

None

Notes

For complex numbers this solve the non-Hermitian transpose system.

SEE ALSO:

solve, petsc.KSPSolveTranspose


Source code at petsc4py/PETSc/KSP.pyx:1662


Print the KSP data structure.

Collective.

viewer (Viewer | None) -- Viewer used to display the KSP.
None

SEE ALSO:

petsc.KSPView


Source code at petsc4py/PETSc/KSP.pyx:428


Attributes Documentation

The solver application context.

Source code at petsc4py/PETSc/KSP.pyx:2088


The absolute tolerance of the solver.

Source code at petsc4py/PETSc/KSP.pyx:2174


The divergence tolerance of the solver.

Source code at petsc4py/PETSc/KSP.pyx:2181


The solver DM.

Source code at petsc4py/PETSc/KSP.pyx:2097


Whether solver uses Knoll trick.

Source code at petsc4py/PETSc/KSP.pyx:2137


Whether guess is non-zero.

Source code at petsc4py/PETSc/KSP.pyx:2130


The convergence history of the solver.

Source code at petsc4py/PETSc/KSP.pyx:2211


Boolean indicating if the solver has converged.

Source code at petsc4py/PETSc/KSP.pyx:2230


Boolean indicating if the solver has failed.

Source code at petsc4py/PETSc/KSP.pyx:2235


Boolean indicating if the solver has not converged yet.

Source code at petsc4py/PETSc/KSP.pyx:2225


The current number of iterations the solver has taken.

Source code at petsc4py/PETSc/KSP.pyx:2197


The system matrix operator.

Source code at petsc4py/PETSc/KSP.pyx:2118


The preconditioner operator.

Source code at petsc4py/PETSc/KSP.pyx:2123


The maximum number of iteration the solver may take.

Source code at petsc4py/PETSc/KSP.pyx:2188


The norm of the residual at the current iteration.

Source code at petsc4py/PETSc/KSP.pyx:2204


The norm used by the solver.

Source code at petsc4py/PETSc/KSP.pyx:2158


The PC of the solver.

Source code at petsc4py/PETSc/KSP.pyx:2146


The side on which preconditioning is performed.

Source code at petsc4py/PETSc/KSP.pyx:2151


The converged reason.

Source code at petsc4py/PETSc/KSP.pyx:2218


The relative tolerance of the solver.

Source code at petsc4py/PETSc/KSP.pyx:2167


The right-hand side vector.

Source code at petsc4py/PETSc/KSP.pyx:2111


The solution vector.

Source code at petsc4py/PETSc/KSP.pyx:2106




petsc4py.PETSc.LGMap

Bases: Object

Mapping from an arbitrary local ordering from 0 to n-1 to a global PETSc ordering used by a vector or matrix.

SEE ALSO:

petsc.ISLocalToGlobalMapping


Enumerations

GLMapMode Enum describing mapping behavior for global-to-local maps when global indices are missing.
Type

petsc4py.PETSc.LGMap.GLMapMode

Bases: object

Enum describing mapping behavior for global-to-local maps when global indices are missing.

Give missing global indices a local index of -1.
Drop missing global indices.

SEE ALSO:

petsc.ISGlobalToLocalMappingMode


Attributes Summary

DROP Constant DROP of type int
MASK Constant MASK of type int

Attributes Documentation

Constant DROP of type int

Constant MASK of type int


petsc4py.PETSc.LGMap.Type

Bases: object

Attributes Summary

BASIC Object BASIC of type str
HASH Object HASH of type str

Attributes Documentation

Object BASIC of type str

Object HASH of type str


Methods Summary

apply(indices[, result]) Convert a locally numbered list of integers to a global numbering.
applyBlock(indices[, result]) Convert a local block numbering to a global block numbering.
applyBlockInverse(indices[, mode]) Compute blocked local numbering from blocked global numbering.
applyIS(iset) Create an index set with global numbering from a local numbering.
applyInverse(indices[, mode]) Compute local numbering from global numbering.
create(indices[, bsize, comm]) Create a local-to-global mapping.
createIS(iset) Create a local-to-global mapping from an index set.
createSF(sf, start) Create a local-to-global mapping from a star forest.
destroy() Destroy the local-to-global mapping.
getBlockIndices() Return the global indices for each local block.
getBlockInfo() Determine the block indices shared with neighboring processes.
getBlockSize() Return the block size of the local-to-global mapping.
getIndices() Return the global indices for each local point in the mapping.
getInfo() Determine the indices shared with neighboring processes.
getSize() Return the local size of the local-to-global mapping.
setFromOptions() Set mapping options from the options database.
setType(lgmap_type) Set the type of the local-to-global map.
view([viewer]) View the local-to-global mapping.

Attributes Summary

block_indices The global indices for each local block in the mapping.
block_info Mapping describing block indices shared with neighboring processes.
block_size The block size.
indices The global indices for each local point in the mapping.
info Mapping describing indices shared with neighboring processes.
size The local size.

Methods Documentation

Convert a locally numbered list of integers to a global numbering.

Not collective.

  • indices (Sequence[int]) -- Input indices in local numbering.
  • result (ArrayInt | None) -- Array to write the global numbering to. If None then a new array will be allocated.

Indices in global numbering. If result is not None then this is returned here.
ArrayInt

SEE ALSO:

LGMap.applyBlock, petsc.ISLocalToGlobalMappingApply


Source code at petsc4py/PETSc/IS.pyx:1407


Convert a local block numbering to a global block numbering.

Not collective.

  • indices (Sequence[int]) -- Input block indices in local numbering.
  • result (ArrayInt | None) -- Array to write the global numbering to. If None then a new array will be allocated.

Block indices in global numbering. If result is not None then this is returned here.
ArrayInt

SEE ALSO:

LGMap.apply, petsc.ISLocalToGlobalMappingApplyBlock


Source code at petsc4py/PETSc/IS.pyx:1445


Compute blocked local numbering from blocked global numbering.

Not collective.

  • indices (Sequence[int]) -- Indices with a global block numbering.
  • mode (GLMapMode | str | None) -- Flag indicating what to do with indices that have no local value, defaults to "mask".

Indices with a local block numbering.
ArrayInt

SEE ALSO:

petsc.ISGlobalToLocalMappingApplyBlock


Source code at petsc4py/PETSc/IS.pyx:1548


Create an index set with global numbering from a local numbering.

Collective.

iset (IS) -- Index set with local numbering.
Index set with global numbering.
IS

SEE ALSO:

petsc.ISLocalToGlobalMappingApplyIS


Source code at petsc4py/PETSc/IS.pyx:1483


Compute local numbering from global numbering.

Not collective.

  • indices (Sequence[int]) -- Indices with a global numbering.
  • mode (GLMapMode | str | None) -- Flag indicating what to do with indices that have no local value, defaults to "mask".

Indices with a local numbering.
ArrayInt

SEE ALSO:

petsc.ISGlobalToLocalMappingApply


Source code at petsc4py/PETSc/IS.pyx:1508


Create a local-to-global mapping.

Not collective.

  • indices (Sequence[int]) -- Global index for each local element.
  • bsize (int | None) -- Block size, defaults to 1.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.ISLocalToGlobalMappingCreate


Source code at petsc4py/PETSc/IS.pyx:1189


Create a local-to-global mapping from an index set.

Not collective.

iset (IS) -- Index set containing the global numbers for each local number.
Self

SEE ALSO:

petsc.ISLocalToGlobalMappingCreateIS


Source code at petsc4py/PETSc/IS.pyx:1225


Create a local-to-global mapping from a star forest.

Collective.

  • sf (SF) -- Star forest mapping contiguous local indices to (rank, offset).
  • start (int) -- First global index on this process.

Self

SEE ALSO:

petsc.ISLocalToGlobalMappingCreateSF


Source code at petsc4py/PETSc/IS.pyx:1246


Destroy the local-to-global mapping.

Not collective.

SEE ALSO:

petsc.ISLocalToGlobalMappingDestroy


Source code at petsc4py/PETSc/IS.pyx:1176



Return the global indices for each local block.

Not collective.

SEE ALSO:

petsc.ISLocalToGlobalMappingGetBlockIndices


Source code at petsc4py/PETSc/IS.pyx:1321

ArrayInt


Determine the block indices shared with neighboring processes.

Collective.

Mapping from neighboring processor number to an array of shared block indices (in local numbering).
dict

SEE ALSO:

petsc.ISLocalToGlobalMappingGetBlockInfo


Source code at petsc4py/PETSc/IS.pyx:1376


Return the block size of the local-to-global mapping.

Not collective.

SEE ALSO:

petsc.ISLocalToGlobalMappingGetBlockSize


Source code at petsc4py/PETSc/IS.pyx:1283



Return the global indices for each local point in the mapping.

Not collective.

SEE ALSO:

petsc.ISLocalToGlobalMappingGetIndices


Source code at petsc4py/PETSc/IS.pyx:1297

ArrayInt


Determine the indices shared with neighboring processes.

Collective.

Mapping from neighboring processor number to an array of shared indices (in local numbering).
dict

SEE ALSO:

petsc.ISLocalToGlobalMappingGetInfo


Source code at petsc4py/PETSc/IS.pyx:1347


Return the local size of the local-to-global mapping.

Not collective.

SEE ALSO:

petsc.ISLocalToGlobalMappingGetSize


Source code at petsc4py/PETSc/IS.pyx:1269



Set mapping options from the options database.

Not collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.ISLocalToGlobalMappingSetFromOptions


Source code at petsc4py/PETSc/IS.pyx:1145



Set the type of the local-to-global map.

Logically collective.

lgmap_type (Type | str) -- The type of the local-to-global mapping.
None

Notes

Use -islocaltoglobalmapping_type to set the type in the options database.

SEE ALSO:

Working with PETSc options (TODO), petsc.ISLocalToGlobalMappingSetType


Source code at petsc4py/PETSc/IS.pyx:1121


View the local-to-global mapping.

Not collective.

viewer (Viewer | None) -- Viewer instance, defaults to an instance of Viewer.Type.ASCII.
None

SEE ALSO:

petsc.ISLocalToGlobalMappingView


Source code at petsc4py/PETSc/IS.pyx:1157


Attributes Documentation

The global indices for each local block in the mapping.

Not collective.

SEE ALSO:

LGMap.getBlockIndices, petsc.ISLocalToGlobalMappingGetBlockIndices


Source code at petsc4py/PETSc/IS.pyx:1628


Mapping describing block indices shared with neighboring processes.

Collective.

SEE ALSO:

LGMap.getBlockInfo, petsc.ISLocalToGlobalMappingGetBlockInfo


Source code at petsc4py/PETSc/IS.pyx:1654


The block size.

Not collective.

SEE ALSO:

LGMap.getBlockSize


Source code at petsc4py/PETSc/IS.pyx:1602


The global indices for each local point in the mapping.

Not collective.

SEE ALSO:

LGMap.getIndices, petsc.ISLocalToGlobalMappingGetIndices


Source code at petsc4py/PETSc/IS.pyx:1615


Mapping describing indices shared with neighboring processes.

Collective.

SEE ALSO:

LGMap.getInfo, petsc.ISLocalToGlobalMappingGetInfo


Source code at petsc4py/PETSc/IS.pyx:1641


The local size.

Not collective.

SEE ALSO:

LGMap.getSize


Source code at petsc4py/PETSc/IS.pyx:1589




petsc4py.PETSc.Log

Bases: object

Logging support.

Methods Summary

Class(name) Source code at petsc4py/PETSc/Log.pyx:25
Event(name[, klass]) Source code at petsc4py/PETSc/Log.pyx:39
EventDecorator([name, klass]) Decorate a function with a PETSc event.
Stage(name) Source code at petsc4py/PETSc/Log.pyx:11
addFlops(flops) Add floating point operations to the current event.
begin() Turn on logging of objects and events.
getCPUTime() Return the CPU time.
getFlops() Return the number of flops used on this processor since the program began.
getTime() Return the current time of day in seconds.
isActive() Return whether logging is currently in progress.
logFlops(flops) Add floating point operations to the current event.
view([viewer]) Print the log.

Methods Documentation

Source code at petsc4py/PETSc/Log.pyx:25

Source code at petsc4py/PETSc/Log.pyx:39

Decorate a function with a PETSc event.

Source code at petsc4py/PETSc/Log.pyx:178


Source code at petsc4py/PETSc/Log.pyx:11

Add floating point operations to the current event.

Not collective.

flops (float) -- The number of flops to log.
None

Notes

This method exists for backward compatibility.

SEE ALSO:

logFlops, petsc.PetscLogFlops


Source code at petsc4py/PETSc/Log.pyx:108


Turn on logging of objects and events.

Collective.

SEE ALSO:

petsc.PetscLogDefaultBegin


Source code at petsc4py/PETSc/Log.pyx:55


Return the CPU time.

Source code at petsc4py/PETSc/Log.pyx:171

float


Return the number of flops used on this processor since the program began.

Not collective.

Number of floating point operations.
float

SEE ALSO:

petsc.PetscGetFlops


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


Return the current time of day in seconds.

Collective.

wctime -- Current time.
float

SEE ALSO:

petsc.PetscTime


Source code at petsc4py/PETSc/Log.pyx:151


Return whether logging is currently in progress.

Not collective.

SEE ALSO:

petsc.PetscLogIsActive


Source code at petsc4py/PETSc/Log.pyx:193



Add floating point operations to the current event.

Not collective.

flops (float) -- The number of flops to log.
None

SEE ALSO:

petsc.PetscLogFlops


Source code at petsc4py/PETSc/Log.pyx:89


Print the log.

Collective.

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

SEE ALSO:

Working with PETSc options (TODO), petsc.PetscLogView


Source code at petsc4py/PETSc/Log.pyx:68



petsc4py.PETSc.LogClass

Bases: object

Methods Summary

activate() Source code at petsc4py/PETSc/Log.pyx:410
deactivate() Source code at petsc4py/PETSc/Log.pyx:413
getActive() Source code at petsc4py/PETSc/Log.pyx:416
getName() Source code at petsc4py/PETSc/Log.pyx:396
setActive(flag) Source code at petsc4py/PETSc/Log.pyx:420

Attributes Summary

active
id
name

Methods Documentation

Source code at petsc4py/PETSc/Log.pyx:410

Source code at petsc4py/PETSc/Log.pyx:413

Source code at petsc4py/PETSc/Log.pyx:416

Source code at petsc4py/PETSc/Log.pyx:396

Source code at petsc4py/PETSc/Log.pyx:420

Attributes Documentation





petsc4py.PETSc.LogEvent

Bases: object

Methods Summary

activate() Indicate that the event should be logged.
begin(*objs) Log the beginning of a user event.
deactivate() Indicate that the event should not be logged.
end(*objs) Log the end of a user event.
getActive() Source code at petsc4py/PETSc/Log.pyx:542
getActiveAll() Source code at petsc4py/PETSc/Log.pyx:572
getName() Source code at petsc4py/PETSc/Log.pyx:504
getPerfInfo([stage]) Get the performance information about the given event in the given event.
setActive(flag) Indicate whether or not the event should be logged.
setActiveAll(flag) Turn on logging of all events.

Attributes Summary

active
active_all
id
name

Methods Documentation

Indicate that the event should be logged.

Logically collective.

SEE ALSO:

petsc.PetscLogEventActivate


Source code at petsc4py/PETSc/Log.pyx:518



Log the beginning of a user event.

Collective.

*objs -- objects associated with the event
None

SEE ALSO:

petsc.PetscLogEventBegin


Source code at petsc4py/PETSc/Log.pyx:465


Indicate that the event should not be logged.

Logically collective.

SEE ALSO:

petsc.PetscLogEventDeactivate


Source code at petsc4py/PETSc/Log.pyx:530



Log the end of a user event.

Collective.

*objs -- Objects associated with the event.
None

SEE ALSO:

petsc.PetscLogEventEnd


Source code at petsc4py/PETSc/Log.pyx:484


Source code at petsc4py/PETSc/Log.pyx:542

Source code at petsc4py/PETSc/Log.pyx:572

Source code at petsc4py/PETSc/Log.pyx:504

Get the performance information about the given event in the given event.

Not collective.

stage (int | None) -- The stage number.
info -- This structure is filled with the performance information.
dict

SEE ALSO:

petsc.PetscLogEventGetPerfInfo


Source code at petsc4py/PETSc/Log.pyx:603


Indicate whether or not the event should be logged.

Logically collective.

flag (bool) -- Activate or deactivate the event.
None

SEE ALSO:

petsc.PetscLogEventDeactivate, petsc.PetscLogEventActivate


Source code at petsc4py/PETSc/Log.pyx:546


Turn on logging of all events.

Logically collective.

flag (bool) -- Activate (if True) or deactivate (if False) the logging of all events.
None

SEE ALSO:

petsc.PetscLogEventSetActiveAll


Source code at petsc4py/PETSc/Log.pyx:576


Attributes Documentation






petsc4py.PETSc.LogStage

Bases: object

Logging support for different stages.

Methods Summary

activate() Activate the stage.
deactivate() Deactivate the stage.
getActive() Check if the stage is activated.
getName() Source code at petsc4py/PETSc/Log.pyx:257
getVisible() Return whether the stage is visible.
pop() Pop a stage from the logging stack.
push() Push a stage on the logging stack.
setActive(flag) Activate or deactivate the current stage.
setVisible(flag) Set the visibility of the stage.

Attributes Summary

active
id
name
visible

Methods Documentation

Activate the stage.

Logically collective.

SEE ALSO:

petsc.PetscLogStageSetActive


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



Deactivate the stage.

Logically collective.

SEE ALSO:

petsc.PetscLogStageSetActive


Source code at petsc4py/PETSc/Log.pyx:283



Check if the stage is activated.

Not collective.

SEE ALSO:

petsc.PetscLogStageGetActive


Source code at petsc4py/PETSc/Log.pyx:295



Source code at petsc4py/PETSc/Log.pyx:257

Return whether the stage is visible.

Not collective.

SEE ALSO:

LogStage.setVisible, petsc.PetscLogStageSetVisible


Source code at petsc4py/PETSc/Log.pyx:331



Pop a stage from the logging stack.

Logically collective.

SEE ALSO:

LogStage.push, petsc.PetscLogStagePop


Source code at petsc4py/PETSc/Log.pyx:242



Push a stage on the logging stack.

Logically collective.

SEE ALSO:

LogStage.pop, petsc.PetscLogStagePush


Source code at petsc4py/PETSc/Log.pyx:230



Activate or deactivate the current stage.

Logically collective.

SEE ALSO:

petsc.PetscLogStageSetActive


Source code at petsc4py/PETSc/Log.pyx:309

flag (bool) --
None


Set the visibility of the stage.

Logically collective.

flag (bool) -- True to make the stage visible, False otherwise.
None

SEE ALSO:

LogStage.getVisible, petsc.PetscLogStageSetVisible


Source code at petsc4py/PETSc/Log.pyx:345


Attributes Documentation






petsc4py.PETSc.Mat

Bases: Object

Matrix object.

Mat is described in the PETSc manual.

SEE ALSO:

petsc.Mat


Enumerations

AssemblyType Matrix assembly type.
DuplicateOption Matrix duplicate option.
FactorShiftType Factored matrix shift type.
InfoType Matrix info type.
Option Matrix option.
OrderingType Factored matrix ordering type.
SORType Matrix SOR type.
SolverType Factored matrix solver type.
Stencil Associate structured grid coordinates with matrix indices.
Structure Matrix modification structure.
Type Matrix type.

petsc4py.PETSc.Mat.AssemblyType

Bases: object

Matrix assembly type.

SEE ALSO:

petsc.MatAssemblyType


Attributes Summary

FINAL Constant FINAL of type int
FINAL_ASSEMBLY Constant FINAL_ASSEMBLY of type int
FLUSH Constant FLUSH of type int
FLUSH_ASSEMBLY Constant FLUSH_ASSEMBLY of type int

Attributes Documentation

Constant FINAL of type int

Constant FINAL_ASSEMBLY of type int

Constant FLUSH of type int

Constant FLUSH_ASSEMBLY of type int


petsc4py.PETSc.Mat.DuplicateOption

Bases: object

Matrix duplicate option.

SEE ALSO:

petsc.MatDuplicateOption


Attributes Summary

COPY_VALUES Constant COPY_VALUES of type int
DO_NOT_COPY_VALUES Constant DO_NOT_COPY_VALUES of type int
SHARE_NONZERO_PATTERN Constant SHARE_NONZERO_PATTERN of type int

Attributes Documentation

Constant COPY_VALUES of type int

Constant DO_NOT_COPY_VALUES of type int

Constant SHARE_NONZERO_PATTERN of type int


petsc4py.PETSc.Mat.FactorShiftType

Bases: object

Factored matrix shift type.

SEE ALSO:

petsc.MatFactorShiftType


Attributes Summary

INBLOCKS Constant INBLOCKS of type int
NONE Constant NONE of type int
NONZERO Constant NONZERO of type int
NZ Constant NZ of type int
PD Constant PD of type int
POSITIVE_DEFINITE Constant POSITIVE_DEFINITE of type int

Attributes Documentation

Constant INBLOCKS of type int

Constant NONE of type int

Constant NONZERO of type int

Constant NZ of type int

Constant PD of type int

Constant POSITIVE_DEFINITE of type int


petsc4py.PETSc.Mat.InfoType

Bases: object

Matrix info type.

Attributes Summary

GLOBAL_MAX Constant GLOBAL_MAX of type int
GLOBAL_SUM Constant GLOBAL_SUM of type int
LOCAL Constant LOCAL of type int

Attributes Documentation

Constant GLOBAL_MAX of type int

Constant GLOBAL_SUM of type int

Constant LOCAL of type int


petsc4py.PETSc.Mat.Option

Bases: object

Matrix option.

SEE ALSO:

petsc.MatOption


Attributes Summary

ERROR_LOWER_TRIANGULAR Constant ERROR_LOWER_TRIANGULAR of type int
FORCE_DIAGONAL_ENTRIES Constant FORCE_DIAGONAL_ENTRIES of type int
GETROW_UPPERTRIANGULAR Constant GETROW_UPPERTRIANGULAR of type int
HERMITIAN Constant HERMITIAN of type int
IGNORE_LOWER_TRIANGULAR Constant IGNORE_LOWER_TRIANGULAR of type int
IGNORE_OFF_PROC_ENTRIES Constant IGNORE_OFF_PROC_ENTRIES of type int
IGNORE_ZERO_ENTRIES Constant IGNORE_ZERO_ENTRIES of type int
KEEP_NONZERO_PATTERN Constant KEEP_NONZERO_PATTERN of type int
NEW_NONZERO_ALLOCATION_ERR Constant NEW_NONZERO_ALLOCATION_ERR of type int
NEW_NONZERO_LOCATIONS Constant NEW_NONZERO_LOCATIONS of type int
NEW_NONZERO_LOCATION_ERR Constant NEW_NONZERO_LOCATION_ERR of type int
NO_OFF_PROC_ENTRIES Constant NO_OFF_PROC_ENTRIES of type int
NO_OFF_PROC_ZERO_ROWS Constant NO_OFF_PROC_ZERO_ROWS of type int
OPTION_MAX Constant OPTION_MAX of type int
OPTION_MIN Constant OPTION_MIN of type int
ROW_ORIENTED Constant ROW_ORIENTED of type int
SORTED_FULL Constant SORTED_FULL of type int
SPD Constant SPD of type int
STRUCTURALLY_SYMMETRIC Constant STRUCTURALLY_SYMMETRIC of type int
STRUCTURE_ONLY Constant STRUCTURE_ONLY of type int
SUBMAT_SINGLEIS Constant SUBMAT_SINGLEIS of type int
SUBSET_OFF_PROC_ENTRIES Constant SUBSET_OFF_PROC_ENTRIES of type int
SYMMETRIC Constant SYMMETRIC of type int
SYMMETRY_ETERNAL Constant SYMMETRY_ETERNAL of type int
UNUSED_NONZERO_LOCATION_ERR Constant UNUSED_NONZERO_LOCATION_ERR of type int
USE_HASH_TABLE Constant USE_HASH_TABLE of type int
USE_INODES Constant USE_INODES of type int

Attributes Documentation

Constant ERROR_LOWER_TRIANGULAR of type int

Constant FORCE_DIAGONAL_ENTRIES of type int

Constant GETROW_UPPERTRIANGULAR of type int

Constant HERMITIAN of type int

Constant IGNORE_LOWER_TRIANGULAR of type int

Constant IGNORE_OFF_PROC_ENTRIES of type int

Constant IGNORE_ZERO_ENTRIES of type int

Constant KEEP_NONZERO_PATTERN of type int

Constant NEW_NONZERO_ALLOCATION_ERR of type int

Constant NEW_NONZERO_LOCATIONS of type int

Constant NEW_NONZERO_LOCATION_ERR of type int

Constant NO_OFF_PROC_ENTRIES of type int

Constant NO_OFF_PROC_ZERO_ROWS of type int

Constant OPTION_MAX of type int

Constant OPTION_MIN of type int

Constant ROW_ORIENTED of type int

Constant SORTED_FULL of type int

Constant SPD of type int

Constant STRUCTURALLY_SYMMETRIC of type int

Constant STRUCTURE_ONLY of type int

Constant SUBMAT_SINGLEIS of type int

Constant SUBSET_OFF_PROC_ENTRIES of type int

Constant SYMMETRIC of type int

Constant SYMMETRY_ETERNAL of type int

Constant UNUSED_NONZERO_LOCATION_ERR of type int

Constant USE_HASH_TABLE of type int

Constant USE_INODES of type int


petsc4py.PETSc.Mat.OrderingType

Bases: object

Factored matrix ordering type.

SEE ALSO:

petsc.MatOrderingType


Attributes Summary

AMD Object AMD of type str
METISND Object METISND of type str
NATURAL Object NATURAL of type str
ND Object ND of type str
OWD Object OWD of type str
QMD Object QMD of type str
RCM Object RCM of type str
ROWLENGTH Object ROWLENGTH of type str
SPECTRAL Object SPECTRAL of type str
WBM Object WBM of type str

Attributes Documentation

Object AMD of type str

Object METISND of type str

Object NATURAL of type str

Object ND of type str

Object OWD of type str

Object QMD of type str

Object RCM of type str

Object ROWLENGTH of type str

Object SPECTRAL of type str

Object WBM of type str


petsc4py.PETSc.Mat.SORType

Bases: object

Matrix SOR type.

SEE ALSO:

petsc.MatSORType


Attributes Summary

APPLY_LOWER Constant APPLY_LOWER of type int
APPLY_UPPER Constant APPLY_UPPER of type int
BACKWARD_SWEEP Constant BACKWARD_SWEEP of type int
EISENSTAT Constant EISENSTAT of type int
FORWARD_SWEEP Constant FORWARD_SWEEP of type int
LOCAL_BACKWARD_SWEEP Constant LOCAL_BACKWARD_SWEEP of type int
LOCAL_FORWARD_SWEEP Constant LOCAL_FORWARD_SWEEP of type int
LOCAL_SYMMETRIC_SWEEP Constant LOCAL_SYMMETRIC_SWEEP of type int
SYMMETRY_SWEEP Constant SYMMETRY_SWEEP of type int
ZERO_INITIAL_GUESS Constant ZERO_INITIAL_GUESS of type int

Attributes Documentation

Constant APPLY_LOWER of type int

Constant APPLY_UPPER of type int

Constant BACKWARD_SWEEP of type int

Constant EISENSTAT of type int

Constant FORWARD_SWEEP of type int

Constant LOCAL_BACKWARD_SWEEP of type int

Constant LOCAL_FORWARD_SWEEP of type int

Constant LOCAL_SYMMETRIC_SWEEP of type int

Constant SYMMETRY_SWEEP of type int

Constant ZERO_INITIAL_GUESS of type int


petsc4py.PETSc.Mat.SolverType

Bases: object

Factored matrix solver type.

SEE ALSO:

petsc.MatSolverType


Attributes Summary

BAS Object BAS of type str
CHOLMOD Object CHOLMOD of type str
CUDA Object CUDA of type str
CUSPARSE Object CUSPARSE of type str
ELEMENTAL Object ELEMENTAL of type str
ESSL Object ESSL of type str
KLU Object KLU of type str
LUSOL Object LUSOL of type str
MATLAB Object MATLAB of type str
MKL_CPARDISO Object MKL_CPARDISO of type str
MKL_PARDISO Object MKL_PARDISO of type str
MUMPS Object MUMPS of type str
PASTIX Object PASTIX of type str
PETSC Object PETSC of type str
SCALAPACK Object SCALAPACK of type str
SPQR Object SPQR of type str
STRUMPACK Object STRUMPACK of type str
SUPERLU Object SUPERLU of type str
SUPERLU_DIST Object SUPERLU_DIST of type str
UMFPACK Object UMFPACK of type str

Attributes Documentation

Object BAS of type str

Object CHOLMOD of type str

Object CUDA of type str

Object CUSPARSE of type str

Object ELEMENTAL of type str

Object ESSL of type str

Object KLU of type str

Object LUSOL of type str

Object MATLAB of type str

Object MKL_CPARDISO of type str

Object MKL_PARDISO of type str

Object MUMPS of type str

Object PASTIX of type str

Object PETSC of type str

Object SCALAPACK of type str

Object SPQR of type str

Object STRUMPACK of type str

Object SUPERLU of type str

Object SUPERLU_DIST of type str

Object UMFPACK of type str


petsc4py.PETSc.Mat.Stencil

Bases: object

Associate structured grid coordinates with matrix indices.

SEE ALSO:

petsc.MatStencil


Attributes Summary

c Field component.
field Field component.
i First logical grid coordinate.
index Logical grid coordinates (i, j, k).
j Second logical grid coordinate.
k Third logical grid coordinate.

Attributes Documentation

Field component.

Source code at petsc4py/PETSc/Mat.pyx:301


Field component.

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


First logical grid coordinate.

Source code at petsc4py/PETSc/Mat.pyx:280


Logical grid coordinates (i, j, k).

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


Second logical grid coordinate.

Source code at petsc4py/PETSc/Mat.pyx:287


Third logical grid coordinate.

Source code at petsc4py/PETSc/Mat.pyx:294



petsc4py.PETSc.Mat.Structure

Bases: object

Matrix modification structure.

SEE ALSO:

petsc.MatStructure


Attributes Summary

DIFFERENT Constant DIFFERENT of type int
DIFFERENT_NONZERO_PATTERN Constant DIFFERENT_NONZERO_PATTERN of type int
DIFFERENT_NZ Constant DIFFERENT_NZ of type int
SAME Constant SAME of type int
SAME_NONZERO_PATTERN Constant SAME_NONZERO_PATTERN of type int
SAME_NZ Constant SAME_NZ of type int
SUBSET Constant SUBSET of type int
SUBSET_NONZERO_PATTERN Constant SUBSET_NONZERO_PATTERN of type int
SUBSET_NZ Constant SUBSET_NZ of type int
UNKNOWN Constant UNKNOWN of type int
UNKNOWN_NONZERO_PATTERN Constant UNKNOWN_NONZERO_PATTERN of type int
UNKNOWN_NZ Constant UNKNOWN_NZ of type int

Attributes Documentation

Constant DIFFERENT of type int

Constant DIFFERENT_NONZERO_PATTERN of type int

Constant DIFFERENT_NZ of type int

Constant SAME of type int

Constant SAME_NONZERO_PATTERN of type int

Constant SAME_NZ of type int

Constant SUBSET of type int

Constant SUBSET_NONZERO_PATTERN of type int

Constant SUBSET_NZ of type int

Constant UNKNOWN of type int

Constant UNKNOWN_NONZERO_PATTERN of type int

Constant UNKNOWN_NZ of type int


petsc4py.PETSc.Mat.Type

Bases: object

Matrix type.

SEE ALSO:

petsc.MatType


Attributes Summary

AIJ Object AIJ of type str
AIJCRL Object AIJCRL of type str
AIJCUSPARSE Object AIJCUSPARSE of type str
AIJMKL Object AIJMKL of type str
AIJPERM Object AIJPERM of type str
AIJSELL Object AIJSELL of type str
AIJVIENNACL Object AIJVIENNACL of type str
BAIJ Object BAIJ of type str
BAIJMKL Object BAIJMKL of type str
BLOCKMAT Object BLOCKMAT of type str
COMPOSITE Object COMPOSITE of type str
CONSTANTDIAGONAL Object CONSTANTDIAGONAL of type str
DENSE Object DENSE of type str
DENSECUDA Object DENSECUDA of type str
DIAGONAL Object DIAGONAL of type str
DUMMY Object DUMMY of type str
ELEMENTAL Object ELEMENTAL of type str
FFT Object FFT of type str
FFTW Object FFTW of type str
H2OPUS Object H2OPUS of type str
HERMITIANTRANSPOSE Object HERMITIANTRANSPOSE of type str
HYPRE Object HYPRE of type str
HYPRESSTRUCT Object HYPRESSTRUCT of type str
HYPRESTRUCT Object HYPRESTRUCT of type str
IS Object IS of type str
KAIJ Object KAIJ of type str
LMVM Object LMVM of type str
LMVMBADBROYDEN Object LMVMBADBROYDEN of type str
LMVMBFGS Object LMVMBFGS of type str
LMVMBROYDEN Object LMVMBROYDEN of type str
LMVMDFP Object LMVMDFP of type str
LMVMDIAGBBROYDEN Object LMVMDIAGBBROYDEN of type str
LMVMSR1 Object LMVMSR1 of type str
LMVMSYMBADBROYDEN Object LMVMSYMBADBROYDEN of type str
LMVMSYMBROYDEN Object LMVMSYMBROYDEN of type str
LOCALREF Object LOCALREF of type str
LRC Object LRC of type str
MAIJ Object MAIJ of type str
MFFD Object MFFD of type str
MPIADJ Object MPIADJ of type str
MPIAIJ Object MPIAIJ of type str
MPIAIJCRL Object MPIAIJCRL of type str
MPIAIJCUSPARSE Object MPIAIJCUSPARSE of type str
MPIAIJMKL Object MPIAIJMKL of type str
MPIAIJPERM Object MPIAIJPERM of type str
MPIAIJSELL Object MPIAIJSELL of type str
MPIAIJVIENNACL Object MPIAIJVIENNACL of type str
MPIBAIJ Object MPIBAIJ of type str
MPIBAIJMKL Object MPIBAIJMKL of type str
MPIDENSE Object MPIDENSE of type str
MPIDENSECUDA Object MPIDENSECUDA of type str
MPIKAIJ Object MPIKAIJ of type str
MPIMAIJ Object MPIMAIJ of type str
MPISBAIJ Object MPISBAIJ of type str
MPISELL Object MPISELL of type str
NEST Object NEST of type str
NORMAL Object NORMAL of type str
NORMALHERMITIAN Object NORMALHERMITIAN of type str
PREALLOCATOR Object PREALLOCATOR of type str
PYTHON Object PYTHON of type str
SAME Object SAME of type str
SBAIJ Object SBAIJ of type str
SCATTER Object SCATTER of type str
SCHURCOMPLEMENT Object SCHURCOMPLEMENT of type str
SELL Object SELL of type str
SEQAIJ Object SEQAIJ of type str
SEQAIJCRL Object SEQAIJCRL of type str
SEQAIJCUSPARSE Object SEQAIJCUSPARSE of type str
SEQAIJMKL Object SEQAIJMKL of type str
SEQAIJPERM Object SEQAIJPERM of type str
SEQAIJSELL Object SEQAIJSELL of type str
SEQAIJVIENNACL Object SEQAIJVIENNACL of type str
SEQBAIJ Object SEQBAIJ of type str
SEQBAIJMKL Object SEQBAIJMKL of type str
SEQCUFFT Object SEQCUFFT of type str
SEQDENSE Object SEQDENSE of type str
SEQDENSECUDA Object SEQDENSECUDA of type str
SEQKAIJ Object SEQKAIJ of type str
SEQMAIJ Object SEQMAIJ of type str
SEQSBAIJ Object SEQSBAIJ of type str
SEQSELL Object SEQSELL of type str
SHELL Object SHELL of type str
SUBMATRIX Object SUBMATRIX of type str
TRANSPOSE Object TRANSPOSE of type str

Attributes Documentation

Object AIJ of type str

Object AIJCRL of type str

Object AIJCUSPARSE of type str

Object AIJMKL of type str

Object AIJPERM of type str

Object AIJSELL of type str

Object AIJVIENNACL of type str

Object BAIJ of type str

Object BAIJMKL of type str

Object BLOCKMAT of type str

Object COMPOSITE of type str

Object CONSTANTDIAGONAL of type str

Object DENSE of type str

Object DENSECUDA of type str

Object DIAGONAL of type str

Object DUMMY of type str

Object ELEMENTAL of type str

Object FFT of type str

Object FFTW of type str

Object H2OPUS of type str

Object HERMITIANTRANSPOSE of type str

Object HYPRE of type str

Object HYPRESSTRUCT of type str

Object HYPRESTRUCT of type str

Object IS of type str

Object KAIJ of type str

Object LMVM of type str

Object LMVMBADBROYDEN of type str

Object LMVMBFGS of type str

Object LMVMBROYDEN of type str

Object LMVMDFP of type str

Object LMVMDIAGBBROYDEN of type str

Object LMVMSR1 of type str

Object LMVMSYMBADBROYDEN of type str

Object LMVMSYMBROYDEN of type str

Object LOCALREF of type str

Object LRC of type str

Object MAIJ of type str

Object MFFD of type str

Object MPIADJ of type str

Object MPIAIJ of type str

Object MPIAIJCRL of type str

Object MPIAIJCUSPARSE of type str

Object MPIAIJMKL of type str

Object MPIAIJPERM of type str

Object MPIAIJSELL of type str

Object MPIAIJVIENNACL of type str

Object MPIBAIJ of type str

Object MPIBAIJMKL of type str

Object MPIDENSE of type str

Object MPIDENSECUDA of type str

Object MPIKAIJ of type str

Object MPIMAIJ of type str

Object MPISBAIJ of type str

Object MPISELL of type str

Object NEST of type str

Object NORMAL of type str

Object NORMALHERMITIAN of type str

Object PREALLOCATOR of type str

Object PYTHON of type str

Object SAME of type str

Object SBAIJ of type str

Object SCATTER of type str

Object SCHURCOMPLEMENT of type str

Object SELL of type str

Object SEQAIJ of type str

Object SEQAIJCRL of type str

Object SEQAIJCUSPARSE of type str

Object SEQAIJMKL of type str

Object SEQAIJPERM of type str

Object SEQAIJSELL of type str

Object SEQAIJVIENNACL of type str

Object SEQBAIJ of type str

Object SEQBAIJMKL of type str

Object SEQCUFFT of type str

Object SEQDENSE of type str

Object SEQDENSECUDA of type str

Object SEQKAIJ of type str

Object SEQMAIJ of type str

Object SEQSBAIJ of type str

Object SEQSELL of type str

Object SHELL of type str

Object SUBMATRIX of type str

Object TRANSPOSE of type str


Methods Summary

H2OpusCompress(tol) Compress a hierarchical matrix.
H2OpusLowRankUpdate(U[, V, s]) Perform a low-rank update of the form self += sUVᵀ.
H2OpusOrthogonalize() Orthogonalize the basis tree of a hierarchical matrix.
SOR(b, x[, omega, sortype, shift, its, lits]) Compute relaxation (SOR, Gauss-Seidel) sweeps.
appendOptionsPrefix(prefix) Append to the prefix used for searching for options in the database.
assemble([assembly]) Assemble the matrix.
assemblyBegin([assembly]) Begin an assembling stage of the matrix.
assemblyEnd([assembly]) Complete an assembling stage of the matrix initiated with assemblyBegin.
axpy(alpha, X[, structure]) Perform the matrix summation self + = ɑ·X.
aypx(alpha, X[, structure]) Perform the matrix summation self = ɑ·self + X.
bindToCPU(flg) Mark a matrix to temporarily stay on the CPU.
boundToCPU() Query if a matrix is bound to the CPU.
chop(tol) Set entries smallest of tol (in absolute values) to zero.
conjugate([out]) Return the conjugate matrix.
convert([mat_type, out]) Convert the matrix type.
copy([result, structure]) Return a copy of the matrix.
create([comm]) Create the matrix.
createAIJ(size[, bsize, nnz, csr, comm]) Create a sparse Type.AIJ matrix, optionally preallocating.
createAIJCRL(size[, bsize, nnz, csr, comm]) Create a sparse Type.AIJCRL matrix.
createAIJWithArrays(size, csr[, bsize, comm]) Create a sparse Type.AIJ matrix with data in CSR format.
createBAIJ(size, bsize[, nnz, csr, comm]) Create a sparse blocked Type.BAIJ matrix, optionally preallocating.
createConstantDiagonal(size, diag[, comm]) Create a diagonal matrix of type Type.CONSTANTDIAGONAL.
createDense(size[, bsize, array, comm]) Create a Type.DENSE matrix.
createDenseCUDA(size[, bsize, array, ...]) Create a Type.DENSECUDA matrix with optional host and device data.
createDiagonal(diag) Create a diagonal matrix of type Type.DIAGONAL.
createH2OpusFromMat(A[, coordinates, dist, ...]) Create a hierarchical Type.H2OPUS matrix sampling from a provided operator.
createHermitianTranspose(mat) Create a Type.HERMITIANTRANSPOSE matrix that behaves like (A*)ᵀ.
createIS(size[, lgmapr, lgmapc, comm]) Create a Type.IS matrix representing globally unassembled operators.
createLRC(A, U, c, V) Create a low-rank correction Type.LRC matrix representing A + UCVᵀ.
createNest(mats[, isrows, iscols, comm]) Create a Type.NEST matrix containing multiple submatrices.
createNormal(mat) Create a Type.NORMAL matrix representing AᵀA.
createNormalHermitian(mat) Create a Type.NORMALHERMITIAN matrix representing (A*)ᵀA.
createPython(size[, context, comm]) Create a Type.PYTHON matrix.
createSBAIJ(size, bsize[, nnz, csr, comm]) Create a sparse Type.SBAIJ matrix in symmetric block format.
createScatter(scatter[, comm]) Create a Type.SCATTER matrix from a vector scatter.
createSubMatrices(isrows[, iscols, submats]) Return several sequential submatrices.
createSubMatrix(isrow[, iscol, submat]) Return a submatrix.
createSubMatrixVirtual(A, isrow[, iscol]) Create a Type.SUBMATRIX matrix that acts as a submatrix.
createTranspose(mat) Create a Type.TRANSPOSE matrix that behaves like Aᵀ.
createVecLeft() Return a left vector, a vector that the matrix vector product can be stored in.
createVecRight() Return a right vector, a vector that the matrix can be multiplied against.
createVecs([side]) Return vectors that can be used in matrix vector products.
destroy() Destroy the matrix.
diagonalScale([L, R]) Perform left and/or right diagonal scaling of the matrix.
duplicate([copy]) Return a clone of the matrix.
equal(mat) Return the result of matrix comparison.
factorCholesky(isperm[, options]) Perform an in-place Cholesky factorization.
factorICC(isperm[, options]) Perform an in-place an incomplete Cholesky factorization.
factorILU(isrow, iscol[, options]) Perform an in-place ILU factorization.
factorLU(isrow, iscol[, options]) Perform an in-place LU factorization.
factorNumericCholesky(mat[, options]) Not implemented.
factorNumericLU(mat[, options]) Not implemented.
factorSymbolicCholesky(isperm[, options]) Not implemented.
factorSymbolicICC(isperm[, options]) Not implemented.
factorSymbolicILU(isrow, iscol[, options]) Not implemented.
factorSymbolicLU(mat, isrow, iscol[, options]) Not implemented.
findZeroRows() Return the index set of empty rows.
fixISLocalEmpty(fix) Compress out zero local rows from the local matrices.
getBlockSize() Return the matrix block size.
getBlockSizes() Return the row and column block sizes.
getColumnIJ([symmetric, compressed]) Return the CSC representation of the local sparsity pattern.
getColumnVector(column[, result]) Return the columnᵗʰ column vector of the matrix.
getDM() Return the DM defining the data layout of the matrix.
getDenseArray([readonly]) Return the array where the data is stored.
getDenseColumnVec(i[, mode]) Return the iᵗʰ column vector of the dense matrix.
getDenseLDA() Return the leading dimension of the array used by the dense matrix.
getDenseLocalMatrix() Return the local part of the dense matrix.
getDiagonal([result]) Return the diagonal of the matrix.
getDiagonalBlock() Return the part of the matrix associated with the on-process coupling.
getISLocalMat() Return the local matrix stored inside a Type.IS matrix.
getInertia() Return the inertia from a factored matrix.
getInfo([info]) Return summary information.
getLGMap() Return the local-to-global mappings.
getLRCMats() Return the constituents of a Type.LRC matrix.
getLocalSize() Return the local number of rows and columns.
getLocalSubMatrix(isrow, iscol[, submat]) Return a reference to a submatrix specified in local numbering.
getMumpsCntl(icntl) Return the MUMPS parameter, CNTL[icntl].
getMumpsIcntl(icntl) Return the MUMPS parameter, ICNTL[icntl].
getMumpsInfo(icntl) Return the MUMPS parameter, INFO[icntl].
getMumpsInfog(icntl) Return the MUMPS parameter, INFOG[icntl].
getMumpsRinfo(icntl) Return the MUMPS parameter, RINFO[icntl].
getMumpsRinfog(icntl) Return the MUMPS parameter, RINFOG[icntl].
getNearNullSpace() Return the near-nullspace.
getNestISs() Return the index sets representing the row and column spaces.
getNestLocalISs() Return the local index sets representing the row and column spaces.
getNestSize() Return the number of rows and columns of the matrix.
getNestSubMatrix(i, j) Return a single submatrix.
getNullSpace() Return the nullspace.
getOption(option) Return the option value.
getOptionsPrefix() Return the prefix used for searching for options in the database.
getOrdering(ord_type) Return a reordering for a matrix to improve a LU factorization.
getOwnershipIS() Return the ranges of rows and columns owned by each process as index sets.
getOwnershipRange() Return the locally owned range of rows.
getOwnershipRangeColumn() Return the locally owned range of columns.
getOwnershipRanges() Return the range of rows owned by each process.
getOwnershipRangesColumn() Return the range of columns owned by each process.
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 matrix.
getRedundantMatrix(nsubcomm[, subcomm, out]) Return redundant matrices on subcommunicators.
getRow(row) Return the column indices and values for the requested row.
getRowIJ([symmetric, compressed]) Return the CSR representation of the local sparsity pattern.
getRowSum([result]) Return the row-sum vector.
getSize() Return the global number of rows and columns.
getSizes() Return the tuple of matrix layouts.
getTransposeNullSpace() Return the transpose nullspace.
getType() Return the type of the matrix.
getValue(row, col) Return the value in the (row,col) position.
getValues(rows, cols[, values]) Return the values in the zip(rows,cols) positions.
getValuesCSR() Return the CSR representation of the local part of the matrix.
getVecType() Return the vector type used by the matrix.
hermitianTranspose([out]) Return the transposed Hermitian matrix.
imagPart([out]) Return the imaginary part of the matrix.
increaseOverlap(iset[, overlap]) Increase the overlap of a index set.
invertBlockDiagonal() Return the inverse of the block-diagonal entries.
isAssembled() The boolean flag indicating if the matrix is assembled.
isHermitian([tol]) Return the boolean indicating if the matrix is Hermitian.
isHermitianKnown() Return the 2-tuple indicating if the matrix is known to be Hermitian.
isStructurallySymmetric() Return the boolean indicating if the matrix is structurally symmetric.
isSymmetric([tol]) Return the boolean indicating if the matrix is symmetric.
isSymmetricKnown() Return the 2-tuple indicating if the matrix is known to be symmetric.
isTranspose([mat, tol]) Return the result of matrix comparison with transposition.
kron(mat[, result]) Compute C, the Kronecker product of A and B.
load(viewer) Load a matrix.
matMatMult(B, C[, result, fill]) Perform matrix-matrix-matrix multiplication D=ABC.
matMult(mat[, result, fill]) Perform matrix-matrix multiplication C=AB.
matSolve(B, X) Solve AX=B, given a factored matrix A.
matTransposeMult(mat[, result, fill]) Perform matrix-matrix multiplication C=ABᵀ.
mult(x, y) Perform the matrix vector product y = A @ x.
multAdd(x, v, y) Perform the matrix vector product with addition y = A @ x + v.
multHermitian(x, y) Perform the Hermitian matrix vector product y = A^H @ x.
multHermitianAdd(x, v, y) Perform the Hermitian matrix vector product with addition y = A^H @ x + v.
multTranspose(x, y) Perform the transposed matrix vector product y = A^T @ x.
multTransposeAdd(x, v, y) Perform the transposed matrix vector product with addition y = A^T @ x + v.
norm([norm_type]) Compute the requested matrix norm.
permute(row, col) Return the permuted matrix.
ptap(P[, result, fill]) Creates the matrix product C = PᵀAP.
rart(R[, result, fill]) Create the matrix product C = RARᵀ.
realPart([out]) Return the real part of the matrix.
reorderForNonzeroDiagonal(isrow, iscol[, atol]) Change a matrix ordering to remove zeros from the diagonal.
restoreDenseColumnVec(i[, mode]) Restore the iᵗʰ column vector of the dense matrix.
restoreISLocalMat(local) Restore the local matrix obtained with getISLocalMat.
restoreLocalSubMatrix(isrow, iscol, submat) Restore a reference to a submatrix obtained with getLocalSubMatrix.
retrieveValues() Retrieve a copy of the matrix values previously stored with storeValues.
scale(alpha) Scale the matrix.
setBlockSize(bsize) Set the matrix block size (same for rows and columns).
setBlockSizes(row_bsize, col_bsize) Set the row and column block sizes.
setDM(dm) Set the DM defining the data layout of the matrix.
setDenseLDA(lda) Set the leading dimension of the array used by the dense matrix.
setDiagonal(diag[, addv]) Set the diagonal values of the matrix.
setFromOptions() Configure the matrix from the options database.
setISLocalMat(local) Set the local matrix stored inside a Type.IS.
setISPreallocation(nnz, onnz) Preallocate memory for a Type.IS parallel matrix.
setLGMap(rmap[, cmap]) Set the local-to-global mappings.
setLRCMats(A, U[, c, V]) Set the constituents of a Type.LRC matrix.
setMumpsCntl(icntl, val) Set a MUMPS parameter, CNTL[icntl] = val.
setMumpsIcntl(icntl, ival) Set a MUMPS parameter, ICNTL[icntl] = ival.
setNearNullSpace(nsp) Set the near-nullspace.
setNestVecType(vec_type) Set the vector type for a Type.NEST matrix.
setNullSpace(nsp) Set the nullspace.
setOption(option, flag) Set option.
setOptionsPrefix(prefix) Set the prefix used for searching for options in the database.
setPreallocationCSR(csr) Preallocate memory for the matrix with a CSR layout.
setPreallocationDense(array) Set the array used for storing matrix elements for a dense matrix.
setPreallocationNNZ(nnz) Preallocate memory for the matrix with a non-zero pattern.
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.
setRandom([random]) Set random values in the matrix.
setSizes(size[, bsize]) Set the local, global and block sizes.
setStencil(dims[, starts, dof]) Set matrix stencil.
setTransposeNullSpace(nsp) Set the transpose nullspace.
setTransposePrecursor(out) Set transpose precursor.
setType(mat_type) Set the matrix type.
setUnfactored() Set a factored matrix to be treated as unfactored.
setUp() Set up the internal data structures for using the matrix.
setValue(row, col, value[, addv]) Set a value to the (row, col) entry of the matrix.
setValueBlockedStagStencil(row, col, value) Not implemented.
setValueBlockedStencil(row, col, value[, addv]) Set a block of values to row and col stencil.
setValueLocal(row, col, value[, addv]) Set a value to the (row, col) entry of the matrix in local ordering.
setValueStagStencil(row, col, value[, addv]) Not implemented.
setValueStencil(row, col, value[, addv]) Set a value to row and col stencil.
setValues(rows, cols, values[, addv]) Set values to the rows ⊗ cols entries of the matrix.
setValuesBlocked(rows, cols, values[, addv]) Set values to the rows ⊗ col block entries of the matrix.
setValuesBlockedCSR(I, J, V[, addv]) Set values stored in block CSR format.
setValuesBlockedIJV(I, J, V[, addv, rowmap]) Set a subset of values stored in block CSR format.
setValuesBlockedLocal(rows, cols, values[, addv]) Set values to the rows ⊗ col block entries of the matrix in local ordering.
setValuesBlockedLocalCSR(I, J, V[, addv]) Set values stored in block CSR format.
setValuesBlockedLocalIJV(I, J, V[, addv, rowmap]) Set a subset of values stored in block CSR format.
setValuesBlockedLocalRCV(R, C, V[, addv]) Undocumented.
setValuesBlockedRCV(R, C, V[, addv]) Undocumented.
setValuesCSR(I, J, V[, addv]) Set values stored in CSR format.
setValuesIJV(I, J, V[, addv, rowmap]) Set a subset of values stored in CSR format.
setValuesLocal(rows, cols, values[, addv]) Set values to the rows ⊗ col entries of the matrix in local ordering.
setValuesLocalCSR(I, J, V[, addv]) Set values stored in CSR format.
setValuesLocalIJV(I, J, V[, addv, rowmap]) Set a subset of values stored in CSR format.
setValuesLocalRCV(R, C, V[, addv]) Undocumented.
setValuesRCV(R, C, V[, addv]) Undocumented.
setVecType(vec_type) Set the vector type.
shift(alpha) Shift the matrix.
solve(b, x) Solve Ax=b, given a factored matrix.
solveAdd(b, y, x) Solve x=y+A⁻¹b, given a factored matrix.
solveBackward(b, x) Solve Ux=b, given a factored matrix A=LU.
solveForward(b, x) Solve Lx = b, given a factored matrix A = LU.
solveTranspose(b, x) Solve Aᵀx=b, given a factored matrix.
solveTransposeAdd(b, y, x) Solve x=y+A⁻ᵀb, given a factored matrix.
storeValues() Stash a copy of the matrix values.
toDLPack([mode]) Return a DLPack PyCapsule wrapping the vector data.
transpose([out]) Return the transposed matrix.
transposeMatMult(mat[, result, fill]) Perform matrix-matrix multiplication C=AᵀB.
view([viewer]) View the matrix.
zeroEntries() Zero the entries of the matrix.
zeroRows(rows[, diag, x, b]) Zero selected rows of the matrix.
zeroRowsColumns(rows[, diag, x, b]) Zero selected rows and columns of the matrix.
zeroRowsColumnsLocal(rows[, diag, x, b]) Zero selected rows and columns of the matrix in local ordering.
zeroRowsColumnsStencil(rows[, diag, x, b]) Zero selected rows and columns of the matrix.
zeroRowsLocal(rows[, diag, x, b]) Zero selected rows of the matrix in local ordering.

Attributes Summary

assembled The boolean flag indicating if the matrix is assembled.
block_size Matrix block size.
block_sizes Matrix row and column block sizes.
hermitian The boolean flag indicating if the matrix is Hermitian.
local_size Matrix local size.
owner_range Matrix local row range.
owner_ranges Matrix row ranges.
size Matrix global size.
sizes Matrix local and global sizes.
structsymm The boolean flag indicating if the matrix is structurally symmetric.
symmetric The boolean flag indicating if the matrix is symmetric.

Methods Documentation

Compress a hierarchical matrix.
tol (float) -- The absolute truncation threshold.

SEE ALSO:

petsc.MatH2OpusCompress


Source code at petsc4py/PETSc/Mat.pyx:4854


Perform a low-rank update of the form self += sUVᵀ.
  • U (Mat) -- The dense low-rank update matrix.
  • V (Mat | None) -- The dense low-rank update matrix. If None, V = U.
  • s (float) -- The scaling factor.


SEE ALSO:

petsc.MatH2OpusLowRankUpdate


Source code at petsc4py/PETSc/Mat.pyx:4871


Orthogonalize the basis tree of a hierarchical matrix.

SEE ALSO:

petsc.MatH2OpusOrthogonalize


Source code at petsc4py/PETSc/Mat.pyx:4843



Compute relaxation (SOR, Gauss-Seidel) sweeps.

Neighborwise collective.

SEE ALSO:

petsc.MatSOR


Source code at petsc4py/PETSc/Mat.pyx:3773

  • b (Vec) --
  • x (Vec) --
  • omega (float) --
  • sortype (SORType | None) --
  • shift (float) --
  • its (int) --
  • lits (int) --

None


Append to the prefix used for searching for options in the database.

Logically collective.

SEE ALSO:

Working with PETSc options (TODO), setOptionsPrefix, petsc.MatAppendOptionsPrefix


Source code at petsc4py/PETSc/Mat.pyx:1691

prefix (str) --
None


Assemble the matrix.

Collective.

assembly (MatAssemblySpec) -- The assembly type.
None

SEE ALSO:

assemblyBegin, assemblyEnd


Source code at petsc4py/PETSc/Mat.pyx:3287


Begin an assembling stage of the matrix.

Collective.

assembly (MatAssemblySpec) -- The assembly type.
None

SEE ALSO:

assemblyEnd, assemble, petsc.MatAssemblyBegin


Source code at petsc4py/PETSc/Mat.pyx:3251


Complete an assembling stage of the matrix initiated with assemblyBegin.

Collective.

assembly (MatAssemblySpec) -- The assembly type.
None

SEE ALSO:

assemblyBegin, assemble, petsc.MatAssemblyEnd


Source code at petsc4py/PETSc/Mat.pyx:3269


Perform the matrix summation self + = ɑ·X.

Collective.

  • alpha (Scalar) -- The scalar.
  • X (Mat) -- The matrix to be added.
  • structure (Structure) -- The structure of the operation.

None

SEE ALSO:

petsc.MatAXPY


Source code at petsc4py/PETSc/Mat.pyx:4050


Perform the matrix summation self = ɑ·self + X.

Collective.

  • alpha (Scalar) -- The scalar.
  • X (Mat) -- The matrix to be added.
  • structure (Structure) -- The structure of the operation.

None

SEE ALSO:

petsc.MatAYPX


Source code at petsc4py/PETSc/Mat.pyx:4073


Mark a matrix to temporarily stay on the CPU.

Once marked, perform computations on the CPU.

flg (bool) -- Bind to the CPU if True.
None

SEE ALSO:

petsc.MatBindToCPU


Source code at petsc4py/PETSc/Mat.pyx:4422


Query if a matrix is bound to the CPU.

SEE ALSO:

petsc.MatBoundToCPU


Source code at petsc4py/PETSc/Mat.pyx:4440



Set entries smallest of tol (in absolute values) to zero.

Collective.

SEE ALSO:

petsc.MatFilter


Source code at petsc4py/PETSc/Mat.pyx:4018

tol (float) --
None


Return the conjugate matrix.

Collective.

out (Mat | None) -- Optional return matrix. If None, the operation is performed in-place. Otherwise, the operation is performed on out.
Mat

SEE ALSO:

realPart, imagPart, petsc.MatConjugate


Source code at petsc4py/PETSc/Mat.pyx:2153


Convert the matrix type.

Collective.

  • mat_type (Type | str) -- The type of the new matrix. If None uses Type.SAME.
  • out (Mat | None) -- Optional return matrix. If None, inplace conversion is performed. Otherwise, the matrix is reused.

Mat

SEE ALSO:

petsc.MatConvert


Source code at petsc4py/PETSc/Mat.pyx:2011


Return a copy of the matrix.

Collective.

  • result (Mat | None) -- Optional return matrix. If None, it is internally created.
  • structure (Structure | None) -- The copy structure. Only relevant if result is not None.

Mat

SEE ALSO:

petsc.MatCopy, petsc.MatDuplicate


Source code at petsc4py/PETSc/Mat.pyx:1966


Create the matrix.

Collective.

Once created, the user should call setType or setFromOptions before using the matrix. Alternatively, specific creation routines such as createAIJ or createBAIJ can be used.

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

SEE ALSO:

destroy, petsc.MatCreate


Source code at petsc4py/PETSc/Mat.pyx:469


Create a sparse Type.AIJ matrix, optionally preallocating.

Collective.

To preallocate the matrix the user can either pass nnz or csr describing the sparsity. If neither is set then preallocation will not occur. Consult the PETSc manual for more information.

  • size (MatSizeSpec) -- Matrix size.
  • bsize (MatBlockSizeSpec | None) -- Matrix block size. If None, a block size of 1 is set.
  • nnz (NNZSpec | None) -- Optional non-zeros preallocation pattern.
  • csr (CSRIndicesSpec | None) -- Optional compressed sparse row layout information. If provided, it takes precedence on nnz.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

setSizes, createBAIJ, petsc.MATAIJ, petsc.MATSEQAIJ, petsc.MATMPIAIJ, petsc.MatCreateAIJ, petsc.MatSeqAIJSetPreallocation, petsc.MatSeqAIJSetPreallocationCSR


Source code at petsc4py/PETSc/Mat.pyx:661


Create a sparse Type.AIJCRL matrix.

Collective.

This is similar to Type.AIJ matrices but stores some additional information that improves vectorization for the matrix-vector product.

To preallocate the matrix the user can either pass nnz or csr describing the sparsity. If neither is set then preallocation will not occur. Consult the PETSc manual for more information.

  • size (MatSizeSpec) -- Matrix size.
  • bsize (MatBlockSizeSpec | None) -- Matrix block size. If None, a block size of 1 is set.
  • nnz (NNZSpec | None) -- Optional non-zeros preallocation pattern.
  • csr (CSRIndicesSpec | None) -- Optional compressed sparse row layout information. If provided, it takes precedence on nnz.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

createAIJ, createBAIJ, petsc.MatCreateSeqAIJCRL, petsc.MatCreateMPIAIJCRL


Source code at petsc4py/PETSc/Mat.pyx:797


Create a sparse Type.AIJ matrix with data in CSR format.

Collective.

  • size (MatSizeSpec) -- Matrix size.
  • csr (CSRSpec | tuple[CSRSpec, CSRSpec]) -- Local matrix data in compressed sparse row format.
  • bsize (MatBlockSizeSpec | None) -- Matrix block size. If None, a block size of 1 is set.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

Notes

For Type.SEQAIJ matrices, the csr data is not copied. For Type.MPIAIJ matrices, the csr data is not copied only in the case it represents on-process and off-process information.

SEE ALSO:

createAIJ, petsc.MatCreateSeqAIJWithArrays, petsc.MatCreateMPIAIJWithArrays, petsc.MatCreateMPIAIJWithSplitArrays


Source code at petsc4py/PETSc/Mat.pyx:905


Create a sparse blocked Type.BAIJ matrix, optionally preallocating.

Collective.

To preallocate the matrix the user can either pass nnz or csr describing the sparsity. If neither is set then preallocation will not occur. Consult the PETSc manual for more information.

  • size (MatSizeSpec) -- Matrix size.
  • bsize (MatBlockSizeSpec) -- Matrix block size.
  • nnz (NNZSpec | None) -- Optional non-zeros preallocation pattern for block rows.
  • csr (CSRIndicesSpec | None) -- Optional block-compressed sparse row layout information. If provided, it takes precedence on nnz.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

setSizes, createAIJ, petsc.MATBAIJ, petsc.MATSEQBAIJ, petsc.MATMPIBAIJ, petsc.MatCreateBAIJ


Source code at petsc4py/PETSc/Mat.pyx:707


Create a diagonal matrix of type Type.CONSTANTDIAGONAL.

Collective.

  • size (MatSizeSpec) -- Matrix size.
  • diag (float) -- The diagonal value.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

createDiagonal


Source code at petsc4py/PETSc/Mat.pyx:1511


Create a Type.DENSE matrix.

Collective.

  • size (MatSizeSpec) -- Matrix size.
  • bsize (MatBlockSizeSpec | None) -- Matrix block size. If None, a block size of 1 is set.
  • array (Sequence[Scalar] | None) -- Optional matrix data. If None, memory is internally allocated.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

createDenseCUDA, petsc.MATDENSE, petsc.MatCreateDense


Source code at petsc4py/PETSc/Mat.pyx:997


Create a Type.DENSECUDA matrix with optional host and device data.

Collective.

  • size (MatSizeSpec) -- Matrix size.
  • bsize (MatBlockSizeSpec | None) -- Matrix block size. If None, a block size of 1 is set.
  • array (Sequence[Scalar] | None) -- Host data. Will be lazily allocated if None.
  • cudahandle (int | None) -- Address of the array on the GPU. Will be lazily allocated if None. If cudahandle is provided, array will be ignored.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

createDense, petsc.MatCreateDenseCUDA


Source code at petsc4py/PETSc/Mat.pyx:1034


Create a diagonal matrix of type Type.DIAGONAL.

Collective.

diag (Vec) -- The vector holding diagonal values.
Self

SEE ALSO:

createConstantDiagonal


Source code at petsc4py/PETSc/Mat.pyx:1545


Create a hierarchical Type.H2OPUS matrix sampling from a provided operator.
  • A (Mat) -- Matrix to be sampled.
  • coordinates (Sequence[Scalar] | None) -- Coordinates of the points.
  • dist (bool | None) -- Whether or not coordinates are distributed, defaults to False.
  • eta (float | None) -- Admissibility condition tolerance, defaults to DECIDE.
  • leafsize (int | None) -- Leaf size in cluster tree, defaults to DECIDE.
  • maxrank (int | None) -- Maximum rank permitted, defaults to DECIDE.
  • bs (int | None) -- Maximum number of samples to take concurrently, defaults to DECIDE.
  • rtol (float | None) -- Relative tolerance for construction, defaults to DECIDE.

Self

Notes

See petsc.MatCreateH2OpusFromMat for the appropriate database options.

SEE ALSO:

Working with PETSc options (TODO), petsc.MatCreateH2OpusFromMat


Source code at petsc4py/PETSc/Mat.pyx:1380


Create a Type.HERMITIANTRANSPOSE matrix that behaves like (A*)ᵀ.

Collective.

mat (Mat) -- Matrix A to represent the hermitian transpose of.
Self

Notes

The Hermitian transpose is never actually formed.

SEE ALSO:

createNormal, createNormalHermitian, petsc.MATHERMITIANTRANSPOSEVIRTUAL, petsc.MatCreateHermitianTranspose


Source code at petsc4py/PETSc/Mat.pyx:1215


Create a Type.IS matrix representing globally unassembled operators.

Collective.

  • size (MatSizeSpec) -- Matrix size.
  • lgmapr (LGMap | None) -- Optional local-to-global mapping for the rows. If None, the local row space matches the global row space.
  • lgmapc (LGMap | None) -- Optional local-to-global mapping for the columns. If None, the local column space matches the global column space.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.MATIS


Source code at petsc4py/PETSc/Mat.pyx:1460


Create a low-rank correction Type.LRC matrix representing A + UCVᵀ.

Collective.

  • A (Mat) -- Sparse matrix, can be None.
  • U (Mat) -- Dense rectangular matrices.
  • V (Mat) -- Dense rectangular matrices.
  • c (Vec) -- Vector containing the diagonal of C, can be None.

Self

Notes

The matrix A + UCVᵀ is never actually formed.

C is a diagonal matrix (represented as a vector) of order k, where k is the number of columns of both U and V.

If A is None then the new object behaves like a low-rank matrix UCVᵀ.

Use the same matrix for V and U (or V=None) for a symmetric low-rank correction, A + UCUᵀ.

If c is None then the low-rank correction is just U*Vᵀ. If a sequential c vector is used for a parallel matrix, PETSc assumes that the values of the vector are consistently set across processors.

SEE ALSO:

petsc.MATLRC, petsc.MatCreateLRC


Source code at petsc4py/PETSc/Mat.pyx:1240


Create a Type.NEST matrix containing multiple submatrices.

Collective.

  • mats (Sequence[Sequence[Mat]]) -- Iterable of matrix block rows with size len(isrows). Each matrix block row must be of size len(iscols). Empty submatrices can be set with None.
  • isrows (Sequence[IS] | None) -- Index set for each nested row block, defaults to contiguous ordering.
  • iscols (Sequence[IS] | None) -- Index set for each nested column block, defaults to contiguous ordering.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.MatCreateNest, petsc.MATNEST


Source code at petsc4py/PETSc/Mat.pyx:1312


Create a Type.NORMAL matrix representing AᵀA.

Collective.

mat (Mat) -- The (possibly rectangular) matrix A.
Self

Notes

The product AᵀA is never actually formed. Instead A and Aᵀ are used during mult and various other matrix operations.

SEE ALSO:

petsc.MATNORMAL, petsc.MatCreateNormal


Source code at petsc4py/PETSc/Mat.pyx:1140


Create a Type.NORMALHERMITIAN matrix representing (A*)ᵀA.

Collective.

mat (Mat) -- The (possibly rectangular) matrix A.
Self

Notes

The product (A*)ᵀA is never actually formed.

SEE ALSO:

createHermitianTranspose, petsc.MATNORMAL, petsc.MATNORMALHERMITIAN, petsc.MatCreateNormalHermitian


Source code at petsc4py/PETSc/Mat.pyx:1190


Create a Type.PYTHON matrix.

Collective.

  • size (MatSizeSpec) -- Matrix size.
  • context (Any) -- An instance of the Python class implementing the required methods.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

PETSc Python matrix type, setType, setPythonContext, Type.PYTHON


Source code at petsc4py/PETSc/Mat.pyx:1569


Create a sparse Type.SBAIJ matrix in symmetric block format.

Collective.

To preallocate the matrix the user can either pass nnz or csr describing the sparsity. If neither is set then preallocation will not occur. Consult the PETSc manual for more information.

  • size (MatSizeSpec) -- Matrix size.
  • bsize (int) -- Matrix block size.
  • nnz (NNZSpec | None) -- Optional upper-triangular (including diagonal) non-zeros preallocation pattern for block rows.
  • csr (CSRIndicesSpec | None) -- Optional block-compressed sparse row layout information. If provided, it takes precedence on nnz.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

createAIJ, createBAIJ, petsc.MatCreateSBAIJ


Source code at petsc4py/PETSc/Mat.pyx:752


Create a Type.SCATTER matrix from a vector scatter.

Collective.

  • scatter (Scatter) -- Vector scatter.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.MATSCATTER, petsc.MatCreateScatter


Source code at petsc4py/PETSc/Mat.pyx:1116


Return several sequential submatrices.

Collective.

  • isrows (IS | Sequence[IS]) -- Row index sets.
  • iscols (IS | Sequence[IS]) -- Column index sets. If None, iscols = isrows.
  • submats (Mat | Sequence[Mat]) -- Optional resultant matrices. When None, new matrices are created, and MAT_INITIAL_MATRIX is used. When not None, the matrices are reused with MAT_REUSE_MATRIX.

Sequence[Mat]

SEE ALSO:

petsc.MatCreateSubMatrices


Source code at petsc4py/PETSc/Mat.pyx:3861


Return a submatrix.

Collective.

  • isrow (IS) -- Row index set.
  • iscol (IS | None) -- Column index set. If None, iscol = isrow.
  • submat (Mat | None) -- Optional resultant matrix. When None, a new matrix is created, and MAT_INITIAL_MATRIX is used. When not None, the matrix is reused with MAT_REUSE_MATRIX.

Mat

SEE ALSO:

petsc.MatCreateSubMatrix


Source code at petsc4py/PETSc/Mat.pyx:3831


Create a Type.SUBMATRIX matrix that acts as a submatrix.

Collective.

  • A (Mat) -- Matrix to extract submatrix from.
  • isrow (IS) -- Rows present in the submatrix.
  • iscol (IS | None) -- Columns present in the submatrix, defaults to isrow.

Self

SEE ALSO:

petsc.MatCreateSubMatrixVirtual


Source code at petsc4py/PETSc/Mat.pyx:1287


Create a Type.TRANSPOSE matrix that behaves like Aᵀ.

Collective.

mat (Mat) -- Matrix A to represent the transpose of.
Self

Notes

The transpose is never actually formed. Instead multTranspose is called whenever the matrix-vector product is computed.

SEE ALSO:

createNormal, petsc.MatCreateTranspose


Source code at petsc4py/PETSc/Mat.pyx:1165


Return a left vector, a vector that the matrix vector product can be stored in.

Collective.

SEE ALSO:

createVecs, createVecRight, petsc.MatCreateVecs


Source code at petsc4py/PETSc/Mat.pyx:3388



Return a right vector, a vector that the matrix can be multiplied against.

Collective.

SEE ALSO:

createVecs, createVecLeft, petsc.MatCreateVecs


Source code at petsc4py/PETSc/Mat.pyx:3374



Return vectors that can be used in matrix vector products.

Collective.

side (Literal['r', 'R', 'right', 'Right', 'RIGHT', 'l', 'L', 'left', 'Left', 'LEFT'] | None) -- If None returns a 2-tuple of vectors (right, left). Otherwise it just return a left or right vector.
Vec | tuple[Vec, Vec]

Notes

right vectors are vectors in the column space of the matrix. left vectors are vectors in the row space of the matrix.

SEE ALSO:

createVecLeft, createVecRight, petsc.MatCreateVecs


Source code at petsc4py/PETSc/Mat.pyx:3334


Destroy the matrix.

Collective.

SEE ALSO:

create, petsc.MatDestroy


Source code at petsc4py/PETSc/Mat.pyx:456



Perform left and/or right diagonal scaling of the matrix.

Collective.

  • L (Vec | None) -- Optional left scaling vector.
  • R (Vec | None) -- Optional right scaling vector.

None

SEE ALSO:

petsc.MatDiagonalScale


Source code at petsc4py/PETSc/Mat.pyx:3525


Return a clone of the matrix.

Collective.

copy (bool) -- If True, it also copies the values.
Mat

SEE ALSO:

petsc.MatDuplicate


Source code at petsc4py/PETSc/Mat.pyx:1944


Return the result of matrix comparison.

Collective.

SEE ALSO:

petsc.MatEqual


Source code at petsc4py/PETSc/Mat.pyx:2197

mat (Mat) --
bool


Perform an in-place Cholesky factorization.

Collective.

  • isperm (IS) -- The row and column permutations.
  • options (dict[str, Any] | None) -- An optional dictionary of options for the factorization. These include fill, the expected fill as a ratio of the original fill.

None

SEE ALSO:

factorLU, petsc.MatCholeskyFactor


Source code at petsc4py/PETSc/Mat.pyx:4585


Perform an in-place an incomplete Cholesky factorization.

Collective.

  • isperm (IS) -- The row and column permutations
  • options (dict[str, Any] | None) -- An optional dictionary of options for the factorization. These include fill, the expected fill as a ratio of the original fill.

None

SEE ALSO:

factorILU, petsc.MatICCFactor


Source code at petsc4py/PETSc/Mat.pyx:4619


Perform an in-place ILU factorization.

Collective.

  • isrow (IS) -- The row permutation.
  • iscol (IS) -- The column permutation.
  • options (dict[str, Any] | None) -- An optional dictionary of options for the factorization. These include levels, the number of levels of fill, fill, the expected fill as a ratio of the original fill, and dtcol, the pivot tolerance where 0 indicates no pivot and 1 indicates full column pivoting.

None

SEE ALSO:

petsc.MatILUFactor


Source code at petsc4py/PETSc/Mat.pyx:4550


Perform an in-place LU factorization.

Collective.

  • isrow (IS) -- The row permutation.
  • iscol (IS) -- The column permutation.
  • options (dict[str, Any] | None) -- An optional dictionary of options for the factorization. These include fill, the expected fill as a ratio of the original fill and dtcol, the pivot tolerance where 0 indicates no pivot and 1 indicates full column pivoting.

None

SEE ALSO:

petsc.MatLUFactor


Source code at petsc4py/PETSc/Mat.pyx:4511


Not implemented.

Source code at petsc4py/PETSc/Mat.pyx:4615

mat (Mat) --
None


Not implemented.

Source code at petsc4py/PETSc/Mat.pyx:4546

mat (Mat) --
None


Not implemented.

Source code at petsc4py/PETSc/Mat.pyx:4611

isperm (IS) --
None


Not implemented.

Source code at petsc4py/PETSc/Mat.pyx:4645

isperm (IS) --
None


Not implemented.

Source code at petsc4py/PETSc/Mat.pyx:4581

  • isrow (IS) --
  • iscol (IS) --

None


Not implemented.

Source code at petsc4py/PETSc/Mat.pyx:4542

  • mat (Mat) --
  • isrow (IS) --
  • iscol (IS) --

None


Return the index set of empty rows.

Collective.

SEE ALSO:

petsc.MatFindZeroRows


Source code at petsc4py/PETSc/Mat.pyx:3320



Compress out zero local rows from the local matrices.

Collective.

fix (bool) -- When True, new local matrices and local to global maps are generated during the final assembly process.
None

SEE ALSO:

petsc.MatISFixLocalEmpty


Source code at petsc4py/PETSc/Mat.pyx:4688


Return the matrix block size.

Not collective.

SEE ALSO:

getBlockSize, petsc.MatGetBlockSize


Source code at petsc4py/PETSc/Mat.pyx:1814



Return the row and column block sizes.

Not collective.

SEE ALSO:

getBlockSize, petsc.MatGetBlockSizes


Source code at petsc4py/PETSc/Mat.pyx:1828

tuple[int, int]


Return the CSC representation of the local sparsity pattern.

Collective.

  • symmetric (bool) -- If True, return the symmetrized graph.
  • compressed (bool) -- If True, return the compressed graph.

tuple[ArrayInt, ArrayInt]

SEE ALSO:

petsc.MatGetRowIJ


Source code at petsc4py/PETSc/Mat.pyx:2448


Return the columnᵗʰ column vector of the matrix.

Collective.

  • column (int) -- Column index.
  • result (Vec | None) -- Optional vector to store the result.

Vec

SEE ALSO:

petsc.MatGetColumnVector


Source code at petsc4py/PETSc/Mat.pyx:3408


Return the DM defining the data layout of the matrix.

Not collective.

SEE ALSO:

petsc.MatGetDM


Source code at petsc4py/PETSc/Mat.pyx:5428



Return the array where the data is stored.

Not collective.

readonly (bool) -- Enable to obtain a read only array.
ArrayScalar

SEE ALSO:

petsc.MatDenseGetArrayRead, petsc.MatDenseGetArray


Source code at petsc4py/PETSc/Mat.pyx:5233


Return the iᵗʰ column vector of the dense matrix.

Collective.

  • i (int) -- The column index to access.
  • mode (AccessModeSpec) -- The access type of the returned array

Vec

SEE ALSO:

restoreDenseColumnVec, petsc.MatDenseGetColumnVec, petsc.MatDenseGetColumnVecRead, petsc.MatDenseGetColumnVecWrite


Source code at petsc4py/PETSc/Mat.pyx:5286


Return the leading dimension of the array used by the dense matrix.

Not collective.

SEE ALSO:

petsc.MatDenseGetLDA


Source code at petsc4py/PETSc/Mat.pyx:5219



Return the local part of the dense matrix.

Not collective.

SEE ALSO:

petsc.MatDenseGetLocalMatrix


Source code at petsc4py/PETSc/Mat.pyx:5271



Return the diagonal of the matrix.

Collective.

result (Vec | None) -- Optional vector to store the result.
Vec

SEE ALSO:

setDiagonal, petsc.MatGetDiagonal


Source code at petsc4py/PETSc/Mat.pyx:3461


Return the part of the matrix associated with the on-process coupling.

Not collective.

SEE ALSO:

petsc.MatGetDiagonalBlock


Source code at petsc4py/PETSc/Mat.pyx:3803



Return the local matrix stored inside a Type.IS matrix.

SEE ALSO:

petsc.MatISGetLocalMat


Source code at petsc4py/PETSc/Mat.pyx:4707



Return the inertia from a factored matrix.

Collective.

The matrix must have been factored by calling factorCholesky.

  • n (int) -- The number of negative eigenvalues.
  • z (int) -- The number of zero eigenvalues.
  • p (int) -- The number of positive eigenvalues.

tuple[int, int, int]

SEE ALSO:

petsc.MatGetInertia


Source code at petsc4py/PETSc/Mat.pyx:4649


Return summary information.

Collective.

info (InfoType) -- If None, it uses InfoType.GLOBAL_SUM.
dict[str, float]

SEE ALSO:

petsc.MatInfo, petsc.MatGetInfo


Source code at petsc4py/PETSc/Mat.pyx:1924


Return the local-to-global mappings.

Not collective.

SEE ALSO:

setLGMap, petsc.MatGetLocalToGlobalMapping


Source code at petsc4py/PETSc/Mat.pyx:2721

tuple[LGMap, LGMap]


Return the constituents of a Type.LRC matrix.

Not collective.

  • A (Mat) -- The A matrix.
  • U (Mat) -- The first dense rectangular matrix.
  • c (Vec) -- The sequential vector containing the diagonal of C.
  • V (Mat) -- The second dense rectangular matrix.

tuple[Mat, Mat, Vec, Mat]

SEE ALSO:

petsc.MatLRCGetMats


Source code at petsc4py/PETSc/Mat.pyx:4782


Return the local number of rows and columns.

Not collective.

SEE ALSO:

getSize, petsc.MatGetLocalSize


Source code at petsc4py/PETSc/Mat.pyx:1784

tuple[int, int]


Return a reference to a submatrix specified in local numbering.

Collective.

  • isrow (IS) -- Row index set.
  • iscol (IS) -- Column index set.
  • submat (Mat | None) -- Optional resultant matrix. When None, a new matrix is created. When not None, the matrix is first destroyed and then recreated.

Mat

SEE ALSO:

restoreLocalSubMatrix, petsc.MatGetLocalSubMatrix


Source code at petsc4py/PETSc/Mat.pyx:3920


Return the MUMPS parameter, CNTL[icntl].

Logically collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.MatMumpsGetCntl


Source code at petsc4py/PETSc/Mat.pyx:4954

icntl (int) --
float


Return the MUMPS parameter, ICNTL[icntl].

Logically collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.MatMumpsGetIcntl


Source code at petsc4py/PETSc/Mat.pyx:4918

icntl (int) --
int


Return the MUMPS parameter, INFO[icntl].

Logically collective.

icntl (int) -- The index of the MUMPS INFO array.
int

SEE ALSO:

petsc.MatMumpsGetInfo


Source code at petsc4py/PETSc/Mat.pyx:4969


Return the MUMPS parameter, INFOG[icntl].

Logically collective.

icntl (int) -- The index of the MUMPS INFOG array.
int

SEE ALSO:

petsc.MatMumpsGetInfog


Source code at petsc4py/PETSc/Mat.pyx:4989


Return the MUMPS parameter, RINFO[icntl].

Logically collective.

icntl (int) -- The index of the MUMPS RINFO array.
float

SEE ALSO:

petsc.MatMumpsGetRinfo


Source code at petsc4py/PETSc/Mat.pyx:5009


Return the MUMPS parameter, RINFOG[icntl].

Logically collective.

icntl (int) -- The index of the MUMPS RINFOG array.
float

SEE ALSO:

petsc.MatMumpsGetRinfog


Source code at petsc4py/PETSc/Mat.pyx:5029


Return the near-nullspace.

Not collective.

SEE ALSO:

getNullSpace, setNearNullSpace, petsc.MatSetNearNullSpace


Source code at petsc4py/PETSc/Mat.pyx:3634

NullSpace


Return the index sets representing the row and column spaces.

Not collective.

SEE ALSO:

petsc.MatNestGetISs


Source code at petsc4py/PETSc/Mat.pyx:5360

tuple[list[IS], list[IS]]


Return the local index sets representing the row and column spaces.

Not collective.

SEE ALSO:

petsc.MatNestGetLocalISs


Source code at petsc4py/PETSc/Mat.pyx:5381

tuple[list[IS], list[IS]]


Return the number of rows and columns of the matrix.

Not collective.

SEE ALSO:

petsc.MatNestGetSize


Source code at petsc4py/PETSc/Mat.pyx:5346

tuple[int, int]


Return a single submatrix.

Not collective.

  • i (int) -- The first index of the matrix within the nesting.
  • j (int) -- The second index of the matrix within the nesting.

Mat

SEE ALSO:

petsc.MatNestGetSubMat


Source code at petsc4py/PETSc/Mat.pyx:5402


Return the nullspace.

Not collective.

SEE ALSO:

setNullSpace, petsc.MatGetNullSpace


Source code at petsc4py/PETSc/Mat.pyx:3580

NullSpace


Return the option value.

Not collective.

SEE ALSO:

setOption, petsc.MatGetOption


Source code at petsc4py/PETSc/Mat.pyx:1742

option (Option) --
bool


Return the prefix used for searching for options in the database.

Not collective.

SEE ALSO:

Working with PETSc options (TODO), setOptionsPrefix, petsc.MatGetOptionsPrefix


Source code at petsc4py/PETSc/Mat.pyx:1677



Return a reordering for a matrix to improve a LU factorization.

Collective.

ord_type (OrderingType) -- The type of reordering.
  • rp (IS) -- The row permutation indices.
  • cp (IS) -- The column permutation indices.

tuple[IS, IS]

SEE ALSO:

petsc.MatGetOrdering


Source code at petsc4py/PETSc/Mat.pyx:4454


Return the ranges of rows and columns owned by each process as index sets.

Not collective.

SEE ALSO:

getOwnershipRanges, getOwnershipRangesColumn, petsc.MatGetOwnershipIS


Source code at petsc4py/PETSc/Mat.pyx:1909

tuple[IS, IS]


Return the locally owned range of rows.

Not collective.

SEE ALSO:

getOwnershipRanges, getOwnershipRangeColumn, petsc.MatGetOwnershipRange


Source code at petsc4py/PETSc/Mat.pyx:1842

tuple[int, int]


Return the locally owned range of columns.

Not collective.

SEE ALSO:

getOwnershipRangesColumn, getOwnershipRange, petsc.MatGetOwnershipRangeColumn


Source code at petsc4py/PETSc/Mat.pyx:1876

tuple[int, int]


Return the range of rows owned by each process.

Not collective.

The returned array is the result of exclusive scan of the local sizes.

SEE ALSO:

getOwnershipRange, petsc.MatGetOwnershipRanges


Source code at petsc4py/PETSc/Mat.pyx:1856

ArrayInt


Return the range of columns owned by each process.

Not collective.

SEE ALSO:

getOwnershipRangeColumn, petsc.MatGetOwnershipRangesColumn


Source code at petsc4py/PETSc/Mat.pyx:1891

ArrayInt


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

Not collective.

SEE ALSO:

PETSc Python matrix type, setPythonContext


Source code at petsc4py/PETSc/Mat.pyx:1616



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

Not collective.

SEE ALSO:

PETSc Python matrix type, setPythonContext, setPythonType, petsc.MatPythonGetType


Source code at petsc4py/PETSc/Mat.pyx:1646



Return redundant matrices on subcommunicators.
  • nsubcomm (int) -- The number of subcommunicators.
  • subcomm (Comm | None) -- Communicator split or None for the null communicator.
  • out (Mat | None) -- Optional resultant matrix. When None, a new matrix is created, and MAT_INITIAL_MATRIX is used. When not None, the matrix is reused with MAT_REUSE_MATRIX.

Mat

SEE ALSO:

petsc.MatCreateRedundantMatrix


Source code at petsc4py/PETSc/Mat.pyx:3433


Return the column indices and values for the requested row.

Not collective.

SEE ALSO:

petsc.MatGetRow


Source code at petsc4py/PETSc/Mat.pyx:2397

row (int) --
tuple[ArrayInt, ArrayScalar]


Return the CSR representation of the local sparsity pattern.

Collective.

  • symmetric (bool) -- If True, return the symmetrized graph.
  • compressed (bool) -- If True, return the compressed graph.

tuple[ArrayInt, ArrayInt]

SEE ALSO:

petsc.MatGetRowIJ


Source code at petsc4py/PETSc/Mat.pyx:2417


Return the row-sum vector.

Collective.

result (Vec | None) -- Optional vector to store the result.
Vec

SEE ALSO:

petsc.MatGetRowSum


Source code at petsc4py/PETSc/Mat.pyx:3483


Return the global number of rows and columns.

Not collective.

SEE ALSO:

getLocalSize, getSizes, petsc.MatGetSize


Source code at petsc4py/PETSc/Mat.pyx:1770

tuple[int, int]


Return the tuple of matrix layouts.

Not collective.

SEE ALSO:

getLocalSize, getSize


Source code at petsc4py/PETSc/Mat.pyx:1798

tuple[LayoutSizeSpec, LayoutSizeSpec]


Return the transpose nullspace.

Not collective.

SEE ALSO:

getNullSpace, setTransposeNullSpace, petsc.MatGetTransposeNullSpace


Source code at petsc4py/PETSc/Mat.pyx:3607

NullSpace


Return the type of the matrix.

Not collective.

SEE ALSO:

setType, Type, petsc.MatGetType


Source code at petsc4py/PETSc/Mat.pyx:1756



Return the value in the (row,col) position.

Not collective.

SEE ALSO:

petsc.MatGetValues


Source code at petsc4py/PETSc/Mat.pyx:2322

Scalar


Return the values in the zip(rows,cols) positions.

Not collective.

  • rows (Sequence[int]) -- Row indices.
  • cols (Sequence[int]) -- Column indices.
  • values (ArrayScalar) -- Optional array where to store the values.

ArrayScalar

SEE ALSO:

petsc.MatGetValues


Source code at petsc4py/PETSc/Mat.pyx:2338


Return the CSR representation of the local part of the matrix.

Not collective.

SEE ALSO:

petsc.MatGetRow


Source code at petsc4py/PETSc/Mat.pyx:2359

tuple[ArrayInt, ArrayInt, ArrayScalar]


Return the vector type used by the matrix.

Not collective.

SEE ALSO:

setVecType, petsc.MatGetVecType


Source code at petsc4py/PETSc/Mat.pyx:626



Return the transposed Hermitian matrix.

Collective.

out (Mat | None) -- Optional return matrix. If None, inplace transposition is performed. Otherwise, the matrix is reused.
Mat

SEE ALSO:

petsc.MatHermitianTranspose


Source code at petsc4py/PETSc/Mat.pyx:2080


Return the imaginary part of the matrix.

Collective.

out (Mat | None) -- Optional return matrix. If None, the operation is performed in-place. Otherwise, the operation is performed on out.
Mat

SEE ALSO:

realPart, conjugate, petsc.MatImaginaryPart


Source code at petsc4py/PETSc/Mat.pyx:2130


Increase the overlap of a index set.

Collective.

SEE ALSO:

petsc.MatIncreaseOverlap


Source code at petsc4py/PETSc/Mat.pyx:3818

  • iset (IS) --
  • overlap (int) --

None


Return the inverse of the block-diagonal entries.

Collective.

SEE ALSO:

petsc.MatInvertBlockDiagonal


Source code at petsc4py/PETSc/Mat.pyx:3547

ArrayScalar


The boolean flag indicating if the matrix is assembled.

Not collective.

SEE ALSO:

assemble, petsc.MatAssembled


Source code at petsc4py/PETSc/Mat.pyx:3306



Return the boolean indicating if the matrix is Hermitian.

Collective.

tol (float) -- Tolerance for comparison.
bool

SEE ALSO:

petsc.MatIsHermitian


Source code at petsc4py/PETSc/Mat.pyx:2269


Return the 2-tuple indicating if the matrix is known to be Hermitian.

Not collective.

SEE ALSO:

petsc.MatIsHermitianKnown


Source code at petsc4py/PETSc/Mat.pyx:2289

tuple[bool, bool]


Return the boolean indicating if the matrix is structurally symmetric.

Source code at petsc4py/PETSc/Mat.pyx:2304



Return the boolean indicating if the matrix is symmetric.

Collective.

tol (float) -- Tolerance for comparison.
bool

SEE ALSO:

petsc.MatIsSymmetric


Source code at petsc4py/PETSc/Mat.pyx:2234


Return the 2-tuple indicating if the matrix is known to be symmetric.

Not collective.

SEE ALSO:

petsc.MatIsSymmetricKnown


Source code at petsc4py/PETSc/Mat.pyx:2254

tuple[bool, bool]


Return the result of matrix comparison with transposition.

Collective.

  • mat (Mat | None) -- Matrix to compare against. Uses self if None.
  • tol (float) -- Tolerance for comparison.

bool

SEE ALSO:

petsc.MatIsTranspose


Source code at petsc4py/PETSc/Mat.pyx:2211


Compute C, the Kronecker product of A and B.
  • mat (Mat) -- The right hand matrix B.
  • result (Mat | None) -- The optional resultant matrix. When None, a new matrix is created, and MAT_INITIAL_MATRIX is used. When it is not None, the matrix is reused with MAT_REUSE_MATRIX.

result -- The resultant matrix C, the Kronecker product of A and B.
Mat

SEE ALSO:

petsc.MatSeqAIJKron, petsc.MatReuse


Source code at petsc4py/PETSc/Mat.pyx:4388


Load a matrix.

Collective.

SEE ALSO:

petsc.MatLoad


Source code at petsc4py/PETSc/Mat.pyx:1993

viewer (Viewer) --
Self


Perform matrix-matrix-matrix multiplication D=ABC.

Neighborwise collective.

  • B (Mat) -- The middle matrix B.
  • C (Mat) -- The right hand matrix C.
  • result (Mat | None) -- The optional resultant matrix D. When None, a new matrix is created, and MAT_INITIAL_MATRIX is used. When D is not None, the matrix is reused with MAT_REUSE_MATRIX.
  • fill (float | None) -- Expected fill as ratio of nnz(C)/nnz(A), use None if you do not have a good estimate. If the result is a dense matrix this is irrelevant.

result -- The resultant product matrix D.
Mat

SEE ALSO:

petsc.MatMatMatMult, petsc.MatReuse


Source code at petsc4py/PETSc/Mat.pyx:4342


Perform matrix-matrix multiplication C=AB.

Neighborwise collective.

  • mat (Mat) -- The right hand matrix B.
  • result (Mat | None) -- The optional resultant matrix C. When None, a new matrix is created, and MAT_INITIAL_MATRIX is used. When C is not None, the matrix is reused with MAT_REUSE_MATRIX.
  • fill (float | None) -- Expected fill as ratio of nnz(C)/(nnz(A) + nnz(B)), use None if you do not have a good estimate. If the result is a dense matrix this is irrelevant.

result -- The resultant product matrix C.
Mat

Notes

To determine the correct fill value, run with -info and search for the string "Fill ratio" to see the value actually needed.

SEE ALSO:

petsc.MatMatMult, petsc.MatReuse


Source code at petsc4py/PETSc/Mat.pyx:4098


Solve AX=B, given a factored matrix A.

Neighborwise collective.

  • B (Mat) -- The right-hand side matrix of type Type.DENSE. Can be of type Type.AIJ if using MUMPS.
  • X (Mat) -- The output solution matrix, must be different than B.

None

SEE ALSO:

KSP.create, petsc.MatMatSolve


Source code at petsc4py/PETSc/Mat.pyx:5179


Perform matrix-matrix multiplication C=ABᵀ.

Neighborwise collective.

  • mat (Mat) -- The right hand matrix B.
  • result (Mat | None) -- The optional resultant matrix C. When None, a new matrix is created, and MAT_INITIAL_MATRIX is used. When C is not None, the matrix is reused with MAT_REUSE_MATRIX.
  • fill (float | None) -- Expected fill as ratio of nnz(C)/(nnz(A) + nnz(B)), use None if you do not have a good estimate. If the result is a dense matrix this is irrelevant.

result -- The resultant product matrix C.
Mat

Notes

To determine the correct fill value, run with -info and search for the string "Fill ratio" to see the value actually needed.

SEE ALSO:

petsc.MatMatTransposeMult, petsc.MatReuse


Source code at petsc4py/PETSc/Mat.pyx:4146


Perform the matrix vector product y = A @ x.

Collective.

  • x (Vec) -- The input vector.
  • y (Vec) -- The output vector.

None

SEE ALSO:

petsc.MatMult


Source code at petsc4py/PETSc/Mat.pyx:3651


Perform the matrix vector product with addition y = A @ x + v.

Collective.

  • x (Vec) -- The input vector for the matrix-vector product.
  • v (Vec) -- The input vector to be added to.
  • y (Vec) -- The output vector.

None

SEE ALSO:

petsc.MatMultAdd


Source code at petsc4py/PETSc/Mat.pyx:3670


Perform the Hermitian matrix vector product y = A^H @ x.

Collective.

  • x (Vec) -- The input vector for the Hermitian matrix-vector product.
  • y (Vec) -- The output vector.

None

SEE ALSO:

petsc.MatMultHermitianTranspose


Source code at petsc4py/PETSc/Mat.pyx:3731


Perform the Hermitian matrix vector product with addition y = A^H @ x + v.

Collective.

  • x (Vec) -- The input vector for the Hermitian matrix-vector product.
  • v (Vec) -- The input vector to be added to.
  • y (Vec) -- The output vector.

None

SEE ALSO:

petsc.MatMultHermitianTransposeAdd


Source code at petsc4py/PETSc/Mat.pyx:3750


Perform the transposed matrix vector product y = A^T @ x.

Collective.

  • x (Vec) -- The input vector.
  • y (Vec) -- The output vector.

None

SEE ALSO:

petsc.MatMultTranspose


Source code at petsc4py/PETSc/Mat.pyx:3691


Perform the transposed matrix vector product with addition y = A^T @ x + v.

Collective.

  • x (Vec) -- The input vector for the transposed matrix-vector product.
  • v (Vec) -- The input vector to be added to.
  • y (Vec) -- The output vector.

None

SEE ALSO:

petsc.MatMultTransposeAdd


Source code at petsc4py/PETSc/Mat.pyx:3710


Compute the requested matrix norm.

Collective.

A 2-tuple is returned if NormType.NORM_1_AND_2 is specified.

SEE ALSO:

petsc.MatNorm, petsc.NormType


Source code at petsc4py/PETSc/Mat.pyx:3969

norm_type (NormTypeSpec) --
float | tuple[float, float]


Return the permuted matrix.

Collective.

  • row (IS) -- Row permutation.
  • col (IS) -- Column permutation.

Mat

SEE ALSO:

petsc.MatPermute


Source code at petsc4py/PETSc/Mat.pyx:2176


Creates the matrix product C = PᵀAP.

Neighborwise collective.

  • P (Mat) -- The matrix P.
  • result (Mat | None) -- The optional resultant matrix C. When None, a new matrix is created, and MAT_INITIAL_MATRIX is used. When C is not None, the matrix is reused with MAT_REUSE_MATRIX.
  • fill (float | None) -- Expected fill as ratio of nnz(C)/(nnz(A) + nnz(P)), use None if you do not have a good estimate. If the result is a dense matrix this is irrelevant.

result -- The resultant product matrix C.
Mat

Notes

To determine the correct fill value, run with -info and search for the string "Fill ratio" to see the value actually needed.

An alternative approach to this function is to use petsc.MatProductCreate and set the desired options before the computation is done.

SEE ALSO:

petsc.MatPtAP, petsc.MatReuse


Source code at petsc4py/PETSc/Mat.pyx:4242


Create the matrix product C = RARᵀ.

Neighborwise collective.

  • R (Mat) -- The projection matrix.
  • result (Mat | None) -- The optional resultant matrix C. When None, a new matrix is created, and MAT_INITIAL_MATRIX is used. When C is not None, the matrix is reused with MAT_REUSE_MATRIX.
  • fill (float | None) -- Expected fill as ratio of nnz(C)/nnz(A), use None if you do not have a good estimate. If the result is a dense matrix this is irrelevant.

result -- The resultant product matrix C.
Mat

Notes

To determine the correct fill value, run with -info and search for the string "Fill ratio" to see the value actually needed.

SEE ALSO:

petsc.MatRARt, petsc.MatReuse


Source code at petsc4py/PETSc/Mat.pyx:4294


Return the real part of the matrix.

Collective.

out (Mat | None) -- Optional return matrix. If None, the operation is performed in-place. Otherwise, the operation is performed on out.
Mat

SEE ALSO:

imagPart, conjugate, petsc.MatRealPart


Source code at petsc4py/PETSc/Mat.pyx:2107


Change a matrix ordering to remove zeros from the diagonal.

Collective.

  • isrow (IS) -- The row reordering.
  • iscol (IS) -- The column reordering.
  • atol (float) -- The absolute tolerance. Values along the diagonal whose absolute value are smaller than this tolerance are moved off the diagonal.

None

SEE ALSO:

getOrdering, petsc.MatReorderForNonzeroDiagonal


Source code at petsc4py/PETSc/Mat.pyx:4482


Restore the iᵗʰ column vector of the dense matrix.

Collective.

  • i (int) -- The column index to be restored.
  • mode (AccessModeSpec) -- The access type of the restored array

None

SEE ALSO:

getDenseColumnVec, petsc.MatDenseRestoreColumnVec, petsc.MatDenseRestoreColumnVecRead, petsc.MatDenseRestoreColumnVecWrite


Source code at petsc4py/PETSc/Mat.pyx:5318


Restore the local matrix obtained with getISLocalMat.
local (Mat) -- The local matrix.
None

SEE ALSO:

petsc.MatISRestoreLocalMat


Source code at petsc4py/PETSc/Mat.pyx:4720


Restore a reference to a submatrix obtained with getLocalSubMatrix.

Collective.

  • isrow (IS) -- Row index set.
  • iscol (IS) -- Column index set.
  • submat (Mat) -- The submatrix.


SEE ALSO:

getLocalSubMatrix, petsc.MatRestoreLocalSubMatrix


Source code at petsc4py/PETSc/Mat.pyx:3946


Retrieve a copy of the matrix values previously stored with storeValues.

Collective.

SEE ALSO:

storeValues, petsc.MatRetrieveValues


Source code at petsc4py/PETSc/Mat.pyx:3239



Scale the matrix.

Collective.

SEE ALSO:

petsc.MatScale


Source code at petsc4py/PETSc/Mat.pyx:3992

alpha (Scalar) --
None


Set the matrix block size (same for rows and columns).

Logically collective.

bsize (int) -- Block size.
None

SEE ALSO:

setBlockSizes, setSizes, petsc.MatSetBlockSize


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


Set the row and column block sizes.

Logically collective.

  • row_bsize (int) -- Row block size.
  • col_bsize (int) -- Column block size.

None

SEE ALSO:

setBlockSize, setSizes, petsc.MatSetBlockSizes


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


Set the DM defining the data layout of the matrix.

Not collective.

dm (DM) -- The DM.
None

SEE ALSO:

petsc.MatSetDM


Source code at petsc4py/PETSc/Mat.pyx:5445


Set the leading dimension of the array used by the dense matrix.

Not collective.

lda (int) -- The leading dimension.
None

SEE ALSO:

petsc.MatDenseSetLDA


Source code at petsc4py/PETSc/Mat.pyx:5201


Set the diagonal values of the matrix.

Collective.

  • diag (Vec) -- Vector storing diagonal values.
  • addv (InsertModeSpec) -- Insertion mode.

None

SEE ALSO:

getDiagonal, petsc.MatDiagonalSet


Source code at petsc4py/PETSc/Mat.pyx:3505


Configure the matrix from the options database.

Collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.MatSetFromOptions


Source code at petsc4py/PETSc/Mat.pyx:1705



Set the local matrix stored inside a Type.IS.
local (Mat) -- The local matrix.
None

SEE ALSO:

petsc.MatISSetLocalMat


Source code at petsc4py/PETSc/Mat.pyx:4735


Preallocate memory for a Type.IS parallel matrix.
  • nnz (Sequence[int]) -- The sequence whose length corresponds to the number of local rows and values which represent the number of nonzeros in the various rows of the diagonal of the local submatrix.
  • onnz (Sequence[int]) -- The sequence whose length corresponds to the number of local rows and values which represent the number of nonzeros in the various rows of the off-diagonal of the local submatrix.

Self

SEE ALSO:

petsc.MatISSetPreallocation


Source code at petsc4py/PETSc/Mat.pyx:4750


Set the local-to-global mappings.

Collective.

  • rmap (LGMap) -- Row mapping.
  • cmap (LGMap | None) -- Column mapping. If None, cmap = rmap.

None

SEE ALSO:

getLGMap, petsc.MatSetLocalToGlobalMapping


Source code at petsc4py/PETSc/Mat.pyx:2701


Set the constituents of a Type.LRC matrix.

Logically collective.

  • A (Mat) -- The A matrix, or None to omit A.
  • U (Mat) -- The first dense rectangular matrix.
  • c (Vec) -- The sequential vector containing the diagonal of C, or None for all ones.
  • V (Mat) -- The second dense rectangular matrix, or None for a copy of U.


SEE ALSO:

petsc.MatLRCSetMats


Source code at petsc4py/PETSc/Mat.pyx:4814


Set a MUMPS parameter, CNTL[icntl] = val.

Logically collective.

  • icntl (int) -- The index of the MUMPS parameter array.
  • val (float) -- The value to set.


SEE ALSO:

Working with PETSc options (TODO), petsc.MatMumpsSetCntl


Source code at petsc4py/PETSc/Mat.pyx:4933


Set a MUMPS parameter, ICNTL[icntl] = ival.

Logically collective.

  • icntl (int) -- The index of the MUMPS parameter array.
  • ival (int) -- The value to set.

None

SEE ALSO:

Working with PETSc options (TODO), petsc.MatMumpsSetIcntl


Source code at petsc4py/PETSc/Mat.pyx:4897


Set the near-nullspace.

Collective.

SEE ALSO:

setNullSpace, getNearNullSpace, petsc.MatSetNearNullSpace


Source code at petsc4py/PETSc/Mat.pyx:3622

nsp (NullSpace) --
None


Set the vector type for a Type.NEST matrix.

Collective.

vec_type (Type | str) -- Vector type used when creating vectors with createVecs.
None

SEE ALSO:

getVecType, petsc.MatNestSetVecType


Source code at petsc4py/PETSc/Mat.pyx:640


Set the nullspace.

Collective.

SEE ALSO:

getNullSpace, petsc.MatSetNullSpace


Source code at petsc4py/PETSc/Mat.pyx:3568

nsp (NullSpace) --
None


Set option.

Collective.

SEE ALSO:

getOption, petsc.MatSetOption


Source code at petsc4py/PETSc/Mat.pyx:1730

  • option (Option) --
  • flag (bool) --

None


Set the prefix used for searching for options in the database.

Logically collective.

SEE ALSO:

Working with PETSc options (TODO), getOptionsPrefix, petsc.MatSetOptionsPrefix


Source code at petsc4py/PETSc/Mat.pyx:1663

prefix (str) --
None


Preallocate memory for the matrix with a CSR layout.

Collective.

Correct preallocation can result in a dramatic reduction in matrix assembly time.

csr (CSRIndicesSpec) -- Local matrix data in compressed sparse row layout format.
Self

Notes

Must use the block-compressed form with Type.BAIJ and Type.SBAIJ.

SEE ALSO:

setPreallocationNNZ, createAIJ, createBAIJ, createSBAIJ, petsc.MatSeqAIJSetPreallocationCSR, petsc.MatMPIAIJSetPreallocationCSR, petsc.MatSeqBAIJSetPreallocationCSR, petsc.MatMPIBAIJSetPreallocationCSR, petsc.MatSeqSBAIJSetPreallocationCSR, petsc.MatMPISBAIJSetPreallocationCSR


Source code at petsc4py/PETSc/Mat.pyx:871


Set the array used for storing matrix elements for a dense matrix.

Collective.

array (Sequence[Scalar]) -- Array that will be used to store matrix data.
Self

SEE ALSO:

petsc.MatSeqDenseSetPreallocation, petsc.MatMPIDenseSetPreallocation


Source code at petsc4py/PETSc/Mat.pyx:1092


Preallocate memory for the matrix with a non-zero pattern.

Collective.

Correct preallocation can result in a dramatic reduction in matrix assembly time.

nnz (NNZSpec) -- The number of non-zeros per row for the local portion of the matrix, or a 2-tuple for the on-process and off-process part of the matrix.
Self

SEE ALSO:

setPreallocationCSR, createAIJ, petsc.MatSeqAIJSetPreallocation, petsc.MatMPIAIJSetPreallocation


Source code at petsc4py/PETSc/Mat.pyx:845


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

Not collective.

SEE ALSO:

PETSc Python matrix type, getPythonContext


Source code at petsc4py/PETSc/Mat.pyx:1604

context (Any) --
None


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

Collective.

SEE ALSO:

PETSc Python matrix type, setPythonContext, getPythonType, petsc.MatPythonSetType


Source code at petsc4py/PETSc/Mat.pyx:1631

py_type (str) --
None


Set random values in the matrix.

Collective.

random (Random | None) -- The random number generator object or None for the default.
None

SEE ALSO:

petsc.MatSetRandom


Source code at petsc4py/PETSc/Mat.pyx:4031


Set the local, global and block sizes.

Collective.

  • size (MatSizeSpec) -- Matrix size.
  • bsize (MatBlockSizeSpec | None) -- Matrix block size. If None, a block size of 1 is set.

None

Examples

Create a Mat with n rows and columns and the same local and global sizes.

>>> mat = PETSc.Mat().create()
>>> mat.setFromOptions()
>>> mat.setSizes(n)

Create a Mat with nr rows, nc columns and the same local and global sizes.

>>> mat = PETSc.Mat().create()
>>> mat.setFromOptions()
>>> mat.setSizes([nr, nc])

Create a Mat with nrl local rows, nrg global rows, ncl local columns and ncg global columns.

>>> mat = PETSc.Mat().create()
>>> mat.setFromOptions()
>>> mat.setSizes([[nrl, nrg], [ncl, ncg]])

SEE ALSO:

setBlockSize, setBlockSizes, petsc.MatSetSizes, petsc.MatSetBlockSize, petsc.MatSetBlockSizes


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


Set matrix stencil.

Not collective.

SEE ALSO:

petsc.MatSetStencil


Source code at petsc4py/PETSc/Mat.pyx:2966

  • dims (DimsSpec) --
  • starts (DimsSpec | None) --
  • dof (int) --

None


Set the transpose nullspace.

Collective.

SEE ALSO:

setNullSpace, getTransposeNullSpace, petsc.MatSetTransposeNullSpace


Source code at petsc4py/PETSc/Mat.pyx:3595

nsp (NullSpace) --
None


Set transpose precursor.

SEE ALSO:

petsc.MatTransposeSetPrecursor


Source code at petsc4py/PETSc/Mat.pyx:2070

out (Mat) --
None


Set the matrix type.

Collective.

mat_type (Type | str) -- The matrix type.
None

SEE ALSO:

create, getType, petsc.MatSetType


Source code at petsc4py/PETSc/Mat.pyx:495


Set a factored matrix to be treated as unfactored.

Logically collective.

SEE ALSO:

petsc.MatSetUnfactored


Source code at petsc4py/PETSc/Mat.pyx:4674



Set up the internal data structures for using the matrix.

Collective.

SEE ALSO:

petsc.MatSetUp


Source code at petsc4py/PETSc/Mat.pyx:1717



Set a value to the (row, col) entry of the matrix.

Not collective.

  • row (int) -- Row index.
  • col (int) -- Column index.
  • value (Scalar) -- The scalar value.
  • addv (InsertModeSpec) -- Insertion mode.

None

SEE ALSO:

petsc.MatSetValues


Source code at petsc4py/PETSc/Mat.pyx:2478


Not implemented.

Source code at petsc4py/PETSc/Mat.pyx:3052



Set a block of values to row and col stencil.

Not collective.

  • row (Stencil) -- Row stencil.
  • col (Stencil) -- Column stencil.
  • value (Sequence[Scalar]) -- The scalar values.
  • addv (InsertModeSpec) -- Insertion mode.

None

SEE ALSO:

petsc.MatSetValuesBlockedStencil


Source code at petsc4py/PETSc/Mat.pyx:3021


Set a value to the (row, col) entry of the matrix in local ordering.

Not collective.

  • row (int) -- Local row index.
  • col (int) -- Local column index.
  • value (Scalar) -- The scalar value.
  • addv (InsertModeSpec) -- Insertion mode.

None

SEE ALSO:

petsc.MatSetValuesLocal


Source code at petsc4py/PETSc/Mat.pyx:2738


Not implemented.

Source code at petsc4py/PETSc/Mat.pyx:3017



Set a value to row and col stencil.

Not collective.

  • row (Stencil) -- Row stencil.
  • col (Stencil) -- Column stencil.
  • value (Sequence[Scalar]) -- The scalar values.
  • addv (InsertModeSpec) -- Insertion mode.

None

SEE ALSO:

petsc.MatSetValuesStencil


Source code at petsc4py/PETSc/Mat.pyx:2986


Set values to the rows ⊗ cols entries of the matrix.

Not collective.

  • rows (Sequence[int]) -- Row indices.
  • cols (Sequence[int]) -- Column indices.
  • values (Sequence[Scalar]) -- The scalar values. A sequence of length at least len(rows) * len(cols).
  • addv (InsertModeSpec) -- Insertion mode.

None

SEE ALSO:

petsc.MatSetValues


Source code at petsc4py/PETSc/Mat.pyx:2511


Set values to the rows ⊗ col block entries of the matrix.

Not collective.

  • rows (Sequence[int]) -- Block row indices.
  • cols (Sequence[int]) -- Block column indices.
  • values (Sequence[Scalar]) -- The scalar values. A sequence of length at least len(rows) * len(cols) * bs * bs, where bs is the block size of the matrix.
  • addv (InsertModeSpec) -- Insertion mode.

None

SEE ALSO:

petsc.MatSetValuesBlocked


Source code at petsc4py/PETSc/Mat.pyx:2605


Set values stored in block CSR format.

Not collective.

  • I (Sequence[int]) -- Block row pointers.
  • J (Sequence[int]) -- Block column indices.
  • V (Sequence[Scalar]) -- The scalar values.
  • addv (InsertModeSpec) -- Insertion mode.

None

SEE ALSO:

petsc.MatSetValuesBlocked


Source code at petsc4py/PETSc/Mat.pyx:2672


Set a subset of values stored in block CSR format.

Not collective.

  • I (Sequence[int]) -- Block row pointers.
  • J (Sequence[int]) -- Block column indices.
  • V (Sequence[Scalar]) -- The scalar values.
  • addv (InsertModeSpec) -- Insertion mode.
  • rowmap (Sequence[int]) -- Optional iterable indicating which block row to insert.

None

SEE ALSO:

petsc.MatSetValuesBlocked


Source code at petsc4py/PETSc/Mat.pyx:2640


Set values to the rows ⊗ col block entries of the matrix in local ordering.

Not collective.

  • rows (Sequence[int]) -- Local block row indices.
  • cols (Sequence[int]) -- Local block column indices.
  • values (Sequence[Scalar]) -- The scalar values. A sequence of length at least len(rows) * len(cols) * bs * bs, where bs is the block size of the matrix.
  • addv (InsertModeSpec) -- Insertion mode.

None

SEE ALSO:

petsc.MatSetValuesBlockedLocal


Source code at petsc4py/PETSc/Mat.pyx:2866


Set values stored in block CSR format.

Not collective.

  • I (Sequence[int]) -- Block row pointers.
  • J (Sequence[int]) -- Local block column indices.
  • V (Sequence[Scalar]) -- The scalar values.
  • addv (InsertModeSpec) -- Insertion mode.

None

SEE ALSO:

petsc.MatSetValuesBlockedLocal


Source code at petsc4py/PETSc/Mat.pyx:2933


Set a subset of values stored in block CSR format.

Not collective.

  • I (Sequence[int]) -- Block row pointers.
  • J (Sequence[int]) -- Local block column indices.
  • V (Sequence[Scalar]) -- The scalar values.
  • addv (InsertModeSpec) -- Insertion mode.
  • rowmap (Sequence[int]) -- Optional iterable indicating which block row to insert.

None

SEE ALSO:

petsc.MatSetValuesBlockedLocal


Source code at petsc4py/PETSc/Mat.pyx:2901


Undocumented.

Source code at petsc4py/PETSc/Mat.pyx:2897



Undocumented.

Source code at petsc4py/PETSc/Mat.pyx:2636



Set values stored in CSR format.

Not collective.

  • I (Sequence[int]) -- Row pointers.
  • J (Sequence[int]) -- Column indices.
  • V (Sequence[Scalar]) -- The scalar values.
  • addv (InsertModeSpec) -- Insertion mode.

None

SEE ALSO:

petsc.MatSetValues


Source code at petsc4py/PETSc/Mat.pyx:2576


Set a subset of values stored in CSR format.

Not collective.

  • I (Sequence[int]) -- Row pointers.
  • J (Sequence[int]) -- Column indices.
  • V (Sequence[Scalar]) -- The scalar values.
  • addv (InsertModeSpec) -- Insertion mode.
  • rowmap (Sequence[int]) -- Optional iterable indicating which row to insert.

None

SEE ALSO:

petsc.MatSetValues


Source code at petsc4py/PETSc/Mat.pyx:2544


Set values to the rows ⊗ col entries of the matrix in local ordering.

Not collective.

  • rows (Sequence[int]) -- Local row indices.
  • cols (Sequence[int]) -- Local column indices.
  • values (Sequence[Scalar]) -- The scalar values. A sequence of length at least len(rows) * len(cols).
  • addv (InsertModeSpec) -- Insertion mode.

None

SEE ALSO:

petsc.MatSetValuesLocal


Source code at petsc4py/PETSc/Mat.pyx:2772


Set values stored in CSR format.

Not collective.

  • I (Sequence[int]) -- Row pointers.
  • J (Sequence[int]) -- Local column indices.
  • V (Sequence[Scalar]) -- The scalar values.
  • addv (InsertModeSpec) -- Insertion mode.

None

SEE ALSO:

petsc.MatSetValuesLocal


Source code at petsc4py/PETSc/Mat.pyx:2837


Set a subset of values stored in CSR format.

Not collective.

  • I (Sequence[int]) -- Row pointers.
  • J (Sequence[int]) -- Local column indices.
  • V (Sequence[Scalar]) -- The scalar values.
  • addv (InsertModeSpec) -- Insertion mode.
  • rowmap (Sequence[int]) -- Optional iterable indicating which row to insert.

None

SEE ALSO:

petsc.MatSetValuesLocal


Source code at petsc4py/PETSc/Mat.pyx:2805


Undocumented.

Source code at petsc4py/PETSc/Mat.pyx:2801



Undocumented.

Source code at petsc4py/PETSc/Mat.pyx:2540



Set the vector type.

Collective.

vec_type (Type | str) -- Vector type used when creating vectors with createVecs.
None

SEE ALSO:

getVecType, petsc.MatSetVecType


Source code at petsc4py/PETSc/Mat.pyx:607


Shift the matrix.

Collective.

SEE ALSO:

petsc.MatShift


Source code at petsc4py/PETSc/Mat.pyx:4005

alpha (Scalar) --
None


Solve Ax=b, given a factored matrix.

Neighborwise collective.

The vectors b and x cannot be the same. Most users should employ the KSP interface for linear solvers instead of working directly with matrix algebra routines.

  • b (Vec) -- The right-hand side vector.
  • x (Vec) -- The output solution vector, must be different than b.

None

SEE ALSO:

KSP.create, solveTranspose, petsc.MatSolve


Source code at petsc4py/PETSc/Mat.pyx:5089


Solve x=y+A⁻¹b, given a factored matrix.

Neighborwise collective.

The vectors b and x cannot be the same.

  • b (Vec) -- The right-hand side vector.
  • y (Vec) -- The vector to be added
  • x (Vec) -- The output solution vector, must be different than b.

None

SEE ALSO:

KSP.create, petsc.MatSolve, petsc.MatSolveAdd


Source code at petsc4py/PETSc/Mat.pyx:5133


Solve Ux=b, given a factored matrix A=LU.

Neighborwise collective.

  • b (Vec) -- The right-hand side vector.
  • x (Vec) -- The output solution vector.

None

SEE ALSO:

petsc.MatBackwardSolve


Source code at petsc4py/PETSc/Mat.pyx:5070


Solve Lx = b, given a factored matrix A = LU.

Neighborwise collective.

  • b (Vec) -- The right-hand side vector.
  • x (Vec) -- The output solution vector.

None

SEE ALSO:

petsc.MatForwardSolve


Source code at petsc4py/PETSc/Mat.pyx:5051


Solve Aᵀx=b, given a factored matrix.

Neighborwise collective.

The vectors b and x cannot be the same.

  • b (Vec) -- The right-hand side vector.
  • x (Vec) -- The output solution vector, must be different than b.

None

SEE ALSO:

KSP.create, petsc.MatSolve, petsc.MatSolveTranspose


Source code at petsc4py/PETSc/Mat.pyx:5112


Solve x=y+A⁻ᵀb, given a factored matrix.

Neighborwise collective.

The vectors b and x cannot be the same.

  • b (Vec) -- The right-hand side vector.
  • y (Vec) -- The vector to be added
  • x (Vec) -- The output solution vector, must be different than b.

None

SEE ALSO:

KSP.create, petsc.MatSolve, petsc.MatSolveTransposeAdd


Source code at petsc4py/PETSc/Mat.pyx:5156


Stash a copy of the matrix values.

Collective.

SEE ALSO:

retrieveValues, petsc.MatStoreValues


Source code at petsc4py/PETSc/Mat.pyx:3227



Return a DLPack PyCapsule wrapping the vector data.

Source code at petsc4py/PETSc/Mat.pyx:5532

mode (AccessModeSpec) --
Any


Return the transposed matrix.

Collective.

out (Mat | None) -- Optional return matrix. If None, inplace transposition is performed. Otherwise, the matrix is reused.
Mat

SEE ALSO:

petsc.MatTranspose


Source code at petsc4py/PETSc/Mat.pyx:2043


Perform matrix-matrix multiplication C=AᵀB.

Neighborwise collective.

  • mat (Mat) -- The right hand matrix B.
  • result (Mat | None) -- The optional resultant matrix C. When None, a new matrix is created, and MAT_INITIAL_MATRIX is used. When C is not None, the matrix is reused with MAT_REUSE_MATRIX.
  • fill (float | None) -- Expected fill as ratio of nnz(C)/(nnz(A) + nnz(B)), use None if you do not have a good estimate. If the result is a dense matrix this is irrelevant.

result -- The resultant product matrix C.
Mat

Notes

To determine the correct fill value, run with -info and search for the string "Fill ratio" to see the value actually needed.

SEE ALSO:

petsc.MatTransposeMatMult, petsc.MatReuse


Source code at petsc4py/PETSc/Mat.pyx:4194


View the matrix.

Collective.

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

Notes

Viewers with type Viewer.Type.ASCII are only recommended for small matrices on small numbers of processes. Larger matrices should use a binary format like Viewer.Type.BINARY.

SEE ALSO:

load, Viewer, petsc.MatView


Source code at petsc4py/PETSc/Mat.pyx:431


Zero the entries of the matrix.

Collective.

SEE ALSO:

petsc.MatZeroEntries


Source code at petsc4py/PETSc/Mat.pyx:2310



Zero selected rows of the matrix.

Collective.

  • rows (IS | Sequence[int]) -- Row indices to be zeroed.
  • diag (Scalar) -- Scalar value to be inserted into the diagonal.
  • x (Vec | None) -- Optional solution vector to be modified for zeroed rows.
  • b (Vec | None) -- Optional right-hand side vector to be modified. It will be adjusted with provided solution entries.

None

SEE ALSO:

zeroRowsLocal, petsc.MatZeroRows, petsc.MatZeroRowsIS


Source code at petsc4py/PETSc/Mat.pyx:3056


Zero selected rows and columns of the matrix.

Collective.

  • rows (IS | Sequence[int]) -- Row/column indices to be zeroed.
  • diag (Scalar) -- Scalar value to be inserted into the diagonal.
  • x (Vec | None) -- Optional solution vector to be modified for zeroed rows.
  • b (Vec | None) -- Optional right-hand side vector to be modified. It will be adjusted with provided solution entries.

None

SEE ALSO:

zeroRowsColumnsLocal, zeroRows, petsc.MatZeroRowsColumns, petsc.MatZeroRowsColumnsIS


Source code at petsc4py/PETSc/Mat.pyx:3122


Zero selected rows and columns of the matrix in local ordering.

Collective.

  • rows (IS | Sequence[int]) -- Local row/column indices to be zeroed.
  • diag (Scalar) -- Scalar value to be inserted into the diagonal.
  • x (Vec | None) -- Optional solution vector to be modified for zeroed rows.
  • b (Vec | None) -- Optional right-hand side vector to be modified. It will be adjusted with provided solution entries.

None

SEE ALSO:

zeroRowsLocal, zeroRowsColumns, petsc.MatZeroRowsColumnsLocal, petsc.MatZeroRowsColumnsLocalIS


Source code at petsc4py/PETSc/Mat.pyx:3156


Zero selected rows and columns of the matrix.

Collective.

  • rows (Sequence[Stencil]) -- Iterable of stencil rows and columns.
  • diag (Scalar) -- Scalar value to be inserted into the diagonal.
  • x (Vec | None) -- Optional solution vector to be modified for zeroed rows.
  • b (Vec | None) -- Optional right-hand side vector to be modified. It will be adjusted with provided solution entries.

None

SEE ALSO:

zeroRowsLocal, zeroRowsColumns, petsc.MatZeroRowsColumnsStencil


Source code at petsc4py/PETSc/Mat.pyx:3190


Zero selected rows of the matrix in local ordering.

Collective.

  • rows (IS | Sequence[int]) -- Local row indices to be zeroed.
  • diag (Scalar) -- Scalar value to be inserted into the diagonal.
  • x (Vec | None) -- Optional solution vector to be modified for zeroed rows.
  • b (Vec | None) -- Optional right-hand side vector to be modified. It will be adjusted with provided solution entries.

None

SEE ALSO:

zeroRows, petsc.MatZeroRowsLocal, petsc.MatZeroRowsLocalIS


Source code at petsc4py/PETSc/Mat.pyx:3089


Attributes Documentation

The boolean flag indicating if the matrix is assembled.

Source code at petsc4py/PETSc/Mat.pyx:5507


Matrix block size.

Source code at petsc4py/PETSc/Mat.pyx:5485


Matrix row and column block sizes.

Source code at petsc4py/PETSc/Mat.pyx:5490


The boolean flag indicating if the matrix is Hermitian.

Source code at petsc4py/PETSc/Mat.pyx:5515


Matrix local size.

Source code at petsc4py/PETSc/Mat.pyx:5480


Matrix local row range.

Source code at petsc4py/PETSc/Mat.pyx:5495


Matrix row ranges.

Source code at petsc4py/PETSc/Mat.pyx:5500


Matrix global size.

Source code at petsc4py/PETSc/Mat.pyx:5475


Matrix local and global sizes.

Source code at petsc4py/PETSc/Mat.pyx:5468


The boolean flag indicating if the matrix is structurally symmetric.

Source code at petsc4py/PETSc/Mat.pyx:5519


The boolean flag indicating if the matrix is symmetric.

Source code at petsc4py/PETSc/Mat.pyx:5511




petsc4py.PETSc.MatPartitioning

Bases: Object

Object for managing the partitioning of a matrix or graph.

Enumerations

Type

petsc4py.PETSc.MatPartitioning.Type

Bases: object

Attributes Summary

PARTITIONINGAVERAGE Object PARTITIONINGAVERAGE of type str
PARTITIONINGCHACO Object PARTITIONINGCHACO of type str
PARTITIONINGCURRENT Object PARTITIONINGCURRENT of type str
PARTITIONINGHIERARCH Object PARTITIONINGHIERARCH of type str
PARTITIONINGPARMETIS Object PARTITIONINGPARMETIS of type str
PARTITIONINGPARTY Object PARTITIONINGPARTY of type str
PARTITIONINGPTSCOTCH Object PARTITIONINGPTSCOTCH of type str
PARTITIONINGSQUARE Object PARTITIONINGSQUARE of type str

Attributes Documentation

Object PARTITIONINGAVERAGE of type str

Object PARTITIONINGCHACO of type str

Object PARTITIONINGCURRENT of type str

Object PARTITIONINGHIERARCH of type str

Object PARTITIONINGPARMETIS of type str

Object PARTITIONINGPARTY of type str

Object PARTITIONINGPTSCOTCH of type str

Object PARTITIONINGSQUARE of type str


Methods Summary

apply(partitioning) Return a partitioning for the graph represented by a sparse matrix.
create([comm]) Create a partitioning context.
destroy() Destroy the partitioning context.
getType() Return the partitioning method.
setAdjacency(adj) Set the adjacency graph (matrix) of the thing to be partitioned.
setFromOptions() Set parameters in the partitioner from the options database.
setType(matpartitioning_type) Set the type of the partitioner to use.
view([viewer]) View the partitioning data structure.

Methods Documentation

Return a partitioning for the graph represented by a sparse matrix.

Collective.

For each local node this tells the processor number that that node is assigned to.

SEE ALSO:

petsc.MatPartitioningApply


Source code at petsc4py/PETSc/MatPartitioning.pyx:142

partitioning (IS) --
None


Create a partitioning context.

Collective.

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

SEE ALSO:

destroy, petsc.MatPartitioningCreate


Source code at petsc4py/PETSc/MatPartitioning.pyx:60


Destroy the partitioning context.

Collective.

SEE ALSO:

create, petsc.MatPartitioningDestroy


Source code at petsc4py/PETSc/MatPartitioning.pyx:47



Return the partitioning method.

Not collective.

SEE ALSO:

setType, petsc.MatPartitioningGetType


Source code at petsc4py/PETSc/MatPartitioning.pyx:98



Set the adjacency graph (matrix) of the thing to be partitioned.

Collective.

adj (Mat) -- The adjacency matrix, this can be any Mat.Type but the natural representation is Mat.Type.MPIADJ.
None

SEE ALSO:

petsc.MatPartitioningSetAdjacency


Source code at petsc4py/PETSc/MatPartitioning.pyx:124


Set parameters in the partitioner from the options database.

Collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.MatPartitioningSetFromOptions


Source code at petsc4py/PETSc/MatPartitioning.pyx:112



Set the type of the partitioner to use.

Collective.

matpartitioning_type (Type | str) -- The partitioner type.
None

SEE ALSO:

getType, petsc.MatPartitioningSetType


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


View the partitioning data structure.

Collective.

viewer (Viewer | None) -- A Viewer to display the graph.
None

SEE ALSO:

petsc.MatPartitioningView


Source code at petsc4py/PETSc/MatPartitioning.pyx:27




petsc4py.PETSc.NormType

Bases: object

Norm type.

Commonly used norm types:

The one norm.
The two norm.
The Frobenius norm.
The infinity norm.

SEE ALSO:

petsc.NormType


Attributes Summary

FRB Constant FRB of type int
FROBENIUS Constant FROBENIUS of type int
INF Constant INF of type int
INFINITY Constant INFINITY of type int
MAX Constant MAX of type int
N1 Constant N1 of type int
N12 Constant N12 of type int
N2 Constant N2 of type int
NORM_1 Constant NORM_1 of type int
NORM_1_AND_2 Constant NORM_1_AND_2 of type int
NORM_2 Constant NORM_2 of type int
NORM_FROBENIUS Constant NORM_FROBENIUS of type int
NORM_INFINITY Constant NORM_INFINITY of type int
NORM_MAX Constant NORM_MAX of type int

Attributes Documentation

Constant FRB of type int

Constant FROBENIUS of type int

Constant INF of type int

Constant INFINITY of type int

Constant MAX of type int

Constant N1 of type int

Constant N12 of type int

Constant N2 of type int

Constant NORM_1 of type int

Constant NORM_1_AND_2 of type int

Constant NORM_2 of type int

Constant NORM_FROBENIUS of type int

Constant NORM_INFINITY of type int

Constant NORM_MAX of type int


petsc4py.PETSc.NullSpace

Bases: Object

Nullspace object.

SEE ALSO:

petsc.MatNullSpace


Methods Summary

create([constant, vectors, comm]) Create the null space.
createRigidBody(coords) Create rigid body modes from coordinates.
destroy() Destroy the null space.
getFunction() Return the callback to remove the nullspace.
getVecs() Return the vectors defining the null space.
hasConstant() Return whether the null space contains the constant.
remove(vec) Remove all components of a null space from a vector.
setFunction(function[, args, kargs]) Set the callback to remove the nullspace.
test(mat) Return if the claimed null space is valid for a matrix.
view([viewer]) View the null space.

Methods Documentation

Create the null space.

Collective.

  • constant (bool) -- A flag to indicate the null space contains the constant vector.
  • vectors (Sequence[Vec]) -- The sequence of vectors that span the null space.
  • comm -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

destroy, petsc.MatNullSpaceCreate


Source code at petsc4py/PETSc/Mat.pyx:5656


Create rigid body modes from coordinates.

Collective.

coords (Vec) -- The block coordinates of each node. Requires the block size to have been set.
Self

SEE ALSO:

petsc.MatNullSpaceCreateRigidBody


Source code at petsc4py/PETSc/Mat.pyx:5693


Destroy the null space.

Collective.

SEE ALSO:

create, petsc.MatNullSpaceDestroy


Source code at petsc4py/PETSc/Mat.pyx:5643



Return the callback to remove the nullspace.

Not collective.

SEE ALSO:

setFunction


Source code at petsc4py/PETSc/Mat.pyx:5785

MatNullFunction


Return the vectors defining the null space.

Not collective.

SEE ALSO:

petsc.MatNullSpaceGetVecs


Source code at petsc4py/PETSc/Mat.pyx:5763

list[Vec]


Return whether the null space contains the constant.

Not collective.

SEE ALSO:

petsc.MatNullSpaceGetVecs


Source code at petsc4py/PETSc/Mat.pyx:5749



Remove all components of a null space from a vector.

Collective.

vec (Vec) -- The vector from which the null space is removed.
None

SEE ALSO:

petsc.MatNullSpaceRemove


Source code at petsc4py/PETSc/Mat.pyx:5799


Set the callback to remove the nullspace.

Logically collective.

  • function (MatNullFunction) -- The callback.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

getFunction, petsc.MatNullSpaceSetFunction


Source code at petsc4py/PETSc/Mat.pyx:5714


Return if the claimed null space is valid for a matrix.

Collective.

mat (Mat) -- The matrix to check.
bool

SEE ALSO:

petsc.MatNullSpaceTest


Source code at petsc4py/PETSc/Mat.pyx:5816


View the null space.

Collective.

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

SEE ALSO:

Viewer, petsc.MatNullSpaceView


Source code at petsc4py/PETSc/Mat.pyx:5624



petsc4py.PETSc.Object

Bases: object

Methods Summary

appendOptionsPrefix(prefix) Source code at petsc4py/PETSc/Object.pyx:82
compose(name, obj) Source code at petsc4py/PETSc/Object.pyx:132
decRef() Source code at petsc4py/PETSc/Object.pyx:158
destroy() Source code at petsc4py/PETSc/Object.pyx:61
getAttr(name) Source code at petsc4py/PETSc/Object.pyx:168
getClassId() Source code at petsc4py/PETSc/Object.pyx:114
getClassName() Source code at petsc4py/PETSc/Object.pyx:119
getComm() Source code at petsc4py/PETSc/Object.pyx:99
getDict() Source code at petsc4py/PETSc/Object.pyx:178
getName() Source code at petsc4py/PETSc/Object.pyx:104
getOptionsPrefix() Source code at petsc4py/PETSc/Object.pyx:77
getRefCount() Source code at petsc4py/PETSc/Object.pyx:124
getTabLevel() Source code at petsc4py/PETSc/Object.pyx:205
getType() Source code at petsc4py/PETSc/Object.pyx:65
incRef() Source code at petsc4py/PETSc/Object.pyx:150
incrementTabLevel(tab[, parent]) Source code at petsc4py/PETSc/Object.pyx:196
query(name) Source code at petsc4py/PETSc/Object.pyx:139
setAttr(name, attr) Source code at petsc4py/PETSc/Object.pyx:173
setFromOptions() Source code at petsc4py/PETSc/Object.pyx:87
setName(name) Source code at petsc4py/PETSc/Object.pyx:109
setOptionsPrefix(prefix) Source code at petsc4py/PETSc/Object.pyx:72
setTabLevel(level) Source code at petsc4py/PETSc/Object.pyx:201
stateGet() Source code at petsc4py/PETSc/Object.pyx:185
stateIncrease() Source code at petsc4py/PETSc/Object.pyx:182
stateSet(state) Source code at petsc4py/PETSc/Object.pyx:190
view([viewer]) Source code at petsc4py/PETSc/Object.pyx:56
viewFromOptions(name[, prefix]) Source code at petsc4py/PETSc/Object.pyx:90

Attributes Summary

classid
comm
fortran
handle
klass
name
prefix
refcount
type

Methods Documentation

Source code at petsc4py/PETSc/Object.pyx:82

Source code at petsc4py/PETSc/Object.pyx:132
obj (Object) --


Source code at petsc4py/PETSc/Object.pyx:158

Source code at petsc4py/PETSc/Object.pyx:61

Source code at petsc4py/PETSc/Object.pyx:168

Source code at petsc4py/PETSc/Object.pyx:114

Source code at petsc4py/PETSc/Object.pyx:119

Source code at petsc4py/PETSc/Object.pyx:99

Source code at petsc4py/PETSc/Object.pyx:178

Source code at petsc4py/PETSc/Object.pyx:104

Source code at petsc4py/PETSc/Object.pyx:77

Source code at petsc4py/PETSc/Object.pyx:124

Source code at petsc4py/PETSc/Object.pyx:205

Source code at petsc4py/PETSc/Object.pyx:65

Source code at petsc4py/PETSc/Object.pyx:150

Source code at petsc4py/PETSc/Object.pyx:196
parent (Object | None) --


Source code at petsc4py/PETSc/Object.pyx:139

Source code at petsc4py/PETSc/Object.pyx:173

Source code at petsc4py/PETSc/Object.pyx:87

Source code at petsc4py/PETSc/Object.pyx:109

Source code at petsc4py/PETSc/Object.pyx:72

Source code at petsc4py/PETSc/Object.pyx:201

Source code at petsc4py/PETSc/Object.pyx:185

Source code at petsc4py/PETSc/Object.pyx:182

Source code at petsc4py/PETSc/Object.pyx:190

Source code at petsc4py/PETSc/Object.pyx:56
viewer (Viewer | None) --


Source code at petsc4py/PETSc/Object.pyx:90
prefix (Object | None) --


Attributes Documentation











petsc4py.PETSc.Options

Bases: object

Options(prefix=None)

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

Methods Summary

clear() Source code at petsc4py/PETSc/Options.pyx:47
create() Source code at petsc4py/PETSc/Options.pyx:37
delValue(name) Source code at petsc4py/PETSc/Options.pyx:93
destroy() Source code at petsc4py/PETSc/Options.pyx:42
getAll() Source code at petsc4py/PETSc/Options.pyx:129
getBool(name[, default]) Source code at petsc4py/PETSc/Options.pyx:107
getInt(name[, default]) Source code at petsc4py/PETSc/Options.pyx:110
getReal(name[, default]) Source code at petsc4py/PETSc/Options.pyx:113
getScalar(name[, default]) Source code at petsc4py/PETSc/Options.pyx:116
getString(name[, default]) Source code at petsc4py/PETSc/Options.pyx:119
hasName(name) Source code at petsc4py/PETSc/Options.pyx:67
insertString(string) Source code at petsc4py/PETSc/Options.pyx:124
prefixPop() Source code at petsc4py/PETSc/Options.pyx:63
prefixPush(prefix) Source code at petsc4py/PETSc/Options.pyx:57
setValue(name, value) Source code at petsc4py/PETSc/Options.pyx:75
view([viewer]) Source code at petsc4py/PETSc/Options.pyx:52

Attributes Summary

prefix

Methods Documentation

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Source code at petsc4py/PETSc/Options.pyx:52
viewer (Viewer | None) --


Attributes Documentation



petsc4py.PETSc.PC

Bases: Object

Preconditioners.

PC is described in the PETSc manual. Calling the PC with a vector as an argument will apply the preconditioner as shown in the example below.

Examples

>>> from petsc4py import PETSc
>>> v = PETSc.Vec().createWithArray([1,2])
>>> m = PETSc.Mat().createDense(2,array=[[1,0],[0,1]])
>>> pc = PETSc.PC().create()
>>> pc.setOperators(m)
>>> u = pc(v) # Vec u is created internally, can also be passed as second argument
    

SEE ALSO:

petsc.PC


Enumerations

ASMType The ASM subtype.
CompositeType The composite type.
DeflationSpaceType The deflation space subtype.
FailedReason The reason the preconditioner has failed.
FieldSplitSchurFactType The field split Schur factorization type.
FieldSplitSchurPreType The field split Schur subtype.
GAMGType The GAMG subtype.
GASMType The GASM subtype.
HPDDMCoarseCorrectionType The HPDDM coarse correction type.
MGCycleType The MG cycle type.
MGType The MG subtype.
PatchConstructType The patch construction type.
Side The manner in which the preconditioner is applied.
Type The preconditioner method.

petsc4py.PETSc.PC.ASMType

Bases: object

The ASM subtype.

Attributes Summary

BASIC Constant BASIC of type int
INTERPOLATE Constant INTERPOLATE of type int
NONE Constant NONE of type int
RESTRICT Constant RESTRICT of type int

Attributes Documentation

Constant BASIC of type int

Constant INTERPOLATE of type int

Constant NONE of type int

Constant RESTRICT of type int


petsc4py.PETSc.PC.CompositeType

Bases: object

The composite type.

Attributes Summary

ADDITIVE Constant ADDITIVE of type int
MULTIPLICATIVE Constant MULTIPLICATIVE of type int
SCHUR Constant SCHUR of type int
SPECIAL Constant SPECIAL of type int
SYMMETRIC_MULTIPLICATIVE Constant SYMMETRIC_MULTIPLICATIVE of type int

Attributes Documentation

Constant ADDITIVE of type int

Constant MULTIPLICATIVE of type int

Constant SCHUR of type int

Constant SPECIAL of type int

Constant SYMMETRIC_MULTIPLICATIVE of type int


petsc4py.PETSc.PC.DeflationSpaceType

Bases: object

The deflation space subtype.

Attributes Summary

AGGREGATION Constant AGGREGATION of type int
BIORTH22 Constant BIORTH22 of type int
DB16 Constant DB16 of type int
DB2 Constant DB2 of type int
DB4 Constant DB4 of type int
DB8 Constant DB8 of type int
HAAR Constant HAAR of type int
MEYER Constant MEYER of type int
USER Constant USER of type int

Attributes Documentation

Constant AGGREGATION of type int

Constant BIORTH22 of type int

Constant DB16 of type int

Constant DB2 of type int

Constant DB4 of type int

Constant DB8 of type int

Constant HAAR of type int

Constant MEYER of type int

Constant USER of type int


petsc4py.PETSc.PC.FailedReason

Bases: object

The reason the preconditioner has failed.

Attributes Summary

FACTOR_NUMERIC_ZEROPIVOT Constant FACTOR_NUMERIC_ZEROPIVOT of type int
FACTOR_OTHER Constant FACTOR_OTHER of type int
FACTOR_OUTMEMORY Constant FACTOR_OUTMEMORY of type int
FACTOR_STRUCT_ZEROPIVOT Constant FACTOR_STRUCT_ZEROPIVOT of type int
NOERROR Constant NOERROR of type int
SETUP_ERROR Constant SETUP_ERROR of type int
SUBPC_ERROR Constant SUBPC_ERROR of type int

Attributes Documentation

Constant FACTOR_NUMERIC_ZEROPIVOT of type int

Constant FACTOR_OTHER of type int

Constant FACTOR_OUTMEMORY of type int

Constant FACTOR_STRUCT_ZEROPIVOT of type int

Constant NOERROR of type int

Constant SETUP_ERROR of type int

Constant SUBPC_ERROR of type int


petsc4py.PETSc.PC.FieldSplitSchurFactType

Bases: object

The field split Schur factorization type.

Attributes Summary

DIAG Constant DIAG of type int
FULL Constant FULL of type int
LOWER Constant LOWER of type int
UPPER Constant UPPER of type int

Attributes Documentation

Constant DIAG of type int

Constant FULL of type int

Constant LOWER of type int

Constant UPPER of type int


petsc4py.PETSc.PC.FieldSplitSchurPreType

Bases: object

The field split Schur subtype.

Attributes Summary

A11 Constant A11 of type int
FULL Constant FULL of type int
SELF Constant SELF of type int
SELFP Constant SELFP of type int
USER Constant USER of type int

Attributes Documentation

Constant A11 of type int

Constant FULL of type int

Constant SELF of type int

Constant SELFP of type int

Constant USER of type int


petsc4py.PETSc.PC.GAMGType

Bases: object

The GAMG subtype.

Attributes Summary

AGG Object AGG of type str
CLASSICAL Object CLASSICAL of type str
GEO Object GEO of type str

Attributes Documentation

Object AGG of type str

Object CLASSICAL of type str

Object GEO of type str


petsc4py.PETSc.PC.GASMType

Bases: object

The GASM subtype.

Attributes Summary

BASIC Constant BASIC of type int
INTERPOLATE Constant INTERPOLATE of type int
NONE Constant NONE of type int
RESTRICT Constant RESTRICT of type int

Attributes Documentation

Constant BASIC of type int

Constant INTERPOLATE of type int

Constant NONE of type int

Constant RESTRICT of type int


petsc4py.PETSc.PC.HPDDMCoarseCorrectionType

Bases: object

The HPDDM coarse correction type.

Attributes Summary

ADDITIVE Constant ADDITIVE of type int
BALANCED Constant BALANCED of type int
DEFLATED Constant DEFLATED of type int

Attributes Documentation

Constant ADDITIVE of type int

Constant BALANCED of type int

Constant DEFLATED of type int


petsc4py.PETSc.PC.MGCycleType

Bases: object

The MG cycle type.

Attributes Summary

V Constant V of type int
W Constant W of type int

Attributes Documentation

Constant V of type int

Constant W of type int


petsc4py.PETSc.PC.MGType

Bases: object

The MG subtype.

Attributes Summary

ADDITIVE Constant ADDITIVE of type int
FULL Constant FULL of type int
KASKADE Constant KASKADE of type int
MULTIPLICATIVE Constant MULTIPLICATIVE of type int

Attributes Documentation

Constant ADDITIVE of type int

Constant FULL of type int

Constant KASKADE of type int

Constant MULTIPLICATIVE of type int


petsc4py.PETSc.PC.PatchConstructType

Bases: object

The patch construction type.

Attributes Summary

PARDECOMP Constant PARDECOMP of type int
PYTHON Constant PYTHON of type int
STAR Constant STAR of type int
USER Constant USER of type int
VANKA Constant VANKA of type int

Attributes Documentation

Constant PARDECOMP of type int

Constant PYTHON of type int

Constant STAR of type int

Constant USER of type int

Constant VANKA of type int


petsc4py.PETSc.PC.Side

Bases: object

The manner in which the preconditioner is applied.

Attributes Summary

L Constant L of type int
LEFT Constant LEFT of type int
R Constant R of type int
RIGHT Constant RIGHT of type int
S Constant S of type int
SYMMETRIC Constant SYMMETRIC of type int

Attributes Documentation

Constant L of type int

Constant LEFT of type int

Constant R of type int

Constant RIGHT of type int

Constant S of type int

Constant SYMMETRIC of type int


petsc4py.PETSc.PC.Type

Bases: object

The preconditioner method.

Attributes Summary

ASM Object ASM of type str
BDDC Object BDDC of type str
BFBT Object BFBT of type str
BJACOBI Object BJACOBI of type str
CHOLESKY Object CHOLESKY of type str
CHOWILUVIENNACL Object CHOWILUVIENNACL of type str
COMPOSITE Object COMPOSITE of type str
CP Object CP of type str
DEFLATION Object DEFLATION of type str
EISENSTAT Object EISENSTAT of type str
EXOTIC Object EXOTIC of type str
FIELDSPLIT Object FIELDSPLIT of type str
GALERKIN Object GALERKIN of type str
GAMG Object GAMG of type str
GASM Object GASM of type str
H2OPUS Object H2OPUS of type str
HMG Object HMG of type str
HPDDM Object HPDDM of type str
HYPRE Object HYPRE of type str
ICC Object ICC of type str
ILU Object ILU of type str
JACOBI Object JACOBI of type str
KACZMARZ Object KACZMARZ of type str
KSP Object KSP of type str
LMVM Object LMVM of type str
LSC Object LSC of type str
LU Object LU of type str
MAT Object MAT of type str
MG Object MG of type str
ML Object ML of type str
NN Object NN of type str
NONE Object NONE of type str
PARMS Object PARMS of type str
PATCH Object PATCH of type str
PBJACOBI Object PBJACOBI of type str
PFMG Object PFMG of type str
PYTHON Object PYTHON of type str
QR Object QR of type str
REDISTRIBUTE Object REDISTRIBUTE of type str
REDUNDANT Object REDUNDANT of type str
ROWSCALINGVIENNACL Object ROWSCALINGVIENNACL of type str
SAVIENNACL Object SAVIENNACL of type str
SHELL Object SHELL of type str
SOR Object SOR of type str
SPAI Object SPAI of type str
SVD Object SVD of type str
SYSPFMG Object SYSPFMG of type str
TELESCOPE Object TELESCOPE of type str
TFS Object TFS of type str
VPBJACOBI Object VPBJACOBI of type str

Attributes Documentation

Object ASM of type str

Object BDDC of type str

Object BFBT of type str

Object BJACOBI of type str

Object CHOLESKY of type str

Object CHOWILUVIENNACL of type str

Object COMPOSITE of type str

Object CP of type str

Object DEFLATION of type str

Object EISENSTAT of type str

Object EXOTIC of type str

Object FIELDSPLIT of type str

Object GALERKIN of type str

Object GAMG of type str

Object GASM of type str

Object H2OPUS of type str

Object HMG of type str

Object HPDDM of type str

Object HYPRE of type str

Object ICC of type str

Object ILU of type str

Object JACOBI of type str

Object KACZMARZ of type str

Object KSP of type str

Object LMVM of type str

Object LSC of type str

Object LU of type str

Object MAT of type str

Object MG of type str

Object ML of type str

Object NN of type str

Object NONE of type str

Object PARMS of type str

Object PATCH of type str

Object PBJACOBI of type str

Object PFMG of type str

Object PYTHON of type str

Object QR of type str

Object REDISTRIBUTE of type str

Object REDUNDANT of type str

Object ROWSCALINGVIENNACL of type str

Object SAVIENNACL of type str

Object SHELL of type str

Object SOR of type str

Object SPAI of type str

Object SVD of type str

Object SYSPFMG of type str

Object TELESCOPE of type str

Object TFS of type str

Object VPBJACOBI of type str


Methods Summary

addCompositePCType(pc_type) Add a PC of the given type to the composite PC.
appendOptionsPrefix(prefix) Append to the prefix used for all the PC options.
apply(x, y) Apply the PC to a vector.
applySymmetricLeft(x, y) Apply the left part of a symmetric PC to a vector.
applySymmetricRight(x, y) Apply the right part of a symmetric PC to a vector.
applyTranspose(x, y) Apply the transpose of the PC to a vector.
create([comm]) Create an empty PC.
createPython([context, comm]) Create a preconditioner of Python type.
destroy() Destroy the PC that was created with create.
getASMSubKSP() Return the local KSP object for all blocks on this process.
getCompositePC(n) Return a component of the composite PC.
getDM() Return the DM associated with the PC.
getDeflationCoarseKSP() Return the coarse problem KSP.
getDeflationPC() Return the additional preconditioner.
getFactorMatrix() Return the factored matrix.
getFactorSolverType() Return the solver package used to perform the factorization.
getFailedReason() Return the reason the PC terminated.
getFailedReasonRank() Return the reason the PC terminated on this rank.
getFieldSplitSchurGetSubKSP() Return the KSP for the Schur complement based splits.
getFieldSplitSubKSP() Return the KSP for all splits.
getHPDDMCoarseCorrectionType() Return the coarse correction type.
getHPDDMSTShareSubKSP() Return true if the KSP in SLEPc ST and the subdomain solver is shared.
getHYPREType() Return the Type.HYPRE type.
getKSP() Return the KSP if the PC is Type.KSP.
getMGCoarseSolve() Return the KSP used on the coarse grid.
getMGInterpolation(level) Return the interpolation operator for the given level.
getMGLevels() Return the number of MG levels.
getMGRScale(level) Return the pointwise scaling for the restriction operator on the given level.
getMGRestriction(level) Return the restriction operator for the given level.
getMGSmoother(level) Return the KSP to be used as a smoother.
getMGSmootherDown(level) Return the KSP to be used as a smoother before coarse grid correction.
getMGSmootherUp(level) Return the KSP to be used as a smoother after coarse grid correction.
getMGType() Return the form of multigrid.
getOperators() Return the matrices associated with a linear system.
getOptionsPrefix() Return the prefix used for all the PC options.
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 preconditioner.
getType() Return the preconditioner type.
getUseAmat() Return the flag to indicate if PC is applied to A or P.
matApply(x, y) Apply the PC to many vectors stored as Mat.Type.DENSE.
reset() Reset the PC, removing any allocated vectors and matrices.
setASMLocalSubdomains(nsd[, is_, is_local]) Set the local subdomains.
setASMOverlap(overlap) Set the overlap between a pair of subdomains.
setASMSortIndices(dosort) Set to sort subdomain indices.
setASMTotalSubdomains(nsd[, is_, is_local]) Set the subdomains for all processes.
setASMType(asmtype) Set the type of restriction and interpolation.
setBDDCChangeOfBasisMat(T[, interior]) Set a user defined change of basis for degrees of freedom.
setBDDCCoarseningRatio(cratio) Set the coarsening ratio used in the multilevel version.
setBDDCDirichletBoundaries(bndr) Set the IS defining Dirichlet boundaries for the global problem.
setBDDCDirichletBoundariesLocal(bndr) Set the IS defining Dirichlet boundaries in local ordering.
setBDDCDiscreteGradient(G[, order, field, ...]) Set the discrete gradient.
setBDDCDivergenceMat(div[, trans, l2l]) Set the linear operator representing ∫ div(u)•p dx.
setBDDCDofsSplitting(isfields) Set the index set(s) defining fields of the global matrix.
setBDDCDofsSplittingLocal(isfields) Set the index set(s) defining fields of the local subdomain matrix.
setBDDCLevels(levels) Set the maximum number of additional levels allowed.
setBDDCNeumannBoundaries(bndr) Set the IS defining Neumann boundaries for the global problem.
setBDDCNeumannBoundariesLocal(bndr) Set the IS defining Neumann boundaries in local ordering.
setBDDCPrimalVerticesIS(primv) Set additional user defined primal vertices.
setBDDCPrimalVerticesLocalIS(primv) Set additional user defined primal vertices.
setCompositeType(ctype) Set the type of composite preconditioner.
setCoordinates(coordinates) Set the coordinates for the nodes on the local process.
setDM(dm) Set the DM that may be used by some preconditioners.
setDeflationCoarseMat(mat) Set the coarse problem matrix.
setDeflationCorrectionFactor(fact) Set the coarse problem correction factor.
setDeflationInitOnly(flg) Set to only perform the initialization.
setDeflationLevels(levels) Set the maximum level of deflation nesting.
setDeflationProjectionNullSpaceMat(mat) Set the projection null space matrix.
setDeflationReductionFactor(red) Set the reduction factor for the preconditioner.
setDeflationSpace(W, transpose) Set the deflation space matrix or its (Hermitian) transpose.
setDeflationSpaceToCompute(space_type, size) Set the deflation space type.
setFactorLevels(levels) Set the number of levels of fill.
setFactorOrdering([ord_type, nzdiag, reuse]) Set options for the matrix factorization reordering.
setFactorPivot([zeropivot, inblocks]) Set options for matrix factorization pivoting.
setFactorSetUpSolverType() Set up the factorization solver.
setFactorShift([shift_type, amount]) Set options for shifting diagonal entries of a matrix.
setFactorSolverType(solver) Set the solver package used to perform the factorization.
setFailedReason(reason) Set the reason the PC terminated.
setFieldSplitFields(bsize, *fields) Sets the elements for the field split.
setFieldSplitIS(*fields) Set the elements for the field split by IS.
setFieldSplitSchurFactType(ctype) Set the type of approximate block factorization.
setFieldSplitSchurPreType(ptype[, pre]) Set from what operator the PC is constructed.
setFieldSplitType(ctype) Set the type of composition of a field split preconditioner.
setFromOptions() Set various PC parameters from user options.
setGAMGLevels(levels) Set the maximum number of levels.
setGAMGSmooths(smooths) Set the number of smoothing steps used on all levels.
setGAMGType(gamgtype) Set the type of algorithm.
setGASMOverlap(overlap) Set the overlap between a pair of subdomains.
setGASMType(gasmtype) Set the type of restriction and interpolation.
setHPDDMAuxiliaryMat(uis, uaux) Set the auxiliary matrix used by the preconditioner.
setHPDDMCoarseCorrectionType(correction_type) Set the coarse correction type.
setHPDDMDeflationMat(uis, U) Set the deflation space used to assemble a coarse operator.
setHPDDMHasNeumannMat(has) Set to indicate that the Mat passed to the PC is the local Neumann matrix.
setHPDDMRHSMat(B) Set the right-hand side matrix of the preconditioner.
setHYPREAMSSetInteriorNodes(interior) Set the list of interior nodes to a zero conductivity region.
setHYPREDiscreteCurl(mat) Set the discrete curl matrix.
setHYPREDiscreteGradient(mat) Set the discrete gradient matrix.
setHYPRESetAlphaPoissonMatrix(mat) Set the vector Poisson matrix.
setHYPRESetBetaPoissonMatrix([mat]) Set the Posson matrix.
setHYPRESetEdgeConstantVectors(ozz, zoz[, zzo]) Set the representation of the constant vector fields in the edge element basis.
setHYPRESetInterpolations(dim[, RT_Pi_Full, ...]) Set the interpolation matrices.
setHYPREType(hypretype) Set the Type.HYPRE type.
setMGCycleType(cycle_type) Set the type of cycles.
setMGCycleTypeOnLevel(level, cycle_type) Set the type of cycle on the given level.
setMGInterpolation(level, mat) Set the interpolation operator for the given level.
setMGLevels(levels) Set the number of MG levels.
setMGR(level, r) Set the vector where the residual is stored.
setMGRScale(level, rscale) Set the pointwise scaling for the restriction operator on the given level.
setMGRestriction(level, mat) Set the restriction operator for the given level.
setMGRhs(level, rhs) Set the vector where the right-hand side is stored.
setMGType(mgtype) Set the form of multigrid.
setMGX(level, x) Set the vector where the solution is stored.
setOperators([A, P]) Set the matrices associated with the linear system.
setOptionsPrefix(prefix) Set the prefix used for all the PC options.
setPatchCellNumbering(sec) Source code at petsc4py/PETSc/PC.pyx:2306
setPatchComputeFunction(function[, args, kargs]) Source code at petsc4py/PETSc/PC.pyx:2363
setPatchComputeFunctionInteriorFacets(function) Source code at petsc4py/PETSc/PC.pyx:2370
setPatchComputeOperator(operator[, args, kargs]) Source code at petsc4py/PETSc/PC.pyx:2349
setPatchComputeOperatorInteriorFacets(operator) Source code at petsc4py/PETSc/PC.pyx:2356
setPatchConstructType(typ[, operator, args, ...]) Source code at petsc4py/PETSc/PC.pyx:2377
setPatchDiscretisationInfo(dms, bs, ...) Source code at petsc4py/PETSc/PC.pyx:2309
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.
setReusePreconditioner(flag) Set to indicate the preconditioner is to be reused.
setSPAIBlockSize(n) Set the block size of the preconditioner.
setSPAICacheSize(size) Set the cache size.
setSPAIEpsilon(val) Set the tolerance for the preconditioner.
setSPAIMax(maxval) Set the size of working buffers in the preconditioner.
setSPAIMaxNew(maxval) Set the maximum number of new non-zero candidates per step.
setSPAINBSteps(nbsteps) Set the maximum number of improvement steps per row.
setSPAISp(sym) Set to specify a symmetric sparsity pattern.
setSPAIVerbose(level) Set the verbosity level.
setType(pc_type) Set the preconditioner type.
setUp() Set up the internal data structures for the PC.
setUpOnBlocks() Set up the PC for each block.
setUseAmat(flag) Set to indicate to apply PC to A and not P.
view([viewer]) View the PC object.

Methods Documentation

Add a PC of the given type to the composite PC.

Collective.

pc_type (Type | str) -- The type of the preconditioner to add.
None

SEE ALSO:

petsc.PCCompositeAddPCType


Source code at petsc4py/PETSc/PC.pyx:1631


Append to the prefix used for all the PC options.

Logically collective.

prefix (str) -- The prefix to append to the current prefix.
None

SEE ALSO:

Working with PETSc options (TODO), petsc.PCAppendOptionsPrefix


Source code at petsc4py/PETSc/PC.pyx:339


Apply the PC to a vector.

Collective.

  • x (Vec) -- The input vector.
  • y (Vec) -- The output vector, cannot be the same as x.

None

SEE ALSO:

petsc.PCApply


Source code at petsc4py/PETSc/PC.pyx:577


Apply the left part of a symmetric PC to a vector.

Collective.

  • x (Vec) -- The input vector.
  • y (Vec) -- The output vector, cannot be the same as x.

None

SEE ALSO:

petsc.PCApplySymmetricLeft


Source code at petsc4py/PETSc/PC.pyx:637


Apply the right part of a symmetric PC to a vector.

Collective.

  • x (Vec) -- The input vector.
  • y (Vec) -- The output vector, cannot be the same as x.

None

SEE ALSO:

petsc.PCApplySymmetricRight


Source code at petsc4py/PETSc/PC.pyx:656


Apply the transpose of the PC to a vector.

Collective.

For complex numbers this applies the non-Hermitian transpose.

  • x (Vec) -- The input vector.
  • y (Vec) -- The output vector, cannot be the same as x.

None

SEE ALSO:

petsc.PCApply


Source code at petsc4py/PETSc/PC.pyx:615


Create an empty PC.

Collective.

The default preconditioner for sparse matrices is ILU or ICC with 0 fill on one process and block Jacobi (BJACOBI) with ILU or ICC in parallel. For dense matrices it is always None.

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

SEE ALSO:

destroy, petsc.PCCreate


Source code at petsc4py/PETSc/PC.pyx:248


Create a preconditioner of Python type.

Collective.

  • context (Any) -- An instance of the Python class implementing the required methods.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

PETSc Python preconditioner type, setType, setPythonContext, PC.Type.PYTHON


Source code at petsc4py/PETSc/PC.pyx:738


Destroy the PC that was created with create.

Collective.

SEE ALSO:

petsc.PCDestroy


Source code at petsc4py/PETSc/PC.pyx:234



Return the local KSP object for all blocks on this process.

Not collective.

SEE ALSO:

petsc.PCASMGetSubKSP


Source code at petsc4py/PETSc/PC.pyx:942

list[KSP]


Return a component of the composite PC.

Not collective.

n (int) -- The index of the PC in the composition.
None

SEE ALSO:

petsc.PCCompositeGetPC


Source code at petsc4py/PETSc/PC.pyx:1610


Return the DM associated with the PC.

Not collective.

SEE ALSO:

petsc.PCGetDM


Source code at petsc4py/PETSc/PC.pyx:677



Return the coarse problem KSP.

Not collective.

SEE ALSO:

petsc.PCDeflationGetCoarseKSP


Source code at petsc4py/PETSc/PC.pyx:2784



Return the additional preconditioner.

SEE ALSO:

petsc.PCDeflationGetPC


Source code at petsc4py/PETSc/PC.pyx:2799



Return the factored matrix.

Not collective.

SEE ALSO:

petsc.PCFactorGetMatrix


Source code at petsc4py/PETSc/PC.pyx:1422



Return the solver package used to perform the factorization.

Not collective.

SEE ALSO:

petsc.PCFactorGetMatSolverType


Source code at petsc4py/PETSc/PC.pyx:1282



Return the reason the PC terminated.

Logically collective.

This is the maximum reason over all ranks in the PC communicator.

SEE ALSO:

petsc.PCGetFailedReason


Source code at petsc4py/PETSc/PC.pyx:504

FailedReason


Return the reason the PC terminated on this rank.

Not collective.

Different ranks may have different reasons.

SEE ALSO:

getFailedReason, petsc.PCGetFailedReasonRank


Source code at petsc4py/PETSc/PC.pyx:521

FailedReason


Return the KSP for the Schur complement based splits.

SEE ALSO:

petsc.PCFieldSplitSchurGetSubKSP, petsc.PCFieldSplitGetSubKSP


Source code at petsc4py/PETSc/PC.pyx:1529

list[KSP]


Return the KSP for all splits.

SEE ALSO:

petsc.PCFieldSplitGetSubKSP


Source code at petsc4py/PETSc/PC.pyx:1511

list[KSP]


Return the coarse correction type.

SEE ALSO:

petsc.PCHPDDMGetCoarseCorrectionType


Source code at petsc4py/PETSc/PC.pyx:2458

HPDDMCoarseCorrectionType


Return true if the KSP in SLEPc ST and the subdomain solver is shared.

SEE ALSO:

petsc.PCHPDDMGetSTShareSubKSP


Source code at petsc4py/PETSc/PC.pyx:2470



Return the Type.HYPRE type.

SEE ALSO:

petsc.PCHYPREGetType


Source code at petsc4py/PETSc/PC.pyx:1072



Return the KSP if the PC is Type.KSP.

Not collective.

SEE ALSO:

petsc.PCKSPGetKSP


Source code at petsc4py/PETSc/PC.pyx:1652


Return the KSP used on the coarse grid.

Not collective.

SEE ALSO:

petsc.PCMGGetCoarseSolve


Source code at petsc4py/PETSc/PC.pyx:1726



Return the interpolation operator for the given level.

Logically collective.

level (int) -- The level where interpolation is defined from level-1 to level.
Mat

SEE ALSO:

petsc.PCMGGetInterpolation


Source code at petsc4py/PETSc/PC.pyx:1761


Return the number of MG levels.

Not collective.

SEE ALSO:

petsc.PCMGGetLevels


Source code at petsc4py/PETSc/PC.pyx:1696



Return the pointwise scaling for the restriction operator on the given level.

Logically collective.

level (int) -- The level where restriction is defined from level to level-1.
Vec

SEE ALSO:

petsc.PCMGGetRScale


Source code at petsc4py/PETSc/PC.pyx:1843


Return the restriction operator for the given level.

Logically collective.

level (int) -- The level where restriction is defined from level to level-1.
Mat

SEE ALSO:

petsc.PCMGGetRestriction


Source code at petsc4py/PETSc/PC.pyx:1802


Return the KSP to be used as a smoother.

Not collective.

level (int) -- The level of the smoother.
KSP

SEE ALSO:

getMGSmootherDown, getMGSmootherUp, petsc.PCMGGetSmoother


Source code at petsc4py/PETSc/PC.pyx:1864


Return the KSP to be used as a smoother before coarse grid correction.

Not collective.

level (int) -- The level of the smoother.
KSP

SEE ALSO:

getMGSmoother, getMGSmootherUp, petsc.PCMGGetSmootherDown


Source code at petsc4py/PETSc/PC.pyx:1885


Return the KSP to be used as a smoother after coarse grid correction.

Not collective.

level (int) -- The level of the smoother.
KSP

SEE ALSO:

getMGSmootherDown, getMGSmoother, petsc.PCMGGetSmootherUp


Source code at petsc4py/PETSc/PC.pyx:1906


Return the form of multigrid.

Logically collective.

SEE ALSO:

petsc.PCMGGetType


Source code at petsc4py/PETSc/PC.pyx:1669

MGType


Return the matrices associated with a linear system.

Not collective.

SEE ALSO:

setOperators, petsc.PCGetOperators


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

tuple[Mat, Mat]


Return the prefix used for all the PC options.

Not collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.PCGetOptionsPrefix


Source code at petsc4py/PETSc/PC.pyx:325



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

Not collective.

SEE ALSO:

PETSc Python preconditioner type, setPythonContext


Source code at petsc4py/PETSc/PC.pyx:775



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

Not collective.

SEE ALSO:

PETSc Python preconditioner type, setPythonContext, setPythonType, petsc.PCPythonGetType


Source code at petsc4py/PETSc/PC.pyx:804



Return the preconditioner type.

Not collective.

SEE ALSO:

setType, petsc.PCGetType


Source code at petsc4py/PETSc/PC.pyx:292



Return the flag to indicate if PC is applied to A or P.

Logically collective.

flag -- True if A is used and False if P.
bool

SEE ALSO:

setUseAmat, petsc.PCGetUseAmat


Source code at petsc4py/PETSc/PC.pyx:442


Apply the PC to many vectors stored as Mat.Type.DENSE.

Collective.

  • x (Mat) -- The input matrix.
  • y (Mat) -- The output matrix, cannot be the same as x.

None

SEE ALSO:

petsc.PCMatApply, petsc.PCApply


Source code at petsc4py/PETSc/PC.pyx:596


Reset the PC, removing any allocated vectors and matrices.

Collective.

SEE ALSO:

petsc.PCReset


Source code at petsc4py/PETSc/PC.pyx:549



Set the local subdomains.

Collective.

  • nsd (int) -- The number of subdomains for this process.
  • is_ (Sequence[IS] | None) -- Defines the subdomains for this process or None to determine internally.
  • is_local (Sequence[IS] | None) -- Defines the local part of the subdomains for this process, only used for PC.ASMType.RESTRICT.

None

SEE ALSO:

setASMTotalSubdomains, petsc.PCASMSetLocalSubdomains


Source code at petsc4py/PETSc/PC.pyx:856


Set the overlap between a pair of subdomains.

Logically collective.

overlap (int) -- The amount of overlap between subdomains.
None

SEE ALSO:

petsc.PCASMSetOverlap


Source code at petsc4py/PETSc/PC.pyx:838


Set to sort subdomain indices.

Logically collective.

dosort (bool) -- Set to True to sort indices
None

SEE ALSO:

petsc.PCASMSetSortIndices


Source code at petsc4py/PETSc/PC.pyx:957


Set the subdomains for all processes.

Collective.

  • nsd (int) -- The number of subdomains for all processes.
  • is_ (Sequence[IS] | None) -- Defines the subdomains for all processes or None to determine internally.
  • is_local (Sequence[IS] | None) -- Defines the local part of the subdomains for this process, only used for PC.ASMType.RESTRICT.

None

SEE ALSO:

setASMLocalSubdomains, petsc.PCASMSetTotalSubdomains


Source code at petsc4py/PETSc/PC.pyx:899


Set the type of restriction and interpolation.

Logically collective.

asmtype (ASMType) -- The type of ASM you wish to use.
None

SEE ALSO:

petsc.PCASMSetType


Source code at petsc4py/PETSc/PC.pyx:820


Set a user defined change of basis for degrees of freedom.

Collective.

  • T (Mat) -- The matrix representing the change of basis.
  • interior (bool) -- Enable to indicate the change of basis affects interior degrees of freedom.

None

SEE ALSO:

petsc.PCBDDCSetChangeOfBasisMat


Source code at petsc4py/PETSc/PC.pyx:2097


Set the coarsening ratio used in the multilevel version.

Logically collective.

cratio (int) -- The coarsening ratio at the coarse level
None

SEE ALSO:

petsc.PCBDDCSetCoarseningRatio


Source code at petsc4py/PETSc/PC.pyx:2152


Set the IS defining Dirichlet boundaries for the global problem.

Collective.

bndr (IS) -- The parallel IS defining Dirichlet boundaries.
None

SEE ALSO:

petsc.PCBDDCSetDirichletBoundaries


Source code at petsc4py/PETSc/PC.pyx:2188


Set the IS defining Dirichlet boundaries in local ordering.

Collective.

bndr (IS) -- The parallel IS defining Dirichlet boundaries in local ordering.
None

SEE ALSO:

setBDDCDirichletBoundaries, petsc.PCBDDCSetDirichletBoundariesLocal


Source code at petsc4py/PETSc/PC.pyx:2205


Set the discrete gradient.

Collective.

  • G (Mat) -- The discrete gradient matrix in Mat.Type.AIJ format.
  • order (int) -- The order of the Nedelec space.
  • field (int) -- The field number of the Nedelec degrees of freedom. This is not used if no fields have been specified.
  • gord (bool) -- Enable to use global ordering in the rows of G.
  • conforming (bool) -- Enable if the mesh is conforming.

None

SEE ALSO:

petsc.PCBDDCSetDiscreteGradient


Source code at petsc4py/PETSc/PC.pyx:2061


Set the linear operator representing ∫ div(u)•p dx.

Collective.

  • div (Mat) -- The matrix in Mat.Type.IS format.
  • trans (bool) -- If True, the pressure/velocity is in the trial/test space respectively. If False the pressure/velocity is in the test/trial space.
  • l2l (IS | None) -- Optional IS describing the local to local map for velocities.

None

SEE ALSO:

petsc.PCBDDCSetDivergenceMat


Source code at petsc4py/PETSc/PC.pyx:2035


Set the index set(s) defining fields of the global matrix.

Collective.

isfields (IS | Sequence[IS]) -- The sequence of IS describing the fields in global ordering.
None

SEE ALSO:

petsc.PCBDDCSetDofsSplitting


Source code at petsc4py/PETSc/PC.pyx:2256


Set the index set(s) defining fields of the local subdomain matrix.

Collective.

Not all nodes need to be listed. Unlisted nodes will belong to the complement field.

isfields (IS | Sequence[IS]) -- The sequence of IS describing the fields in local ordering.

SEE ALSO:

petsc.PCBDDCSetDofsSplittingLocal


Source code at petsc4py/PETSc/PC.pyx:2279


Set the maximum number of additional levels allowed.

Logically collective.

levels (int) -- The maximum number of levels.
None

SEE ALSO:

petsc.PCBDDCSetLevels


Source code at petsc4py/PETSc/PC.pyx:2170


Set the IS defining Neumann boundaries for the global problem.

Collective.

bndr (IS) -- The parallel IS defining Neumann boundaries.
None

SEE ALSO:

petsc.PCBDDCSetNeumannBoundaries


Source code at petsc4py/PETSc/PC.pyx:2222


Set the IS defining Neumann boundaries in local ordering.

Collective.

bndr (IS) -- The parallel IS defining Neumann boundaries in local ordering.
None

SEE ALSO:

setBDDCNeumannBoundaries, petsc.PCBDDCSetNeumannBoundariesLocal


Source code at petsc4py/PETSc/PC.pyx:2239


Set additional user defined primal vertices.

Collective.

primv (IS) -- The IS of primal vertices in global numbering.
None

SEE ALSO:

petsc.PCBDDCSetPrimalVerticesIS


Source code at petsc4py/PETSc/PC.pyx:2118


Set additional user defined primal vertices.

Collective.

primv (IS) -- The IS of primal vertices in local numbering.
None

SEE ALSO:

petsc.PCBDDCSetPrimalVerticesLocalIS


Source code at petsc4py/PETSc/PC.pyx:2135


Set the type of composite preconditioner.

Logically collective.

ctype (CompositeType) -- The type of composition.
None

SEE ALSO:

petsc.PCCompositeSetType


Source code at petsc4py/PETSc/PC.pyx:1592


Set the coordinates for the nodes on the local process.

Collective.

coordinates (Sequence[Sequence[float]]) -- The two dimensional coordinate array.
None

SEE ALSO:

petsc.PCSetCoordinates


Source code at petsc4py/PETSc/PC.pyx:711


Set the DM that may be used by some preconditioners.

Logically collective.

dm (DM) -- The DM object.
None

SEE ALSO:

petsc.PCSetDM


Source code at petsc4py/PETSc/PC.pyx:694


Set the coarse problem matrix.

Collective.

mat (Mat) -- The coarse problem matrix.
None

SEE ALSO:

petsc.PCDeflationSetCoarseMat


Source code at petsc4py/PETSc/PC.pyx:2767


Set the coarse problem correction factor.

Logically collective.

fact (float) -- The correction factor.
None

SEE ALSO:

petsc.PCDeflationSetCorrectionFactor


Source code at petsc4py/PETSc/PC.pyx:2690


Set to only perform the initialization.

Logically collective.

Sets initial guess to the solution on the deflation space but does not apply the deflation preconditioner. The additional preconditioner is still applied.

flg (bool) -- Enable to only initialize the preconditioner.
None

SEE ALSO:

petsc.PCDeflationSetInitOnly


Source code at petsc4py/PETSc/PC.pyx:2632


Set the maximum level of deflation nesting.

Logically collective.

levels (int) -- The maximum deflation level.
None

SEE ALSO:

petsc.PCDeflationSetLevels


Source code at petsc4py/PETSc/PC.pyx:2654


Set the projection null space matrix.

Collective.

mat (Mat) -- The projection null space matrix.
None

SEE ALSO:

petsc.PCDeflationSetProjectionNullSpaceMat


Source code at petsc4py/PETSc/PC.pyx:2750


Set the reduction factor for the preconditioner.

Logically collective.

red (int) -- The reduction factor or DEFAULT.
None

SEE ALSO:

petsc.PCDeflationSetReductionFactor


Source code at petsc4py/PETSc/PC.pyx:2672


Set the deflation space matrix or its (Hermitian) transpose.

Logically collective.

  • W (Mat) -- The deflation matrix.
  • transpose (bool) -- Enable to indicate that W is an explicit transpose of the deflation matrix.

None

SEE ALSO:

petsc.PCDeflationSetSpace


Source code at petsc4py/PETSc/PC.pyx:2729


Set the deflation space type.

Logically collective.

  • space_type (DeflationSpaceType) -- The deflation space type.
  • size (int) -- The size of the space to compute

None

SEE ALSO:

petsc.PCDeflationSetSpaceToCompute


Source code at petsc4py/PETSc/PC.pyx:2708


Set the number of levels of fill.

Logically collective.

levels (int) -- The number of levels to fill.
None

SEE ALSO:

petsc.PCFactorSetLevels


Source code at petsc4py/PETSc/PC.pyx:1404


Set options for the matrix factorization reordering.

Logically collective.

  • ord_type (str | None) -- The name of the matrix ordering or None to leave unchanged.
  • nzdiag (float | None) -- Threshold to consider diagonal entries in the matrix as zero.
  • reuse (bool | None) -- Enable to reuse the ordering of a factored matrix.

None

SEE ALSO:

petsc.PCFactorSetMatOrderingType, petsc.PCFactorReorderForNonzeroDiagonal, petsc.PCFactorSetReuseOrdering


Source code at petsc4py/PETSc/PC.pyx:1310


Set options for matrix factorization pivoting.

Logically collective.

  • zeropivot (float | None) -- The size at which smaller pivots are treated as zero.
  • inblocks (bool | None) -- Enable to allow pivoting while factoring in blocks.

None

SEE ALSO:

petsc.PCFactorSetZeroPivot, petsc.PCFactorSetPivotInBlocks


Source code at petsc4py/PETSc/PC.pyx:1347


Set up the factorization solver.

This can be called after KSP.setOperators or PC.setOperators, causes petsc.MatGetFactor to be called so then one may set the options for that particular factorization object.

SEE ALSO:

Working with PETSc options (TODO), petsc.PCFactorSetUpMatSolverType


Source code at petsc4py/PETSc/PC.pyx:1296



Set options for shifting diagonal entries of a matrix.
  • shift_type (FactorShiftType | None) -- The type of shift, or None to leave unchanged.
  • amount (float | None) -- The amount of shift. Specify DEFAULT to determine internally or None to leave unchanged.

None

SEE ALSO:

petsc.PCFactorSetShiftType, petsc.PCFactorSetShiftAmount


Source code at petsc4py/PETSc/PC.pyx:1376


Set the solver package used to perform the factorization.

Logically collective.

solver (SolverType | str) -- The solver package used to factorize.
None

SEE ALSO:

petsc.PCFactorSetMatSolverType


Source code at petsc4py/PETSc/PC.pyx:1263


Set the reason the PC terminated.

Logically collective.

reason (FailedReason | str) -- the reason the PC terminated
None

SEE ALSO:

petsc.PCSetFailedReason


Source code at petsc4py/PETSc/PC.pyx:486


Sets the elements for the field split.
  • bsize (int) -- The block size
  • fields (Tuple[str, Sequence[int]]) -- A sequence of tuples containing the split name and a sequence of integers that define the elements in the split.

None

SEE ALSO:

petsc.PCFieldSplitSetBlockSize, petsc.PCFieldSplitSetFields


Source code at petsc4py/PETSc/PC.pyx:1483


Set the elements for the field split by IS.

Logically collective.

Solve options for this split will be available under the prefix -fieldsplit_SPLITNAME_*.

fields (Tuple[str, IS]) -- A sequence of tuples containing the split name and the IS that defines the elements in the split.
None

SEE ALSO:

Working with PETSc options (TODO), petsc.PCFieldSplitSetIS


Source code at petsc4py/PETSc/PC.pyx:1457


Set the type of approximate block factorization.

Collective.

ctype (FieldSplitSchurFactType) -- The type indicating which blocks to retain.
None

SEE ALSO:

petsc.PCFieldSplitSetSchurFactType


Source code at petsc4py/PETSc/PC.pyx:1547


Set from what operator the PC is constructed.

Collective.

  • ptype (FieldSplitSchurPreType) -- The type of matrix to use for preconditioning the Schur complement.
  • pre (Mat | None) -- The optional matrix to use for preconditioning.

None

SEE ALSO:

petsc.PCFieldSplitSetSchurPre


Source code at petsc4py/PETSc/PC.pyx:1565


Set the type of composition of a field split preconditioner.

Collective.

ctype (CompositeType) -- The type of composition.
None

SEE ALSO:

petsc.PCFieldSplitSetType


Source code at petsc4py/PETSc/PC.pyx:1439


Set various PC parameters from user options.

Collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.PCSetFromOptions


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



Set the maximum number of levels.

Not collective.

levels (int) -- The maximum number of levels to use.
None

SEE ALSO:

petsc.PCGAMGSetNlevels


Source code at petsc4py/PETSc/PC.pyx:1034


Set the number of smoothing steps used on all levels.

Logically collective.

smooths (int) -- The maximum number of smooths.
None

SEE ALSO:

petsc.PCGAMGSetNSmooths


Source code at petsc4py/PETSc/PC.pyx:1052


Set the type of algorithm.

Collective.

gamgtype (GAMGType | str) -- The type of GAMG
None

SEE ALSO:

petsc.PCGAMGSetType


Source code at petsc4py/PETSc/PC.pyx:1015


Set the overlap between a pair of subdomains.

Logically collective.

overlap (int) -- The amount of overlap between subdomains.
None

SEE ALSO:

petsc.PCGASMSetOverlap


Source code at petsc4py/PETSc/PC.pyx:995


Set the type of restriction and interpolation.

Logically collective.

gasmtype (GASMType) -- The type of GASM.
None

SEE ALSO:

petsc.PCGASMSetType


Source code at petsc4py/PETSc/PC.pyx:977


Set the auxiliary matrix used by the preconditioner.
  • uis (IS) -- The IS of the local auxiliary matrix
  • uaux (Mat) -- The auxiliary sequential matrix

None

SEE ALSO:

petsc.PCHPDDMSetAuxiliaryMat


Source code at petsc4py/PETSc/PC.pyx:2392


Set the coarse correction type.

Collective.

correction_type (HPDDMCoarseCorrectionType) -- The type of coarse correction to apply.
None

SEE ALSO:

petsc.PCHPDDMSetCoarseCorrectionType


Source code at petsc4py/PETSc/PC.pyx:2440


Set the deflation space used to assemble a coarse operator.
  • uis (IS) -- The IS of the local deflation matrix.
  • U (Mat) -- The deflation sequential matrix of type Mat.Type.DENSE.


SEE ALSO:

petsc.PCHPDDMSetDeflationMat


Source code at petsc4py/PETSc/PC.pyx:2482


Set to indicate that the Mat passed to the PC is the local Neumann matrix.
has (bool) -- Enable to indicate the matrix is the local Neumann matrix.
None

SEE ALSO:

petsc.PCHPDDMHasNeumannMat


Source code at petsc4py/PETSc/PC.pyx:2424


Set the right-hand side matrix of the preconditioner.
B (Mat) -- The right-hand side sequential matrix.
None

SEE ALSO:

petsc.PCHPDDMSetRHSMat


Source code at petsc4py/PETSc/PC.pyx:2409


Set the list of interior nodes to a zero conductivity region.

Collective.

interior (Vec) -- A vector where a value of 1.0 indicates an interior node.
None

SEE ALSO:

petsc.PCHYPREAMSSetInteriorNodes


Source code at petsc4py/PETSc/PC.pyx:1244


Set the discrete curl matrix.

Collective.

mat (Mat) -- The discrete curl.
None

SEE ALSO:

petsc.PCHYPRESetDiscreteCurl


Source code at petsc4py/PETSc/PC.pyx:1102


Set the discrete gradient matrix.

Collective.

mat (Mat) -- The discrete gradient.
None

SEE ALSO:

petsc.PCHYPRESetDiscreteGradient


Source code at petsc4py/PETSc/PC.pyx:1119


Set the vector Poisson matrix.

Collective.

mat (Mat) -- The vector Poisson matrix.
None

SEE ALSO:

petsc.PCHYPRESetAlphaPoissonMatrix


Source code at petsc4py/PETSc/PC.pyx:1136


Set the Posson matrix.

Collective.

mat (Mat | None) -- The Poisson matrix or None to turn off.
None

SEE ALSO:

petsc.PCHYPRESetBetaPoissonMatrix


Source code at petsc4py/PETSc/PC.pyx:1153


Set the representation of the constant vector fields in the edge element basis.

Collective.

  • ozz (Vec) -- A vector representing [1,0,0] or [1,0] in 2D.
  • zoz (Vec) -- A vector representing [0,1,0] or [0,1] in 2D.
  • zzo (Vec | None) -- A vector representing [0,0,1] or None in 2D.

None

SEE ALSO:

petsc.PCHYPRESetEdgeConstantVectors


Source code at petsc4py/PETSc/PC.pyx:1220


Set the interpolation matrices.

Collective.

  • dim (int) -- The dimension of the problem.
  • RT_Pi_Full (Mat | None) -- The Raviart-Thomas interpolation matrix or None to omit.
  • RT_Pi -- The xyz components of the Raviart-Thomas interpolation matrix, or None to omit.
  • ND_Pi_Full (Mat | None) -- The Nedelec interpolation matrix or None to omit.
  • ND_Pi -- The xyz components of the Nedelec interpolation matrix, or None to omit.

None

SEE ALSO:

petsc.PCHYPRESetInterpolations


Source code at petsc4py/PETSc/PC.pyx:1172


Set the Type.HYPRE type.
hypretype (str) -- The name of the type, one of "euclid", "pilut", "parasails", "boomeramg", "ams", "ads"

SEE ALSO:

petsc.PCHYPRESetType


Source code at petsc4py/PETSc/PC.pyx:1084


Set the type of cycles.
cycle_type (MGCycleType) -- The type of multigrid cycles to use.
None

SEE ALSO:

setMGCycleTypeOnLevel, petsc.PCMGSetCycleType


Source code at petsc4py/PETSc/PC.pyx:1927


Set the type of cycle on the given level.

Logically collective.

  • level (int) -- The level on which to set the cycle type.
  • cycle_type (MGCycleType) -- The type of multigrid cycles to use.

None

SEE ALSO:

setMGCycleType, petsc.PCMGSetCycleTypeOnLevel


Source code at petsc4py/PETSc/PC.pyx:1943


Set the interpolation operator for the given level.

Logically collective.

  • level -- The level where interpolation is defined from level-1 to level.
  • mat (Mat) -- The interpolation operator

None

SEE ALSO:

petsc.PCMGSetInterpolation


Source code at petsc4py/PETSc/PC.pyx:1741


Set the number of MG levels.
levels (int) -- The number of levels
None

SEE ALSO:

petsc.PCMGSetLevels


Source code at petsc4py/PETSc/PC.pyx:1710


Set the vector where the residual is stored.

Logically collective.

If not provided, one will be set internally. Will be cleaned up in destroy.

  • level (int) -- The level on which to set the residual.
  • r (Vec) -- The vector where the residual is stored.

None

SEE ALSO:

petsc.PCMGSetR


Source code at petsc4py/PETSc/PC.pyx:2010


Set the pointwise scaling for the restriction operator on the given level.

Logically collective.

  • level (int) -- The level where restriction is defined from level to level-1.
  • rscale (Vec) -- The scaling vector.

None

SEE ALSO:

petsc.PCMGSetRScale


Source code at petsc4py/PETSc/PC.pyx:1823


Set the restriction operator for the given level.

Logically collective.

  • level (int) -- The level where restriction is defined from level to level-1.
  • mat (Mat) -- The restriction operator

None

SEE ALSO:

petsc.PCMGSetRestriction


Source code at petsc4py/PETSc/PC.pyx:1782


Set the vector where the right-hand side is stored.

Logically collective.

If not provided, one will be set internally. Will be cleaned up in destroy.

  • level (int) -- The level on which to set the right-hand side.
  • rhs (Vec) -- The vector where the right-hand side is stored.

None

SEE ALSO:

petsc.PCMGSetRhs


Source code at petsc4py/PETSc/PC.pyx:1964


Set the form of multigrid.

Logically collective.

SEE ALSO:

petsc.PCMGSetType


Source code at petsc4py/PETSc/PC.pyx:1683

mgtype (MGType) --


Set the vector where the solution is stored.

Logically collective.

If not provided, one will be set internally. Will be cleaned up in destroy.

  • level (int) -- The level on which to set the solution.
  • x (Vec) -- The vector where the solution is stored.

None

SEE ALSO:

petsc.PCMGSetX


Source code at petsc4py/PETSc/PC.pyx:1987


Set the matrices associated with the linear system.

Logically collective.

Passing None for A or P removes the matrix that is currently used. PETSc does not reset the matrix entries of either A or P to zero after a linear solve; the user is completely responsible for matrix assembly. See Mat.zeroEntries to zero all elements of a matrix.

  • A (Mat | None) -- the matrix which defines the linear system
  • P (Mat | None) -- the matrix to be used in constructing the preconditioner, usually the same as A

None

SEE ALSO:

petsc.PCSetOperators


Source code at petsc4py/PETSc/PC.pyx:370


Set the prefix used for all the PC options.

Logically collective.

prefix (str) -- The prefix to prepend to all option names.
None

SEE ALSO:

Working with PETSc options (TODO), petsc.PCSetOptionsPrefix


Source code at petsc4py/PETSc/PC.pyx:306


Source code at petsc4py/PETSc/PC.pyx:2306
sec (Section) --


Source code at petsc4py/PETSc/PC.pyx:2363


Source code at petsc4py/PETSc/PC.pyx:2349


Source code at petsc4py/PETSc/PC.pyx:2377


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

Not collective.

SEE ALSO:

PETSc Python preconditioner type, getPythonContext


Source code at petsc4py/PETSc/PC.pyx:763

context (Any) --
None


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

Collective.

SEE ALSO:

PETSc Python preconditioner type, setPythonContext, getPythonType, petsc.PCPythonSetType


Source code at petsc4py/PETSc/PC.pyx:790

py_type (str) --
None


Set to indicate the preconditioner is to be reused.

Logically collective.

Normally if the A matrix inside a PC changes, the PC automatically updates itself using information from the changed matrix. Enable this option prevents this.

flag (bool) -- Set to True to use the reuse the current preconditioner and False to recompute on changes to the matrix.
None

SEE ALSO:

setOperators, petsc.PCSetReusePreconditioner


Source code at petsc4py/PETSc/PC.pyx:461


Set the block size of the preconditioner.
n (int) -- The block size, defaults to 1.
None

SEE ALSO:

petsc.PCSPAISetBlockSize


Source code at petsc4py/PETSc/PC.pyx:2566


Set the cache size.
size (int) -- The size of the cache, defaults to 5.
None

SEE ALSO:

petsc.PCSPAISetCacheSize


Source code at petsc4py/PETSc/PC.pyx:2582


Set the tolerance for the preconditioner.
val (float) -- The tolerance, defaults to 0.4.
None

SEE ALSO:

petsc.PCSPAISetEpsilon


Source code at petsc4py/PETSc/PC.pyx:2501


Set the size of working buffers in the preconditioner.
maxval (int) -- Number of entries in the work arrays to be allocated, defaults to 5000.
None

SEE ALSO:

petsc.PCSPAISetMax


Source code at petsc4py/PETSc/PC.pyx:2533


Set the maximum number of new non-zero candidates per step.
maxval (int) -- Number of entries allowed, defaults to 5.
None

SEE ALSO:

petsc.PCSPAISetMaxNew


Source code at petsc4py/PETSc/PC.pyx:2550


Set the maximum number of improvement steps per row.
nbsteps (int) -- The number of steps, defaults to 5.
None

SEE ALSO:

petsc.PCSPAISetNBSteps


Source code at petsc4py/PETSc/PC.pyx:2517


Set to specify a symmetric sparsity pattern.
sym (int) -- Enable to indicate the matrix is symmetric.
None

SEE ALSO:

petsc.PCSPAISetSp


Source code at petsc4py/PETSc/PC.pyx:2614


Set the verbosity level.
level (int) -- The level of verbosity, defaults to 1.
None

SEE ALSO:

petsc.PCSPAISetVerbose


Source code at petsc4py/PETSc/PC.pyx:2598


Set the preconditioner type.

Collective.

pc_type (Type | str) -- The preconditioner type.
None

SEE ALSO:

Working with PETSc options (TODO), getType, petsc.TSSetType


Source code at petsc4py/PETSc/PC.pyx:273


Set up the internal data structures for the PC.

Collective.

SEE ALSO:

petsc.PCSetUp


Source code at petsc4py/PETSc/PC.pyx:537



Set up the PC for each block.

Collective.

For nested preconditioners such as BJACOBI, setUp is not called on each sub-KSP when setUp is called on the outer PC. This routine ensures it is called.

SEE ALSO:

setUp, petsc.PCSetUpOnBlocks


Source code at petsc4py/PETSc/PC.pyx:561



Set to indicate to apply PC to A and not P.

Logically collective.

Sets a flag to indicate that when the preconditioner needs to apply (part of) the operator during the preconditioning process, it applies to A provided to TS.setRHSJacobian, TS.setIJacobian, SNES.setJacobian, KSP.setOperators or PC.setOperators not the P.

flag (bool) -- Set True to use A and False to use P.
None

SEE ALSO:

setOperators, petsc.PCSetUseAmat


Source code at petsc4py/PETSc/PC.pyx:416


View the PC object.

Collective.

viewer (Viewer | None) -- The visualization context.
None

SEE ALSO:

petsc.PCView


Source code at petsc4py/PETSc/PC.pyx:215




petsc4py.PETSc.Partitioner

Bases: Object

A graph partitioner.

Enumerations

Type

petsc4py.PETSc.Partitioner.Type

Bases: object

Attributes Summary

CHACO Object CHACO of type str
GATHER Object GATHER of type str
MATPARTITIONING Object MATPARTITIONING of type str
PARMETIS Object PARMETIS of type str
PTSCOTCH Object PTSCOTCH of type str
SHELL Object SHELL of type str
SIMPLE Object SIMPLE of type str

Attributes Documentation

Object CHACO of type str

Object GATHER of type str

Object MATPARTITIONING of type str

Object PARMETIS of type str

Object PTSCOTCH of type str

Object SHELL of type str

Object SIMPLE of type str


Methods Summary

create([comm]) Create an empty partitioner object.
destroy() Destroy the partitioner object.
getType() Return the partitioner type.
reset() Reset data structures of the partitioner.
setFromOptions() Set parameters in the partitioner from the options database.
setShellPartition(numProcs[, sizes, points]) Set a custom partition for a mesh.
setType(part_type) Build a particular type of the partitioner.
setUp() Construct data structures for the partitioner.
view([viewer]) View the partitioner.

Methods Documentation

Create an empty partitioner object.

Collective.

The type can be set with setType.

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

SEE ALSO:

setType, petsc.PetscPartitionerCreate


Source code at petsc4py/PETSc/Partitioner.pyx:55


Destroy the partitioner object.

Collective.

SEE ALSO:

petsc.PetscPartitionerDestroy


Source code at petsc4py/PETSc/Partitioner.pyx:42



Return the partitioner type.

Not collective.

SEE ALSO:

setType, petsc.PetscPartitionerGetType


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



Reset data structures of the partitioner.

Collective.

SEE ALSO:

petsc.PetscPartitionerReset


Source code at petsc4py/PETSc/Partitioner.pyx:135



Set parameters in the partitioner from the options database.

Collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.PetscPartitionerSetFromOptions


Source code at petsc4py/PETSc/Partitioner.pyx:111



Set a custom partition for a mesh.

Collective.

  • sizes (Sequence[int] | None) -- The number of points in each partition.
  • points (Sequence[int] | None) -- A permutation of the points that groups those assigned to each partition in order (i.e., partition 0 first, partition 1 next, etc.).
  • numProcs (int) --

None

SEE ALSO:

petsc.PetscPartitionerShellSetPartition


Source code at petsc4py/PETSc/Partitioner.pyx:147


Build a particular type of the partitioner.

Collective.

part_type (Type | str) -- The kind of partitioner.
None

SEE ALSO:

getType, petsc.PetscPartitionerSetType


Source code at petsc4py/PETSc/Partitioner.pyx:78


Construct data structures for the partitioner.

Collective.

SEE ALSO:

petsc.PetscPartitionerSetUp


Source code at petsc4py/PETSc/Partitioner.pyx:123



View the partitioner.

Collective.

viewer (Viewer | None) -- A Viewer to display the graph.
None

SEE ALSO:

petsc.PetscPartitionerView


Source code at petsc4py/PETSc/Partitioner.pyx:23




petsc4py.PETSc.Quad

Bases: Object

Quadrature rule for integration.

Methods Summary

create([comm]) Create a Quad object.
destroy() Destroy the Quad object.
duplicate() Create a deep copy of the Quad object.
getData() Return the data defining the Quad.
getNumComponents() Return the number of components for functions to be integrated.
getOrder() Return the order of the method in the Quad.
setNumComponents(nc) Return the number of components for functions to be integrated.
setOrder(order) Set the order of the method in the Quad.
view([viewer]) View a Quad object.

Methods Documentation

Create a Quad object.

Collective.

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

SEE ALSO:

petsc.PetscQuadratureCreate


Source code at petsc4py/PETSc/DT.pyx:28


Destroy the Quad object.

Collective.

SEE ALSO:

petsc.PetscQuadratureDestroy


Source code at petsc4py/PETSc/DT.pyx:63



Create a deep copy of the Quad object.

Collective.

SEE ALSO:

petsc.PetscQuadratureDuplicate


Source code at petsc4py/PETSc/DT.pyx:49



Return the data defining the Quad.

Not collective.

  • points (ArrayReal) -- The coordinates of the quadrature points.
  • weights (ArrayReal) -- The quadrature weights.

tuple(ArrayReal, ArrayReal)

SEE ALSO:

petsc.PetscQuadratureGetData


Source code at petsc4py/PETSc/DT.pyx:76


Return the number of components for functions to be integrated.

Not collective.

SEE ALSO:

setNumComponents, petsc.PetscQuadratureGetNumComponents


Source code at petsc4py/PETSc/DT.pyx:104



Return the order of the method in the Quad.

Not collective.

SEE ALSO:

setOrder, petsc.PetscQuadratureGetOrder


Source code at petsc4py/PETSc/DT.pyx:136



Return the number of components for functions to be integrated.

Not collective.

nc (int) -- The number of components.
None

SEE ALSO:

getNumComponents, petsc.PetscQuadratureSetNumComponents


Source code at petsc4py/PETSc/DT.pyx:118


Set the order of the method in the Quad.

Not collective.

order (int) -- The order of the quadrature, i.e. the highest degree polynomial that is exactly integrated.
None

SEE ALSO:

getOrder, petsc.PetscQuadratureSetOrder


Source code at petsc4py/PETSc/DT.pyx:150


View a Quad object.

Collective.

viewer (Viewer | None) -- A Viewer to display the graph.
None

SEE ALSO:

petsc.PetscQuadratureView


Source code at petsc4py/PETSc/DT.pyx:9



petsc4py.PETSc.Random

Bases: Object

The random number generator object.

SEE ALSO:

petsc.PetscRandom


Enumerations

Type The random number generator type.

petsc4py.PETSc.Random.Type

Bases: object

The random number generator type.

Attributes Summary

RAND Object RAND of type str
RAND48 Object RAND48 of type str
RANDER48 Object RANDER48 of type str
RANDOM123 Object RANDOM123 of type str
SPRNG Object SPRNG of type str

Attributes Documentation

Object RAND of type str

Object RAND48 of type str

Object RANDER48 of type str

Object RANDOM123 of type str

Object SPRNG of type str


Methods Summary

create([comm]) Create a random number generator object.
destroy() Destroy the random number generator object.
getInterval() Return the interval containing the random numbers generated.
getSeed() Return the random number generator seed.
getType() Return the type of the random number generator object.
getValue() Generate a scalar random number.
getValueReal() Generate a real random number.
setFromOptions() Configure the random number generator from the options database.
setInterval(interval) Set the interval of the random number generator.
setSeed([seed]) Set the seed of random number generator.
setType(rnd_type) Set the type of the random number generator object.
view([viewer]) View a random number generator object.

Attributes Summary

interval The interval of the generated random numbers.
seed The seed of the random number generator.

Methods Documentation

Create a random number generator object.

Collective.

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

SEE ALSO:

Sys.getDefaultComm, petsc.PetscRandomCreate


Source code at petsc4py/PETSc/Random.pyx:73


Destroy the random number generator object.

Collective.

SEE ALSO:

petsc.PetscRandomDestroy


Source code at petsc4py/PETSc/Random.pyx:60



Return the interval containing the random numbers generated.

Not collective.

SEE ALSO:

setInterval, petsc.PetscRandomGetInterval


Source code at petsc4py/PETSc/Random.pyx:198

tuple[Scalar, Scalar]


Return the random number generator seed.

Not collective.

SEE ALSO:

setSeed, petsc.PetscRandomGetSeed


Source code at petsc4py/PETSc/Random.pyx:165



Return the type of the random number generator object.

Not collective.

SEE ALSO:

setType, petsc.PetscRandomGetType


Source code at petsc4py/PETSc/Random.pyx:111



Generate a scalar random number.

Not collective.

SEE ALSO:

petsc.PetscRandomGetValue


Source code at petsc4py/PETSc/Random.pyx:137

Scalar


Generate a real random number.

Not collective.

SEE ALSO:

petsc.PetscRandomGetValueReal


Source code at petsc4py/PETSc/Random.pyx:151

float


Configure the random number generator from the options database.

Collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.PetscRandomSetFromOptions


Source code at petsc4py/PETSc/Random.pyx:125



Set the interval of the random number generator.

Not collective.

SEE ALSO:

getInterval, petsc.PetscRandomSetInterval


Source code at petsc4py/PETSc/Random.pyx:213

interval (tuple[Scalar, Scalar]) --
None


Set the seed of random number generator.

Not collective.

seed (int | None) -- The value for the seed. If None, it only seeds the generator.
None

SEE ALSO:

getSeed, petsc.PetscRandomSetSeed, petsc.PetscRandomSeed


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


Set the type of the random number generator object.

Collective.

rnd_type (Type | str) -- The type of the generator.
None

SEE ALSO:

getType, petsc.PetscRandomSetType


Source code at petsc4py/PETSc/Random.pyx:92


View a random number generator object.

Collective.

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

SEE ALSO:

petsc.PetscRandomView


Source code at petsc4py/PETSc/Random.pyx:40


Attributes Documentation

The interval of the generated random numbers.

Source code at petsc4py/PETSc/Random.pyx:239


The seed of the random number generator.

Source code at petsc4py/PETSc/Random.pyx:232




petsc4py.PETSc.SF

Bases: Object

Star Forest object for communication.

SF is used for setting up and managing the communication of certain entries of arrays and Vec between MPI processes.

Enumerations

Type

petsc4py.PETSc.SF.Type

Bases: object

Attributes Summary

ALLGATHER Object ALLGATHER of type str
ALLGATHERV Object ALLGATHERV of type str
ALLTOALL Object ALLTOALL of type str
BASIC Object BASIC of type str
GATHER Object GATHER of type str
GATHERV Object GATHERV of type str
NEIGHBOR Object NEIGHBOR of type str
WINDOW Object WINDOW of type str

Attributes Documentation

Object ALLGATHER of type str

Object ALLGATHERV of type str

Object ALLTOALL of type str

Object BASIC of type str

Object GATHER of type str

Object GATHERV of type str

Object NEIGHBOR of type str

Object WINDOW of type str


Methods Summary

bcastBegin(unit, rootdata, leafdata, op) Begin pointwise broadcast.
bcastEnd(unit, rootdata, leafdata, op) End a broadcast & reduce operation started with bcastBegin.
compose(sf) Compose a new SF.
computeDegree() Compute and return the degree of each root vertex.
create([comm]) Create a star forest communication context.
createEmbeddedLeafSF(selected) Remove edges from all but the selected leaves.
createEmbeddedRootSF(selected) Remove edges from all but the selected roots.
createInverse() Create the inverse map.
createSectionSF(rootSection, remoteOffsets, ...) Create an expanded SF of DOFs.
destroy() Destroy the star forest.
distributeSection(rootSection[, leafSection]) Create a new, reorganized Section.
fetchAndOpBegin(unit, rootdata, leafdata, ...) Begin fetch and update operation.
fetchAndOpEnd(unit, rootdata, leafdata, ...) End operation started in a matching call to fetchAndOpBegin.
gatherBegin(unit, leafdata, multirootdata) Begin pointwise gather of all leaves into multi-roots.
gatherEnd(unit, leafdata, multirootdata) End gather operation that was started with gatherBegin.
getGraph() Return star forest graph.
getMulti() Return the inner SF implementing gathers and scatters.
getType() Return the type name of the star forest.
reduceBegin(unit, leafdata, rootdata, op) Begin reduction of leafdata into rootdata.
reduceEnd(unit, leafdata, rootdata, op) End a reduction operation started with reduceBegin.
reset() Reset a star forest so that different sizes or neighbors can be used.
scatterBegin(unit, multirootdata, leafdata) Begin pointwise scatter operation.
scatterEnd(unit, multirootdata, leafdata) End scatter operation that was started with scatterBegin.
setFromOptions() Set options using the options database.
setGraph(nroots, local, remote) Set star forest graph.
setRankOrder(flag) Sort multi-points for gathers and scatters by rank order.
setType(sf_type) Set the type of the star forest.
setUp() Set up communication structures.
view([viewer]) View a star forest.

Methods Documentation

Begin pointwise broadcast.

Collective.

Root values are reduced to leaf values. This call has to be concluded with a call to bcastEnd.

  • unit (Datatype) -- MPI datatype.
  • rootdata (ndarray) -- Buffer to broadcast.
  • leafdata (ndarray) -- Buffer to be reduced with values from each leaf's respective root.
  • op (Op) -- MPI reduction operation.

None

SEE ALSO:

bcastEnd, petsc.PetscSFBcastBegin


Source code at petsc4py/PETSc/SF.pyx:436


End a broadcast & reduce operation started with bcastBegin.

Collective.

  • unit (Datatype) -- MPI datatype.
  • rootdata (ndarray) -- Buffer to broadcast.
  • leafdata (ndarray) -- Buffer to be reduced with values from each leaf's respective root.
  • op (Op) -- MPI reduction operation.

None

SEE ALSO:

bcastBegin, petsc.PetscSFBcastEnd


Source code at petsc4py/PETSc/SF.pyx:465


Compose a new SF.

Collective.

Puts the sf under this object in a top (roots) down (leaves) view.

sf (SF) -- SF to put under this object.
SF

SEE ALSO:

petsc.PetscSFCompose


Source code at petsc4py/PETSc/SF.pyx:415


Compute and return the degree of each root vertex.

Collective.

SEE ALSO:

petsc.PetscSFComputeDegreeBegin, petsc.PetscSFComputeDegreeEnd


Source code at petsc4py/PETSc/SF.pyx:281

ArrayInt


Create a star forest communication context.

Collective.

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

SEE ALSO:

petsc.PetscSFCreate


Source code at petsc4py/PETSc/SF.pyx:65


Remove edges from all but the selected leaves.

Collective.

Does not remap indices.

selected (Sequence[int]) -- Indices of the selected roots on this process.
SF

SEE ALSO:

petsc.PetscSFCreateEmbeddedLeafSF


Source code at petsc4py/PETSc/SF.pyx:323


Remove edges from all but the selected roots.

Collective.

Does not remap indices.

selected (Sequence[int]) -- Indices of the selected roots on this process.
SF

SEE ALSO:

petsc.PetscSFCreateEmbeddedRootSF


Source code at petsc4py/PETSc/SF.pyx:299


Create the inverse map.

Collective.

Create the inverse map given a PetscSF in which all vertices have degree 1.

SEE ALSO:

petsc.PetscSFCreateInverseSF


Source code at petsc4py/PETSc/SF.pyx:264



Create an expanded SF of DOFs.

Collective.

Assumes the input SF relates points.

  • rootSection (Section) -- Data layout of remote points for outgoing data (this is usually the serial section).
  • remoteOffsets (Sequence[int] | None) -- Offsets for point data on remote processes (these are offsets from the root section), or None.
  • leafSection (Section) -- Data layout of local points for incoming data (this is the distributed section).

SF

SEE ALSO:

petsc.PetscSFCreateSectionSF


Source code at petsc4py/PETSc/SF.pyx:347


Destroy the star forest.

Collective.

SEE ALSO:

petsc.PetscSFDestroy


Source code at petsc4py/PETSc/SF.pyx:52



Create a new, reorganized Section.

Collective.

Moves from the root to the leaves of the SF.

  • rootSection (Section) -- Section defined on root space.
  • leafSection (Section | None) -- Section defined on the leaf space.

tuple[ArrayInt, Section]

SEE ALSO:

petsc.PetscSFDistributeSection


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


Begin fetch and update operation.

Collective.

This operation fetches values from root and updates atomically by applying an operation using the leaf value.

This call has to be completed with fetchAndOpEnd.

  • unit (Datatype) -- MPI datatype.
  • rootdata (ndarray) -- Root values to be updated, input state is seen by first process to perform an update.
  • leafdata (ndarray) -- Leaf values to use in reduction.
  • leafupdate (ndarray) -- State at each leaf's respective root immediately prior to my atomic update.
  • op (Op) -- MPI reduction operation.

None

SEE ALSO:

fetchAndOpEnd, petsc.PetscSFFetchAndOpBegin


Source code at petsc4py/PETSc/SF.pyx:644


End operation started in a matching call to fetchAndOpBegin.

Collective.

  • unit (Datatype) -- MPI datatype.
  • rootdata (ndarray) -- Root values to be updated, input state is seen by first process to perform an update.
  • leafdata (ndarray) -- Leaf values to use in reduction.
  • leafupdate (ndarray) -- State at each leaf's respective root immediately prior to my atomic update.
  • op (Op) -- MPI reduction operation.

None

SEE ALSO:

fetchAndOpBegin, petsc.PetscSFFetchAndOpEnd


Source code at petsc4py/PETSc/SF.pyx:680


Begin pointwise gather of all leaves into multi-roots.

Collective.

This call has to be completed with gatherEnd.

  • unit (Datatype) -- MPI datatype.
  • leafdata (ndarray) -- Leaf data to gather to roots.
  • multirootdata (ndarray) -- Root buffer to gather into, amount of space per root is equal to its degree.

None

SEE ALSO:

gatherEnd, petsc.PetscSFGatherBegin


Source code at petsc4py/PETSc/SF.pyx:594


End gather operation that was started with gatherBegin.

Collective.

  • unit (Datatype) -- MPI datatype.
  • leafdata (ndarray) -- Leaf data to gather to roots.
  • multirootdata (ndarray) -- Root buffer to gather into, amount of space per root is equal to its degree.

None

SEE ALSO:

gatherBegin, petsc.PetscSFGatherEnd


Source code at petsc4py/PETSc/SF.pyx:620


Return star forest graph.

Not collective.

The number of leaves can be determined from the size of ilocal.

  • nroots (int) -- Number of root vertices on the current process (these are possible targets for other process to attach leaves).
  • ilocal (ArrayInt) -- Locations of leaves in leafdata buffers.
  • iremote (ArrayInt) -- Remote locations of root vertices for each leaf on the current process.

tuple[int, ArrayInt, ArrayInt]

SEE ALSO:

petsc.PetscSFGetGraph


Source code at petsc4py/PETSc/SF.pyx:157


Return the inner SF implementing gathers and scatters.

Collective.

SEE ALSO:

petsc.PetscSFGetMultiSF


Source code at petsc4py/PETSc/SF.pyx:249



Return the type name of the star forest.

Collective.

SEE ALSO:

petsc.PetscSFGetType


Source code at petsc4py/PETSc/SF.pyx:105



Begin reduction of leafdata into rootdata.

Collective.

This call has to be completed with call to reduceEnd.

  • unit (Datatype) -- MPI datatype.
  • leafdata (ndarray) -- Values to reduce.
  • rootdata (ndarray) -- Result of reduction of values from all leaves of each root.
  • op (Op) -- MPI reduction operation.

None

SEE ALSO:

reduceEnd, petsc.PetscSFReduceBegin


Source code at petsc4py/PETSc/SF.pyx:491


End a reduction operation started with reduceBegin.

Collective.

  • unit (Datatype) -- MPI datatype.
  • leafdata (ndarray) -- Values to reduce.
  • rootdata (ndarray) -- Result of reduction of values from all leaves of each root.
  • op (Op) -- MPI reduction operation.

None

SEE ALSO:

reduceBegin, petsc.PetscSFReduceEnd


Source code at petsc4py/PETSc/SF.pyx:519


Reset a star forest so that different sizes or neighbors can be used.

Collective.

SEE ALSO:

petsc.PetscSFReset


Source code at petsc4py/PETSc/SF.pyx:143



Begin pointwise scatter operation.

Collective.

Operation is from multi-roots to leaves. This call has to be completed with scatterEnd.

  • unit (Datatype) -- MPI datatype.
  • multirootdata (ndarray) -- Root buffer to send to each leaf, one unit of data per leaf.
  • leafdata (ndarray) -- Leaf data to be updated with personal data from each respective root.

None

SEE ALSO:

scatterEnd, petsc.PetscSFScatterBegin


Source code at petsc4py/PETSc/SF.pyx:545


End scatter operation that was started with scatterBegin.

Collective.

  • unit (Datatype) -- MPI datatype.
  • multirootdata (ndarray) -- Root buffer to send to each leaf, one unit of data per leaf.
  • leafdata (ndarray) -- Leaf data to be updated with personal data from each respective root.

None

SEE ALSO:

scatterBegin, petsc.PetscSFScatterEnd


Source code at petsc4py/PETSc/SF.pyx:571


Set options using the options database.

Logically collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.PetscSFSetFromOptions


Source code at petsc4py/PETSc/SF.pyx:119



Set star forest graph.

Collective.

The number of leaves argument can be determined from the size of local and/or remote.

  • nroots (int) -- Number of root vertices on the current process (these are possible targets for other process to attach leaves).
  • local (Sequence[int]) -- Locations of leaves in leafdata buffers, pass None for contiguous storage.
  • remote (Sequence[int]) -- Remote locations of root vertices for each leaf on the current process. Should be 2*nleaves long as (rank, index) pairs.

None

SEE ALSO:

petsc.PetscSFSetGraph


Source code at petsc4py/PETSc/SF.pyx:192


Sort multi-points for gathers and scatters by rank order.

Logically collective.

flag (bool) -- True to sort, False to skip sorting.
None

SEE ALSO:

petsc.PetscSFSetRankOrder


Source code at petsc4py/PETSc/SF.pyx:231


Set the type of the star forest.

Collective.

sf_type (Type | str) -- The star forest type.
None

SEE ALSO:

petsc.PetscSFSetType


Source code at petsc4py/PETSc/SF.pyx:86


Set up communication structures.

Collective.

SEE ALSO:

petsc.PetscSFSetUp


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



View a star forest.

Collective.

viewer (Viewer | None) -- A Viewer to display the graph.
None

SEE ALSO:

petsc.PetscSFView


Source code at petsc4py/PETSc/SF.pyx:33




petsc4py.PETSc.SNES

Bases: Object

Nonlinear equations solver.

SNES is described in the PETSc manual.

SEE ALSO:

petsc.SNES


Enumerations

ConvergedReason SNES solver termination reason.
NormSchedule SNES norm schedule.
Type SNES solver type.

petsc4py.PETSc.SNES.ConvergedReason

Bases: object

SNES solver termination reason.

SEE ALSO:

petsc.SNESGetConvergedReason


Attributes Summary

CONVERGED_FNORM_ABS Constant CONVERGED_FNORM_ABS of type int
CONVERGED_FNORM_RELATIVE Constant CONVERGED_FNORM_RELATIVE of type int
CONVERGED_ITERATING Constant CONVERGED_ITERATING of type int
CONVERGED_ITS Constant CONVERGED_ITS of type int
CONVERGED_SNORM_RELATIVE Constant CONVERGED_SNORM_RELATIVE of type int
DIVERGED_DTOL Constant DIVERGED_DTOL of type int
DIVERGED_FNORM_NAN Constant DIVERGED_FNORM_NAN of type int
DIVERGED_FUNCTION_COUNT Constant DIVERGED_FUNCTION_COUNT of type int
DIVERGED_FUNCTION_DOMAIN Constant DIVERGED_FUNCTION_DOMAIN of type int
DIVERGED_INNER Constant DIVERGED_INNER of type int
DIVERGED_JACOBIAN_DOMAIN Constant DIVERGED_JACOBIAN_DOMAIN of type int
DIVERGED_LINEAR_SOLVE Constant DIVERGED_LINEAR_SOLVE of type int
DIVERGED_LINE_SEARCH Constant DIVERGED_LINE_SEARCH of type int
DIVERGED_LOCAL_MIN Constant DIVERGED_LOCAL_MIN of type int
DIVERGED_MAX_IT Constant DIVERGED_MAX_IT of type int
DIVERGED_TR_DELTA Constant DIVERGED_TR_DELTA of type int
ITERATING Constant ITERATING of type int

Attributes Documentation

Constant CONVERGED_FNORM_ABS of type int

Constant CONVERGED_FNORM_RELATIVE of type int

Constant CONVERGED_ITERATING of type int

Constant CONVERGED_ITS of type int

Constant CONVERGED_SNORM_RELATIVE of type int

Constant DIVERGED_DTOL of type int

Constant DIVERGED_FNORM_NAN of type int

Constant DIVERGED_FUNCTION_COUNT of type int

Constant DIVERGED_FUNCTION_DOMAIN of type int

Constant DIVERGED_INNER of type int

Constant DIVERGED_JACOBIAN_DOMAIN of type int

Constant DIVERGED_LINEAR_SOLVE of type int

Constant DIVERGED_LINE_SEARCH of type int

Constant DIVERGED_LOCAL_MIN of type int

Constant DIVERGED_MAX_IT of type int

Constant DIVERGED_TR_DELTA of type int

Constant ITERATING of type int


petsc4py.PETSc.SNES.NormSchedule

Bases: object

SNES norm schedule.

SEE ALSO:

petsc.SNESNormSchedule


Attributes Summary

ALWAYS Constant ALWAYS of type int
DEFAULT Constant DEFAULT of type int
FINAL_ONLY Constant FINAL_ONLY of type int
INITIAL_FINAL_ONLY Constant INITIAL_FINAL_ONLY of type int
INITIAL_ONLY Constant INITIAL_ONLY of type int
NONE Constant NONE of type int
NORM_ALWAYS Constant NORM_ALWAYS of type int
NORM_DEFAULT Constant NORM_DEFAULT of type int
NORM_FINAL_ONLY Constant NORM_FINAL_ONLY of type int
NORM_INITIAL_FINAL_ONLY Constant NORM_INITIAL_FINAL_ONLY of type int
NORM_INITIAL_ONLY Constant NORM_INITIAL_ONLY of type int
NORM_NONE Constant NORM_NONE of type int

Attributes Documentation

Constant ALWAYS of type int

Constant DEFAULT of type int

Constant FINAL_ONLY of type int

Constant INITIAL_FINAL_ONLY of type int

Constant INITIAL_ONLY of type int

Constant NONE of type int

Constant NORM_ALWAYS of type int

Constant NORM_DEFAULT of type int

Constant NORM_FINAL_ONLY of type int

Constant NORM_INITIAL_FINAL_ONLY of type int

Constant NORM_INITIAL_ONLY of type int

Constant NORM_NONE of type int


petsc4py.PETSc.SNES.Type

Bases: object

SNES solver type.

SEE ALSO:

petsc.SNESType


Attributes Summary

ANDERSON Object ANDERSON of type str
ASPIN Object ASPIN of type str
COMPOSITE Object COMPOSITE of type str
FAS Object FAS of type str
KSPONLY Object KSPONLY of type str
KSPTRANSPOSEONLY Object KSPTRANSPOSEONLY of type str
MS Object MS of type str
NASM Object NASM of type str
NCG Object NCG of type str
NEWTONLS Object NEWTONLS of type str
NEWTONTR Object NEWTONTR of type str
NGMRES Object NGMRES of type str
NGS Object NGS of type str
NRICHARDSON Object NRICHARDSON of type str
PATCH Object PATCH of type str
PYTHON Object PYTHON of type str
QN Object QN of type str
SHELL Object SHELL of type str
VINEWTONRSLS Object VINEWTONRSLS of type str
VINEWTONSSLS Object VINEWTONSSLS of type str

Attributes Documentation

Object ANDERSON of type str

Object ASPIN of type str

Object COMPOSITE of type str

Object FAS of type str

Object KSPONLY of type str

Object KSPTRANSPOSEONLY of type str

Object MS of type str

Object NASM of type str

Object NCG of type str

Object NEWTONLS of type str

Object NEWTONTR of type str

Object NGMRES of type str

Object NGS of type str

Object NRICHARDSON of type str

Object PATCH of type str

Object PYTHON of type str

Object QN of type str

Object SHELL of type str

Object VINEWTONRSLS of type str

Object VINEWTONSSLS of type str


Methods Summary

appendOptionsPrefix(prefix) Append to the prefix used for searching for options in the database.
callConvergenceTest(its, xnorm, ynorm, fnorm) Compute the convergence test.
computeFunction(x, f) Compute the function.
computeJacobian(x, J[, P]) Compute the Jacobian.
computeNGS(x[, b]) Compute a nonlinear Gauss-Seidel step.
computeObjective(x) Compute the value of the objective function.
converged(its, xnorm, ynorm, fnorm) Compute the convergence test and update the solver converged reason.
create([comm]) Create a SNES solver.
createPython([context, comm]) Create a nonlinear solver of Python type.
destroy() Destroy the solver.
getApplicationContext() Return the application context.
getCompositeNumber() Return the number of solvers in the composite.
getCompositeSNES(n) Return the n-th solver in the composite.
getConvergedReason() Return the termination flag.
getConvergenceHistory() Return the convergence history.
getConvergenceTest() Return the callback to used as convergence test.
getDM() Return the DM associated with the solver.
getErrorIfNotConverged() Return the flag indicating error on divergence.
getFASCoarseSolve() Return the SNES used at the coarsest level of the FAS hierarchy.
getFASCycleSNES(level) Return the SNES corresponding to a particular level of the FAS hierarchy.
getFASInjection(level) Return the Mat used to apply the injection from level-1 to level.
getFASInterpolation(level) Return the Mat used to apply the interpolation from level-1 to level.
getFASLevels() Return the number of levels used.
getFASRestriction(level) Return the Mat used to apply the restriction from level-1 to level.
getFASSmoother(level) Return the smoother used at a given level of the FAS hierarchy.
getFASSmootherDown(level) Return the downsmoother used at a given level of the FAS hierarchy.
getFASSmootherUp(level) Return the upsmoother used at a given level of the FAS hierarchy.
getFunction() Return the callback to compute the nonlinear function.
getFunctionEvaluations() Return the current number of function evaluations.
getFunctionNorm() Return the function norm.
getInitialGuess() Return the callback to compute the initial guess.
getIterationNumber() Return the current iteration number.
getJacobian() Return the matrices used to compute the Jacobian and the callback tuple.
getKSP() Return the linear solver used by the nonlinear solver.
getKSPFailures() Return the current number of linear solve failures.
getLinearSolveIterations() Return the total number of linear iterations.
getMaxFunctionEvaluations() Return the maximum allowed number of function evaluations.
getMaxKSPFailures() Return the maximum allowed number of linear solve failures.
getMaxStepFailures() Return the maximum allowed number of step failures.
getMonitor() Return the callback used to monitor solver convergence.
getNASMNumber() Return the number of solvers in NASM.
getNASMSNES(n) Return the n-th solver in NASM.
getNGS() Return the nonlinear Gauss-Seidel callback tuple.
getNPC() Return the nonlinear preconditioner associated with the solver.
getNPCSide() Return the nonlinear preconditioning side.
getNormSchedule() Return the norm schedule.
getObjective() Return the objective callback tuple.
getOptionsPrefix() Return the prefix used for searching for options in the database.
getParamsEW() Get the parameters of the Eisenstat and Walker trick.
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 solver.
getRhs() Return the vector holding the right-hand side.
getSolution() Return the vector holding the solution.
getSolutionUpdate() Return the vector holding the solution update.
getStepFailures() Return the current number of step failures.
getTolerances() Return the tolerance parameters used in the solver convergence tests.
getType() Return the type of the solver.
getUpdate() Return the callback to compute the update at the beginning of each step.
getUseEW() Return the flag indicating if the solver uses the Eisenstat-Walker trick.
getUseFD() Return true if the solver uses color finite-differencing for the Jacobian.
getUseMF() Return the flag indicating if the solver uses matrix-free finite-differencing.
getVIInactiveSet() Return the index set for the inactive set.
hasNPC() Return a boolean indicating whether the solver has a nonlinear preconditioner.
logConvergenceHistory(norm[, linear_its]) Log residual norm and linear iterations.
monitor(its, rnorm) Monitor the solver.
monitorCancel() Cancel all the monitors of the solver.
reset() Reset the solver.
setApplicationContext(appctx) Set the application context.
setConvergedReason(reason) Set the termination flag.
setConvergenceHistory([length, reset]) Set the convergence history.
setConvergenceTest(converged[, args, kargs]) Set the callback to use as convergence test.
setDM(dm) Associate a DM with the solver.
setErrorIfNotConverged(flag) Immediately generate an error if the solver has not converged.
setFASInjection(level, mat) Set the Mat to be used to apply the injection from level-1 to level.
setFASInterpolation(level, mat) Set the Mat to be used to apply the interpolation from level-1 to level.
setFASLevels(levels[, comms]) Set the number of levels to use with FAS.
setFASRScale(level, vec) Set the scaling factor of the restriction operator from level to level-1.
setFASRestriction(level, mat) Set the Mat to be used to apply the restriction from level-1 to level.
setForceIteration(force) Force solve to take at least one iteration.
setFromOptions() Configure the solver from the options database.
setFunction(function[, f, args, kargs]) Set the callback to compute the nonlinear function.
setFunctionNorm(norm) Set the function norm value.
setInitialGuess(initialguess[, args, kargs]) Set the callback to compute the initial guess.
setIterationNumber(its) Set the current iteration number.
setJacobian(jacobian[, J, P, args, kargs]) Set the callback to compute the Jacobian.
setKSP(ksp) Set the linear solver that will be used by the nonlinear solver.
setLineSearchPreCheck(precheck[, args, kargs]) Set the callback that will be called before applying the linesearch.
setMaxFunctionEvaluations(max_funcs) Set the maximum allowed number of function evaluations.
setMaxKSPFailures(max_fails) Set the maximum allowed number of linear solve failures.
setMaxStepFailures(max_fails) Set the maximum allowed number of step failures.
setMonitor(monitor[, args, kargs]) Set the callback used to monitor solver convergence.
setNGS(ngs[, args, kargs]) Set the callback to compute nonlinear Gauss-Seidel.
setNPC(snes) Set the nonlinear preconditioner.
setNPCSide(side) Set the nonlinear preconditioning side.
setNormSchedule(normsched) Set the norm schedule.
setObjective(objective[, args, kargs]) Set the callback to compute the objective function.
setOptionsPrefix(prefix) Set the prefix used for searching for options in the database.
setParamsEW([version, rtol_0, rtol_max, ...]) Set the parameters for the Eisenstat and Walker trick.
setPatchCellNumbering(sec) Set cell patch numbering.
setPatchComputeFunction(function[, args, kargs]) Set patch compute function.
setPatchComputeOperator(operator[, args, kargs]) Set patch compute operator.
setPatchConstructType(typ[, operator, args, ...]) Set patch construct type.
setPatchDiscretisationInfo(dms, bs, ...) Set patch discretisation information.
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.
setResetCounters([reset]) Set the flag to reset the counters.
setSolution(vec) Set the vector used to store the solution.
setTolerances([rtol, atol, stol, max_it]) Set the tolerance parameters used in the solver convergence tests.
setType(snes_type) Set the type of the solver.
setUp() Set up the internal data structures for using the solver.
setUpMatrices() Ensures that matrices are available for Newton-like methods.
setUpdate(update[, args, kargs]) Set the callback to compute update at the beginning of each step.
setUseEW([flag]) Tell the solver to use the Eisenstat-Walker trick.
setUseFD([flag]) Set the boolean flag to use coloring finite-differencing for Jacobian assembly.
setUseMF([flag]) Set the boolean flag indicating to use matrix-free finite-differencing.
setVariableBounds(xl, xu) Set the vector for the variable bounds.
solve([b, x]) Solve the nonlinear equations.
view([viewer]) View the solver.

Attributes Summary

appctx Application context.
atol Absolute residual tolerance.
dm DM.
history Convergence history.
is_converged Boolean indicating if the solver has converged.
is_diverged Boolean indicating if the solver has failed.
is_iterating Boolean indicating if the solver has not converged yet.
its Number of iterations.
ksp Linear solver.
max_funcs Maximum number of function evaluations.
max_it Maximum number of iterations.
norm Function norm.
npc Nonlinear preconditioner.
reason Converged reason.
rtol Relative residual tolerance.
stol Solution update tolerance.
use_ew
use_fd Boolean indicating if the solver uses coloring finite-differencing.
use_mf Boolean indicating if the solver uses matrix-free finite-differencing.
vec_rhs Right-hand side vector.
vec_sol Solution vector.
vec_upd Update vector.

Methods Documentation

Append to the prefix used for searching for options in the database.

Logically collective.

SEE ALSO:

Working with PETSc options (TODO), setOptionsPrefix, petsc.SNESAppendOptionsPrefix


Source code at petsc4py/PETSc/SNES.pyx:224

prefix (str) --
None


Compute the convergence test.

Collective.

  • its (int) -- Iteration number.
  • xnorm (float) -- Solution norm.
  • ynorm (float) -- Update norm.
  • fnorm (float) -- Function norm.

ConvergedReason

SEE ALSO:

setConvergenceTest, getConvergenceTest


Source code at petsc4py/PETSc/SNES.pyx:1159


Compute the function.

Collective.

  • x (Vec) -- The input state vector.
  • f (Vec) -- The output vector.

None

SEE ALSO:

setFunction, petsc.SNESComputeFunction


Source code at petsc4py/PETSc/SNES.pyx:903


Compute the Jacobian.

Collective.

  • x (Vec) -- The input state vector.
  • J (Mat) -- The output Jacobian matrix.
  • P (Mat | None) -- The output Jacobian matrix used to construct the preconditioner.

None

SEE ALSO:

setJacobian, petsc.SNESComputeJacobian


Source code at petsc4py/PETSc/SNES.pyx:922


Compute a nonlinear Gauss-Seidel step.

Collective.

  • x (Vec) -- The input/output state vector.
  • b (Vec | None) -- The input right-hand side vector.

None

SEE ALSO:

setNGS, getNGS, petsc.SNESComputeNGS


Source code at petsc4py/PETSc/SNES.pyx:1005


Compute the value of the objective function.

Collective.

x (Vec) -- The input state vector.
float

SEE ALSO:

setObjective, petsc.SNESComputeObjective


Source code at petsc4py/PETSc/SNES.pyx:945


Compute the convergence test and update the solver converged reason.

Collective.

  • its (int) -- Iteration number.
  • xnorm (float) -- Solution norm.
  • ynorm (float) -- Update norm.
  • fnorm (float) -- Function norm.

None

SEE ALSO:

setConvergenceTest, getConvergenceTest, petsc.SNESConverged


Source code at petsc4py/PETSc/SNES.pyx:1189


Create a SNES solver.

Collective.

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

SEE ALSO:

Sys.getDefaultComm, petsc.SNESCreate


Source code at petsc4py/PETSc/SNES.pyx:142


Create a nonlinear solver of Python type.

Collective.

  • context (Any) -- An instance of the Python class implementing the required methods.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

PETSc Python nonlinear solver type (TODO), setType, setPythonContext, Type.PYTHON


Source code at petsc4py/PETSc/SNES.pyx:1983


Destroy the solver.

Collective.

SEE ALSO:

petsc.SNESDestroy


Source code at petsc4py/PETSc/SNES.pyx:129



Return the application context.

Source code at petsc4py/PETSc/SNES.pyx:261



Return the number of solvers in the composite.

Not collective.

SEE ALSO:

getCompositeSNES, petsc.SNESCompositeGetNumber, petsc.SNESCOMPOSITE


Source code at petsc4py/PETSc/SNES.pyx:2084



Return the n-th solver in the composite.

Not collective.

SEE ALSO:

getCompositeNumber, petsc.SNESCompositeGetSNES, petsc.SNESCOMPOSITE


Source code at petsc4py/PETSc/SNES.pyx:2067

n (int) --
SNES


Return the termination flag.

Not collective.

SEE ALSO:

setConvergedReason, petsc.SNESGetConvergedReason


Source code at petsc4py/PETSc/SNES.pyx:1570

ConvergedReason


Return the convergence history.

Not collective.

SEE ALSO:

petsc.SNESGetConvergenceHistory


Source code at petsc4py/PETSc/SNES.pyx:1241

tuple[ArrayReal, ArrayInt]


Return the callback to used as convergence test.

Not collective.

SEE ALSO:

setConvergenceTest, callConvergenceTest


Source code at petsc4py/PETSc/SNES.pyx:1147

SNESConvergedFunction


Return the DM associated with the solver.

Not collective.

SEE ALSO:

setDM, petsc.SNESGetDM


Source code at petsc4py/PETSc/SNES.pyx:276



Return the flag indicating error on divergence.

Not collective.

SEE ALSO:

setErrorIfNotConverged, petsc.SNESGetErrorIfNotConverged


Source code at petsc4py/PETSc/SNES.pyx:1597



Return the SNES used at the coarsest level of the FAS hierarchy.

Not collective.

SEE ALSO:

getFASSmoother, petsc.SNESFASGetCoarseSolve, petsc.SNESFAS


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



Return the SNES corresponding to a particular level of the FAS hierarchy.

Not collective.

SEE ALSO:

setFASLevels, getFASCoarseSolve, getFASSmoother, petsc.SNESFASGetCycleSNES, petsc.SNESFAS


Source code at petsc4py/PETSc/SNES.pyx:458

level (int) --
SNES


Return the Mat used to apply the injection from level-1 to level.

Not collective.

SEE ALSO:

setFASInjection, petsc.SNESFASGetInjection, petsc.SNESFAS


Source code at petsc4py/PETSc/SNES.pyx:381

level (int) --
Mat


Return the Mat used to apply the interpolation from level-1 to level.

Not collective.

SEE ALSO:

setFASInterpolation, petsc.SNESFASGetInterpolation, petsc.SNESFAS


Source code at petsc4py/PETSc/SNES.pyx:321

level (int) --
Mat


Return the number of levels used.

Not collective.

SEE ALSO:

setFASLevels, petsc.SNESFASGetLevels, petsc.SNESFAS


Source code at petsc4py/PETSc/SNES.pyx:444



Return the Mat used to apply the restriction from level-1 to level.

Not collective.

SEE ALSO:

setFASRestriction, petsc.SNESFASGetRestriction, petsc.SNESFAS


Source code at petsc4py/PETSc/SNES.pyx:351

level (int) --
Mat


Return the smoother used at a given level of the FAS hierarchy.

Not collective.

SEE ALSO:

setFASLevels, getFASCoarseSolve, getFASSmootherDown, getFASSmootherUp, petsc.SNESFASGetSmoother, petsc.SNESFAS


Source code at petsc4py/PETSc/SNES.pyx:490

level (int) --
SNES


Return the downsmoother used at a given level of the FAS hierarchy.

Not collective.

SEE ALSO:

setFASLevels, getFASCoarseSolve, getFASSmoother, getFASSmootherUp, petsc.SNESFASGetSmootherDown, petsc.SNESFAS


Source code at petsc4py/PETSc/SNES.pyx:507

level (int) --
SNES


Return the upsmoother used at a given level of the FAS hierarchy.

Not collective.

SEE ALSO:

setFASLevels, getFASCoarseSolve, getFASSmoother, getFASSmootherDown, petsc.SNESFASGetSmootherUp, petsc.SNESFAS


Source code at petsc4py/PETSc/SNES.pyx:524

level (int) --
SNES


Return the callback to compute the nonlinear function.

Not collective.

SEE ALSO:

setFunction, petsc.SNESGetFunction


Source code at petsc4py/PETSc/SNES.pyx:723

SNESFunction


Return the current number of function evaluations.

Not collective.

SEE ALSO:

setMaxFunctionEvaluations, petsc.SNESGetNumberFunctionEvals


Source code at petsc4py/PETSc/SNES.pyx:1391



Return the function norm.

Not collective.

SEE ALSO:

setFunctionNorm, petsc.SNESGetFunctionNorm


Source code at petsc4py/PETSc/SNES.pyx:1668

float


Return the callback to compute the initial guess.

Not collective.

SEE ALSO:

setInitialGuess


Source code at petsc4py/PETSc/SNES.pyx:677

SNESGuessFunction


Return the current iteration number.

Not collective.

SEE ALSO:

setIterationNumber, petsc.SNESGetIterationNumber


Source code at petsc4py/PETSc/SNES.pyx:1626



Return the matrices used to compute the Jacobian and the callback tuple.

Not collective.

  • J (Mat) -- The matrix to store the Jacobian.
  • P (Mat) -- The matrix to construct the preconditioner.
  • callback (SNESJacobianFunction) -- callback, positional and keyword arguments.

tuple[Mat, Mat, SNESJacobianFunction]

SEE ALSO:

setJacobian, petsc.SNESGetJacobian


Source code at petsc4py/PETSc/SNES.pyx:832


Return the linear solver used by the nonlinear solver.

Not collective.

SEE ALSO:

setKSP, petsc.SNESGetKSP


Source code at petsc4py/PETSc/SNES.pyx:1767



Return the current number of linear solve failures.

Not collective.

SEE ALSO:

getMaxKSPFailures, petsc.SNESGetLinearSolveFailures


Source code at petsc4py/PETSc/SNES.pyx:1473



Return the total number of linear iterations.

Not collective.

SEE ALSO:

petsc.SNESGetLinearSolveIterations


Source code at petsc4py/PETSc/SNES.pyx:1682



Return the maximum allowed number of function evaluations.

Not collective.

SEE ALSO:

setMaxFunctionEvaluations, petsc.SNESSetTolerances


Source code at petsc4py/PETSc/SNES.pyx:1375



Return the maximum allowed number of linear solve failures.

Not collective.

SEE ALSO:

setMaxKSPFailures, petsc.SNESGetMaxLinearSolveFailures


Source code at petsc4py/PETSc/SNES.pyx:1459



Return the maximum allowed number of step failures.

Not collective.

SEE ALSO:

setMaxStepFailures, petsc.SNESGetMaxNonlinearStepFailures


Source code at petsc4py/PETSc/SNES.pyx:1418



Return the callback used to monitor solver convergence.

Not collective.

SEE ALSO:

setMonitor


Source code at petsc4py/PETSc/SNES.pyx:1310

list[tuple[SNESMonitorFunction, tuple[Any, ...], dict[str, Any]]]


Return the number of solvers in NASM.

Not collective.

SEE ALSO:

getNASMSNES, petsc.SNESNASMGetNumber, petsc.SNESNASM


Source code at petsc4py/PETSc/SNES.pyx:2116



Return the n-th solver in NASM.

Not collective.

SEE ALSO:

getNASMNumber, petsc.SNESNASMGetSNES, petsc.SNESNASM


Source code at petsc4py/PETSc/SNES.pyx:2100

n (int) --
SNES


Return the nonlinear Gauss-Seidel callback tuple.

Not collective.

SEE ALSO:

setNGS, computeNGS


Source code at petsc4py/PETSc/SNES.pyx:991

SNESNGSFunction


Return the nonlinear preconditioner associated with the solver.

Not collective.

SEE ALSO:

setNPC, hasNPC, setNPCSide, getNPCSide, petsc.SNESGetNPC


Source code at petsc4py/PETSc/SNES.pyx:543



Return the nonlinear preconditioning side.

Not collective.

SEE ALSO:

setNPC, getNPC, hasNPC, setNPCSide, petsc.SNESGetNPCSide


Source code at petsc4py/PETSc/SNES.pyx:596



Return the norm schedule.

Not collective.

SEE ALSO:

setNormSchedule, petsc.SNESGetNormSchedule


Source code at petsc4py/PETSc/SNES.pyx:1098

NormSchedule


Return the objective callback tuple.

Not collective.

SEE ALSO:

setObjective


Source code at petsc4py/PETSc/SNES.pyx:889

SNESObjFunction


Return the prefix used for searching for options in the database.

Not collective.

SEE ALSO:

Working with PETSc options (TODO), setOptionsPrefix, petsc.SNESGetOptionsPrefix


Source code at petsc4py/PETSc/SNES.pyx:210



Get the parameters of the Eisenstat and Walker trick.

Not collective.

SEE ALSO:

setUseEW, setParamsEW, petsc.SNESKSPGetParametersEW


Source code at petsc4py/PETSc/SNES.pyx:1871

dict[str, int | float]


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

Not collective.

SEE ALSO:

PETSc Python nonlinear solver type (TODO), setPythonContext


Source code at petsc4py/PETSc/SNES.pyx:2020



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

Not collective.

SEE ALSO:

PETSc Python nonlinear solver type (TODO), setPythonContext, setPythonType, petsc.SNESPythonGetType


Source code at petsc4py/PETSc/SNES.pyx:2050



Return the vector holding the right-hand side.

Not collective.

SEE ALSO:

petsc.SNESGetRhs


Source code at petsc4py/PETSc/SNES.pyx:1696



Return the vector holding the solution.

Not collective.

SEE ALSO:

setSolution, petsc.SNESGetSolution


Source code at petsc4py/PETSc/SNES.pyx:1711



Return the vector holding the solution update.

Not collective.

SEE ALSO:

petsc.SNESGetSolutionUpdate


Source code at petsc4py/PETSc/SNES.pyx:1738



Return the current number of step failures.

Not collective.

SEE ALSO:

getMaxStepFailures, petsc.SNESGetNonlinearStepFailures


Source code at petsc4py/PETSc/SNES.pyx:1432



Return the tolerance parameters used in the solver convergence tests.

Collective.

  • rtol (float) -- The relative norm of the residual.
  • atol (float) -- The absolute norm of the residual.
  • stol (float) -- The absolute norm of the step.
  • max_it (int) -- The maximum allowed number of iterations.

tuple[float, float, float, int]

SEE ALSO:

setTolerances, petsc.SNESGetTolerances


Source code at petsc4py/PETSc/SNES.pyx:1059


Return the type of the solver.

Not collective.

SEE ALSO:

setType, petsc.SNESGetType


Source code at petsc4py/PETSc/SNES.pyx:182



Return the callback to compute the update at the beginning of each step.

Not collective.

SEE ALSO:

setUpdate


Source code at petsc4py/PETSc/SNES.pyx:783

SNESUpdateFunction


Return the flag indicating if the solver uses the Eisenstat-Walker trick.

Not Collective.

SEE ALSO:

setUseEW, setParamsEW, petsc.SNESKSPGetUseEW


Source code at petsc4py/PETSc/SNES.pyx:1805



Return true if the solver uses color finite-differencing for the Jacobian.

Not collective.

SEE ALSO:

setUseFD


Source code at petsc4py/PETSc/SNES.pyx:1938

False


Return the flag indicating if the solver uses matrix-free finite-differencing.

Not collective.

SEE ALSO:

setUseMF


Source code at petsc4py/PETSc/SNES.pyx:1911



Return the index set for the inactive set.

Not collective.

SEE ALSO:

petsc.SNESVIGetInactiveSet


Source code at petsc4py/PETSc/SNES.pyx:1966



Return a boolean indicating whether the solver has a nonlinear preconditioner.

Not collective.

SEE ALSO:

setNPC, getNPC, setNPCSide, getNPCSide, petsc.SNESHasNPC


Source code at petsc4py/PETSc/SNES.pyx:558



Log residual norm and linear iterations.

Source code at petsc4py/PETSc/SNES.pyx:1259

  • norm (float) --
  • linear_its (int) --

None


Monitor the solver.

Collective.

  • its -- Current number of iterations.
  • rnorm -- Current value of the residual norm.

None

SEE ALSO:

setMonitor, petsc.SNESMonitor


Source code at petsc4py/PETSc/SNES.pyx:1337


Cancel all the monitors of the solver.

Logically collective.

SEE ALSO:

setMonitor, petsc.SNESMonitorCancel


Source code at petsc4py/PETSc/SNES.pyx:1322



Reset the solver.

Collective.

SEE ALSO:

petsc.SNESReset


Source code at petsc4py/PETSc/SNES.pyx:1522



Set the application context.

Source code at petsc4py/PETSc/SNES.pyx:252

appctx (Any) --
None


Set the termination flag.

Collective.

SEE ALSO:

getConvergedReason, petsc.SNESSetConvergedReason


Source code at petsc4py/PETSc/SNES.pyx:1557

reason (ConvergedReason) --
None


Set the convergence history.

Logically collective.

SEE ALSO:

petsc.SNESSetConvergenceHistory


Source code at petsc4py/PETSc/SNES.pyx:1217



Set the callback to use as convergence test.

Logically collective.

  • converged (SNESConvergedFunction | Literal['skip', 'default']) -- The convergence testing callback.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

getConvergenceTest, callConvergenceTest, petsc.SNESSetConvergenceTest


Source code at petsc4py/PETSc/SNES.pyx:1112


Associate a DM with the solver.

Not collective.

SEE ALSO:

getDM, petsc.SNESSetDM


Source code at petsc4py/PETSc/SNES.pyx:293

dm (DM) --
None


Immediately generate an error if the solver has not converged.

Collective.

SEE ALSO:

getErrorIfNotConverged, petsc.SNESSetErrorIfNotConverged


Source code at petsc4py/PETSc/SNES.pyx:1584

flag (bool) --
None


Set the Mat to be used to apply the injection from level-1 to level.

Collective.

SEE ALSO:

getFASInjection, setFASInterpolation, setFASRestriction, petsc.SNESFASSetInjection, petsc.SNESFAS


Source code at petsc4py/PETSc/SNES.pyx:367

  • level (int) --
  • mat (Mat) --

None


Set the Mat to be used to apply the interpolation from level-1 to level.

Collective.

SEE ALSO:

getFASInterpolation, setFASRestriction, setFASInjection, petsc.SNESFASSetInterpolation, petsc.SNESFAS


Source code at petsc4py/PETSc/SNES.pyx:307

  • level (int) --
  • mat (Mat) --

None


Set the number of levels to use with FAS.

Collective.

  • levels (int) -- The number of levels
  • comms (Sequence[Comm]) -- An optional sequence of communicators of length Logging Levels, or None for the default communicator Sys.getDefaultComm.

None

SEE ALSO:

getFASLevels, petsc.SNESFASSetLevels, petsc.SNESFAS


Source code at petsc4py/PETSc/SNES.pyx:410


Set the scaling factor of the restriction operator from level to level-1.

Collective.

SEE ALSO:

setFASRestriction, petsc.SNESFASSetRScale, petsc.SNESFAS


Source code at petsc4py/PETSc/SNES.pyx:397

  • level (int) --
  • vec (Vec) --

None


Set the Mat to be used to apply the restriction from level-1 to level.

Collective.

SEE ALSO:

setFASRScale, getFASRestriction, setFASInterpolation, setFASInjection, petsc.SNESFASSetRestriction, petsc.SNESFAS


Source code at petsc4py/PETSc/SNES.pyx:337

  • level (int) --
  • mat (Mat) --

None


Force solve to take at least one iteration.

Collective.

SEE ALSO:

petsc.SNESSetForceIteration


Source code at petsc4py/PETSc/SNES.pyx:1640

force (bool) --
None


Configure the solver from the options database.

Collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.SNESSetFromOptions


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



Set the callback to compute the nonlinear function.

Logically collective.

  • function (SNESFunction) -- The callback.
  • f (Vec | None) -- An optional vector to store the result.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

getFunction, petsc.SNESSetFunction


Source code at petsc4py/PETSc/SNES.pyx:689


Set the function norm value.

Collective.

This is only of use to implementers of custom SNES types.

SEE ALSO:

getFunctionNorm, petsc.SNESSetFunctionNorm


Source code at petsc4py/PETSc/SNES.pyx:1653

norm (float) --
None


Set the callback to compute the initial guess.

Logically collective.

  • initialguess (SNESGuessFunction) -- The callback.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

getInitialGuess, petsc.SNESSetComputeInitialGuess


Source code at petsc4py/PETSc/SNES.pyx:646


Set the current iteration number.

Collective.

This is only of use to implementers of custom SNES types.

SEE ALSO:

getIterationNumber, petsc.SNESSetIterationNumber


Source code at petsc4py/PETSc/SNES.pyx:1611

its (int) --
None


Set the callback to compute the Jacobian.

Logically collective.

  • jacobian (SNESJacobianFunction) -- The Jacobian callback.
  • J (Mat | None) -- The matrix to store the Jacobian.
  • P (Mat | None) -- The matrix to construct the preconditioner.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

getJacobian, petsc.SNESSetJacobian


Source code at petsc4py/PETSc/SNES.pyx:795


Set the linear solver that will be used by the nonlinear solver.

Logically collective.

SEE ALSO:

getKSP, petsc.SNESSetKSP


Source code at petsc4py/PETSc/SNES.pyx:1755

ksp (KSP) --
None


Set the callback that will be called before applying the linesearch.

Logically collective.

  • precheck (SNESLSPreFunction) -- The callback.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

petsc.SNESLineSearchSetPreCheck


Source code at petsc4py/PETSc/SNES.pyx:612


Set the maximum allowed number of function evaluations.

Collective.

SEE ALSO:

getMaxFunctionEvaluations, petsc.SNESSetTolerances


Source code at petsc4py/PETSc/SNES.pyx:1360

max_funcs (int) --
None


Set the maximum allowed number of linear solve failures.

Collective.

SEE ALSO:

getMaxKSPFailures, petsc.SNESSetMaxLinearSolveFailures


Source code at petsc4py/PETSc/SNES.pyx:1446

max_fails (int) --
None


Set the maximum allowed number of step failures.

Collective.

SEE ALSO:

getMaxStepFailures, petsc.SNESSetMaxNonlinearStepFailures


Source code at petsc4py/PETSc/SNES.pyx:1405

max_fails (int) --
None


Set the callback used to monitor solver convergence.

Logically collective.

  • monitor (SNESMonitorFunction) -- The callback.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

getMonitor, petsc.SNESMonitorSet


Source code at petsc4py/PETSc/SNES.pyx:1280


Set the callback to compute nonlinear Gauss-Seidel.

Logically collective.

  • ngs (SNESNGSFunction) -- The nonlinear Gauss-Seidel callback.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

getNGS, computeNGS, petsc.SNESSetNGS


Source code at petsc4py/PETSc/SNES.pyx:964


Set the nonlinear preconditioner.

Logically collective.

SEE ALSO:

getNPC, hasNPC, setNPCSide, getNPCSide, petsc.SNESSetNPC


Source code at petsc4py/PETSc/SNES.pyx:572

snes (SNES) --
None


Set the nonlinear preconditioning side.

Collective.

SEE ALSO:

setNPC, getNPC, hasNPC, getNPCSide, petsc.SNESSetNPCSide


Source code at petsc4py/PETSc/SNES.pyx:584

side (Side) --
None


Set the norm schedule.

Collective.

SEE ALSO:

getNormSchedule, petsc.SNESSetNormSchedule


Source code at petsc4py/PETSc/SNES.pyx:1086

normsched (NormSchedule) --
None


Set the callback to compute the objective function.

Logically collective.

  • objective (SNESObjFunction) -- The Jacobian callback.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

getObjective, petsc.SNESSetObjective


Source code at petsc4py/PETSc/SNES.pyx:859


Set the prefix used for searching for options in the database.

Logically collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.SNESSetOptionsPrefix


Source code at petsc4py/PETSc/SNES.pyx:196

prefix (str) --
None


Set the parameters for the Eisenstat and Walker trick.

Logically collective.

  • version (int) -- The version of the algorithm. Defaults to DEFAULT.
  • rtol_0 (float) -- The initial relative residual norm. Defaults to DEFAULT.
  • rtol_max (float) -- The maximum relative residual norm. Defaults to DEFAULT.
  • gamma (float) -- Parameter. Defaults to DEFAULT.
  • alpha (float) -- Parameter. Defaults to DEFAULT.
  • alpha2 (float) -- Parameter. Defaults to DEFAULT.
  • threshold (float) -- Parameter. Defaults to DEFAULT.

None

SEE ALSO:

setUseEW, getParamsEW, petsc.SNESKSPSetParametersEW


Source code at petsc4py/PETSc/SNES.pyx:1819


Set cell patch numbering.

Source code at petsc4py/PETSc/SNES.pyx:2132

sec (Section) --
None


Set patch compute function.

Source code at petsc4py/PETSc/SNES.pyx:2185



Set patch compute operator.

Source code at petsc4py/PETSc/SNES.pyx:2177



Set patch construct type.

Source code at petsc4py/PETSc/SNES.pyx:2193



Set patch discretisation information.

Source code at petsc4py/PETSc/SNES.pyx:2136



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

Not collective.

SEE ALSO:

PETSc Python nonlinear solver type (TODO), getPythonContext


Source code at petsc4py/PETSc/SNES.pyx:2008

context (Any) --
None


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

Collective.

SEE ALSO:

PETSc Python nonlinear solver type (TODO), setPythonContext, getPythonType, petsc.SNESPythonSetType


Source code at petsc4py/PETSc/SNES.pyx:2035

py_type (str) --
None


Set the flag to reset the counters.

Collective.

SEE ALSO:

petsc.SNESSetCountersReset


Source code at petsc4py/PETSc/SNES.pyx:1265

reset (bool) --
None


Set the vector used to store the solution.

Collective.

SEE ALSO:

getSolution, petsc.SNESSetSolution


Source code at petsc4py/PETSc/SNES.pyx:1726

vec (Vec) --
None


Set the tolerance parameters used in the solver convergence tests.

Collective.

  • rtol (float) -- The relative norm of the residual. Defaults to DEFAULT.
  • atol (float) -- The absolute norm of the residual. Defaults to DEFAULT.
  • stol (float) -- The absolute norm of the step. Defaults to DEFAULT.
  • max_it (int) -- The maximum allowed number of iterations. Defaults to DEFAULT

None

SEE ALSO:

getTolerances, petsc.SNESSetTolerances


Source code at petsc4py/PETSc/SNES.pyx:1028


Set the type of the solver.

Logically collective.

snes_type (Type | str) -- The type of the solver.
None

SEE ALSO:

getType, petsc.SNESSetType


Source code at petsc4py/PETSc/SNES.pyx:163


Set up the internal data structures for using the solver.

Collective.

SEE ALSO:

petsc.SNESSetUp


Source code at petsc4py/PETSc/SNES.pyx:1496



Ensures that matrices are available for Newton-like methods.

Collective.

This is only of use to implementers of custom SNES types.

SEE ALSO:

setUp, petsc.SNESSetUpMatrices


Source code at petsc4py/PETSc/SNES.pyx:1508



Set the callback to compute update at the beginning of each step.

Logically collective.

  • update (SNESUpdateFunction) -- The callback.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

getUpdate, petsc.SNESSetUpdate


Source code at petsc4py/PETSc/SNES.pyx:752


Tell the solver to use the Eisenstat-Walker trick.

Logically collective.

  • flag (bool) -- Whether or not to use the Eisenstat-Walker trick.
  • *targs (Any) -- Positional arguments for setParamsEW.
  • **kargs (Any) -- Keyword arguments for setParamsEW.

None

SEE ALSO:

getUseEW, setParamsEW, petsc.SNESKSPSetUseEW


Source code at petsc4py/PETSc/SNES.pyx:1782


Set the boolean flag to use coloring finite-differencing for Jacobian assembly.

Logically collective.

SEE ALSO:

getUseFD


Source code at petsc4py/PETSc/SNES.pyx:1925



Set the boolean flag indicating to use matrix-free finite-differencing.

Logically collective.

SEE ALSO:

getUseMF


Source code at petsc4py/PETSc/SNES.pyx:1898



Set the vector for the variable bounds.

Collective.

SEE ALSO:

petsc.SNESVISetVariableBounds


Source code at petsc4py/PETSc/SNES.pyx:1954

  • xl (Vec) --
  • xu (Vec) --

None


Solve the nonlinear equations.

Collective.

  • b (Vec | None) -- The affine right-hand side or None to use zero.
  • x (Vec | None) -- The starting vector or None to use the vector stored internally.

None

SEE ALSO:

setSolution, getSolution, petsc.SNESSolve


Source code at petsc4py/PETSc/SNES.pyx:1534


View the solver.

Collective.

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

SEE ALSO:

petsc.SNESView


Source code at petsc4py/PETSc/SNES.pyx:110


Attributes Documentation

Application context.

Source code at petsc4py/PETSc/SNES.pyx:2209


Absolute residual tolerance.

Source code at petsc4py/PETSc/SNES.pyx:2275


DM.

Source code at petsc4py/PETSc/SNES.pyx:2218


Convergence history.

Source code at petsc4py/PETSc/SNES.pyx:2321


Boolean indicating if the solver has converged.

Source code at petsc4py/PETSc/SNES.pyx:2340


Boolean indicating if the solver has failed.

Source code at petsc4py/PETSc/SNES.pyx:2345


Boolean indicating if the solver has not converged yet.

Source code at petsc4py/PETSc/SNES.pyx:2335


Number of iterations.

Source code at petsc4py/PETSc/SNES.pyx:2307


Linear solver.

Source code at petsc4py/PETSc/SNES.pyx:2253


Maximum number of function evaluations.

Source code at petsc4py/PETSc/SNES.pyx:2298


Maximum number of iterations.

Source code at petsc4py/PETSc/SNES.pyx:2289


Function norm.

Source code at petsc4py/PETSc/SNES.pyx:2314


Nonlinear preconditioner.

Source code at petsc4py/PETSc/SNES.pyx:2227


Converged reason.

Source code at petsc4py/PETSc/SNES.pyx:2328


Relative residual tolerance.

Source code at petsc4py/PETSc/SNES.pyx:2268


Solution update tolerance.

Source code at petsc4py/PETSc/SNES.pyx:2282



Boolean indicating if the solver uses coloring finite-differencing.

Source code at petsc4py/PETSc/SNES.pyx:2359


Boolean indicating if the solver uses matrix-free finite-differencing.

Source code at petsc4py/PETSc/SNES.pyx:2352


Right-hand side vector.

Source code at petsc4py/PETSc/SNES.pyx:2246


Solution vector.

Source code at petsc4py/PETSc/SNES.pyx:2236


Update vector.

Source code at petsc4py/PETSc/SNES.pyx:2241




petsc4py.PETSc.Scatter

Bases: Object

Scatter object.

The object used to perform data movement between vectors. Scatter is described in the PETSc manual.

SEE ALSO:

Vec, SF, petsc.VecScatter


Enumerations

Mode Scatter mode.
Type Scatter type.

petsc4py.PETSc.Scatter.Mode

Bases: object

Scatter mode.

Most commonly used scatter modes are:

Scatter values in the forward direction.
Scatter values in the reverse direction.

SEE ALSO:

Scatter.create, Scatter.begin, Scatter.end, petsc.ScatterMode


Attributes Summary

FORWARD Constant FORWARD of type int
FORWARD_LOCAL Constant FORWARD_LOCAL of type int
REVERSE Constant REVERSE of type int
REVERSE_LOCAL Constant REVERSE_LOCAL of type int
SCATTER_FORWARD Constant SCATTER_FORWARD of type int
SCATTER_FORWARD_LOCAL Constant SCATTER_FORWARD_LOCAL of type int
SCATTER_REVERSE Constant SCATTER_REVERSE of type int
SCATTER_REVERSE_LOCAL Constant SCATTER_REVERSE_LOCAL of type int

Attributes Documentation

Constant FORWARD of type int

Constant FORWARD_LOCAL of type int

Constant REVERSE of type int

Constant REVERSE_LOCAL of type int

Constant SCATTER_FORWARD of type int

Constant SCATTER_FORWARD_LOCAL of type int

Constant SCATTER_REVERSE of type int

Constant SCATTER_REVERSE_LOCAL of type int


petsc4py.PETSc.Scatter.Type

Bases: object

Scatter type.

SEE ALSO:

petsc.VecScatterType


Attributes Summary

ALLGATHER Object ALLGATHER of type str
ALLGATHERV Object ALLGATHERV of type str
ALLTOALL Object ALLTOALL of type str
BASIC Object BASIC of type str
GATHER Object GATHER of type str
GATHERV Object GATHERV of type str
NEIGHBOR Object NEIGHBOR of type str
WINDOW Object WINDOW of type str

Attributes Documentation

Object ALLGATHER of type str

Object ALLGATHERV of type str

Object ALLTOALL of type str

Object BASIC of type str

Object GATHER of type str

Object GATHERV of type str

Object NEIGHBOR of type str

Object WINDOW of type str


Methods Summary

begin(vec_from, vec_to[, addv, mode]) Begin a generalized scatter from one vector into another.
copy() Return a copy of the scatter.
create(vec_from, is_from, vec_to, is_to) Create a scatter object.
destroy() Destroy the scatter.
end(vec_from, vec_to[, addv, mode]) Complete a generalized scatter from one vector into another.
getType() Return the type of the scatter.
scatter(vec_from, vec_to[, addv, mode]) Perform a generalized scatter from one vector into another.
setFromOptions() Configure the scatter from the options database.
setType(scatter_type) Set the type of the scatter.
setUp() Set up the internal data structures for using the scatter.
toAll(vec) Create a scatter that communicates a vector to all sharing processes.
toZero(vec) Create a scatter that communicates a vector to rank zero.
view([viewer]) View the scatter.

Methods Documentation

Begin a generalized scatter from one vector into another.

Collective.

This call has to be concluded with a call to end. For additional details on the Parameters, see scatter.

SEE ALSO:

create, end, petsc.VecScatterBegin


Source code at petsc4py/PETSc/Scatter.pyx:263

  • vec_from (Vec) --
  • vec_to (Vec) --
  • addv (InsertModeSpec) --
  • mode (ScatterModeSpec) --

None


Return a copy of the scatter.

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

Scatter


Create a scatter object.

Collective.

  • vec_from (Vec) -- Representative vector from which to scatter the data.
  • is_from (IS) -- Indices of vec_from to scatter. If None, use all indices.
  • vec_to (Vec) -- Representative vector to which scatter the data.
  • is_to (IS) -- Indices of vec_to where to receive. If None, use all indices.

Self

Examples

The scatter object can be used to repeatedly perform data movement. It is the PETSc equivalent of NumPy-like indexing and slicing, with support for parallel communications:

>>> revmode = PETSc.Scatter.Mode.REVERSE
>>> v1 = PETSc.Vec().createWithArray([1, 2, 3])
>>> v2 = PETSc.Vec().createWithArray([0, 0, 0])
>>> sct = PETSc.Scatter().create(v1,None,v2,None)
>>> sct.scatter(v1,v2) # v2[:] = v1[:]
>>> sct.scatter(v2,v1,mode=revmode) # v1[:] = v2[:]

>>> revmode = PETSc.Scatter.Mode.REVERSE
>>> v1 = PETSc.Vec().createWithArray([1, 2, 3, 4])
>>> v2 = PETSc.Vec().createWithArray([0, 0])
>>> is1 = PETSc.IS().createStride(2, 3, -2)
>>> sct = PETSc.Scatter().create(v1,is1,v2,None)
>>> sct.scatter(v1,v2) # v2[:] = v1[3:0:-2]
>>> sct.scatter(v2,v1,mode=revmode) # v1[3:0:-2] = v2[:]

SEE ALSO:

IS, petsc.VecScatterCreate


Source code at petsc4py/PETSc/Scatter.pyx:90


Destroy the scatter.

Collective.

SEE ALSO:

petsc.VecScatterDestroy


Source code at petsc4py/PETSc/Scatter.pyx:77



Complete a generalized scatter from one vector into another.

Collective.

This call has to be preceded by a call to begin. For additional details on the Parameters, see scatter.

SEE ALSO:

create, begin, petsc.VecScatterEnd


Source code at petsc4py/PETSc/Scatter.pyx:287

  • vec_from (Vec) --
  • vec_to (Vec) --
  • addv (InsertModeSpec) --
  • mode (ScatterModeSpec) --

None


Return the type of the scatter.

Not collective.

SEE ALSO:

setType, petsc.VecScatterGetType


Source code at petsc4py/PETSc/Scatter.pyx:161



Perform a generalized scatter from one vector into another.

Collective.

  • vec_from (Vec) -- The source vector.
  • vec_to (Vec) -- The destination vector.
  • addv (InsertModeSpec) -- Insertion mode.
  • mode (ScatterModeSpec) -- Scatter mode.

None

SEE ALSO:

create, begin, end, petsc.VecScatterBegin, petsc.VecScatterEnd


Source code at petsc4py/PETSc/Scatter.pyx:311


Configure the scatter from the options database.

Collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.VecScatterSetFromOptions


Source code at petsc4py/PETSc/Scatter.pyx:175



Set the type of the scatter.

Logically collective.

SEE ALSO:

getType, petsc.VecScatterSetType


Source code at petsc4py/PETSc/Scatter.pyx:147

scatter_type (Type | str) --
None


Set up the internal data structures for using the scatter.

Collective.

SEE ALSO:

petsc.VecScatterSetUp


Source code at petsc4py/PETSc/Scatter.pyx:187



Create a scatter that communicates a vector to all sharing processes.

Collective.

vec (Vec) -- The vector to scatter from.
tuple[Scatter, Vec]

Notes

The created scatter will have the same communicator of vec. The method also returns an output vector of appropriate size to contain the result of the operation.

SEE ALSO:

toZero, petsc.VecScatterCreateToAll


Source code at petsc4py/PETSc/Scatter.pyx:206


Create a scatter that communicates a vector to rank zero.

Collective.

vec (Vec) -- The vector to scatter from.
tuple[Scatter, Vec]

Notes

The created scatter will have the same communicator of vec. The method also returns an output vector of appropriate size to contain the result of the operation.

SEE ALSO:

toAll, petsc.VecScatterCreateToZero


Source code at petsc4py/PETSc/Scatter.pyx:234


View the scatter.

Collective.

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

SEE ALSO:

petsc.VecScatterView


Source code at petsc4py/PETSc/Scatter.pyx:58




petsc4py.PETSc.ScatterMode

Bases: object

Scatter mode.

Most commonly used scatter modes are:

Scatter values in the forward direction.
Scatter values in the reverse direction.

SEE ALSO:

Scatter.create, Scatter.begin, Scatter.end, petsc.ScatterMode


Attributes Summary

FORWARD Constant FORWARD of type int
FORWARD_LOCAL Constant FORWARD_LOCAL of type int
REVERSE Constant REVERSE of type int
REVERSE_LOCAL Constant REVERSE_LOCAL of type int
SCATTER_FORWARD Constant SCATTER_FORWARD of type int
SCATTER_FORWARD_LOCAL Constant SCATTER_FORWARD_LOCAL of type int
SCATTER_REVERSE Constant SCATTER_REVERSE of type int
SCATTER_REVERSE_LOCAL Constant SCATTER_REVERSE_LOCAL of type int

Attributes Documentation

Constant FORWARD of type int

Constant FORWARD_LOCAL of type int

Constant REVERSE of type int

Constant REVERSE_LOCAL of type int

Constant SCATTER_FORWARD of type int

Constant SCATTER_FORWARD_LOCAL of type int

Constant SCATTER_REVERSE of type int

Constant SCATTER_REVERSE_LOCAL of type int


petsc4py.PETSc.Section

Bases: Object

Mapping from integers in a range to unstructured set of integers.

Methods Summary

addConstraintDof(point, numDof) Increment the number of constrained DOFs for a given point.
addDof(point, numDof) Add numDof degrees of freedom associated with a given point.
addFieldConstraintDof(point, field, numDof) Add numDof constrained DOFs for a given field on a point.
addFieldDof(point, field, numDof) Add numDof DOFs associated with a field on a given point.
clone() Return a copy of the section.
create([comm]) Allocate a section and set the map contents to the default.
createGlobalSection(sf) Create a section describing the global field layout.
destroy() Destroy a section.
getChart() Return the range in which points (indices) lie for this section.
getConstrainedStorageSize() Return the size capable of holding all unconstrained DOFs in a section.
getConstraintDof(point) Return the number of constrained DOFs associated with a given point.
getConstraintIndices(point) Return the point DOFs numbers which are constrained for a given point.
getDof(point) Return the number of degrees of freedom for a given point.
getFieldComponents(field) Return the number of field components for the given field.
getFieldConstraintDof(point, field) Return the number of constrained DOFs for a given field on a point.
getFieldConstraintIndices(point, field) Return the field DOFs numbers, in [0, DOFs), which are constrained.
getFieldDof(point, field) Return the number of DOFs associated with a field on a given point.
getFieldName(field) Return the name of a field in the section.
getFieldOffset(point, field) Return the offset for the field DOFs on the given point.
getMaxDof() Return the maximum number of DOFs for any point in the section.
getNumFields() Return the number of fields in a section.
getOffset(point) Return the offset for the DOFs associated with the given point.
getOffsetRange() Return the full range of offsets, [start, end), for a section.
getPermutation() Return the permutation that was set with setPermutation.
getStorageSize() Return the size capable of holding all the DOFs defined in a section.
reset() Free all section data.
setChart(pStart, pEnd) Set the range in which points (indices) lie for this section.
setConstraintDof(point, numDof) Set the number of constrained DOFs associated with a given point.
setConstraintIndices(point, indices) Set the point DOFs numbers, in [0, DOFs), which are constrained.
setDof(point, numDof) Set the number of degrees of freedom associated with a given point.
setFieldComponents(field, numComp) Set the number of field components for the given field.
setFieldConstraintDof(point, field, numDof) Set the number of constrained DOFs for a given field on a point.
setFieldConstraintIndices(point, field, indices) Set the field DOFs numbers, in [0, DOFs), which are constrained.
setFieldDof(point, field, numDof) Set the number of DOFs associated with a field on a given point.
setFieldName(field, fieldName) Set the name of a field in the section.
setFieldOffset(point, field, offset) Set the offset for the DOFs on the given field at a point.
setNumFields(numFields) Set the number of fields in a section.
setOffset(point, offset) Set the offset for the DOFs associated with the given point.
setPermutation(perm) Set the permutation for [0, pEnd - pStart).
setUp() Calculate offsets.
view([viewer]) View the section.

Methods Documentation

Increment the number of constrained DOFs for a given point.

Not collective.

  • point (int) -- The point.
  • numDof (int) -- The number of additional DOFs which are fixed by constraints.

None

SEE ALSO:

setConstraintDof, getConstraintDof, petsc.PetscSectionAddConstraintDof


Source code at petsc4py/PETSc/Section.pyx:489


Add numDof degrees of freedom associated with a given point.

Not collective.

  • point (int) -- The point.
  • numDof (int) -- The number of additional DOFs.

None

SEE ALSO:

setDof, getDof, petsc.PetscSectionAddDof


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


Add numDof constrained DOFs for a given field on a point.

Not collective.

  • point (int) -- The point.
  • field (int) -- The field.
  • numDof (int) -- The number of additional DOFs which are fixed by constraints.

None

SEE ALSO:

setFieldConstraintDof, getFieldConstraintDof, petsc.PetscSectionAddFieldConstraintDof


Source code at petsc4py/PETSc/Section.pyx:562


Add numDof DOFs associated with a field on a given point.

Not collective.

  • point (int) -- The point.
  • field (int) -- The field.
  • numDof (int) -- The number of additional DOFs.

None

SEE ALSO:

setFieldDof, getFieldDof, petsc.PetscSectionAddFieldDof


Source code at petsc4py/PETSc/Section.pyx:425


Return a copy of the section.

Collective.

The copy is shallow, if possible.

SEE ALSO:

petsc.PetscSectionClone


Source code at petsc4py/PETSc/Section.pyx:84

Section


Allocate a section and set the map contents to the default.

Collective.

Typical calling sequence: - create - setNumFields - setChart - setDof - setUp - getOffset - destroy

The Section object and methods are intended to be used in the PETSc Vec and Mat implementations. The indices returned by the Section are appropriate for the kind of Vec it is associated with. For example, if the vector being indexed is a local vector, we call the section a local section. If the section indexes a global vector, we call it a global section. For parallel vectors, like global vectors, we use negative indices to indicate DOFs owned by other processes.

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

SEE ALSO:

petsc.PetscSectionCreate


Source code at petsc4py/PETSc/Section.pyx:46


Create a section describing the global field layout.

Collective.

The section describes the global field layout using the local section and an SF describing the section point overlap.

If we have a set of local sections defining the layout of a set of local vectors, and also an SF to determine which section points are shared and the ownership, we can calculate a global section defining the parallel data layout, and the associated global vector.

This gives negative sizes and offsets to points not owned by this process.

includeConstraints and localOffsets parameters of the C API are always set to False.

sf (SF) -- The SF describing the parallel layout of the section points (leaves are unowned local points).
Section

SEE ALSO:

petsc.PetscSectionCreateGlobalSection


Source code at petsc4py/PETSc/Section.pyx:853


Destroy a section.

Not collective.

SEE ALSO:

petsc.PetscSectionDestroy


Source code at petsc4py/PETSc/Section.pyx:33



Return the range in which points (indices) lie for this section.

Not collective.

The range is [pStart, pEnd), i.e., from the first point to one past the last point.

SEE ALSO:

petsc.PetscSectionGetChart


Source code at petsc4py/PETSc/Section.pyx:242

tuple[int, int]


Return the size capable of holding all unconstrained DOFs in a section.

Not collective.

SEE ALSO:

getStorageSize, petsc.PetscSectionGetConstrainedStorageSize


Source code at petsc4py/PETSc/Section.pyx:727



Return the number of constrained DOFs associated with a given point.

Not collective.

point (int) -- The point.
int

SEE ALSO:

setConstraintDof, petsc.PetscSectionGetConstraintDof


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


Return the point DOFs numbers which are constrained for a given point.

Not collective.

The range is in [0, DOFs).

point (int) -- The point.
ArrayInt

SEE ALSO:

setConstraintIndices, petsc.PetscSectionGetConstraintIndices


Source code at petsc4py/PETSc/Section.pyx:592


Return the number of degrees of freedom for a given point.

Not collective.

In a global section, this value will be negative for points not owned by this process.

point (int) -- The point.
int

SEE ALSO:

setDof, addDof, petsc.PetscSectionGetDof


Source code at petsc4py/PETSc/Section.pyx:315


Return the number of field components for the given field.

Not collective.

field (int) -- The field number.
int

SEE ALSO:

setFieldComponents, petsc.PetscSectionGetFieldComponents


Source code at petsc4py/PETSc/Section.pyx:202


Return the number of constrained DOFs for a given field on a point.

Not collective.

  • point (int) -- The point.
  • field (int) -- The field.

int

SEE ALSO:

setFieldConstraintDof, petsc.PetscSectionGetFieldConstraintDof


Source code at petsc4py/PETSc/Section.pyx:510


Return the field DOFs numbers, in [0, DOFs), which are constrained.

Not collective.

The constrained DOFs are sorted in ascending order.

  • field (int) -- The field number.
  • point (int) -- The point.

ArrayInt

SEE ALSO:

setFieldConstraintIndices, petsc.PetscSectionGetFieldConstraintIndices


Source code at petsc4py/PETSc/Section.pyx:640


Return the number of DOFs associated with a field on a given point.

Not collective.

  • point (int) -- The point.
  • field (int) -- The field.

int

SEE ALSO:

setFieldDof, petsc.PetscSectionGetFieldDof


Source code at petsc4py/PETSc/Section.pyx:379


Return the name of a field in the section.

Not collective.

field (int) -- The field number.
str

SEE ALSO:

setFieldName, petsc.PetscSectionGetFieldName


Source code at petsc4py/PETSc/Section.pyx:160


Return the offset for the field DOFs on the given point.

Not collective.

In a global section, this offset will be negative for points not owned by this process.

  • point (int) -- The point.
  • field (int) -- The field.

int

SEE ALSO:

setFieldOffset, petsc.PetscSectionGetFieldOffset


Source code at petsc4py/PETSc/Section.pyx:786


Return the maximum number of DOFs for any point in the section.

Not collective.

SEE ALSO:

petsc.PetscSectionGetMaxDof


Source code at petsc4py/PETSc/Section.pyx:699



Return the number of fields in a section.

Not collective.

Returns 0 if no fields were defined.

SEE ALSO:

setNumFields, petsc.PetscSectionGetNumFields


Source code at petsc4py/PETSc/Section.pyx:126



Return the offset for the DOFs associated with the given point.

Not collective.

In a global section, this offset will be negative for points not owned by this process.

point (int) -- The point.
int

SEE ALSO:

setOffset, petsc.PetscSectionGetOffset


Source code at petsc4py/PETSc/Section.pyx:741


Return the full range of offsets, [start, end), for a section.

Not collective.

SEE ALSO:

petsc.PetscSectionGetOffsetRange


Source code at petsc4py/PETSc/Section.pyx:838

tuple[int, int]


Return the permutation that was set with setPermutation.

Not collective.

SEE ALSO:

setPermutation, petsc.PetscSectionGetPermutation


Source code at petsc4py/PETSc/Section.pyx:283



Return the size capable of holding all the DOFs defined in a section.

Not collective.

SEE ALSO:

getConstrainedStorageSize, petsc.PetscSectionGetStorageSize


Source code at petsc4py/PETSc/Section.pyx:713



Free all section data.

Not collective.

SEE ALSO:

petsc.PetscSectionReset


Source code at petsc4py/PETSc/Section.pyx:114



Set the range in which points (indices) lie for this section.

Not collective.

The range is [pStart, pEnd), i.e., from the first point to one past the last point.

  • pStart (int) -- The first point.
  • pEnd (int) -- One past the last point.

None

SEE ALSO:

petsc.PetscSectionSetChart


Source code at petsc4py/PETSc/Section.pyx:259


Set the number of constrained DOFs associated with a given point.

Not collective.

  • point (int) -- The point.
  • numDof (int) -- The number of DOFs which are fixed by constraints.

None

SEE ALSO:

getConstraintDof, addConstraintDof, petsc.PetscSectionSetConstraintDof


Source code at petsc4py/PETSc/Section.pyx:468


Set the point DOFs numbers, in [0, DOFs), which are constrained.

Not collective.

  • point (int) -- The point.
  • indices (Sequence[int]) -- The constrained DOFs.

None

SEE ALSO:

getConstraintIndices, petsc.PetscSectionSetConstraintIndices


Source code at petsc4py/PETSc/Section.pyx:616


Set the number of degrees of freedom associated with a given point.

Not collective.

  • point (int) -- The point.
  • numDof (int) -- The number of DOFs.

None

SEE ALSO:

getDof, addDof, petsc.PetscSectionSetDof


Source code at petsc4py/PETSc/Section.pyx:337


Set the number of field components for the given field.

Not collective.

  • field (int) -- The field number.
  • numComp (int) -- The number of field components.

None

SEE ALSO:

getFieldComponents, petsc.PetscSectionSetFieldComponents


Source code at petsc4py/PETSc/Section.pyx:221


Set the number of constrained DOFs for a given field on a point.

Not collective.

  • point (int) -- The point.
  • field (int) -- The field.
  • numDof (int) -- The number of DOFs which are fixed by constraints.

None

SEE ALSO:

getFieldConstraintDof, addFieldConstraintDof, petsc.PetscSectionSetFieldConstraintDof


Source code at petsc4py/PETSc/Section.pyx:532


Set the field DOFs numbers, in [0, DOFs), which are constrained.

Not collective.

  • point (int) -- The point.
  • field (int) -- The field number.
  • indices (Sequence[int]) -- The constrained DOFs.

None

SEE ALSO:

getFieldConstraintIndices, petsc.PetscSectionSetFieldConstraintIndices


Source code at petsc4py/PETSc/Section.pyx:667


Set the number of DOFs associated with a field on a given point.

Not collective.

  • point (int) -- The point.
  • field (int) -- The field.
  • numDof (int) -- The number of DOFs.

None

SEE ALSO:

getFieldDof, addFieldDof, petsc.PetscSectionSetFieldDof


Source code at petsc4py/PETSc/Section.pyx:401


Set the name of a field in the section.

Not collective.

  • field (int) -- The field number.
  • fieldName (str) -- The field name.

None

SEE ALSO:

getFieldName, petsc.PetscSectionSetFieldName


Source code at petsc4py/PETSc/Section.pyx:180


Set the offset for the DOFs on the given field at a point.

Not collective.

The user usually does not call this function, but uses setUp.

  • point (int) -- The point.
  • field (int) -- The field.
  • offset (int) -- The offset.

None

SEE ALSO:

getFieldOffset, petsc.PetscSectionSetFieldOffset


Source code at petsc4py/PETSc/Section.pyx:812


Set the number of fields in a section.

Not collective.

numFields (int) -- The number of fields.
None

SEE ALSO:

getNumFields, petsc.PetscSectionSetNumFields


Source code at petsc4py/PETSc/Section.pyx:142


Set the offset for the DOFs associated with the given point.

Not collective.

The user usually does not call this function, but uses setUp.

  • point (int) -- The point.
  • offset (int) -- The offset.

None

SEE ALSO:

getOffset, petsc.PetscSectionSetOffset


Source code at petsc4py/PETSc/Section.pyx:763


Set the permutation for [0, pEnd - pStart).

Not collective.

perm (IS) -- The permutation of points.
None

SEE ALSO:

getPermutation, petsc.PetscSectionSetPermutation


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


Calculate offsets.

Not collective.

Offsets are based on the number of degrees of freedom for each point.

SEE ALSO:

petsc.PetscSectionSetUp


Source code at petsc4py/PETSc/Section.pyx:100



View the section.

Collective.

viewer (Viewer | None) -- A Viewer to display the section.
None

SEE ALSO:

petsc.PetscSectionView


Source code at petsc4py/PETSc/Section.pyx:14



petsc4py.PETSc.Space

Bases: Object

Linear space object.

Enumerations

Type

petsc4py.PETSc.Space.Type

Bases: object

Attributes Summary

POINT Object POINT of type str
POLYNOMIAL Object POLYNOMIAL of type str
PTRIMMED Object PTRIMMED of type str
SUBSPACE Object SUBSPACE of type str
SUM Object SUM of type str
TENSOR Object TENSOR of type str
WXY Object WXY of type str

Attributes Documentation

Object POINT of type str

Object POLYNOMIAL of type str

Object PTRIMMED of type str

Object SUBSPACE of type str

Object SUM of type str

Object TENSOR of type str

Object WXY of type str


Methods Summary

create([comm]) Create an empty Space object.
destroy() Destroy the Space object.
getDegree() Return the polynomial degrees that characterize this space.
getDimension() Return the number of basis vectors.
getNumComponents() Return the number of components for this space.
getNumVariables() Return the number of variables for this space.
getPTrimmedFormDegree() Return the form degree of the trimmed polynomials.
getPointPoints() Return the evaluation points for the space as the points of a quad.
getPolynomialTensor() Return whether a function space is a space of tensor polynomials.
getSumConcatenate() Return the concatenate flag for this space.
getSumNumSubspaces() Return the number of spaces in the sum.
getSumSubspace(s) Return a space in the sum.
getTensorNumSubspaces() Return the number of spaces in the tensor product.
getTensorSubspace(s) Return a space in the tensor product.
getType() Return the type of the space object.
setDegree(degree, maxDegree) Set the degree of approximation for this space.
setFromOptions() Set parameters in Space from the options database.
setNumComponents(nc) Set the number of components for this space.
setNumVariables(n) Set the number of variables for this space.
setPTrimmedFormDegree(formDegree) Set the form degree of the trimmed polynomials.
setPointPoints(quad) Set the evaluation points for the space to be based on a quad.
setPolynomialTensor(tensor) Set whether a function space is a space of tensor polynomials.
setSumConcatenate(concatenate) Set the concatenate flag for this space.
setSumNumSubspaces(numSumSpaces) Set the number of spaces in the sum.
setSumSubspace(s, subsp) Set a space in the sum.
setTensorNumSubspaces(numTensSpaces) Set the number of spaces in the tensor product.
setTensorSubspace(s, subsp) Set a space in the tensor product.
setType(space_type) Build a particular type of space.
setUp() Construct data structures for the Space.
view([viewer]) View a Space.
viewFromOptions(name[, obj]) View a Space based on values in the options database.

Methods Documentation

Create an empty Space object.

Collective.

The type can then be set with setType.

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

SEE ALSO:

petsc.PetscSpaceCreate


Source code at petsc4py/PETSc/Space.pyx:34


Destroy the Space object.

Collective.

SEE ALSO:

petsc.PetscSpaceDestroy


Source code at petsc4py/PETSc/Space.pyx:57



Return the polynomial degrees that characterize this space.
  • minDegree (int) -- The degree of the largest polynomial space contained in the space.
  • maxDegree (int) -- The degree of the smallest polynomial space containing the space.

tuple[int, int]

SEE ALSO:

setDegree, petsc.PetscSpaceGetDegree


Source code at petsc4py/PETSc/Space.pyx:113


Return the number of basis vectors.

SEE ALSO:

petsc.PetscSpaceGetDimension


Source code at petsc4py/PETSc/Space.pyx:101



Return the number of components for this space.

SEE ALSO:

setNumComponents, petsc.PetscSpaceGetNumComponents


Source code at petsc4py/PETSc/Space.pyx:184



Return the number of variables for this space.

SEE ALSO:

setNumVariables, petsc.PetscSpaceGetNumVariables


Source code at petsc4py/PETSc/Space.pyx:156



Return the form degree of the trimmed polynomials.

SEE ALSO:

setPTrimmedFormDegree, petsc.PetscSpacePTrimmedGetFormDegree


Source code at petsc4py/PETSc/Space.pyx:515



Return the evaluation points for the space as the points of a quad.

Logically collective.

SEE ALSO:

setPointPoints, petsc.PetscSpacePointGetPoints


Source code at petsc4py/PETSc/Space.pyx:485



Return whether a function space is a space of tensor polynomials.

Return True if a function space is a space of tensor polynomials (the space is spanned by polynomials whose degree in each variable is bounded by the given order), as opposed to polynomials (the space is spanned by polynomials whose total degree—summing over all variables is bounded by the given order).

SEE ALSO:

setPolynomialTensor, petsc.PetscSpacePolynomialGetTensor


Source code at petsc4py/PETSc/Space.pyx:424



Return the concatenate flag for this space.

A concatenated sum space will have the number of components equal to the sum of the number of components of all subspaces. A non-concatenated, or direct sum space will have the same number of components as its subspaces.

SEE ALSO:

setSumConcatenate, petsc.PetscSpaceSumGetConcatenate


Source code at petsc4py/PETSc/Space.pyx:257



Return the number of spaces in the sum.

SEE ALSO:

setSumNumSubspaces, petsc.PetscSpaceSumGetNumSubspaces


Source code at petsc4py/PETSc/Space.pyx:296



Return a space in the sum.
s (int) -- The space number.
Space

SEE ALSO:

setSumSubspace, petsc.PetscSpaceSumGetSubspace


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


Return the number of spaces in the tensor product.

SEE ALSO:

setTensorNumSubspaces, petsc.PetscSpaceTensorGetNumSubspaces


Source code at petsc4py/PETSc/Space.pyx:360



Return a space in the tensor product.
s (int) -- The space number.
Space

SEE ALSO:

setTensorSubspace, petsc.PetscSpaceTensorGetSubspace


Source code at petsc4py/PETSc/Space.pyx:390


Return the type of the space object.

Not collective.

SEE ALSO:

setType, petsc.PetscSpaceGetType


Source code at petsc4py/PETSc/Space.pyx:223



Set the degree of approximation for this space.

One of degree and maxDegree can be None.

  • degree (int | None) -- The degree of the largest polynomial space contained in the space.
  • maxDegree (int | None) -- The degree of the largest polynomial space containing the space.

None

SEE ALSO:

getDegree, petsc.PetscSpaceSetDegree


Source code at petsc4py/PETSc/Space.pyx:132


Set parameters in Space from the options database.

Collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.PetscSpaceSetFromOptions


Source code at petsc4py/PETSc/Space.pyx:89



Set the number of components for this space.
nc (int) -- The number of components.
None

SEE ALSO:

getNumComponents, petsc.PetscSpaceSetNumComponents


Source code at petsc4py/PETSc/Space.pyx:196


Set the number of variables for this space.
n (int) -- The number of variables (x, y, z etc.).
None

SEE ALSO:

getNumVariables, petsc.PetscSpaceSetNumVariables


Source code at petsc4py/PETSc/Space.pyx:168


Set the form degree of the trimmed polynomials.
formDegree (int) -- The form degree.
None

SEE ALSO:

getPTrimmedFormDegree, petsc.PetscSpacePTrimmedSetFormDegree


Source code at petsc4py/PETSc/Space.pyx:499


Set the evaluation points for the space to be based on a quad.

Logically collective.

Sets the evaluation points for the space to coincide with the points of a quadrature rule.

quad (Quad) -- The Quad defining the points.
None

SEE ALSO:

getPointPoints, petsc.PetscSpacePointSetPoints


Source code at petsc4py/PETSc/Space.pyx:465


Set whether a function space is a space of tensor polynomials.

Set to True for a function space which is a space of tensor polynomials (the space is spanned by polynomials whose degree in each variable is bounded by the given order), as opposed to polynomials (the space is spanned by polynomials whose total degree—summing over all variables is bounded by the given order).

tensor (bool) -- True for a tensor polynomial space, False for a polynomial space.
None

SEE ALSO:

getPolynomialTensor, petsc.PetscSpacePolynomialSetTensor


Source code at petsc4py/PETSc/Space.pyx:442


Set the concatenate flag for this space.

A concatenated sum space will have the number of components equal to the sum of the number of components of all subspaces. A non-concatenated, or direct sum space will have the same number of components as its subspaces.

concatenate (bool) -- True if subspaces are concatenated components, False if direct summands.
None

SEE ALSO:

getSumConcatenate, petsc.PetscSpaceSumSetConcatenate


Source code at petsc4py/PETSc/Space.pyx:274


Set the number of spaces in the sum.
numSumSpaces (int) -- The number of spaces.
None

SEE ALSO:

getSumNumSubspaces, petsc.PetscSpaceSumSetNumSubspaces


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


Set a space in the sum.
  • s (int) -- The space number.
  • subsp (Space) -- The number of spaces.

None

SEE ALSO:

getSumSubspace, petsc.PetscSpaceSumSetSubspace


Source code at petsc4py/PETSc/Space.pyx:326


Set the number of spaces in the tensor product.
numTensSpaces (int) -- The number of spaces.
None

SEE ALSO:

getTensorNumSubspaces, petsc.PetscSpaceTensorSetNumSubspaces


Source code at petsc4py/PETSc/Space.pyx:408


Set a space in the tensor product.
  • s (int) -- The space number.
  • subsp (Space) -- The number of spaces.

None

SEE ALSO:

getTensorSubspace, petsc.PetscSpaceTensorSetSubspace


Source code at petsc4py/PETSc/Space.pyx:372


Build a particular type of space.

Collective.

space_type (Type | str) -- The kind of space.
Self

SEE ALSO:

getType, petsc.PetscSpaceSetType


Source code at petsc4py/PETSc/Space.pyx:237


Construct data structures for the Space.

Collective.

SEE ALSO:

petsc.PetscSpaceSetUp


Source code at petsc4py/PETSc/Space.pyx:22



View a Space.

Collective.

viewer (Viewer | None) -- A Viewer to display the Space.
None

SEE ALSO:

petsc.PetscSpaceView


Source code at petsc4py/PETSc/Space.pyx:70


View a Space based on values in the options database.

Collective.

  • name (str) -- Command line option name.
  • obj (Object | None) -- Optional object that provides the options prefix.

None

SEE ALSO:

Working with PETSc options (TODO), petsc.PetscSpaceViewFromOptions


Source code at petsc4py/PETSc/Space.pyx:527




petsc4py.PETSc.Sys

Bases: object

System utilities.

Methods Summary

Print(*args[, sep, end, comm]) Print output from the first processor of a communicator.
getDefaultComm() Get the default MPI communicator used to create PETSc objects.
getVersion([devel, date, author]) Return PETSc version information.
getVersionInfo() Return PETSc version information.
hasExternalPackage(package) Return whether PETSc has support for external package.
infoAllow(flag[, filename, mode]) Enables or disables PETSc info messages.
isFinalized() Return whether PETSc has been finalized.
isInitialized() Return whether PETSc has been initialized.
popErrorHandler() Remove the current error handler.
popSignalHandler() Remove the current signal handler.
pushErrorHandler(errhandler) Set the current error handler.
registerCitation(citation) Register BibTeX citation.
setDefaultComm(comm) Set the default MPI communicator used to create PETSc objects.
sleep([seconds]) Sleep some number of seconds.
splitOwnership(size[, bsize, comm]) Given a global (or local) size determines a local (or global) size.
syncFlush([comm]) Flush output from previous syncPrint calls.
syncPrint(*args[, sep, end, flush, comm]) Print synchronized output from several processors of a communicator.

Methods Documentation

Print output from the first processor of a communicator.

Collective.

  • *args (Any) -- Positional arguments.
  • sep (str) -- String inserted between values, by default a space.
  • end (str) -- String appended after the last value, by default a newline.
  • comm (Comm | None) -- MPI communicator, defaults to getDefaultComm.
  • **kwargs (Any) -- Keyword arguments.

None

SEE ALSO:

petsc.PetscPrintf


Source code at petsc4py/PETSc/Sys.pyx:156


Get the default MPI communicator used to create PETSc objects.

Not collective.

SEE ALSO:

setDefaultComm


Source code at petsc4py/PETSc/Sys.pyx:117



Return PETSc version information.

Not collective.

  • devel (bool) -- Additionally, return whether using an in-development version.
  • date (bool) -- Additionally, return date information.
  • author (bool) -- Additionally, return author information.

  • major (int) -- Major version number.
  • minor (int) -- Minor version number.
  • micro (int) -- Micro (or patch) version number.

tuple[int, int, int]

SEE ALSO:

petsc.PetscGetVersion, petsc.PetscGetVersionNumber


Source code at petsc4py/PETSc/Sys.pyx:7


Return PETSc version information.

Not collective.

info -- Dictionary with version information.
dict

SEE ALSO:

petsc.PetscGetVersion, petsc.PetscGetVersionNumber


Source code at petsc4py/PETSc/Sys.pyx:63


Return whether PETSc has support for external package.

Not collective.

package (str) -- The external package name.
bool

SEE ALSO:

petsc.PetscHasExternalPackage


Source code at petsc4py/PETSc/Sys.pyx:455


Enables or disables PETSc info messages.

Not collective.

  • flag (bool) -- Whether to enable info messages.
  • filename (str | None) -- Name of a file where to dump output.
  • mode (str) -- Write mode for file, by default "w".

None

SEE ALSO:

petsc.PetscInfoAllow, petsc.PetscInfoSetFile


Source code at petsc4py/PETSc/Sys.pyx:397


Return whether PETSc has been finalized.

Not collective.

SEE ALSO:

isInitialized


Source code at petsc4py/PETSc/Sys.pyx:102



Return whether PETSc has been initialized.

Not collective.

SEE ALSO:

isFinalized


Source code at petsc4py/PETSc/Sys.pyx:89



Remove the current error handler.

Logically collective.

SEE ALSO:

petsc.PetscPopErrorHandler


Source code at petsc4py/PETSc/Sys.pyx:371



Remove the current signal handler.

Logically collective.

SEE ALSO:

petsc.PetscPopSignalHandler


Source code at petsc4py/PETSc/Sys.pyx:384



Set the current error handler.

Logically collective.

errhandler (str) -- The name of the error handler.
None

SEE ALSO:

petsc.PetscPushErrorHandler


Source code at petsc4py/PETSc/Sys.pyx:335


Register BibTeX citation.

Not collective.

citation (str) -- The BibTex citation entry to register.
None

SEE ALSO:

petsc.PetscCitationsRegister


Source code at petsc4py/PETSc/Sys.pyx:432


Set the default MPI communicator used to create PETSc objects.

Logically collective.

comm (Comm | None) -- MPI communicator. If set to None, uses COMM_WORLD.
None

SEE ALSO:

getDefaultComm


Source code at petsc4py/PETSc/Sys.pyx:132


Sleep some number of seconds.

Not collective.

seconds (float) -- Time to sleep in seconds.
None

SEE ALSO:

petsc.PetscSleep


Source code at petsc4py/PETSc/Sys.pyx:314


Given a global (or local) size determines a local (or global) size.

Collective.

  • size (int | tuple[int, int]) -- Global size N or 2-tuple (n, N) with local and global sizes. Either of n or N (but not both) can be None.
  • bsize (int | None) -- Block size, defaults to 1.
  • comm (Comm | None) -- MPI communicator, defaults to getDefaultComm.

  • n (int) -- The local size.
  • N (int) -- The global size.

tuple[int, int]

Notes

The size argument corresponds to the full size of the vector. That is, an array with 10 blocks and a block size of 3 will have a size of 30, not 10.

SEE ALSO:

petsc.PetscSplitOwnership


Source code at petsc4py/PETSc/Sys.pyx:264


Flush output from previous syncPrint calls.

Collective.

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

SEE ALSO:

petsc.PetscSynchronizedPrintf, petsc.PetscSynchronizedFlush


Source code at petsc4py/PETSc/Sys.pyx:243


Print synchronized output from several processors of a communicator.

Not collective.

  • *args (Any) -- Positional arguments.
  • sep (str) -- String inserted between values, by default a space.
  • end (str) -- String appended after the last value, by default a newline.
  • flush (bool) -- Whether to flush output with syncFlush.
  • comm (Comm | None) -- MPI communicator, defaults to getDefaultComm.
  • **kwargs (Any) -- Keyword arguments.

None

SEE ALSO:

petsc.PetscSynchronizedPrintf, petsc.PetscSynchronizedFlush


Source code at petsc4py/PETSc/Sys.pyx:199



petsc4py.PETSc.TAO

Bases: Object

Optimization solver.

TAO is described in the PETSc manual.

SEE ALSO:

petsc.Tao


Enumerations

BNCGType TAO Bound Constrained Conjugate Gradient (BNCG) Update Type.
ConvergedReason TAO solver termination reason.
Type TAO solver type.

petsc4py.PETSc.TAO.BNCGType

Bases: object

TAO Bound Constrained Conjugate Gradient (BNCG) Update Type.

Attributes Summary

DK Constant DK of type int
DY Constant DY of type int
FR Constant FR of type int
GD Constant GD of type int
HS Constant HS of type int
HZ Constant HZ of type int
KD Constant KD of type int
PCGD Constant PCGD of type int
PRP Constant PRP of type int
PRP_PLUS Constant PRP_PLUS of type int
SSML_BFGS Constant SSML_BFGS of type int
SSML_BRDN Constant SSML_BRDN of type int
SSML_DFP Constant SSML_DFP of type int

Attributes Documentation

Constant DK of type int

Constant DY of type int

Constant FR of type int

Constant GD of type int

Constant HS of type int

Constant HZ of type int

Constant KD of type int

Constant PCGD of type int

Constant PRP of type int

Constant PRP_PLUS of type int

Constant SSML_BFGS of type int

Constant SSML_BRDN of type int

Constant SSML_DFP of type int


petsc4py.PETSc.TAO.ConvergedReason

Bases: object

TAO solver termination reason.

SEE ALSO:

petsc.TaoConvergedReason


Attributes Summary

CONTINUE_ITERATING Constant CONTINUE_ITERATING of type int
CONVERGED_GATOL Constant CONVERGED_GATOL of type int
CONVERGED_GRTOL Constant CONVERGED_GRTOL of type int
CONVERGED_GTTOL Constant CONVERGED_GTTOL of type int
CONVERGED_ITERATING Constant CONVERGED_ITERATING of type int
CONVERGED_MINF Constant CONVERGED_MINF of type int
CONVERGED_STEPTOL Constant CONVERGED_STEPTOL of type int
CONVERGED_USER Constant CONVERGED_USER of type int
DIVERGED_LS_FAILURE Constant DIVERGED_LS_FAILURE of type int
DIVERGED_MAXFCN Constant DIVERGED_MAXFCN of type int
DIVERGED_MAXITS Constant DIVERGED_MAXITS of type int
DIVERGED_NAN Constant DIVERGED_NAN of type int
DIVERGED_TR_REDUCTION Constant DIVERGED_TR_REDUCTION of type int
DIVERGED_USER Constant DIVERGED_USER of type int
ITERATING Constant ITERATING of type int

Attributes Documentation

Constant CONTINUE_ITERATING of type int

Constant CONVERGED_GATOL of type int

Constant CONVERGED_GRTOL of type int

Constant CONVERGED_GTTOL of type int

Constant CONVERGED_ITERATING of type int

Constant CONVERGED_MINF of type int

Constant CONVERGED_STEPTOL of type int

Constant CONVERGED_USER of type int

Constant DIVERGED_LS_FAILURE of type int

Constant DIVERGED_MAXFCN of type int

Constant DIVERGED_MAXITS of type int

Constant DIVERGED_NAN of type int

Constant DIVERGED_TR_REDUCTION of type int

Constant DIVERGED_USER of type int

Constant ITERATING of type int


petsc4py.PETSc.TAO.Type

Bases: object

TAO solver type.

SEE ALSO:

petsc.TaoType


Attributes Summary

ADMM Object ADMM of type str
ALMM Object ALMM of type str
ASFLS Object ASFLS of type str
ASILS Object ASILS of type str
BLMVM Object BLMVM of type str
BMRM Object BMRM of type str
BNCG Object BNCG of type str
BNLS Object BNLS of type str
BNTL Object BNTL of type str
BNTR Object BNTR of type str
BQNKLS Object BQNKLS of type str
BQNKTL Object BQNKTL of type str
BQNKTR Object BQNKTR of type str
BQNLS Object BQNLS of type str
BQPIP Object BQPIP of type str
BRGN Object BRGN of type str
CG Object CG of type str
GPCG Object GPCG of type str
IPM Object IPM of type str
LCL Object LCL of type str
LMVM Object LMVM of type str
NLS Object NLS of type str
NM Object NM of type str
NTL Object NTL of type str
NTR Object NTR of type str
OWLQN Object OWLQN of type str
PDIPM Object PDIPM of type str
POUNDERS Object POUNDERS of type str
PYTHON Object PYTHON of type str
SHELL Object SHELL of type str
SSFLS Object SSFLS of type str
SSILS Object SSILS of type str
TRON Object TRON of type str

Attributes Documentation

Object ADMM of type str

Object ALMM of type str

Object ASFLS of type str

Object ASILS of type str

Object BLMVM of type str

Object BMRM of type str

Object BNCG of type str

Object BNLS of type str

Object BNTL of type str

Object BNTR of type str

Object BQNKLS of type str

Object BQNKTL of type str

Object BQNKTR of type str

Object BQNLS of type str

Object BQPIP of type str

Object BRGN of type str

Object CG of type str

Object GPCG of type str

Object IPM of type str

Object LCL of type str

Object LMVM of type str

Object NLS of type str

Object NM of type str

Object NTL of type str

Object NTR of type str

Object OWLQN of type str

Object PDIPM of type str

Object POUNDERS of type str

Object PYTHON of type str

Object SHELL of type str

Object SSFLS of type str

Object SSILS of type str

Object TRON of type str


Methods Summary

appendOptionsPrefix(prefix) Append to the prefix used for searching for options in the database.
cancelMonitor() Cancel all the monitors of the solver.
computeConstraints(x, c) Compute the vector corresponding to the constraints.
computeDualVariables(xl, xu) Compute the dual vectors corresponding to variables' bounds.
computeGradient(x, g) Compute the gradient of the objective function.
computeHessian(x, H[, P]) Compute the Hessian of the objective function.
computeJacobian(x, J[, P]) Compute the Jacobian.
computeObjective(x) Compute the value of the objective function.
computeObjectiveGradient(x, g) Compute the gradient of the objective function and its value.
computeResidual(x, f) Compute the residual.
computeVariableBounds(xl, xu) Compute the vectors corresponding to variables' bounds.
create([comm]) Create a TAO solver.
createPython([context, comm]) Create an optimization solver of Python type.
destroy() Destroy the solver.
getAppCtx() Return the application context.
getBNCGType() Return the type of the BNCG solver.
getBRGNDampingVector() Return the damping vector.
getBRGNSubsolver() Return the subsolver inside the BRGN solver.
getConstraintTolerances() Return the constraints tolerance parameters used in the convergence tests.
getConvergedReason() Return the termination flag.
getConvergenceTest() Return the callback used to test for solver convergence.
getGradient() Return the vector used to store the gradient and the evaluation callback.
getGradientNorm() Return the matrix used to compute inner products.
getHessian() Return the matrices used to store the Hessian and the evaluation callback.
getIterationNumber() Return the current iteration number.
getKSP() Return the linear solver used by the nonlinear solver.
getLMVMH0() Return the initial Hessian for the quasi-Newton approximation.
getLMVMH0KSP() Return the KSP for the inverse of the initial Hessian approximation.
getLineSearch() Return the TAO Line Search object.
getMaximumFunctionEvaluations() Return the maximum number of objective evaluations within the solver.
getMaximumIterations() Return the maximum number of solver iterations.
getMonitor() Return the callback used to monitor solver convergence.
getObjectiveAndGradient() Return the vector used to store the gradient and the evaluation callback.
getObjectiveValue() Return the current value of the objective function.
getOptionsPrefix() Return the prefix used for searching for options in the database.
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 solver.
getSolution() Return the vector holding the solution.
getSolutionNorm() Return the objective function value and the norms of gradient and constraints.
getSolutionStatus() Return the solution status.
getTolerances() Return the tolerance parameters used in the solver convergence tests.
getType() Return the type of the solver.
getUpdate() Return the callback to compute the update.
getVariableBounds() Return the upper and lower bounds vectors.
monitor([its, f, res, cnorm, step]) Monitor the solver.
setAppCtx(appctx) Set the application context.
setBNCGType(cg_type) Set the type of the BNCG solver.
setBRGNDictionaryMatrix(D) Set the dictionary matrix.
setBRGNRegularizerHessian(hessian[, H, ...]) Set the callback to compute the regularizer Hessian.
setBRGNRegularizerObjectiveGradient(objgrad) Set the callback to compute the regularizer objective and gradient.
setBRGNRegularizerWeight(weight) Set the regularizer weight.
setBRGNSmoothL1Epsilon(epsilon) Set the smooth L1 epsilon.
setConstraintTolerances([catol, crtol]) Set the constraints tolerance parameters used in the solver convergence tests.
setConstraints(constraints[, C, args, kargs]) Set the callback to compute constraints.
setConvergedReason(reason) Set the termination flag.
setConvergenceTest(converged[, args, kargs]) Set the callback used to test for solver convergence.
setEqualityConstraints(equality_constraints, c) Set equality constraints callback.
setFromOptions() Configure the solver from the options database.
setGradient(gradient[, g, args, kargs]) Set the gradient evaluation callback.
setGradientNorm(mat) Set the matrix used to compute inner products.
setHessian(hessian[, H, P, args, kargs]) Set the callback to compute the Hessian matrix.
setInitialTrustRegionRadius(radius) Set the initial trust region radius.
setIterationNumber(its) Set the current iteration number.
setJacobian(jacobian[, J, P, args, kargs]) Set the callback to compute the Jacobian.
setJacobianDesign(jacobian_design[, J, ...]) Set Jacobian design callback.
setJacobianEquality(jacobian_equality[, J, ...]) Set Jacobian equality constraints callback.
setJacobianResidual(jacobian[, J, P, args, ...]) Set the callback to compute the least-squares residual Jacobian.
setJacobianState(jacobian_state[, J, P, I, ...]) Set Jacobian state callback.
setLMVMH0(mat) Set the initial Hessian for the quasi-Newton approximation.
setMaximumFunctionEvaluations(mit) Set the maximum number of objective evaluations within the solver.
setMaximumIterations(mit) Set the maximum number of solver iterations.
setMonitor(monitor[, args, kargs]) Set the callback used to monitor solver convergence.
setObjective(objective[, args, kargs]) Set the objective function evaluation callback.
setObjectiveGradient(objgrad[, g, args, kargs]) Set the objective function and gradient evaluation callback.
setOptionsPrefix(prefix) Set the prefix used for searching for options in the 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.
setResidual(residual[, R, args, kargs]) Set the residual evaluation callback for least-squares applications.
setSolution(x) Set the vector used to store the solution.
setStateDesignIS([state, design]) Set the index sets indicating state and design variables.
setTolerances([gatol, grtol, gttol]) Set the tolerance parameters used in the solver convergence tests.
setType(tao_type) Set the type of the solver.
setUp() Set up the internal data structures for using the solver.
setUpdate(update[, args, kargs]) Set the callback to compute update at each optimization step.
setVariableBounds(varbounds[, args, kargs]) Set the upper and lower bounds for the optimization problem.
solve([x]) Solve the optimization problem.
view([viewer]) View the solver.

Attributes Summary

appctx Application context.
cnorm Constraints norm.
converged Boolean indicating if the solver has converged.
ctol Broken.
diverged Boolean indicating if the solver has failed.
ftol Broken.
function Objective value.
gnorm Gradient norm.
gradient Gradient vector.
gtol Broken.
iterating Boolean indicating if the solver has not converged yet.
its Number of iterations.
ksp Linear solver.
objective Objective value.
reason Converged reason.
solution Solution vector.

Methods Documentation

Append to the prefix used for searching for options in the database.

Logically collective.

SEE ALSO:

Working with PETSc options (TODO), setOptionsPrefix, petsc.TaoAppendOptionsPrefix


Source code at petsc4py/PETSc/TAO.pyx:210

prefix (str) --
None


Cancel all the monitors of the solver.

Logically collective.

SEE ALSO:

setMonitor, petsc.TaoCancelMonitors


Source code at petsc4py/PETSc/TAO.pyx:1210



Compute the vector corresponding to the constraints.

Collective.

  • x (Vec) -- The parameter vector.
  • c (Vec) -- The output constraints vector.

None

SEE ALSO:

setVariableBounds, petsc.TaoComputeVariableBounds


Source code at petsc4py/PETSc/TAO.pyx:886


Compute the dual vectors corresponding to variables' bounds.

Collective.

SEE ALSO:

petsc.TaoComputeDualVariables


Source code at petsc4py/PETSc/TAO.pyx:850

  • xl (Vec) --
  • xu (Vec) --

None


Compute the gradient of the objective function.

Collective.

  • x (Vec) -- The parameter vector.
  • g (Vec) -- The output gradient vector.

None

SEE ALSO:

setGradient, petsc.TaoComputeGradient


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


Compute the Hessian of the objective function.

Collective.

  • x (Vec) -- The parameter vector.
  • H (Mat) -- The output Hessian matrix.
  • P (Mat | None) -- The output Hessian matrix used to construct the preconditioner.

None

SEE ALSO:

setHessian, petsc.TaoComputeHessian


Source code at petsc4py/PETSc/TAO.pyx:905


Compute the Jacobian.

Collective.

  • x (Vec) -- The parameter vector.
  • J (Mat) -- The output Jacobian matrix.
  • P (Mat | None) -- The output Jacobian matrix used to construct the preconditioner.

None

SEE ALSO:

setJacobian, petsc.TaoComputeJacobian


Source code at petsc4py/PETSc/TAO.pyx:928


Compute the value of the objective function.

Collective.

x (Vec) -- The parameter vector.
float

SEE ALSO:

setObjective, petsc.TaoComputeObjective


Source code at petsc4py/PETSc/TAO.pyx:771


Compute the gradient of the objective function and its value.

Collective.

  • x (Vec) -- The parameter vector.
  • g (Vec) -- The output gradient vector.

float

SEE ALSO:

setObjectiveGradient, setGradient, setObjective, petsc.TaoComputeObjectiveAndGradient


Source code at petsc4py/PETSc/TAO.pyx:828


Compute the residual.

Collective.

  • x (Vec) -- The parameter vector.
  • f (Vec) -- The output vector.

None

SEE ALSO:

setResidual, petsc.TaoComputeResidual


Source code at petsc4py/PETSc/TAO.pyx:790


Compute the vectors corresponding to variables' bounds.

Collective.

SEE ALSO:

setVariableBounds, petsc.TaoComputeVariableBounds


Source code at petsc4py/PETSc/TAO.pyx:862

  • xl (Vec) --
  • xu (Vec) --

None


Create a TAO solver.

Collective.

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

SEE ALSO:

Sys.getDefaultComm, petsc.TaoCreate


Source code at petsc4py/PETSc/TAO.pyx:142


Create an optimization solver of Python type.

Collective.

  • context (Any) -- An instance of the Python class implementing the required methods.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

PETSc Python optimization solver type (TODO), setType, setPythonContext, Type.PYTHON


Source code at petsc4py/PETSc/TAO.pyx:1652


Destroy the solver.

Collective.

SEE ALSO:

petsc.TaoDestroy


Source code at petsc4py/PETSc/TAO.pyx:129



Return the application context.

Source code at petsc4py/PETSc/TAO.pyx:283



Return the type of the BNCG solver.

Not collective.

SEE ALSO:

setBNCGType, petsc.TaoBNCGGetType


Source code at petsc4py/PETSc/TAO.pyx:1406

BNCGType


Return the damping vector.

Not collective.

Source code at petsc4py/PETSc/TAO.pyx:1637



Return the subsolver inside the BRGN solver.

Not collective.

SEE ALSO:

petsc.TaoBRGNGetSubsolver


Source code at petsc4py/PETSc/TAO.pyx:1554



Return the constraints tolerance parameters used in the convergence tests.

Not collective.

  • catol (float) -- The absolute norm of the constraints.
  • crtol (float) -- The relative norm of the constraints.

tuple[float, float]

SEE ALSO:

setConstraintTolerances, petsc.TaoGetConstraintTolerances


Source code at petsc4py/PETSc/TAO.pyx:1081


Return the termination flag.

Not collective.

SEE ALSO:

setConvergedReason, petsc.TaoGetConvergedReason


Source code at petsc4py/PETSc/TAO.pyx:1155

ConvergedReason


Return the callback used to test for solver convergence.

Not collective.

SEE ALSO:

setConvergenceTest


Source code at petsc4py/PETSc/TAO.pyx:1130

tuple[TAOConvergedFunction, tuple[Any, ...], dict[str, Any]]


Return the vector used to store the gradient and the evaluation callback.

Not collective.

SEE ALSO:

setGradient, setHessian, petsc.TaoGetGradient


Source code at petsc4py/PETSc/TAO.pyx:415

tuple[Vec, TAOGradientFunction]


Return the matrix used to compute inner products.

Not collective.

SEE ALSO:

setGradientNorm, petsc.TaoGetGradientNorm


Source code at petsc4py/PETSc/TAO.pyx:1321



Return the matrices used to store the Hessian and the evaluation callback.

Not collective.

SEE ALSO:

setHessian, petsc.TaoGetHessian


Source code at petsc4py/PETSc/TAO.pyx:577

tuple[Mat, Mat, TAOHessianFunction]


Return the current iteration number.

Not collective.

SEE ALSO:

setIterationNumber, petsc.TaoGetIterationNumber


Source code at petsc4py/PETSc/TAO.pyx:1433



Return the linear solver used by the nonlinear solver.

Not collective.

SEE ALSO:

petsc.TaoGetKSP


Source code at petsc4py/PETSc/TAO.pyx:1537



Return the initial Hessian for the quasi-Newton approximation.

Not collective.

SEE ALSO:

setLMVMH0, petsc.TaoLMVMGetH0


Source code at petsc4py/PETSc/TAO.pyx:1348



Return the KSP for the inverse of the initial Hessian approximation.

Not collective.

SEE ALSO:

setLMVMH0, petsc.TaoLMVMGetH0KSP


Source code at petsc4py/PETSc/TAO.pyx:1363



Return the TAO Line Search object.

Not collective.

SEE ALSO:

petsc.TaoGetLineSearch


Source code at petsc4py/PETSc/TAO.pyx:1734

TAOLineSearch


Return the maximum number of objective evaluations within the solver.

Not collective.

SEE ALSO:

setMaximumFunctionEvaluations, petsc.TaoGetMaximumFunctionEvaluations


Source code at petsc4py/PETSc/TAO.pyx:1045



Return the maximum number of solver iterations.

Not collective.

SEE ALSO:

setMaximumIterations, petsc.TaoGetMaximumIterations


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



Return the callback used to monitor solver convergence.

Not collective.

SEE ALSO:

setMonitor


Source code at petsc4py/PETSc/TAO.pyx:1198

list[tuple[TAOMonitorFunction, tuple[Any, ...], dict[str, Any]]]


Return the vector used to store the gradient and the evaluation callback.

Not collective.

SEE ALSO:

setObjectiveGradient, petsc.TaoGetObjectiveAndGradient


Source code at petsc4py/PETSc/TAO.pyx:461

tuple[Vec, TAOObjectiveGradientFunction]


Return the current value of the objective function.

Not collective.

SEE ALSO:

setObjective, petsc.TaoGetSolutionStatus


Source code at petsc4py/PETSc/TAO.pyx:1447

float


Return the prefix used for searching for options in the database.

Not collective.

SEE ALSO:

Working with PETSc options (TODO), setOptionsPrefix, petsc.TaoGetOptionsPrefix


Source code at petsc4py/PETSc/TAO.pyx:224



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

Not collective.

SEE ALSO:

PETSc Python optimization solver type (TODO), setPythonContext


Source code at petsc4py/PETSc/TAO.pyx:1689



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

Not collective.

SEE ALSO:

PETSc Python optimization solver type (TODO), setPythonContext, setPythonType, petsc.TaoPythonGetType


Source code at petsc4py/PETSc/TAO.pyx:1719



Return the vector holding the solution.

Not collective.

SEE ALSO:

setSolution, petsc.TaoGetSolution


Source code at petsc4py/PETSc/TAO.pyx:1294



Return the objective function value and the norms of gradient and constraints.

Not collective.

  • f (float) -- Current value of the objective function.
  • res (float) -- Current value of the residual norm.
  • cnorm (float) -- Current value of the constrains norm.

tuple[float, float, float]

SEE ALSO:

getSolutionStatus, petsc.TaoGetSolutionStatus


Source code at petsc4py/PETSc/TAO.pyx:1477


Return the solution status.

Not collective.

  • its (int) -- Current number of iterations.
  • f (float) -- Current value of the objective function.
  • res (float) -- Current value of the residual norm.
  • cnorm (float) -- Current value of the constrains norm.
  • step (float) -- Current value of the step.
  • reason (ConvergedReason) -- Current value of converged reason.

tuple[int, float, float, float, float, ConvergedReason]

SEE ALSO:

petsc.TaoGetSolutionStatus


Source code at petsc4py/PETSc/TAO.pyx:1502


Return the tolerance parameters used in the solver convergence tests.

Not collective.

  • gatol (float) -- The absolute norm of the gradient.
  • grtol (float) -- The relative norm of the gradient with respect to the initial norm of the objective.
  • gttol (float) -- The relative norm of the gradient with respect to the initial norm of the gradient.

tuple[float, float, float]

SEE ALSO:

setTolerances, petsc.TaoGetTolerances


Source code at petsc4py/PETSc/TAO.pyx:980


Return the type of the solver.

Not collective.

SEE ALSO:

setType, petsc.TaoGetType


Source code at petsc4py/PETSc/TAO.pyx:182



Return the callback to compute the update.

Not collective.

SEE ALSO:

setUpdate


Source code at petsc4py/PETSc/TAO.pyx:757

tuple[TAOUpdateFunction, tuple[Any, ...], dict[str, Any]]


Return the upper and lower bounds vectors.

Not collective.

SEE ALSO:

setVariableBounds, petsc.TaoGetVariableBounds


Source code at petsc4py/PETSc/TAO.pyx:1378

tuple[Vec, Vec]


Monitor the solver.

Collective.

This function should be called without arguments, unless users want to modify the values internally stored by the solver.

  • its (int) -- Current number of iterations or None to use the value stored internally by the solver.
  • f (float) -- Current value of the objective function or None to use the value stored internally by the solver.
  • res (float) -- Current value of the residual norm or None to use the value stored internally by the solver.
  • cnorm (float) -- Current value of the constrains norm or None to use the value stored internally by the solver.
  • step (float) -- Current value of the step or None to use the value stored internally by the solver.

None

SEE ALSO:

setMonitor, petsc.TaoMonitor


Source code at petsc4py/PETSc/TAO.pyx:1224


Set the application context.

Source code at petsc4py/PETSc/TAO.pyx:279

appctx (Any) --
None


Set the type of the BNCG solver.

Collective.

SEE ALSO:

getBNCGType, petsc.TaoBNCGSetType


Source code at petsc4py/PETSc/TAO.pyx:1393

cg_type (BNCGType) --
None


Set the dictionary matrix.

Collective.

SEE ALSO:

petsc.TaoBRGNSetDictionaryMatrix


Source code at petsc4py/PETSc/TAO.pyx:1625

D (Mat) --
None


Set the callback to compute the regularizer Hessian.

Logically collective.

SEE ALSO:

petsc.TaoBRGNSetRegularizerHessianRoutine


Source code at petsc4py/PETSc/TAO.pyx:1585

  • H (Mat | None) --
  • args (tuple[Any, ...] | None) --
  • kargs (dict[str, Any] | None) --

None


Set the callback to compute the regularizer objective and gradient.

Logically collective.

SEE ALSO:

petsc.TaoBRGNSetRegularizerObjectiveAndGradientRoutine


Source code at petsc4py/PETSc/TAO.pyx:1569

  • args (tuple[Any, ...] | None) --
  • kargs (dict[str, Any] | None) --

None


Set the regularizer weight.

Collective.

Source code at petsc4py/PETSc/TAO.pyx:1603

weight (float) --
None


Set the smooth L1 epsilon.

Collective.

SEE ALSO:

petsc.TaoBRGNSetL1SmoothEpsilon


Source code at petsc4py/PETSc/TAO.pyx:1612

epsilon (float) --
None


Set the constraints tolerance parameters used in the solver convergence tests.

Collective.

  • catol (float) -- The absolute norm of the constraints. Defaults to DEFAULT.
  • crtol (float) -- The relative norm of the constraints. Defaults to DEFAULT.

None

SEE ALSO:

getConstraintTolerances, petsc.TaoSetConstraintTolerances


Source code at petsc4py/PETSc/TAO.pyx:1059


Set the callback to compute constraints.

Logically collective.

  • constraints (TAOConstraintsFunction) -- The callback.
  • C (Vec | None) -- The vector to hold the constraints.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

petsc.TaoSetConstraintsRoutine


Source code at petsc4py/PETSc/TAO.pyx:513


Set the termination flag.

Collective.

SEE ALSO:

getConvergedReason, petsc.TaoSetConvergedReason


Source code at petsc4py/PETSc/TAO.pyx:1142

reason (ConvergedReason) --
None


Set the callback used to test for solver convergence.

Logically collective.

  • converged (TAOConvergedFunction | None) -- The callback. If None, reset to the default convergence test.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

getConvergenceTest, petsc.TaoSetConvergenceTest


Source code at petsc4py/PETSc/TAO.pyx:1102


Set equality constraints callback.

Logically collective.

SEE ALSO:

petsc.TaoSetEqualityConstraintsRoutine


Source code at petsc4py/PETSc/TAO.pyx:688

  • c (Vec) --
  • args (tuple[Any, ...] | None) --
  • kargs (dict[str, Any] | None) --

None


Configure the solver from the options database.

Collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.TaoSetFromOptions


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



Set the gradient evaluation callback.

Logically collective.

  • gradient (TAOGradientFunction) -- The gradient callback.
  • g (Vec | None) -- The vector to store the gradient.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

setObjective, setObjectiveGradient, setHessian, petsc.TaoSetGradient


Source code at petsc4py/PETSc/TAO.pyx:386


Set the matrix used to compute inner products.

Collective.

SEE ALSO:

getGradientNorm, petsc.TaoSetGradientNorm


Source code at petsc4py/PETSc/TAO.pyx:1309

mat (Mat) --
None


Set the callback to compute the Hessian matrix.

Logically collective.

  • hessian (TAOHessianFunction) -- The Hessian callback.
  • H (Mat | None) -- The matrix to store the Hessian.
  • P (Mat | None) -- The matrix to construct the preconditioner.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

getHessian, setObjective, setObjectiveGradient, setGradient, petsc.TaoSetHessian


Source code at petsc4py/PETSc/TAO.pyx:542


Set the initial trust region radius.

Collective.

SEE ALSO:

petsc.TaoSetInitialTrustRegionRadius


Source code at petsc4py/PETSc/TAO.pyx:264

radius (float) --
None


Set the current iteration number.

Collective.

SEE ALSO:

getIterationNumber, petsc.TaoSetIterationNumber


Source code at petsc4py/PETSc/TAO.pyx:1420

its (int) --
None


Set the callback to compute the Jacobian.

Logically collective.

  • jacobian (TAOJacobianFunction) -- The Jacobian callback.
  • J (Mat | None) -- The matrix to store the Jacobian.
  • P (Mat | None) -- The matrix to construct the preconditioner.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

petsc.TaoSetJacobianRoutine


Source code at petsc4py/PETSc/TAO.pyx:595


Set Jacobian design callback.

Logically collective.

SEE ALSO:

petsc.TaoSetJacobianDesignRoutine


Source code at petsc4py/PETSc/TAO.pyx:668

  • J (Mat | None) --
  • args (tuple[Any, ...] | None) --
  • kargs (dict[str, Any] | None) --

None


Set Jacobian equality constraints callback.

Logically collective.

SEE ALSO:

petsc.TaoSetJacobianEqualityRoutine


Source code at petsc4py/PETSc/TAO.pyx:706

  • J (Mat | None) --
  • P (Mat | None) --
  • args (tuple[Any, ...] | None) --
  • kargs (dict[str, Any] | None) --

None


Set the callback to compute the least-squares residual Jacobian.

Logically collective.

  • jacobian (TAOJacobianResidualFunction) -- The Jacobian callback.
  • J (Mat | None) -- The matrix to store the Jacobian.
  • P (Mat | None) -- The matrix to construct the preconditioner.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

setResidual, petsc.TaoSetJacobianResidualRoutine


Source code at petsc4py/PETSc/TAO.pyx:353


Set Jacobian state callback.

Logically collective.

SEE ALSO:

petsc.TaoSetJacobianStateRoutine


Source code at petsc4py/PETSc/TAO.pyx:644

  • J (Mat | None) --
  • P (Mat | None) --
  • I (Mat | None) --
  • args (tuple[Any, ...] | None) --
  • kargs (dict[str, Any] | None) --

None


Set the initial Hessian for the quasi-Newton approximation.

Collective.

SEE ALSO:

getLMVMH0, petsc.TaoLMVMSetH0


Source code at petsc4py/PETSc/TAO.pyx:1336

mat (Mat) --
None


Set the maximum number of objective evaluations within the solver.

Collective.

SEE ALSO:

setMaximumIterations, petsc.TaoSetMaximumFunctionEvaluations


Source code at petsc4py/PETSc/TAO.pyx:1032

mit (int) --
None


Set the maximum number of solver iterations.

Collective.

SEE ALSO:

setTolerances, petsc.TaoSetMaximumIterations


Source code at petsc4py/PETSc/TAO.pyx:1005

mit (int) --
float


Set the callback used to monitor solver convergence.

Logically collective.

  • monitor (TAOMonitorFunction) -- The callback.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

getMonitor, petsc.TaoSetMonitor


Source code at petsc4py/PETSc/TAO.pyx:1169


Set the objective function evaluation callback.

Logically collective.

  • objective (TAOObjectiveFunction) -- The objective function callback.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

setGradient, setObjectiveGradient, petsc.TaoSetObjective


Source code at petsc4py/PETSc/TAO.pyx:299


Set the objective function and gradient evaluation callback.

Logically collective.

  • objgrad (TAOObjectiveGradientFunction) -- The objective function and gradient callback.
  • g (Vec | None) -- The vector to store the gradient.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

setObjective, setGradient, setHessian, getObjectiveAndGradient, petsc.TaoSetObjectiveAndGradient


Source code at petsc4py/PETSc/TAO.pyx:431


Set the prefix used for searching for options in the database.

Logically collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.TaoSetOptionsPrefix


Source code at petsc4py/PETSc/TAO.pyx:196

prefix (str) --
None


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

Not collective.

SEE ALSO:

PETSc Python optimization solver type (TODO), getPythonContext


Source code at petsc4py/PETSc/TAO.pyx:1677

context (Any) --
None


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

Collective.

SEE ALSO:

PETSc Python optimization solver type (TODO), setPythonContext, getPythonType, petsc.TaoPythonSetType


Source code at petsc4py/PETSc/TAO.pyx:1704

py_type (str) --
None


Set the residual evaluation callback for least-squares applications.

Logically collective.

  • residual (TAOResidualFunction) -- The residual callback.
  • R (Vec | None) -- The vector to store the residual.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

setJacobianResidual, petsc.TaoSetResidualRoutine


Source code at petsc4py/PETSc/TAO.pyx:324


Set the vector used to store the solution.

Collective.

SEE ALSO:

getSolution, petsc.TaoSetSolution


Source code at petsc4py/PETSc/TAO.pyx:287

x (Vec) --
None


Set the index sets indicating state and design variables.

Collective.

SEE ALSO:

petsc.TaoSetStateDesignIS


Source code at petsc4py/PETSc/TAO.pyx:629

  • state (IS | None) --
  • design (IS | None) --

None


Set the tolerance parameters used in the solver convergence tests.

Collective.

  • gatol (float) -- The absolute norm of the gradient. Defaults to DEFAULT.
  • grtol (float) -- The relative norm of the gradient with respect to the initial norm of the objective. Defaults to DEFAULT.
  • gttol (float) -- The relative norm of the gradient with respect to the initial norm of the gradient. Defaults to DEFAULT.

None

SEE ALSO:

getTolerances, petsc.TaoSetTolerances


Source code at petsc4py/PETSc/TAO.pyx:953


Set the type of the solver.

Logically collective.

tao_type (Type | str) -- The type of the solver.
None

SEE ALSO:

getType, petsc.TaoSetType


Source code at petsc4py/PETSc/TAO.pyx:163


Set up the internal data structures for using the solver.

Collective.

SEE ALSO:

petsc.TaoSetUp


Source code at petsc4py/PETSc/TAO.pyx:250



Set the callback to compute update at each optimization step.

Logically collective.

  • update (TAOUpdateFunction) -- The update callback or None to reset it.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

getUpdate, petsc.TaoSetUpdate


Source code at petsc4py/PETSc/TAO.pyx:728


Set the upper and lower bounds for the optimization problem.

Logically collective.

  • varbounds (tuple[Vec, Vec] | TAOVariableBoundsFunction) -- Either a tuple of Vec or a TAOVariableBoundsFunction callback.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

petsc.TaoSetVariableBounds, petsc.TaoSetVariableBoundsRoutine


Source code at petsc4py/PETSc/TAO.pyx:477


Solve the optimization problem.

Collective.

x (Vec | None) -- The starting vector or None to use the vector stored internally.
None

SEE ALSO:

setSolution, getSolution, petsc.TaoSolve


Source code at petsc4py/PETSc/TAO.pyx:1275


View the solver.

Collective.

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

SEE ALSO:

petsc.TaoView


Source code at petsc4py/PETSc/TAO.pyx:110


Attributes Documentation

Application context.

Source code at petsc4py/PETSc/TAO.pyx:1755


Constraints norm.

Source code at petsc4py/PETSc/TAO.pyx:1820


Boolean indicating if the solver has converged.

Source code at petsc4py/PETSc/TAO.pyx:1857


Broken.

Source code at petsc4py/PETSc/TAO.pyx:1796


Boolean indicating if the solver has failed.

Source code at petsc4py/PETSc/TAO.pyx:1862


Broken.

Source code at petsc4py/PETSc/TAO.pyx:1772


Objective value.

Source code at petsc4py/PETSc/TAO.pyx:1835


Gradient norm.

Source code at petsc4py/PETSc/TAO.pyx:1815


Gradient vector.

Source code at petsc4py/PETSc/TAO.pyx:1840


Broken.

Source code at petsc4py/PETSc/TAO.pyx:1784


Boolean indicating if the solver has not converged yet.

Source code at petsc4py/PETSc/TAO.pyx:1852


Number of iterations.

Source code at petsc4py/PETSc/TAO.pyx:1810


Linear solver.

Source code at petsc4py/PETSc/TAO.pyx:1764


Objective value.

Source code at petsc4py/PETSc/TAO.pyx:1830


Converged reason.

Source code at petsc4py/PETSc/TAO.pyx:1847


Solution vector.

Source code at petsc4py/PETSc/TAO.pyx:1825




petsc4py.PETSc.TAOLineSearch

Bases: Object

TAO Line Search.

Enumerations

ConvergedReason TAO Line Search Termination Reasons.
Type TAO Line Search Types.

petsc4py.PETSc.TAOLineSearch.ConvergedReason

Bases: object

TAO Line Search Termination Reasons.

Attributes Summary

CONTINUE_SEARCH Constant CONTINUE_SEARCH of type int
FAILED_ASCENT Constant FAILED_ASCENT of type int
FAILED_BADPARAMETER Constant FAILED_BADPARAMETER of type int
FAILED_INFORNAN Constant FAILED_INFORNAN of type int
HALTED_LOWERBOUND Constant HALTED_LOWERBOUND of type int
HALTED_MAXFCN Constant HALTED_MAXFCN of type int
HALTED_OTHER Constant HALTED_OTHER of type int
HALTED_RTOL Constant HALTED_RTOL of type int
HALTED_UPPERBOUND Constant HALTED_UPPERBOUND of type int
HALTED_USER Constant HALTED_USER of type int
SUCCESS Constant SUCCESS of type int
SUCCESS_USER Constant SUCCESS_USER of type int

Attributes Documentation

Constant CONTINUE_SEARCH of type int

Constant FAILED_ASCENT of type int

Constant FAILED_BADPARAMETER of type int

Constant FAILED_INFORNAN of type int

Constant HALTED_LOWERBOUND of type int

Constant HALTED_MAXFCN of type int

Constant HALTED_OTHER of type int

Constant HALTED_RTOL of type int

Constant HALTED_UPPERBOUND of type int

Constant HALTED_USER of type int

Constant SUCCESS of type int

Constant SUCCESS_USER of type int


petsc4py.PETSc.TAOLineSearch.Type

Bases: object

TAO Line Search Types.

Attributes Summary

ARMIJO Object ARMIJO of type str
GPCG Object GPCG of type str
IPM Object IPM of type str
MORETHUENTE Object MORETHUENTE of type str
OWARMIJO Object OWARMIJO of type str
UNIT Object UNIT of type str

Attributes Documentation

Object ARMIJO of type str

Object GPCG of type str

Object IPM of type str

Object MORETHUENTE of type str

Object OWARMIJO of type str

Object UNIT of type str


Methods Summary

apply(x, g, s) Performs a line-search in a given step direction.
create([comm]) Create a TAO linesearch.
destroy() Destroy the linesearch object.
getOptionsPrefix() Return the prefix used for searching for options in the database.
getType() Return the type of the linesearch.
setFromOptions() Configure the linesearch from the options database.
setGradient(gradient[, args, kargs]) Set the gradient evaluation callback.
setObjective(objective[, args, kargs]) Set the objective function evaluation callback.
setObjectiveGradient(objgrad[, args, kargs]) Set the objective function and gradient evaluation callback.
setOptionsPrefix(prefix) Set the prefix used for searching for options in the database.
setType(ls_type) Set the type of the linesearch.
setUp() Set up the internal data structures for using the linesearch.
useTAORoutine(tao) Use the objective and gradient evaluation routines from the given Tao object.
view([viewer]) View the linesearch object.

Methods Documentation

Performs a line-search in a given step direction.

Collective.

SEE ALSO:

petsc.TaoLineSearchApply


Source code at petsc4py/PETSc/TAO.pyx:2144

  • x (Vec) --
  • g (Vec) --
  • s (Vec) --

tuple[float, float, str]


Create a TAO linesearch.

Collective.

comm -- MPI communicator, defaults to Sys.getDefaultComm.
Self

SEE ALSO:

Sys.getDefaultComm, petsc.TaoLineSearchCreate


Source code at petsc4py/PETSc/TAO.pyx:1947


Destroy the linesearch object.

Collective.

SEE ALSO:

petsc.TaoLineSearchDestroy


Source code at petsc4py/PETSc/TAO.pyx:1934



Return the prefix used for searching for options in the database.

Not collective.

SEE ALSO:

Working with PETSc options (TODO), setOptionsPrefix, petsc.TaoLineSearchGetOptionsPrefix


Source code at petsc4py/PETSc/TAO.pyx:2039



Return the type of the linesearch.

Not collective.

SEE ALSO:

setType, petsc.TaoLineSearchGetType


Source code at petsc4py/PETSc/TAO.pyx:1987



Configure the linesearch from the options database.

Collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.TaoLineSearchSetFromOptions


Source code at petsc4py/PETSc/TAO.pyx:2001



Set the gradient evaluation callback.

Logically collective.

  • gradient (TAOLSGradientFunction) -- The gradient callback.
  • g -- The vector to store the gradient.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

setObjective, setObjectiveGradient, setHessian, petsc.TaoLineSearchSetGradientRoutine


Source code at petsc4py/PETSc/TAO.pyx:2078


Set the objective function evaluation callback.

Logically collective.

  • objective (TAOLSObjectiveFunction) -- The objective function callback.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

setGradient, setObjectiveGradient, petsc.TaoLineSearchSetObjectiveRoutine


Source code at petsc4py/PETSc/TAO.pyx:2053


Set the objective function and gradient evaluation callback.

Logically collective.

  • objgrad (TAOLSObjectiveGradientFunction) -- The objective function and gradient callback.
  • g -- The vector to store the gradient.
  • args (tuple[Any, ...] | None) -- Positional arguments for the callback.
  • kargs (dict[str, Any] | None) -- Keyword arguments for the callback.

None

SEE ALSO:

setObjective, setGradient, setHessian, getObjectiveAndGradient, petsc.TaoLineSearchSetObjectiveAndGradientRoutine


Source code at petsc4py/PETSc/TAO.pyx:2105


Set the prefix used for searching for options in the database.

Logically collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.TaoLineSearchSetOptionsPrefix


Source code at petsc4py/PETSc/TAO.pyx:2025



Set the type of the linesearch.

Logically collective.

ls_type (Type | str) -- The type of the solver.
None

SEE ALSO:

getType, petsc.TaoLineSearchSetType


Source code at petsc4py/PETSc/TAO.pyx:1968


Set up the internal data structures for using the linesearch.

Collective.

SEE ALSO:

petsc.TaoLineSearchSetUp


Source code at petsc4py/PETSc/TAO.pyx:2013



Use the objective and gradient evaluation routines from the given Tao object.

Logically collective.

SEE ALSO:

petsc.TaoLineSearchUseTaoRoutines


Source code at petsc4py/PETSc/TAO.pyx:2132

tao (TAO) --
None


View the linesearch object.

Collective.

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

SEE ALSO:

petsc.TaoLineSearchView


Source code at petsc4py/PETSc/TAO.pyx:1915




petsc4py.PETSc.TS

Bases: Object

ODE integrator.

TS is described in the PETSc manual.

SEE ALSO:

petsc.TS


Enumerations

ARKIMEXType The ARKIMEX subtype.
ConvergedReason The reason the time step is converging.
DIRKType The DIRK subtype.
EquationType Distinguishes among types of explicit and implicit equations.
ExactFinalTime The method for ending time stepping.
ProblemType Distinguishes linear and nonlinear problems.
RKType The RK subtype.
Type The time stepping method.

petsc4py.PETSc.TS.ARKIMEXType

Bases: object

The ARKIMEX subtype.

Attributes Summary

ARKIMEX1BEE Object ARKIMEX1BEE of type str
ARKIMEX2C Object ARKIMEX2C of type str
ARKIMEX2D Object ARKIMEX2D of type str
ARKIMEX2E Object ARKIMEX2E of type str
ARKIMEX3 Object ARKIMEX3 of type str
ARKIMEX4 Object ARKIMEX4 of type str
ARKIMEX5 Object ARKIMEX5 of type str
ARKIMEXA2 Object ARKIMEXA2 of type str
ARKIMEXARS122 Object ARKIMEXARS122 of type str
ARKIMEXARS443 Object ARKIMEXARS443 of type str
ARKIMEXBPR3 Object ARKIMEXBPR3 of type str
ARKIMEXL2 Object ARKIMEXL2 of type str
ARKIMEXPRSSP2 Object ARKIMEXPRSSP2 of type str

Attributes Documentation

Object ARKIMEX1BEE of type str

Object ARKIMEX2C of type str

Object ARKIMEX2D of type str

Object ARKIMEX2E of type str

Object ARKIMEX3 of type str

Object ARKIMEX4 of type str

Object ARKIMEX5 of type str

Object ARKIMEXA2 of type str

Object ARKIMEXARS122 of type str

Object ARKIMEXARS443 of type str

Object ARKIMEXBPR3 of type str

Object ARKIMEXL2 of type str

Object ARKIMEXPRSSP2 of type str


petsc4py.PETSc.TS.ConvergedReason

Bases: object

The reason the time step is converging.

Attributes Summary

CONVERGED_EVENT Constant CONVERGED_EVENT of type int
CONVERGED_ITERATING Constant CONVERGED_ITERATING of type int
CONVERGED_ITS Constant CONVERGED_ITS of type int
CONVERGED_TIME Constant CONVERGED_TIME of type int
CONVERGED_USER Constant CONVERGED_USER of type int
DIVERGED_NONLINEAR_SOLVE Constant DIVERGED_NONLINEAR_SOLVE of type int
DIVERGED_STEP_REJECTED Constant DIVERGED_STEP_REJECTED of type int
ITERATING Constant ITERATING of type int

Attributes Documentation

Constant CONVERGED_EVENT of type int

Constant CONVERGED_ITERATING of type int

Constant CONVERGED_ITS of type int

Constant CONVERGED_TIME of type int

Constant CONVERGED_USER of type int

Constant DIVERGED_NONLINEAR_SOLVE of type int

Constant DIVERGED_STEP_REJECTED of type int

Constant ITERATING of type int


petsc4py.PETSc.TS.DIRKType

Bases: object

The DIRK subtype.

Attributes Summary

DIRK657A Object DIRK657A of type str
DIRK658A Object DIRK658A of type str
DIRK7510SAL Object DIRK7510SAL of type str
DIRK759A Object DIRK759A of type str
DIRK8614A Object DIRK8614A of type str
DIRK8616SAL Object DIRK8616SAL of type str
DIRKES122SAL Object DIRKES122SAL of type str
DIRKES213SAL Object DIRKES213SAL of type str
DIRKES324SAL Object DIRKES324SAL of type str
DIRKES325SAL Object DIRKES325SAL of type str
DIRKES648SA Object DIRKES648SA of type str
DIRKES7510SA Object DIRKES7510SA of type str
DIRKES8516SAL Object DIRKES8516SAL of type str
DIRKS212 Object DIRKS212 of type str
DIRKS659A Object DIRKS659A of type str
DIRKS7511SAL Object DIRKS7511SAL of type str

Attributes Documentation

Object DIRK657A of type str

Object DIRK658A of type str

Object DIRK7510SAL of type str

Object DIRK759A of type str

Object DIRK8614A of type str

Object DIRK8616SAL of type str

Object DIRKES122SAL of type str

Object DIRKES213SAL of type str

Object DIRKES324SAL of type str

Object DIRKES325SAL of type str

Object DIRKES648SA of type str

Object DIRKES7510SA of type str

Object DIRKES8516SAL of type str

Object DIRKS212 of type str

Object DIRKS659A of type str

Object DIRKS7511SAL of type str


petsc4py.PETSc.TS.EquationType

Bases: object

Distinguishes among types of explicit and implicit equations.

Attributes Summary

DAE_IMPLICIT_INDEX1 Constant DAE_IMPLICIT_INDEX1 of type int
DAE_IMPLICIT_INDEX2 Constant DAE_IMPLICIT_INDEX2 of type int
DAE_IMPLICIT_INDEX3 Constant DAE_IMPLICIT_INDEX3 of type int
DAE_IMPLICIT_INDEXHI Constant DAE_IMPLICIT_INDEXHI of type int
DAE_SEMI_EXPLICIT_INDEX1 Constant DAE_SEMI_EXPLICIT_INDEX1 of type int
DAE_SEMI_EXPLICIT_INDEX2 Constant DAE_SEMI_EXPLICIT_INDEX2 of type int
DAE_SEMI_EXPLICIT_INDEX3 Constant DAE_SEMI_EXPLICIT_INDEX3 of type int
DAE_SEMI_EXPLICIT_INDEXHI Constant DAE_SEMI_EXPLICIT_INDEXHI of type int
EXPLICIT Constant EXPLICIT of type int
IMPLICIT Constant IMPLICIT of type int
ODE_EXPLICIT Constant ODE_EXPLICIT of type int
ODE_IMPLICIT Constant ODE_IMPLICIT of type int
UNSPECIFIED Constant UNSPECIFIED of type int

Attributes Documentation

Constant DAE_IMPLICIT_INDEX1 of type int

Constant DAE_IMPLICIT_INDEX2 of type int

Constant DAE_IMPLICIT_INDEX3 of type int

Constant DAE_IMPLICIT_INDEXHI of type int

Constant DAE_SEMI_EXPLICIT_INDEX1 of type int

Constant DAE_SEMI_EXPLICIT_INDEX2 of type int

Constant DAE_SEMI_EXPLICIT_INDEX3 of type int

Constant DAE_SEMI_EXPLICIT_INDEXHI of type int

Constant EXPLICIT of type int

Constant IMPLICIT of type int

Constant ODE_EXPLICIT of type int

Constant ODE_IMPLICIT of type int

Constant UNSPECIFIED of type int


petsc4py.PETSc.TS.ExactFinalTime

Bases: object

The method for ending time stepping.

Attributes Summary

INTERPOLATE Constant INTERPOLATE of type int
MATCHSTEP Constant MATCHSTEP of type int
STEPOVER Constant STEPOVER of type int
UNSPECIFIED Constant UNSPECIFIED of type int

Attributes Documentation

Constant INTERPOLATE of type int

Constant MATCHSTEP of type int

Constant STEPOVER of type int

Constant UNSPECIFIED of type int


petsc4py.PETSc.TS.ProblemType

Bases: object

Distinguishes linear and nonlinear problems.

Attributes Summary

LINEAR Constant LINEAR of type int
NONLINEAR Constant NONLINEAR of type int

Attributes Documentation

Constant LINEAR of type int

Constant NONLINEAR of type int


petsc4py.PETSc.TS.RKType

Bases: object

The RK subtype.

Attributes Summary

RK1FE Object RK1FE of type str
RK2A Object RK2A of type str
RK2B Object RK2B of type str
RK3 Object RK3 of type str
RK3BS Object RK3BS of type str
RK4 Object RK4 of type str
RK5BS Object RK5BS of type str
RK5DP Object RK5DP of type str
RK5F Object RK5F of type str
RK6VR Object RK6VR of type str
RK7VR Object RK7VR of type str
RK8VR Object RK8VR of type str

Attributes Documentation

Object RK1FE of type str

Object RK2A of type str

Object RK2B of type str

Object RK3 of type str

Object RK3BS of type str

Object RK4 of type str

Object RK5BS of type str

Object RK5DP of type str

Object RK5F of type str

Object RK6VR of type str

Object RK7VR of type str

Object RK8VR of type str


petsc4py.PETSc.TS.Type

Bases: object

The time stepping method.

Attributes Summary

ALPHA Object ALPHA of type str
ALPHA2 Object ALPHA2 of type str
ARKIMEX Object ARKIMEX of type str
BASICSYMPLECTIC Object BASICSYMPLECTIC of type str
BDF Object BDF of type str
BE Object BE of type str
BEULER Object BEULER of type str
CN Object CN of type str
CRANK_NICOLSON Object CRANK_NICOLSON of type str
DIRK Object DIRK of type str
DISCGRAD Object DISCGRAD of type str
EIMEX Object EIMEX of type str
EULER Object EULER of type str
FE Object FE of type str
GLEE Object GLEE of type str
GLLE Object GLLE of type str
MIMEX Object MIMEX of type str
MPRK Object MPRK of type str
PSEUDO Object PSEUDO of type str
PYTHON Object PYTHON of type str
RADAU5 Object RADAU5 of type str
RK Object RK of type str
ROSW Object ROSW of type str
RUNGE_KUTTA Object RUNGE_KUTTA of type str
SSP Object SSP of type str
SUNDIALS Object SUNDIALS of type str
TH Object TH of type str
THETA Object THETA of type str

Attributes Documentation

Object ALPHA of type str

Object ALPHA2 of type str

Object ARKIMEX of type str

Object BASICSYMPLECTIC of type str

Object BDF of type str

Object BE of type str

Object BEULER of type str

Object CN of type str

Object CRANK_NICOLSON of type str

Object DIRK of type str

Object DISCGRAD of type str

Object EIMEX of type str

Object EULER of type str

Object FE of type str

Object GLEE of type str

Object GLLE of type str

Object MIMEX of type str

Object MPRK of type str

Object PSEUDO of type str

Object PYTHON of type str

Object RADAU5 of type str

Object RK of type str

Object ROSW of type str

Object RUNGE_KUTTA of type str

Object SSP of type str

Object SUNDIALS of type str

Object TH of type str

Object THETA of type str


Methods Summary

adjointReset() Reset a TS, removing any allocated vectors and matrices.
adjointSetSteps(adjoint_steps) Set the number of steps the adjoint solver should take backward in time.
adjointSetUp() Set up the internal data structures for the later use of an adjoint solver.
adjointSolve() Solve the discrete adjoint problem for an ODE/DAE.
adjointStep() Step one time step backward in the adjoint run.
appendOptionsPrefix(prefix) Append to the prefix used for all the TS options.
clone() Return a shallow clone of the TS object.
computeI2Function(t, x, xdot, xdotdot, f) Evaluate the DAE residual in implicit form.
computeI2Jacobian(t, x, xdot, xdotdot, v, a, J) Evaluate the Jacobian of the DAE.
computeIFunction(t, x, xdot, f[, imex]) Evaluate the DAE residual written in implicit form.
computeIJacobian(t, x, xdot, a, J[, P, imex]) Evaluate the Jacobian of the DAE.
computeIJacobianP(t, x, xdot, a, J[, imex]) Evaluate the Jacobian with respect to parameters.
computeRHSFunction(t, x, f) Evaluate the right-hand side function.
computeRHSFunctionLinear(t, x, f) Evaluate the right-hand side via the user-provided Jacobian.
computeRHSJacobian(t, x, J[, P]) Compute the Jacobian matrix that has been set with setRHSJacobian.
computeRHSJacobianConstant(t, x, J[, P]) Reuse a Jacobian that is time-independent.
computeRHSJacobianP(t, x, J) Run the user-defined JacobianP function.
create([comm]) Create an empty TS.
createPython([context, comm]) Create an integrator of Python type.
createQuadratureTS([forward]) Create a sub TS that evaluates integrals over time.
destroy() Destroy the TS that was created with create.
getARKIMEXType() Return the Type.ARKIMEX scheme.
getAlphaParams() Return the algorithmic parameters for Type.ALPHA.
getAppCtx() Return the application context.
getConvergedReason() Return the reason the TS step was stopped.
getCostGradients() Return the cost gradients.
getCostIntegral() Return a vector of values of the integral term in the cost functions.
getDIRKType() Return the Type.DIRK scheme.
getDM() Return the DM associated with the TS.
getEquationType() Get the type of the equation that TS is solving.
getI2Function() Return the vector and function which computes the residual.
getI2Jacobian() Return the matrices and function which computes the Jacobian.
getIFunction() Return the vector and function which computes the implicit residual.
getIJacobian() Return the matrices and function which computes the implicit Jacobian.
getKSP() Return the KSP associated with the TS.
getKSPIterations() Return the total number of linear iterations used by the TS.
getMaxSteps() Return the maximum number of steps to use.
getMaxTime() Return the maximum (final) time.
getMonitor() Return the monitor.
getNumEvents() Return the number of events.
getOptionsPrefix() Return the prefix used for all the TS options.
getPostStep() Return the poststep function.
getPreStep() Return the prestep function.
getPrevTime() Return the starting time of the previously completed step.
getProblemType() Return the type of problem to be solved.
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 solver.
getQuadratureTS() Return the sub TS that evaluates integrals over time.
getRHSFunction() Return the vector where the rhs is stored and the function used to compute it.
getRHSJacobian() Return the Jacobian and the function used to compute them.
getRKType() Return the Type.RK scheme.
getSNES() Return the SNES associated with the TS.
getSNESFailures() Return the total number of failed SNES solves in the TS.
getSNESIterations() Return the total number of nonlinear iterations used by the TS.
getSolution() Return the solution at the present timestep.
getSolution2() Return the solution and time derivative at the present timestep.
getSolveTime() Return the time after a call to solve.
getStepLimits() Return the minimum and maximum allowed time step sizes.
getStepNumber() Return the number of time steps completed.
getStepRejections() Return the total number of rejected steps.
getTheta() Return the abscissa of the stage in (0,1] for Type.THETA.
getThetaEndpoint() Return whether the endpoint variable of Type.THETA is used.
getTime() Return the time of the most recently completed step.
getTimeSpan() Return the time span.
getTimeSpanSolutions() Return the solutions at the times in the time span.
getTimeStep() Return the duration of the current timestep.
getTolerances() Return the tolerances for local truncation error.
getType() Return the TS type.
interpolate(t, u) Interpolate the solution to a given time.
load(viewer) Load a TS that has been stored in binary with view.
monitor(step, time[, u]) Monitor the solve.
monitorCancel() Clear all the monitors that have been set.
removeTrajectory() Remove the internal TS trajectory object.
reset() Reset the TS, removing any allocated vectors and matrices.
restartStep() Flag the solver to restart the next step.
rollBack() Roll back one time step.
setARKIMEXFullyImplicit(flag) Solve both parts of the equation implicitly.
setARKIMEXType(ts_type) Set the type of Type.ARKIMEX scheme.
setAlphaParams([alpha_m, alpha_f, gamma]) Set the algorithmic parameters for Type.ALPHA.
setAlphaRadius(radius) Set the spectral radius for Type.ALPHA.
setAppCtx(appctx) Set the application context.
setConvergedReason(reason) Set the reason for handling the convergence of solve.
setCostGradients(vl[, vm]) Set the cost gradients.
setDIRKType(ts_type) Set the type of Type.DIRK scheme.
setDM(dm) Set the DM that may be used by some nonlinear solvers or preconditioners.
setEquationType(eqtype) Set the type of the equation that TS is solving.
setErrorIfStepFails([flag]) Immediately error is no step succeeds.
setEventHandler(direction, terminate, ...[, ...]) Set a function used for detecting events.
setEventTolerances([tol, vtol]) Set tolerances for event zero crossings when using event handler.
setExactFinalTime(option) Set method of computing the final time step.
setFromOptions() Set various TS parameters from user options.
setI2Function(function[, f, args, kargs]) Set the function to compute the 2nd order DAE.
setI2Jacobian(jacobian[, J, P, args, kargs]) Set the function to compute the Jacobian of the 2nd order DAE.
setIFunction(function[, f, args, kargs]) Set the function representing the DAE to be solved.
setIJacobian(jacobian[, J, P, args, kargs]) Set the function to compute the Jacobian.
setIJacobianP(jacobian[, J, args, kargs]) Set the function that computes the Jacobian.
setMaxSNESFailures(n) Set the maximum number of SNES solves failures allowed.
setMaxStepRejections(n) Set the maximum number of step rejections before a time step fails.
setMaxSteps(max_steps) Set the maximum number of steps to use.
setMaxTime(max_time) Set the maximum (final) time.
setMonitor(monitor[, args, kargs]) Set an additional monitor to the TS.
setOptionsPrefix(prefix) Set the prefix used for all the TS options.
setPostStep(poststep[, args, kargs]) Set a function to be called at the end of each time step.
setPreStep(prestep[, args, kargs]) Set a function to be called at the beginning of each time step.
setProblemType(ptype) Set the type of problem to be solved.
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.
setRHSFunction(function[, f, args, kargs]) Set the routine for evaluating the function G in U_t = G(t,u).
setRHSJacobian(jacobian[, J, P, args, kargs]) Set the function to compute the Jacobian of G in U_t = G(U,t).
setRHSJacobianP(jacobianp[, A, args, kargs]) Set the function that computes the Jacobian with respect to the parameters.
setRKType(ts_type) Set the type of the Runge-Kutta scheme.
setSaveTrajectory() Enable to save solutions as an internal TS trajectory.
setSolution(u) Set the initial solution vector.
setSolution2(u, v) Set the initial solution and its time derivative.
setStepLimits(hmin, hmax) Set the minimum and maximum allowed step sizes.
setStepNumber(step_number) Set the number of steps completed.
setTheta(theta) Set the abscissa of the stage in (0,1] for Type.THETA.
setThetaEndpoint([flag]) Set to use the endpoint variant of Type.THETA.
setTime(t) Set the time.
setTimeSpan(tspan) Set the time span.
setTimeStep(time_step) Set the duration of the timestep.
setTolerances([rtol, atol]) Set tolerances for local truncation error when using an adaptive controller.
setType(ts_type) Set the method to be used as the TS solver.
setUp() Set up the internal data structures for the TS.
solve(u) Step the requested number of timesteps.
step() Take one step.
view([viewer]) Print the TS object.

Attributes Summary

appctx Application context.
atol The absolute tolerance.
converged Indicates the TS has converged.
diverged Indicates the TS has stopped.
dm The DM.
equation_type The equation type.
iterating Indicates the TS is still iterating.
ksp The KSP.
max_steps The maximum number of steps.
max_time The maximum time.
problem_type The problem type.
reason The converged reason.
rtol The relative tolerance.
snes The SNES.
step_number The current step number.
time The current time.
time_step The current time step size.
vec_sol The solution vector.

Methods Documentation

Reset a TS, removing any allocated vectors and matrices.

Collective.

SEE ALSO:

petsc.TSAdjointReset


Source code at petsc4py/PETSc/TS.pyx:2612



Set the number of steps the adjoint solver should take backward in time.
adjoint_steps (int) -- The number of steps to take.
None

SEE ALSO:

petsc.TSAdjointSetSteps


Source code at petsc4py/PETSc/TS.pyx:2560


Set up the internal data structures for the later use of an adjoint solver.

Collective.

SEE ALSO:

petsc.TSAdjointSetUp


Source code at petsc4py/PETSc/TS.pyx:2576



Solve the discrete adjoint problem for an ODE/DAE.

Collective.

SEE ALSO:

petsc.TSAdjointSolve


Source code at petsc4py/PETSc/TS.pyx:2588



Step one time step backward in the adjoint run.

Collective.

SEE ALSO:

petsc.TSAdjointStep


Source code at petsc4py/PETSc/TS.pyx:2600



Append to the prefix used for all the TS options.

Logically collective.

prefix (str) -- The prefix to append to the current prefix.
None

Notes

A hyphen must not be given at the beginning of the prefix name.

SEE ALSO:

Working with PETSc options (TODO), petsc.TSAppendOptionsPrefix


Source code at petsc4py/PETSc/TS.pyx:486


Return a shallow clone of the TS object.

Collective.

SEE ALSO:

petsc.TSClone


Source code at petsc4py/PETSc/TS.pyx:229



Evaluate the DAE residual in implicit form.

Collective.

  • t (float) -- The current time.
  • x (Vec) -- The state vector.
  • xdot (Vec) -- The time derivative of the state vector.
  • xdotdot (Vec) -- The second time derivative of the state vector.
  • f (Vec) -- The vector into which the residual is stored.

None

SEE ALSO:

petsc.TSComputeI2Function


Source code at petsc4py/PETSc/TS.pyx:1083


Evaluate the Jacobian of the DAE.

Collective.

If F(t,U,V,A)=0 is the DAE, the required Jacobian is dF/dU + v dF/dV + a dF/dA.

  • t (float) -- The current time.
  • x (Vec) -- The state vector.
  • xdot (Vec) -- The time derivative of the state vector.
  • xdotdot (Vec) -- The second time derivative of the state vector.
  • v (float) -- The shift to apply to the first derivative.
  • a (float) -- The shift to apply to the second derivative.
  • J (Mat) -- The matrix into which the Jacobian is computed.
  • P (Mat | None) -- The optional matrix to use for building a preconditioner matrix.

None

SEE ALSO:

petsc.TSComputeI2Jacobian


Source code at petsc4py/PETSc/TS.pyx:1110


Evaluate the DAE residual written in implicit form.

Collective.

  • t (float) -- The current time.
  • x (Vec) -- The state vector.
  • xdot (Vec) -- The time derivative of the state vector.
  • f (Vec) -- The vector into which the residual is stored.
  • imex (bool) -- A flag which indicates if the RHS should be kept separate.

None

SEE ALSO:

petsc.TSComputeIFunction


Source code at petsc4py/PETSc/TS.pyx:868


Evaluate the Jacobian of the DAE.

Collective.

If F(t,U,Udot)=0 is the DAE, the required Jacobian is dF/dU + shift*dF/dUdot

  • t (float) -- The current time.
  • x (Vec) -- The state vector.
  • xdot (Vec) -- The time derivative of the state vector.
  • a (float) -- The shift to apply
  • J (Mat) -- The matrix into which the Jacobian is computed.
  • P (Mat | None) -- The optional matrix to use for building a preconditioner matrix.
  • imex (bool) -- A flag which indicates if the RHS should be kept separate.

None

SEE ALSO:

petsc.TSComputeIJacobian


Source code at petsc4py/PETSc/TS.pyx:898


Evaluate the Jacobian with respect to parameters.

Collective.

  • t (float) -- The current time.
  • x (Vec) -- The state vector.
  • xdot (Vec) -- The time derivative of the state vector.
  • a (float) -- The shift to apply
  • J (Mat) -- The matrix into which the Jacobian is computed.
  • imex (bool) -- A flag which indicates if the RHS should be kept separate.

None

SEE ALSO:

petsc.TSComputeIJacobianP


Source code at petsc4py/PETSc/TS.pyx:938


Evaluate the right-hand side function.
  • t (float) -- The time at which to evaluate the RHS.
  • x (Vec) -- The state vector.
  • f (Vec) -- The Vec into which the RHS is computed.

None

SEE ALSO:

petsc.TSComputeRHSFunction


Source code at petsc4py/PETSc/TS.pyx:619


Evaluate the right-hand side via the user-provided Jacobian.
  • t (float) -- The time at which to evaluate the RHS.
  • x (Vec) -- The state vector.
  • f (Vec) -- The Vec into which the RHS is computed.

None

SEE ALSO:

petsc.TSComputeRHSFunctionLinear


Source code at petsc4py/PETSc/TS.pyx:639


Compute the Jacobian matrix that has been set with setRHSJacobian.

Collective.

  • t (float) -- The time at which to evaluate the Jacobian.
  • x (Vec) -- The state vector.
  • J (Mat) -- The matrix into which the Jacobian is computed.
  • P (Mat | None) -- The optional matrix to use for building a preconditioner matrix.

None

SEE ALSO:

petsc.TSComputeRHSJacobian


Source code at petsc4py/PETSc/TS.pyx:659


Reuse a Jacobian that is time-independent.

Collective.

  • t (float) -- The time at which to evaluate the Jacobian.
  • x (Vec) -- The state vector.
  • J (Mat) -- A pointer to the stored Jacobian.
  • P (Mat | None) -- An optional pointer to the preconditioner matrix.

None

SEE ALSO:

petsc.TSComputeRHSJacobianConstant


Source code at petsc4py/PETSc/TS.pyx:685


Run the user-defined JacobianP function.
  • t (float) -- The time at which to compute the Jacobian.
  • x (Vec) -- The solution at which to compute the Jacobian.
  • J (Mat) -- The output Jacobian matrx.

None

SEE ALSO:

petsc.TSComputeRHSJacobianP


Source code at petsc4py/PETSc/TS.pyx:2540


Create an empty TS.

The problem type can then be set with setProblemType and the type of solver can then be set with setType.

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

SEE ALSO:

petsc.TSCreate


Source code at petsc4py/PETSc/TS.pyx:207


Create an integrator of Python type.

Collective.

  • context (Any) -- An instance of the Python class implementing the required methods.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

PETSc Python ode-integrator type (TODO), setType, setPythonContext, Type.PYTHON


Source code at petsc4py/PETSc/TS.pyx:2626


Create a sub TS that evaluates integrals over time.
forward (bool) -- Enable to evaluate forward in time.
TS

SEE ALSO:

petsc.TSCreateQuadratureTS


Source code at petsc4py/PETSc/TS.pyx:2465


Destroy the TS that was created with create.

SEE ALSO:

petsc.TSDestroy


Source code at petsc4py/PETSc/TS.pyx:196



Return the Type.ARKIMEX scheme.

SEE ALSO:

petsc.TSARKIMEXGetType


Source code at petsc4py/PETSc/TS.pyx:346



Return the algorithmic parameters for Type.ALPHA.

SEE ALSO:

petsc.TSAlphaGetParams


Source code at petsc4py/PETSc/TS.pyx:2827

tuple[float, float, float]


Return the application context.

Source code at petsc4py/PETSc/TS.pyx:536



Return the reason the TS step was stopped.

Not collective.

Can only be called once solve is complete.

SEE ALSO:

petsc.TSGetConvergedReason


Source code at petsc4py/PETSc/TS.pyx:1876

ConvergedReason


Return the cost gradients.

SEE ALSO:

setCostGradients, petsc.TSGetCostGradients


Source code at petsc4py/PETSc/TS.pyx:2409

tuple[list[Vec], list[Vec]]


Return a vector of values of the integral term in the cost functions.

SEE ALSO:

petsc.TSGetCostIntegral


Source code at petsc4py/PETSc/TS.pyx:2350



Return the Type.DIRK scheme.

SEE ALSO:

setDIRKType, petsc.TSDIRKGetType


Source code at petsc4py/PETSc/TS.pyx:379



Return the DM associated with the TS.

Not collective.

Only valid if nonlinear solvers or preconditioners are used which use the DM.

SEE ALSO:

petsc.TSGetDM


Source code at petsc4py/PETSc/TS.pyx:1369



Get the type of the equation that TS is solving.

Not collective.

SEE ALSO:

petsc.TSGetEquationType


Source code at petsc4py/PETSc/TS.pyx:435

EquationType


Return the vector and function which computes the residual.

Not collective.

SEE ALSO:

petsc.TSGetI2Function


Source code at petsc4py/PETSc/TS.pyx:1159

tuple[Vec, TSI2Function]


Return the matrices and function which computes the Jacobian.

Not collective.

SEE ALSO:

petsc.TSGetI2Jacobian


Source code at petsc4py/PETSc/TS.pyx:1175

tuple[Mat, Mat, TSI2Jacobian]


Return the vector and function which computes the implicit residual.

Not collective.

SEE ALSO:

petsc.TSGetIFunction


Source code at petsc4py/PETSc/TS.pyx:972

tuple[Vec, TSIFunction]


Return the matrices and function which computes the implicit Jacobian.

Not collective.

SEE ALSO:

petsc.TSGetIJacobian


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

tuple[Mat, Mat, TSIJacobian]


Return the KSP associated with the TS.

Not collective.

SEE ALSO:

petsc.TSGetKSP


Source code at petsc4py/PETSc/TS.pyx:1352



Return the total number of linear iterations used by the TS.

Not collective.

This counter is reset to zero for each successive call to solve.

SEE ALSO:

petsc.TSGetKSPIterations


Source code at petsc4py/PETSc/TS.pyx:1637



Return the maximum number of steps to use.

Not collective.

SEE ALSO:

petsc.TSGetMaxSteps


Source code at petsc4py/PETSc/TS.pyx:1606



Return the maximum (final) time.

Not collective.

Defaults to 5.

SEE ALSO:

petsc.TSGetMaxTime


Source code at petsc4py/PETSc/TS.pyx:1570

float


Return the monitor.

SEE ALSO:

setMonitor


Source code at petsc4py/PETSc/TS.pyx:1928

list[tuple[TSMonitorFunction, tuple[Any, ...], dict[str, Any]]]


Return the number of events.

Logically collective.

SEE ALSO:

petsc.TSGetNumEvents


Source code at petsc4py/PETSc/TS.pyx:2071



Return the prefix used for all the TS options.

Not collective.

SEE ALSO:

petsc.TSGetOptionsPrefix


Source code at petsc4py/PETSc/TS.pyx:472



Return the poststep function.

Source code at petsc4py/PETSc/TS.pyx:2162

tuple[TSPostStepFunction, tuple[Any, ...] | None, dict[str, Any] | None]


Return the prestep function.

SEE ALSO:

setPreStep


Source code at petsc4py/PETSc/TS.pyx:2120

tuple[TSPreStepFunction, tuple[Any, ...] | None, dict[str, Any] | None]


Return the starting time of the previously completed step.

Not collective.

SEE ALSO:

petsc.TSGetPrevTime


Source code at petsc4py/PETSc/TS.pyx:1444

float


Return the type of problem to be solved.

SEE ALSO:

petsc.TSGetProblemType


Source code at petsc4py/PETSc/TS.pyx:406

ProblemType


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

Not collective.

SEE ALSO:

PETSc Python ode-integrator type (TODO), setPythonContext


Source code at petsc4py/PETSc/TS.pyx:2663



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

Not collective.

SEE ALSO:

PETSc Python ode-integrator type (TODO), setPythonContext, setPythonType, petsc.TSPythonGetType


Source code at petsc4py/PETSc/TS.pyx:2692



Return the sub TS that evaluates integrals over time.
  • forward (bool) -- True if evaluating the integral forward in time
  • qts (TS) -- The sub TS

tuple[bool, TS]

SEE ALSO:

petsc.TSGetQuadratureTS


Source code at petsc4py/PETSc/TS.pyx:2484


Return the vector where the rhs is stored and the function used to compute it.

Not collective.

SEE ALSO:

petsc.TSGetRHSFunction


Source code at petsc4py/PETSc/TS.pyx:711

tuple[Vec, TSRHSFunction]


Return the Jacobian and the function used to compute them.

Not collective.

SEE ALSO:

petsc.TSGetRHSJacobian


Source code at petsc4py/PETSc/TS.pyx:727

tuple[Mat, Mat, TSRHSJacobian]


Return the Type.RK scheme.

SEE ALSO:

petsc.TSRKGetType


Source code at petsc4py/PETSc/TS.pyx:334



Return the SNES associated with the TS.

Not collective.

SEE ALSO:

petsc.TSGetSNES


Source code at petsc4py/PETSc/TS.pyx:1337



Return the total number of failed SNES solves in the TS.

Not collective.

This counter is reset to zero for each successive call to solve.

SEE ALSO:

petsc.TSGetSNESFailures


Source code at petsc4py/PETSc/TS.pyx:1721



Return the total number of nonlinear iterations used by the TS.

Not collective.

This counter is reset to zero for each successive call to solve.

SEE ALSO:

petsc.TSGetSNESIterations


Source code at petsc4py/PETSc/TS.pyx:1620



Return the solution at the present timestep.

Not collective.

It is valid to call this routine inside the function that you are evaluating in order to move to the new timestep. This vector is not changed until the solution at the next timestep has been calculated.

SEE ALSO:

petsc.TSGetSolution


Source code at petsc4py/PETSc/TS.pyx:1210



Return the solution and time derivative at the present timestep.

Not collective.

It is valid to call this routine inside the function that you are evaluating in order to move to the new timestep. These vectors are not changed until the solution at the next timestep has been calculated.

SEE ALSO:

petsc.TS2GetSolution


Source code at petsc4py/PETSc/TS.pyx:1248

tuple[Vec, Vec]


Return the time after a call to solve.

Not collective.

This time corresponds to the final time set with setMaxTime.

SEE ALSO:

petsc.TSGetSolveTime


Source code at petsc4py/PETSc/TS.pyx:1458

float


Return the minimum and maximum allowed time step sizes.

SEE ALSO:

petsc.TSAdaptGetStepLimits


Source code at petsc4py/PETSc/TS.pyx:2302

tuple[float, float]


Return the number of time steps completed.

Not collective.

SEE ALSO:

petsc.TSGetStepNumber


Source code at petsc4py/PETSc/TS.pyx:1534



Return the total number of rejected steps.

Not collective.

This counter is reset to zero for each successive call to solve.

SEE ALSO:

petsc.TSGetStepRejections


Source code at petsc4py/PETSc/TS.pyx:1681



Return the abscissa of the stage in (0,1] for Type.THETA.

Not collective.

SEE ALSO:

petsc.TSThetaGetTheta


Source code at petsc4py/PETSc/TS.pyx:2728

float


Return whether the endpoint variable of Type.THETA is used.

SEE ALSO:

petsc.TSThetaGetEndpoint


Source code at petsc4py/PETSc/TS.pyx:2758



Return the time of the most recently completed step.

Not collective.

When called during time step evaluation (e.g. during residual evaluation or via hooks set using setPreStep or setPostStep), the time returned is at the start of the step.

SEE ALSO:

petsc.TSGetTime


Source code at petsc4py/PETSc/TS.pyx:1426

float


Return the time span.

Not collective.

SEE ALSO:

petsc.TSGetTimeSpan


Source code at petsc4py/PETSc/TS.pyx:1303

ArrayReal


Return the solutions at the times in the time span.

SEE ALSO:

setTimeSpan, petsc.TSGetTimeSpanSolutions


Source code at petsc4py/PETSc/TS.pyx:1319

list[Vec]


Return the duration of the current timestep.

Not collective.

SEE ALSO:

petsc.TSGetTimeStep


Source code at petsc4py/PETSc/TS.pyx:1493

float


Return the tolerances for local truncation error.

Logically collective.

  • rtol (float) -- the relative tolerance
  • atol (float) -- the absolute tolerance

tuple[float, float]

SEE ALSO:

petsc.TSGetTolerances


Source code at petsc4py/PETSc/TS.pyx:1799


Return the TS type.

SEE ALSO:

petsc.TSGetType


Source code at petsc4py/PETSc/TS.pyx:322



Interpolate the solution to a given time.

Collective.

  • t (float) -- The time to interpolate.
  • u (Vec) -- The state vector to interpolate.

None

SEE ALSO:

petsc.TSInterpolate


Source code at petsc4py/PETSc/TS.pyx:2259


Load a TS that has been stored in binary with view.
viewer (Viewer) -- The visualization context.
None

SEE ALSO:

petsc.TSLoad


Source code at petsc4py/PETSc/TS.pyx:181


Monitor the solve.
  • step (int) -- The step number that has just completed.
  • time (float) -- The model time of the state.
  • u (Vec | None) -- The state at the current model time.

None

SEE ALSO:

petsc.TSMonitor


Source code at petsc4py/PETSc/TS.pyx:1953


Clear all the monitors that have been set.

Logically collective.

SEE ALSO:

petsc.TSMonitorCancel


Source code at petsc4py/PETSc/TS.pyx:1938



Remove the internal TS trajectory object.

Collective.

SEE ALSO:

petsc.TSRemoveTrajectory


Source code at petsc4py/PETSc/TS.pyx:2338



Reset the TS, removing any allocated vectors and matrices.

Collective.

SEE ALSO:

petsc.TSReset


Source code at petsc4py/PETSc/TS.pyx:2178



Flag the solver to restart the next step.

Collective.

Multistep methods like TSBDF or Runge-Kutta methods with FSAL property require restarting the solver in the event of discontinuities. These discontinuities may be introduced as a consequence of explicitly modifications to the solution vector (which PETSc attempts to detect and handle) or problem coefficients (which PETSc is not able to detect). For the sake of correctness and maximum safety, users are expected to call TSRestart() whenever they introduce discontinuities in callback routines (e.g. prestep and poststep routines, or implicit/rhs function routines with discontinuous source terms).

SEE ALSO:

petsc.TSRestartStep


Source code at petsc4py/PETSc/TS.pyx:2206



Roll back one time step.

SEE ALSO:

petsc.TSRollBack


Source code at petsc4py/PETSc/TS.pyx:2229



Solve both parts of the equation implicitly.
flag (bool) -- Set to True for fully implicit.
None

SEE ALSO:

petsc.TSARKIMEXSetFullyImplicit


Source code at petsc4py/PETSc/TS.pyx:306


Set the type of Type.ARKIMEX scheme.
ts_type (ARKIMEXType | str) -- The type of Type.ARKIMEX scheme.
None

Notes

-ts_arkimex_type sets scheme type from the commandline.

SEE ALSO:

petsc.TSARKIMEXSetType


Source code at petsc4py/PETSc/TS.pyx:285


Set the algorithmic parameters for Type.ALPHA.

Logically collective.

Users should call setAlphaRadius.

  • alpha_m (float | None) -- Parameter, leave None to keep current value.
  • alpha_f (float | None) -- Parameter, leave None to keep current value.
  • gamma (float | None) -- Parameter, leave None to keep current value.

None

SEE ALSO:

petsc.TSAlphaSetParams


Source code at petsc4py/PETSc/TS.pyx:2794


Set the spectral radius for Type.ALPHA.

Logically collective.

radius (float) -- the spectral radius
None

Notes

-ts_alpha_radius can be used to set this from the commandline.

SEE ALSO:

petsc.TSAlphaSetRadius


Source code at petsc4py/PETSc/TS.pyx:2772


Set the application context.

Not collective.

appctx (Any) -- The application context.
None

Source code at petsc4py/PETSc/TS.pyx:523


Set the reason for handling the convergence of solve.

Logically collective.

Can only be called when solve is active and reason must contain common value.

reason (ConvergedReason) -- The reason for convergence.
None

SEE ALSO:

petsc.TSSetConvergedReason


Source code at petsc4py/PETSc/TS.pyx:1855


Set the cost gradients.

Logically collective.

  • vl (Vec | Sequence[Vec] | None) -- gradients with respect to the initial condition variables, the dimension and parallel layout of these vectors is the same as the ODE solution vector
  • vm (Vec | Sequence[Vec] | None) -- gradients with respect to the parameters, the number of entries in these vectors is the same as the number of parameters

None

SEE ALSO:

petsc.TSSetCostGradients


Source code at petsc4py/PETSc/TS.pyx:2363


Set the type of Type.DIRK scheme.
ts_type (DIRKType | str) -- The type of Type.DIRK scheme.
None

Notes

-ts_dirk_type sets scheme type from the commandline.

SEE ALSO:

petsc.TSDIRKSetType


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


Set the DM that may be used by some nonlinear solvers or preconditioners.

Logically collective.

dm (DM) -- The DM object.
None

SEE ALSO:

petsc.TSSetDM


Source code at petsc4py/PETSc/TS.pyx:1389


Set the type of the equation that TS is solving.

Not collective.

eqtype (EquationType) -- The type of equation.
None

SEE ALSO:

petsc.TSSetEquationType


Source code at petsc4py/PETSc/TS.pyx:418


Immediately error is no step succeeds.

Not collective.

flag (bool) -- Enable to error if no step succeeds.
None

Notes

-ts_error_if_step_fails to enable from the commandline.

SEE ALSO:

petsc.TSSetErrorIfStepFails


Source code at petsc4py/PETSc/TS.pyx:1738


Set a function used for detecting events.

Logically collective.

  • direction (Sequence[int]) -- Direction of zero crossing to be detected {-1,0,+1}.
  • terminate (Sequence[bool]) -- Flags for each event to indicate stepping should be terminated.
  • eventhandler (TSEventHandlerFunction) -- Function for detecting the event
  • postevent (TSPostEventFunction) -- Function to execute after the event
  • args (tuple[Any, ...] | None) -- Additional positional arguments for eventhandler.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for eventhandler.

None

SEE ALSO:

petsc.TSSetEventHandler


Source code at petsc4py/PETSc/TS.pyx:1980


Set tolerances for event zero crossings when using event handler.

Logically collective.

setEventHandler must have already been called.

  • tol (float) -- The scalar tolerance or None to leave at the current value
  • vtol (Sequence[float]) -- A sequence of scalar tolerance for each event. Used in preference to tol if present. Set to None to leave at the current value.

None

Notes

-ts_event_tol can be used to set values from the commandline.

SEE ALSO:

petsc.TSSetEventTolerances


Source code at petsc4py/PETSc/TS.pyx:2035


Set method of computing the final time step.

Logically collective.

option (ExactFinalTime) -- The exact final time option
None

Notes

-ts_exact_final_time may be used to specify from the commandline.

SEE ALSO:

petsc.TSSetExactFinalTime


Source code at petsc4py/PETSc/TS.pyx:1833


Set various TS parameters from user options.

Collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.TSSetFromOptions


Source code at petsc4py/PETSc/TS.pyx:509



Set the function to compute the 2nd order DAE.

Logically collective.

  • function (TSI2Function) -- The right-hand side function.
  • f (Vec | None) -- The vector to store values or None to be created internally.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for function.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for function.

None

SEE ALSO:

petsc.TSSetI2Function


Source code at petsc4py/PETSc/TS.pyx:1004


Set the function to compute the Jacobian of the 2nd order DAE.

Logically collective.

  • jacobian (TSI2Jacobian) -- The function which computes the Jacobian.
  • J (Mat | None) -- The matrix into which the Jacobian is computed.
  • P (Mat | None) -- The optional matrix to use for building a preconditioner matrix.
  • args -- Additional positional arguments for jacobian.
  • kargs -- Additional keyword arguments for jacobian.

None

SEE ALSO:

petsc.TSSetI2Jacobian


Source code at petsc4py/PETSc/TS.pyx:1041


Set the function representing the DAE to be solved.

Logically collective.

  • function (TSIFunction) -- The right-hand side function.
  • f (Vec | None) -- The vector to store values or None to be created internally.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for function.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for function.

None

SEE ALSO:

petsc.TSSetIFunction


Source code at petsc4py/PETSc/TS.pyx:745


Set the function to compute the Jacobian.

Logically collective.

Set the function to compute the matrix dF/dU + a*dF/dU_t where F(t,U,U_t) is the function provided with setIFunction.

  • jacobian (TSIJacobian) -- The function which computes the Jacobian.
  • J (Mat | None) -- The matrix into which the Jacobian is computed.
  • P (Mat | None) -- The optional matrix to use for building a preconditioner matrix.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for jacobian.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for jacobian.

None

SEE ALSO:

petsc.TSSetIJacobian


Source code at petsc4py/PETSc/TS.pyx:782


Set the function that computes the Jacobian.

Logically collective.

Set the function that computes the Jacobian of F with respect to the parameters P where F(Udot,U,t) = G(U,P,t), as well as the location to store the matrix.

  • jacobian -- The function which computes the Jacobian.
  • J (Mat | None) -- The matrix into which the Jacobian is computed.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for jacobian.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for jacobian.

None

SEE ALSO:

petsc.TSSetIJacobianP


Source code at petsc4py/PETSc/TS.pyx:827


Set the maximum number of SNES solves failures allowed.

Not collective.

n (int) -- The maximum number of failed nonlinear solver, use -1 for unlimited.
None

SEE ALSO:

petsc.TSSetMaxSNESFailures


Source code at petsc4py/PETSc/TS.pyx:1698


Set the maximum number of step rejections before a time step fails.

Not collective.

n (int) -- The maximum number of rejected steps, use -1 for unlimited.
None

Notes

-ts_max_reject can be used to set this from the commandline

SEE ALSO:

petsc.TSSetMaxStepRejections


Source code at petsc4py/PETSc/TS.pyx:1654


Set the maximum number of steps to use.

Logically collective.

Defaults to 5000.

max_steps (int) -- The maximum number of steps to use.
None

SEE ALSO:

petsc.TSSetMaxSteps


Source code at petsc4py/PETSc/TS.pyx:1586


Set the maximum (final) time.

Logically collective.

max_time (float) -- the final time
None

Notes

-ts_max_time sets the max time from the commandline

SEE ALSO:

petsc.TSSetMaxTime


Source code at petsc4py/PETSc/TS.pyx:1548


Set an additional monitor to the TS.

Logically collective.

  • monitor (TSMonitorFunction) -- The custom monitor function.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for monitor.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for monitor.

None

SEE ALSO:

petsc.TSMonitorSet


Source code at petsc4py/PETSc/TS.pyx:1894


Set the prefix used for all the TS options.

Logically collective.

prefix (str) -- The prefix to prepend to all option names.
None

Notes

A hyphen must not be given at the beginning of the prefix name.

SEE ALSO:

Working with PETSc options (TODO), petsc.TSSetOptionsPrefix


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


Set a function to be called at the end of each time step.

Logically collective.

  • poststep (TSPostStepFunction) -- The function to be called at the end of each step.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for poststep.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for poststep.

None

SEE ALSO:

petsc.TSSetPostStep


Source code at petsc4py/PETSc/TS.pyx:2130


Set a function to be called at the beginning of each time step.

Logically collective.

  • prestep (TSPreStepFunction) -- The function to be called at the beginning of each step.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for prestep.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for prestep.

None

SEE ALSO:

petsc.TSSetPreStep


Source code at petsc4py/PETSc/TS.pyx:2087


Set the type of problem to be solved.
ptype (ProblemType) -- The type of problem of the forms.
None

SEE ALSO:

petsc.TSSetProblemType


Source code at petsc4py/PETSc/TS.pyx:391


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

Not collective.

SEE ALSO:

PETSc Python ode-integrator type (TODO), getPythonContext


Source code at petsc4py/PETSc/TS.pyx:2651

context (Any) --
None


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

Collective.

SEE ALSO:

PETSc Python ode-integrator type (TODO), setPythonContext, getPythonType, petsc.TSPythonSetType


Source code at petsc4py/PETSc/TS.pyx:2678

py_type (str) --
None


Set the routine for evaluating the function G in U_t = G(t,u).
  • function (TSRHSFunction) -- The right-hand side function.
  • f (Vec | None) -- The vector into which the right-hand side is computed.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for function.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for function.

None

SEE ALSO:

petsc.TSSetRHSFunction


Source code at petsc4py/PETSc/TS.pyx:542


Set the function to compute the Jacobian of G in U_t = G(U,t).

Logically collective.

  • jacobian (TSRHSJacobian) -- The right-hand side function.
  • J (Mat | None) -- The matrix into which the jacobian is computed.
  • P (Mat | None) -- The matrix into which the preconditioner is computed.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for jacobian.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for jacobian.

None

SEE ALSO:

petsc.TSSetRHSJacobian


Source code at petsc4py/PETSc/TS.pyx:577


Set the function that computes the Jacobian with respect to the parameters.

Logically collective.

  • jacobianp (TSRHSJacobianP) -- The user-defined function.
  • A (Mat | None) -- The matrix into which the Jacobian will be computed.
  • args (tuple[Any, ...] | None) -- Additional positional arguments for jacobianp.
  • kargs (dict[str, Any] | None) -- Additional keyword arguments for jacobianp.

None

SEE ALSO:

petsc.TSSetRHSJacobianP


Source code at petsc4py/PETSc/TS.pyx:2428


Set the type of the Runge-Kutta scheme.
ts_type (RKType | str) -- The type of scheme.
None

Notes

-ts_rk_type sets scheme type from the commandline.

SEE ALSO:

petsc.TSRKSetType


Source code at petsc4py/PETSc/TS.pyx:264


Enable to save solutions as an internal TS trajectory.

Collective.

This routine should be called after all TS options have been set.

Notes

-ts_save_trajectory can be used to save a trajectory to a file.

SEE ALSO:

petsc.TSSetSaveTrajectory


Source code at petsc4py/PETSc/TS.pyx:2319



Set the initial solution vector.

Logically collective.

u (Vec) -- The solution vector.
None

SEE ALSO:

petsc.TSSetSolution


Source code at petsc4py/PETSc/TS.pyx:1193


Set the initial solution and its time derivative.

Logically collective.

  • u (Vec) -- The solution vector.
  • v (Vec) -- The time derivative vector.

None

SEE ALSO:

petsc.TS2SetSolution


Source code at petsc4py/PETSc/TS.pyx:1229


Set the minimum and maximum allowed step sizes.

Logically collective.

  • hmin (float) -- the minimum step size
  • hmax (float) -- the maximum step size

None

SEE ALSO:

petsc.TSAdaptSetStepLimits


Source code at petsc4py/PETSc/TS.pyx:2279


Set the number of steps completed.

Logically collective.

For most uses of the TS solvers the user need not explicitly call setStepNumber, as the step counter is appropriately updated in solve/step/rollBack. Power users may call this routine to reinitialize timestepping by setting the step counter to zero (and time to the initial time) to solve a similar problem with different initial conditions or parameters. It may also be used to continue timestepping from a previously interrupted run in such a way that TS monitors will be called with a initial nonzero step counter.

step_number (int) -- the number of steps completed
None

SEE ALSO:

petsc.TSSetStepNumber


Source code at petsc4py/PETSc/TS.pyx:1507


Set the abscissa of the stage in (0,1] for Type.THETA.
theta (float) -- stage abscissa
None

Notes

-ts_theta_theta can be used to set a value from the commandline.

SEE ALSO:

petsc.TSThetaSetTheta


Source code at petsc4py/PETSc/TS.pyx:2708


Set to use the endpoint variant of Type.THETA.
flag -- Enable to use the endpoint variant.
None

SEE ALSO:

petsc.TSThetaSetEndpoint


Source code at petsc4py/PETSc/TS.pyx:2742


Set the time.

Logically collective.

t (float) -- The time.
None

SEE ALSO:

petsc.TSSetTime


Source code at petsc4py/PETSc/TS.pyx:1408


Set the time span.

Collective.

The solution will be computed and stored for each time requested in the span. The times must be all increasing and correspond to the intermediate points for time integration. ExactFinalTime.MATCHSTEP must be used to make the last time step in each sub-interval match the intermediate points specified. The intermediate solutions are saved in a vector array that can be accessed with getTimeSpanSolutions.

tspan (Sequence[float]) -- The sequence of time points.
None

Notes

-ts_time_span <t0,...tf> sets the time span from the commandline

SEE ALSO:

petsc.TSSetTimeSpan


Source code at petsc4py/PETSc/TS.pyx:1271


Set the duration of the timestep.

Logically collective.

time_step (float) -- the duration of the timestep
None

SEE ALSO:

petsc.TSSetTimeStep


Source code at petsc4py/PETSc/TS.pyx:1475


Set tolerances for local truncation error when using an adaptive controller.

Logically collective.

  • rtol (float) -- The relative tolerance or None to leave the current value.
  • atol (float) -- The absolute tolerance or None to leave the current value.

None

Notes

-ts_rtol and -ts_atol may be used to set values from the commandline.

SEE ALSO:

petsc.TSSetTolerances


Source code at petsc4py/PETSc/TS.pyx:1760


Set the method to be used as the TS solver.
ts_type (Type | str) -- The solver type.
None

Notes

-ts_type sets the method from the commandline

SEE ALSO:

petsc.TSSetType


Source code at petsc4py/PETSc/TS.pyx:243


Set up the internal data structures for the TS.

Collective.

SEE ALSO:

petsc.TSSetUp


Source code at petsc4py/PETSc/TS.pyx:2166



Step the requested number of timesteps.

Collective.

u (Vec) -- The solution vector. Can be None if setSolution was used and setExactFinalTime is not set as TS_EXACTFINALTIME_MATCHSTEP. Otherwise this vector must contain the initial conditions and will contain the solution at the final requested time.
None

SEE ALSO:

petsc.TSSolve


Source code at petsc4py/PETSc/TS.pyx:2239


Take one step.

Collective.

The preferred interface for the TS solvers is solve. If you need to execute code at the beginning or ending of each step, use setPreStep and setPostStep respectively.

SEE ALSO:

petsc.TSStep


Source code at petsc4py/PETSc/TS.pyx:2190



Print the TS object.

Collective.

viewer (Viewer | None) -- The visualization context.
None

Notes

-ts_view calls TSView at the end of TSStep

SEE ALSO:

petsc.TSView


Source code at petsc4py/PETSc/TS.pyx:158


Attributes Documentation

Application context.

Source code at petsc4py/PETSc/TS.pyx:2841


The absolute tolerance.

Source code at petsc4py/PETSc/TS.pyx:2934


Indicates the TS has converged.

Source code at petsc4py/PETSc/TS.pyx:2953


Indicates the TS has stopped.

Source code at petsc4py/PETSc/TS.pyx:2958


The DM.

Source code at petsc4py/PETSc/TS.pyx:2850


The equation type.

Source code at petsc4py/PETSc/TS.pyx:2866


Indicates the TS is still iterating.

Source code at petsc4py/PETSc/TS.pyx:2948


The KSP.

Source code at petsc4py/PETSc/TS.pyx:2878


The maximum number of steps.

Source code at petsc4py/PETSc/TS.pyx:2918


The maximum time.

Source code at petsc4py/PETSc/TS.pyx:2911


The problem type.

Source code at petsc4py/PETSc/TS.pyx:2859


The converged reason.

Source code at petsc4py/PETSc/TS.pyx:2941


The relative tolerance.

Source code at petsc4py/PETSc/TS.pyx:2927


The SNES.

Source code at petsc4py/PETSc/TS.pyx:2873


The current step number.

Source code at petsc4py/PETSc/TS.pyx:2904


The current time.

Source code at petsc4py/PETSc/TS.pyx:2890


The current time step size.

Source code at petsc4py/PETSc/TS.pyx:2897


The solution vector.

Source code at petsc4py/PETSc/TS.pyx:2883




petsc4py.PETSc.Vec

Bases: Object

A vector object.

SEE ALSO:

petsc.Vec


Enumerations

Option Vector assembly option.
Type The vector type.

petsc4py.PETSc.Vec.Option

Bases: object

Vector assembly option.

Attributes Summary

IGNORE_NEGATIVE_INDICES Constant IGNORE_NEGATIVE_INDICES of type int
IGNORE_OFF_PROC_ENTRIES Constant IGNORE_OFF_PROC_ENTRIES of type int

Attributes Documentation

Constant IGNORE_NEGATIVE_INDICES of type int

Constant IGNORE_OFF_PROC_ENTRIES of type int


petsc4py.PETSc.Vec.Type

Bases: object

The vector type.

Attributes Summary

CUDA Object CUDA of type str
HIP Object HIP of type str
KOKKOS Object KOKKOS of type str
MPI Object MPI of type str
MPICUDA Object MPICUDA of type str
MPIHIP Object MPIHIP of type str
MPIKOKKOS Object MPIKOKKOS of type str
MPIVIENNACL Object MPIVIENNACL of type str
NEST Object NEST of type str
SEQ Object SEQ of type str
SEQCUDA Object SEQCUDA of type str
SEQHIP Object SEQHIP of type str
SEQKOKKOS Object SEQKOKKOS of type str
SEQVIENNACL Object SEQVIENNACL of type str
SHARED Object SHARED of type str
STANDARD Object STANDARD of type str
VIENNACL Object VIENNACL of type str

Attributes Documentation

Object CUDA of type str

Object HIP of type str

Object KOKKOS of type str

Object MPI of type str

Object MPICUDA of type str

Object MPIHIP of type str

Object MPIKOKKOS of type str

Object MPIVIENNACL of type str

Object NEST of type str

Object SEQ of type str

Object SEQCUDA of type str

Object SEQHIP of type str

Object SEQKOKKOS of type str

Object SEQVIENNACL of type str

Object SHARED of type str

Object STANDARD of type str

Object VIENNACL of type str


Methods Summary

abs() Replace each entry (xₙ) in the vector by abs|xₙ|.
appendOptionsPrefix(prefix) Append to the prefix used for searching for options in the database.
assemble() Assemble the vector.
assemblyBegin() Begin an assembling stage of the vector.
assemblyEnd() Finish the assembling stage initiated with assemblyBegin.
attachDLPackInfo([vec, dltensor]) Attach tensor information from another vector or DLPack tensor.
axpby(alpha, beta, x) Compute and store y = ɑ·x + β·y.
axpy(alpha, x) Compute and store y = ɑ·x + y.
aypx(alpha, x) Compute and store y = x + ɑ·y.
bindToCPU(flg) Bind vector operations execution on the CPU.
boundToCPU() Return whether the vector has been bound to the CPU.
chop(tol) Set all vector entries less than some absolute tolerance to zero.
clearDLPackInfo() Clear tensor information.
conjugate() Conjugate the vector.
copy([result]) Return a copy of the vector.
create([comm]) Create a vector object.
createCUDAWithArrays([cpuarray, cudahandle, ...]) Create a Type.CUDA vector with optional arrays.
createGhost(ghosts, size[, bsize, comm]) Create a parallel vector with ghost padding on each processor.
createGhostWithArray(ghosts, array[, size, ...]) Create a parallel vector with ghost padding and provided arrays.
createHIPWithArrays([cpuarray, hiphandle, ...]) Create a Type.HIP vector with optional arrays.
createLocalVector() Create a local vector.
createMPI(size[, bsize, comm]) Create a parallel Type.MPI vector.
createNest(vecs[, isets, comm]) Create a Type.NEST vector containing multiple nested subvectors.
createSeq(size[, bsize, comm]) Create a sequential Type.SEQ vector.
createShared(size[, bsize, comm]) Create a Type.SHARED vector that uses shared memory.
createViennaCLWithArrays([cpuarray, ...]) Create a Type.VIENNACL vector with optional arrays.
createWithArray(array[, size, bsize, comm]) Create a vector using a provided array.
createWithDLPack(dltensor[, size, bsize, comm]) Create a vector wrapping a DLPack object, sharing the same memory.
destroy() Destroy the vector.
dot(vec) Return the dot product with vec.
dotBegin(vec) Begin computing the dot product.
dotEnd(vec) Finish computing the dot product initiated with dotBegin.
dotNorm2(vec) Return the dot product with vec and its squared norm.
duplicate([array]) Create a new vector with the same type, optionally with data.
equal(vec) Return whether the vector is equal to another.
exp() Replace each entry (xₙ) in the vector by exp(xₙ).
getArray([readonly]) Return local portion of the vector as an ndarray.
getBlockSize() Return the block size of the vector.
getBuffer([readonly]) Return a buffered view of the local portion of the vector.
getCLContextHandle() Return the OpenCL context associated with the vector.
getCLMemHandle([mode]) Return the OpenCL buffer associated with the vector.
getCLQueueHandle() Return the OpenCL command queue associated with the vector.
getCUDAHandle([mode]) Return a pointer to the device buffer.
getDM() Return the DM associated to the vector.
getHIPHandle([mode]) Return a pointer to the device buffer.
getLGMap() Return the local-to-global mapping.
getLocalSize() Return the local size of the vector.
getLocalVector(lvec[, readonly]) Maps the local portion of the vector into a local vector.
getNestSubVecs() Return all the vectors contained in the nested vector.
getOffloadMask() Return the offloading status of the vector.
getOptionsPrefix() Return the prefix used for searching for options in the database.
getOwnershipRange() Return the locally owned range of indices (start, end).
getOwnershipRanges() Return the range of indices owned by each process.
getSize() Return the global size of the vector.
getSizes() Return the vector sizes.
getSubVector(iset[, subvec]) Return a subvector from given indices.
getType() Return the type of the vector.
getValue(index) Return a single value from the vector.
getValues(indices[, values]) Return values from certain locations in the vector.
getValuesStagStencil(indices[, values]) Not implemented.
ghostUpdate([addv, mode]) Update ghosted vector entries.
ghostUpdateBegin([addv, mode]) Begin updating ghosted vector entries.
ghostUpdateEnd([addv, mode]) Finish updating ghosted vector entries initiated with ghostUpdateBegin.
isaxpy(idx, alpha, x) Add a scaled reduced-space vector to a subset of the vector.
isset(idx, alpha) Set specific elements of the vector to the same value.
load(viewer) Load a vector.
localForm() Return a context manager for viewing ghost vectors in local form.
log() Replace each entry in the vector by its natural logarithm.
mDot(vecs[, out]) Not implemented.
mDotBegin(vecs[, out]) Not implemented.
mDotEnd(vecs[, out]) Not implemented.
max() Return the vector entry with maximum real part and its location.
maxPointwiseDivide(vec) Return the maximum of the component-wise absolute value division.
maxpy(alphas, vecs) Compute and store y = Σₙ(ɑₙ·Xₙ) + y with X an array of vectors.
min() Return the vector entry with minimum real part and its location.
mtDot(vecs[, out]) Not implemented.
mtDotBegin(vecs[, out]) Not implemented.
mtDotEnd(vecs[, out]) Not implemented.
norm([norm_type]) Compute the vector norm.
normBegin([norm_type]) Begin computing the vector norm.
normEnd([norm_type]) Finish computations initiated with normBegin.
normalize() Normalize the vector by its 2-norm.
permute(order[, invert]) Permute the vector in-place with a provided ordering.
placeArray(array) Set the local portion of the vector to a provided array.
pointwiseDivide(x, y) Compute and store the component-wise division of two vectors.
pointwiseMax(x, y) Compute and store the component-wise maximum of two vectors.
pointwiseMaxAbs(x, y) Compute and store the component-wise maximum absolute values.
pointwiseMin(x, y) Compute and store the component-wise minimum of two vectors.
pointwiseMult(x, y) Compute and store the component-wise multiplication of two vectors.
reciprocal() Replace each entry in the vector by its reciprocal.
resetArray([force]) Reset the vector to use its default array.
restoreCLMemHandle() Restore a pointer to the OpenCL buffer obtained with getCLMemHandle.
restoreCUDAHandle(handle[, mode]) Restore a pointer to the device buffer obtained with getCUDAHandle.
restoreHIPHandle(handle[, mode]) Restore a pointer to the device buffer obtained with getHIPHandle.
restoreLocalVector(lvec[, readonly]) Unmap a local access obtained with getLocalVector.
restoreSubVector(iset, subvec) Restore a subvector extracted using getSubVector.
scale(alpha) Scale all entries of the vector.
set(alpha) Set all components of the vector to the same value.
setArray(array) Set values for the local portion of the vector.
setBlockSize(bsize) Set the block size of the vector.
setDM(dm) Associate a DM to the vector.
setFromOptions() Configure the vector from the options database.
setLGMap(lgmap) Set the local-to-global mapping.
setMPIGhost(ghosts) Set the ghost points for a ghosted vector.
setNestSubVecs(sx[, idxm]) Set the component vectors at specified indices in the nested vector.
setOption(option, flag) Set option.
setOptionsPrefix(prefix) Set the prefix used for searching for options in the database.
setRandom([random]) Set all components of the vector to random numbers.
setSizes(size[, bsize]) Set the local and global sizes of the vector.
setType(vec_type) Set the vector type.
setUp() Set up the internal data structures for using the vector.
setValue(index, value[, addv]) Insert or add a single value in the vector.
setValueLocal(index, value[, addv]) Insert or add a single value in the vector using a local numbering.
setValues(indices, values[, addv]) Insert or add multiple values in the vector.
setValuesBlocked(indices, values[, addv]) Insert or add blocks of values in the vector.
setValuesBlockedLocal(indices, values[, addv]) Insert or add blocks of values in the vector with a local numbering.
setValuesLocal(indices, values[, addv]) Insert or add multiple values in the vector with a local numbering.
setValuesStagStencil(indices, values[, addv]) Not implemented.
shift(alpha) Shift all entries in the vector.
sqrtabs() Replace each entry (xₙ) in the vector by √|xₙ|.
strideGather(field, vec[, addv]) Insert component values into a single-component vector.
strideMax(field) Return the maximum of entries in a subvector.
strideMin(field) Return the minimum of entries in a subvector.
strideNorm(field[, norm_type]) Return the norm of entries in a subvector.
strideScale(field, alpha) Scale a component of the vector.
strideScatter(field, vec[, addv]) Scatter entries into a component of another vector.
strideSum(field) Sum subvector entries.
sum() Return the sum of all the entries of the vector.
swap(vec) Swap the content of two vectors.
tDot(vec) Return the indefinite dot product with vec.
tDotBegin(vec) Begin computing the indefinite dot product.
tDotEnd(vec) Finish computing the indefinite dot product initiated with tDotBegin.
toDLPack([mode]) Return a DLPack PyCapsule wrapping the vector data.
view([viewer]) Display the vector.
waxpy(alpha, x, y) Compute and store w = ɑ·x + y.
zeroEntries() Set all entries in the vector to zero.

Attributes Summary

array Alias for array_w.
array_r Read-only ndarray containing the local portion of the vector.
array_w Writeable ndarray containing the local portion of the vector.
block_size The block size.
buffer Alias for buffer_w.
buffer_r Read-only buffered view of the local portion of the vector.
buffer_w Writeable buffered view of the local portion of the vector.
local_size The local vector size.
owner_range The locally owned range of indices in the form [low, high).
owner_ranges The range of indices owned by each process.
size The global vector size.
sizes The local and global vector sizes.

Methods Documentation

Replace each entry (xₙ) in the vector by abs|xₙ|.

Logically collective.

SEE ALSO:

petsc.VecAbs


Source code at petsc4py/PETSc/Vec.pyx:2154



Append to the prefix used for searching for options in the database.

Logically collective.

SEE ALSO:

Working with PETSc options (TODO), setOptionsPrefix, petsc.VecAppendOptionsPrefix


Source code at petsc4py/PETSc/Vec.pyx:1045

prefix (str) --
None


Assemble the vector.

Collective.

SEE ALSO:

assemblyBegin, assemblyEnd


Source code at petsc4py/PETSc/Vec.pyx:2915



Begin an assembling stage of the vector.

Collective.

SEE ALSO:

assemblyEnd, petsc.VecAssemblyBegin


Source code at petsc4py/PETSc/Vec.pyx:2891



Finish the assembling stage initiated with assemblyBegin.

Collective.

SEE ALSO:

assemblyBegin, petsc.VecAssemblyEnd


Source code at petsc4py/PETSc/Vec.pyx:2903



Attach tensor information from another vector or DLPack tensor.

Logically collective.

This tensor information is required when converting a Vec to a DLPack object.

  • vec (Vec | None) -- Vector with attached tensor information. This is typically created by calling createWithDLPack.
  • dltensor -- DLPack tensor. This will only be used if vec is None.

Self

Notes

This operation does not copy any data from vec or dltensor.

SEE ALSO:

clearDLPackInfo, createWithDLPack


Source code at petsc4py/PETSc/Vec.pyx:655


Compute and store y = ɑ·x + β·y.

Logically collective.

  • alpha (Scalar) -- First scale factor.
  • beta (Scalar) -- Second scale factor.
  • x (Vec) -- Input vector, must not be the current vector.

None

SEE ALSO:

axpy, aypx, waxpy, petsc.VecAXPBY


Source code at petsc4py/PETSc/Vec.pyx:2385


Compute and store y = ɑ·x + y.

Logically collective.

  • alpha (Scalar) -- Scale factor.
  • x (Vec) -- Input vector.

None

SEE ALSO:

isaxpy, petsc.VecAXPY


Source code at petsc4py/PETSc/Vec.pyx:2321


Compute and store y = x + ɑ·y.

Logically collective.

  • alpha (Scalar) -- Scale factor.
  • x (Vec) -- Input vector, must not be the current vector.

None

SEE ALSO:

axpy, axpby, petsc.VecAYPX


Source code at petsc4py/PETSc/Vec.pyx:2365


Bind vector operations execution on the CPU.

Logically collective.

SEE ALSO:

boundToCPU, petsc.VecBindToCPU


Source code at petsc4py/PETSc/Vec.pyx:1413

flg (bool) --
None


Return whether the vector has been bound to the CPU.

Not collective.

SEE ALSO:

bindToCPU, petsc.VecBoundToCPU


Source code at petsc4py/PETSc/Vec.pyx:1426



Set all vector entries less than some absolute tolerance to zero.

Collective.

tol (float) -- The absolute tolerance below which entries are set to zero.
None

SEE ALSO:

petsc.VecFilter


Source code at petsc4py/PETSc/Vec.pyx:1754


Clear tensor information.

Logically collective.

SEE ALSO:

attachDLPackInfo, createWithDLPack


Source code at petsc4py/PETSc/Vec.pyx:718



Conjugate the vector.

Logically collective.

SEE ALSO:

petsc.VecConjugate


Source code at petsc4py/PETSc/Vec.pyx:2166


Return a copy of the vector.

Logically collective.

This operation copies vector entries to the new vector.

result (Vec | None) -- Target vector for the copy. If None then a new vector is created internally.
Vec

SEE ALSO:

duplicate, petsc.VecCopy


Source code at petsc4py/PETSc/Vec.pyx:1729


Create a vector object.

Collective.

After creation the vector type can then be set with setType.

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

SEE ALSO:

destroy, petsc.VecCreate


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


Create a Type.CUDA vector with optional arrays.

Collective.

  • cpuarray (Sequence[Scalar] | None) -- Host array. Will be lazily allocated if not provided.
  • cudahandle (Any | None) -- Address of the array on the GPU. Will be lazily allocated if not provided.
  • size (LayoutSizeSpec | None) -- Vector size.
  • bsize (int | None) -- Vector block size. If None, bsize = 1.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.VecCreateSeqCUDAWithArrays, petsc.VecCreateMPICUDAWithArrays


Source code at petsc4py/PETSc/Vec.pyx:377


Create a parallel vector with ghost padding on each processor.

Collective.

  • ghosts (Sequence[int]) -- Global indices of ghost points.
  • size (LayoutSizeSpec) -- Vector size.
  • bsize (int | None) -- Vector block size. If None, bsize = 1.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

createGhostWithArray, petsc.VecCreateGhost, petsc.VecCreateGhostBlock


Source code at petsc4py/PETSc/Vec.pyx:832


Create a parallel vector with ghost padding and provided arrays.

Collective.

  • ghosts (Sequence[int]) -- Global indices of ghost points.
  • array (Sequence[Scalar]) -- Array to store the vector values. Must be at least as large as the local size of the vector (including ghost points).
  • size (LayoutSizeSpec | None) -- Vector size.
  • bsize (int | None) -- Vector block size. If None, bsize = 1.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

createGhost, petsc.VecCreateGhostWithArray, petsc.VecCreateGhostBlockWithArray


Source code at petsc4py/PETSc/Vec.pyx:875


Create a Type.HIP vector with optional arrays.

Collective.

  • cpuarray (Sequence[Scalar] | None) -- Host array. Will be lazily allocated if not provided.
  • hiphandle (Any | None) -- Address of the array on the GPU. Will be lazily allocated if not provided.
  • size (LayoutSizeSpec | None) -- Vector size.
  • bsize (int | None) -- Vector block size. If None, bsize = 1.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.VecCreateSeqHIPWithArrays, petsc.VecCreateMPIHIPWithArrays


Source code at petsc4py/PETSc/Vec.pyx:436


Create a local vector.

Not collective.

The local vector.
Vec

SEE ALSO:

getLocalVector, petsc.VecCreateLocalVector


Source code at petsc4py/PETSc/Vec.pyx:1221


Create a parallel Type.MPI vector.

Collective.

  • size (LayoutSizeSpec) -- Vector size.
  • bsize (int | None) -- Vector block size. If None, bsize = 1.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

createSeq, petsc.VecCreateMPI


Source code at petsc4py/PETSc/Vec.pyx:288


Create a Type.NEST vector containing multiple nested subvectors.

Collective.

  • vecs (Sequence[Vec]) -- Iterable of subvectors.
  • isets (Sequence[IS]) -- Iterable of index sets for each nested subvector. Defaults to contiguous ordering.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.VecCreateNest


Source code at petsc4py/PETSc/Vec.pyx:968


Create a sequential Type.SEQ vector.

Collective.

  • size (LayoutSizeSpec) -- Vector size.
  • bsize (int | None) -- Vector block size. If None, bsize = 1.
  • comm (Comm | None) -- MPI communicator, defaults to COMM_SELF.

Self

SEE ALSO:

createMPI, petsc.VecCreateSeq


Source code at petsc4py/PETSc/Vec.pyx:251


Create a Type.SHARED vector that uses shared memory.

Collective.

  • size (LayoutSizeSpec) -- Vector size.
  • bsize (int | None) -- Vector block size. If None, bsize = 1.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.VecCreateShared


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


Create a Type.VIENNACL vector with optional arrays.

Collective.

  • cpuarray (Sequence[Scalar] | None) -- Host array. Will be lazily allocated if not provided.
  • viennaclvechandle (Any | None) -- Address of the array on the GPU. Will be lazily allocated if not provided.
  • size (LayoutSizeSpec | None) -- Vector size.
  • bsize (int | None) -- Vector block size. If None, bsize = 1.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.VecCreateSeqViennaCLWithArrays, petsc.VecCreateMPIViennaCLWithArrays


Source code at petsc4py/PETSc/Vec.pyx:495


Create a vector using a provided array.

Collective.

This method will create either a Type.SEQ or Type.MPI depending on the size of the communicator.

  • array (Sequence[Scalar]) -- Array to store the vector values. Must be at least as large as the local size of the vector.
  • size (LayoutSizeSpec | None) -- Vector size.
  • bsize (int | None) -- Vector block size. If None, bsize = 1.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

petsc.VecCreateSeqWithArray, petsc.VecCreateMPIWithArray


Source code at petsc4py/PETSc/Vec.pyx:325


Create a vector wrapping a DLPack object, sharing the same memory.

Collective.

This operation does not modify the storage of the original tensor and should be used with contiguous tensors only. If the tensor is stored in row-major order (e.g. PyTorch tensors), the resulting vector will look like an unrolled tensor using row-major order.

The resulting vector type will be one of Type.SEQ, Type.MPI, Type.SEQCUDA, Type.MPICUDA, Type.SEQHIP or Type.MPIHIP depending on the type of dltensor and the number of processes in the communicator.

  • dltensor -- Either an object with a __dlpack__ method or a DLPack tensor object.
  • size (LayoutSizeSpec | None) -- Vector size.
  • bsize (int | None) -- Vector block size. If None, bsize = 1.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

Source code at petsc4py/PETSc/Vec.pyx:555


Destroy the vector.

Collective.

SEE ALSO:

create, petsc.VecDestroy


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



Return the dot product with vec.

Collective.

For complex numbers this computes yᴴ·x with self as x, vec as y and where yᴴ denotes the conjugate transpose of y.

Use tDot for the indefinite form yᵀ·x where yᵀ denotes the transpose of y.

vec (Vec) -- Vector to compute the dot product with.
Scalar

SEE ALSO:

dotBegin, dotEnd, tDot, petsc.VecDot


Source code at petsc4py/PETSc/Vec.pyx:1809


Begin computing the dot product.

Collective.

This should be paired with a call to dotEnd.

vec (Vec) -- Vector to compute the dot product with.
None

SEE ALSO:

dotEnd, dot, petsc.VecDotBegin


Source code at petsc4py/PETSc/Vec.pyx:1834


Finish computing the dot product initiated with dotBegin.

Collective.

SEE ALSO:

dotBegin, dot, petsc.VecDotEnd


Source code at petsc4py/PETSc/Vec.pyx:1854

vec (Vec) --
Scalar


Return the dot product with vec and its squared norm.

Collective.

SEE ALSO:

dot, norm, petsc.VecDotNorm2


Source code at petsc4py/PETSc/Vec.pyx:2012

vec (Vec) --
tuple[Scalar, float]


Create a new vector with the same type, optionally with data.

Collective.

array (Sequence[Scalar] | None) -- Optional values to store in the new vector.
Vec

SEE ALSO:

copy, petsc.VecDuplicate


Source code at petsc4py/PETSc/Vec.pyx:1704


Return whether the vector is equal to another.

Collective.

vec (Vec) -- Vector to compare with.
bool

SEE ALSO:

petsc.VecEqual


Source code at petsc4py/PETSc/Vec.pyx:1790


Replace each entry (xₙ) in the vector by exp(xₙ).

Logically collective.

SEE ALSO:

log, petsc.VecExp


Source code at petsc4py/PETSc/Vec.pyx:2118



Return local portion of the vector as an ndarray.

Logically collective.

readonly (bool) -- Request read-only access.
ArrayScalar

SEE ALSO:

setArray, getBuffer


Source code at petsc4py/PETSc/Vec.pyx:1330


Return the block size of the vector.

Not collective.

SEE ALSO:

petsc.VecGetBlockSize


Source code at petsc4py/PETSc/Vec.pyx:1166



Return a buffered view of the local portion of the vector.

Logically collective.

readonly (bool) -- Request read-only access.
Buffer object wrapping the local portion of the vector data. This can be used either as a context manager providing access as a numpy array or can be passed to array constructors accepting buffered objects such as numpy.asarray.
typing.Any

Examples

Accessing the data with a context manager:

>>> vec = PETSc.Vec().createWithArray([1, 2, 3])
>>> with vec.getBuffer() as arr:
...     arr
array([1., 2., 3.])

Converting the buffer to an ndarray:

>>> buf = PETSc.Vec().createWithArray([1, 2, 3]).getBuffer()
>>> np.asarray(buf)
array([1., 2., 3.])

SEE ALSO:

getArray


Source code at petsc4py/PETSc/Vec.pyx:1287


Return the OpenCL context associated with the vector.

Not collective.

Pointer to underlying CL context. This can be used with pyopencl through pyopencl.Context.from_int_ptr.
int

SEE ALSO:

getCLQueueHandle, petsc.VecViennaCLGetCLContext


Source code at petsc4py/PETSc/Vec.pyx:1614


Return the OpenCL buffer associated with the vector.

Not collective.

Pointer to the device buffer. This can be used with pyopencl through pyopencl.Context.from_int_ptr.
int
mode (AccessModeSpec) --

Notes

This method may incur a host-to-device copy if the device data is out of date and mode is "r" or "rw".

SEE ALSO:

restoreCLMemHandle, petsc.VecViennaCLGetCLMem, petsc.VecViennaCLGetCLMemRead, petsc.VecViennaCLGetCLMemWrite


Source code at petsc4py/PETSc/Vec.pyx:1654


Return the OpenCL command queue associated with the vector.

Not collective.

Pointer to underlying CL command queue. This can be used with pyopencl through pyopencl.Context.from_int_ptr.
int

SEE ALSO:

getCLContextHandle, petsc.VecViennaCLGetCLQueue


Source code at petsc4py/PETSc/Vec.pyx:1634


Return a pointer to the device buffer.

Not collective.

The returned pointer should be released using restoreCUDAHandle with the same access mode.

CUDA device pointer.
typing.Any
mode (AccessModeSpec) --

Notes

This method may incur a host-to-device copy if the device data is out of date and mode is "r" or "rw".

SEE ALSO:

restoreCUDAHandle, petsc.VecCUDAGetArray, petsc.VecCUDAGetArrayRead, petsc.VecCUDAGetArrayWrite


Source code at petsc4py/PETSc/Vec.pyx:1440


Return the DM associated to the vector.

Not collective.

SEE ALSO:

setDM, petsc.VecGetDM


Source code at petsc4py/PETSc/Vec.pyx:3375



Return a pointer to the device buffer.

Not collective.

The returned pointer should be released using restoreHIPHandle with the same access mode.

HIP device pointer.
typing.Any
mode (AccessModeSpec) --

Notes

This method may incur a host-to-device copy if the device data is out of date and mode is "r" or "rw".

SEE ALSO:

restoreHIPHandle, petsc.VecHIPGetArray, petsc.VecHIPGetArrayRead, petsc.VecHIPGetArrayWrite


Source code at petsc4py/PETSc/Vec.pyx:1514


Return the local-to-global mapping.

Not collective.

SEE ALSO:

setLGMap, petsc.VecGetLocalToGlobalMapping


Source code at petsc4py/PETSc/Vec.pyx:2764

LGMap


Return the local size of the vector.

Not collective.

SEE ALSO:

setSizes, getSize, petsc.VecGetLocalSize


Source code at petsc4py/PETSc/Vec.pyx:1124



Maps the local portion of the vector into a local vector.

Logically collective.

  • lvec (Vec) -- The local vector obtained from createLocalVector.
  • readonly (bool) -- Request read-only access.

None

SEE ALSO:

createLocalVector, restoreLocalVector, petsc.VecGetLocalVectorRead, petsc.VecGetLocalVector


Source code at petsc4py/PETSc/Vec.pyx:1240


Return all the vectors contained in the nested vector.

Not collective.

SEE ALSO:

setNestSubVecs, petsc.VecNestGetSubVecs


Source code at petsc4py/PETSc/Vec.pyx:3306

list[Vec]


Return the offloading status of the vector.

Not collective.

Common return values include:

  • 1: PETSC_OFFLOAD_CPU - CPU has valid entries
  • 2: PETSC_OFFLOAD_GPU - GPU has valid entries
  • 3: PETSC_OFFLOAD_BOTH - CPU and GPU are in sync

Enum value from petsc.PetscOffloadMask describing the offloading status.
int

SEE ALSO:

petsc.VecGetOffloadMask, petsc.PetscOffloadMask


Source code at petsc4py/PETSc/Vec.pyx:1588


Return the prefix used for searching for options in the database.

Not collective.

SEE ALSO:

Working with PETSc options (TODO), setOptionsPrefix, petsc.VecGetOptionsPrefix


Source code at petsc4py/PETSc/Vec.pyx:1031



Return the locally owned range of indices (start, end).

Not collective.

  • start (int) -- The first local element.
  • end (int) -- One more than the last local element.

tuple[int, int]

SEE ALSO:

getOwnershipRanges, petsc.VecGetOwnershipRange


Source code at petsc4py/PETSc/Vec.pyx:1180


Return the range of indices owned by each process.

Not collective.

The returned array is the result of exclusive scan of the local sizes.

SEE ALSO:

getOwnershipRange, petsc.VecGetOwnershipRanges


Source code at petsc4py/PETSc/Vec.pyx:1201

ArrayInt


Return the global size of the vector.

Not collective.

SEE ALSO:

setSizes, getLocalSize, petsc.VecGetSize


Source code at petsc4py/PETSc/Vec.pyx:1110



Return the vector sizes.

Not collective.

SEE ALSO:

getSize, getLocalSize, petsc.VecGetLocalSize, petsc.VecGetSize


Source code at petsc4py/PETSc/Vec.pyx:1138

LayoutSizeSpec


Return a subvector from given indices.

Collective.

Once finished with the subvector it should be returned with restoreSubVector.

  • iset (IS) -- Index set describing which indices to extract into the subvector.
  • subvec (Vec | None) -- Subvector to copy entries into. If None then a new Vec will be created.

Vec

SEE ALSO:

restoreSubVector, petsc.VecGetSubVector


Source code at petsc4py/PETSc/Vec.pyx:3261


Return the type of the vector.

Not collective.

SEE ALSO:

setType, petsc.VecGetType


Source code at petsc4py/PETSc/Vec.pyx:1096



Return a single value from the vector.

Not collective.

Only values locally stored may be accessed.

index (int) -- Location of the value to read.
Scalar

SEE ALSO:

getValues, petsc.VecGetValues


Source code at petsc4py/PETSc/Vec.pyx:2581


Return values from certain locations in the vector.

Not collective.

Only values locally stored may be accessed.

  • indices (Sequence[int]) -- Locations of the values to read.
  • values (Sequence[Scalar] | None) -- Location to store the collected values. If not provided then a new array will be allocated.

ArrayScalar

SEE ALSO:

getValue, setValues, petsc.VecGetValues


Source code at petsc4py/PETSc/Vec.pyx:2603


Not implemented.

Source code at petsc4py/PETSc/Vec.pyx:2629



Update ghosted vector entries.

Neighborwise collective.

  • addv (InsertModeSpec) -- Insertion mode.
  • mode (ScatterModeSpec) -- Scatter mode.

None

Examples

To accumulate ghost region values onto owning processes:

>>> vec.ghostUpdate(InsertMode.ADD_VALUES, ScatterMode.REVERSE)

Update ghost regions:

>>> vec.ghostUpdate(InsertMode.INSERT_VALUES, ScatterMode.FORWARD)

SEE ALSO:

ghostUpdateBegin, ghostUpdateEnd


Source code at petsc4py/PETSc/Vec.pyx:3204


Begin updating ghosted vector entries.

Neighborwise collective.

SEE ALSO:

ghostUpdateEnd, ghostUpdate, createGhost, petsc.VecGhostUpdateBegin


Source code at petsc4py/PETSc/Vec.pyx:3168

  • addv (InsertModeSpec) --
  • mode (ScatterModeSpec) --

None


Finish updating ghosted vector entries initiated with ghostUpdateBegin.

Neighborwise collective.

SEE ALSO:

ghostUpdateBegin, ghostUpdate, createGhost, petsc.VecGhostUpdateEnd


Source code at petsc4py/PETSc/Vec.pyx:3186

  • addv (InsertModeSpec) --
  • mode (ScatterModeSpec) --

None


Add a scaled reduced-space vector to a subset of the vector.

Logically collective.

This is equivalent to y[idx[i]] += alpha*x[i].

  • idx (IS) -- Index set for the reduced space. Negative indices are skipped.
  • alpha (Scalar) -- Scale factor.
  • x (Vec) -- Reduced-space vector.

None

SEE ALSO:

axpy, aypx, axpby, petsc.VecISAXPY


Source code at petsc4py/PETSc/Vec.pyx:2341


Set specific elements of the vector to the same value.

Not collective.

  • idx (IS) -- Index set specifying the vector entries to set.
  • alpha (Scalar) -- Value to set the selected entries to.

None

SEE ALSO:

set, zeroEntries, petsc.VecISSet


Source code at petsc4py/PETSc/Vec.pyx:2244


Load a vector.

Collective.

SEE ALSO:

view, petsc.VecLoad


Source code at petsc4py/PETSc/Vec.pyx:1772

viewer (Viewer) --
Self


Return a context manager for viewing ghost vectors in local form.

Logically collective.

Context manager yielding the vector in local (ghosted) form.
typing.Any

Notes

This operation does not perform a copy. To obtain up-to-date ghost values ghostUpdateBegin and ghostUpdateEnd must be called first.

Non-ghost values can be found at values[0:nlocal] and ghost values at values[nlocal:nlocal+nghost].

Examples

>>> with vec.localForm() as lf:
...     # compute with lf

SEE ALSO:

createGhost, ghostUpdateBegin, ghostUpdateEnd, petsc.VecGhostGetLocalForm, petsc.VecGhostRestoreLocalForm


Source code at petsc4py/PETSc/Vec.pyx:3135


Replace each entry in the vector by its natural logarithm.

Logically collective.

SEE ALSO:

exp, petsc.VecLog


Source code at petsc4py/PETSc/Vec.pyx:2130



Not implemented.

Source code at petsc4py/PETSc/Vec.pyx:1924



Not implemented.

Source code at petsc4py/PETSc/Vec.pyx:1928



Not implemented.

Source code at petsc4py/PETSc/Vec.pyx:1932



Return the vector entry with maximum real part and its location.

Collective.

  • p (int) -- Location of the maximum value. If multiple entries exist with the same value then the smallest index will be returned.
  • val (Scalar) -- Minimum value.

tuple[int, float]

SEE ALSO:

min, petsc.VecMax


Source code at petsc4py/PETSc/Vec.pyx:2064


Return the maximum of the component-wise absolute value division.

Logically collective.

Equivalent to result = max_i abs(x[i] / y[i]).

  • x -- Numerator vector.
  • y -- Denominator vector.
  • vec (Vec) --

float

SEE ALSO:

pointwiseMin, pointwiseMax, pointwiseMaxAbs, petsc.VecMaxPointwiseDivide


Source code at petsc4py/PETSc/Vec.pyx:2557


Compute and store y = Σₙ(ɑₙ·Xₙ) + y with X an array of vectors.

Logically collective.

Equivalent to y[:] = alphas[i]*vecs[i, :] + y[:].

  • alphas (Sequence[Scalar]) -- Array of scale factors, one for each vector in vecs.
  • vecs (Sequence[Vec]) -- Array of vectors.

None

SEE ALSO:

axpy, aypx, axpby, waxpy, petsc.VecMAXPY


Source code at petsc4py/PETSc/Vec.pyx:2430


Return the vector entry with minimum real part and its location.

Collective.

  • p (int) -- Location of the minimum value. If multiple entries exist with the same value then the smallest index will be returned.
  • val (Scalar) -- Minimum value.

tuple[int, float]

SEE ALSO:

max, petsc.VecMin


Source code at petsc4py/PETSc/Vec.pyx:2041


Not implemented.

Source code at petsc4py/PETSc/Vec.pyx:1936



Not implemented.

Source code at petsc4py/PETSc/Vec.pyx:1940



Not implemented.

Source code at petsc4py/PETSc/Vec.pyx:1944



Compute the vector norm.

Collective.

A 2-tuple is returned if NormType.NORM_1_AND_2 is specified.

SEE ALSO:

petsc.VecNorm, petsc.NormType


Source code at petsc4py/PETSc/Vec.pyx:1948

norm_type (NormTypeSpec) --
float | tuple[float, float]


Begin computing the vector norm.

Collective.

This should be paired with a call to normEnd.

SEE ALSO:

normEnd, norm, petsc.VecNormBegin


Source code at petsc4py/PETSc/Vec.pyx:1971

norm_type (NormTypeSpec) --
None


Finish computations initiated with normBegin.

Collective.

SEE ALSO:

normBegin, norm, petsc.VecNormEnd


Source code at petsc4py/PETSc/Vec.pyx:1991

norm_type (NormTypeSpec) --
float | tuple[float, float]


Normalize the vector by its 2-norm.

Collective.

The vector norm before normalization.
float

SEE ALSO:

norm, petsc.VecNormalize


Source code at petsc4py/PETSc/Vec.pyx:2087


Permute the vector in-place with a provided ordering.

Collective.

  • order (IS) -- Ordering for the permutation.
  • invert (bool) -- Whether to invert the permutation.

None

SEE ALSO:

petsc.VecPermute


Source code at petsc4py/PETSc/Vec.pyx:2198


Set the local portion of the vector to a provided array.

Not collective.

SEE ALSO:

resetArray, setArray, petsc.VecPlaceArray


Source code at petsc4py/PETSc/Vec.pyx:1362

array (Sequence[Scalar]) --
None


Compute and store the component-wise division of two vectors.

Logically collective.

Equivalent to w[i] = x[i] / y[i].

  • x (Vec) -- Numerator vector.
  • y (Vec) -- Denominator vector.

None

SEE ALSO:

pointwiseMult, petsc.VecPointwiseDivide


Source code at petsc4py/PETSc/Vec.pyx:2479


Compute and store the component-wise maximum of two vectors.

Logically collective.

Equivalent to w[i] = max(x[i], y[i]).

  • x (Vec) -- Input vectors to find the component-wise maxima.
  • y (Vec) -- Input vectors to find the component-wise maxima.

None

SEE ALSO:

pointwiseMin, pointwiseMaxAbs, petsc.VecPointwiseMax


Source code at petsc4py/PETSc/Vec.pyx:2519


Compute and store the component-wise maximum absolute values.

Logically collective.

Equivalent to w[i] = max(abs(x[i]), abs(y[i])).

  • x (Vec) -- Input vectors to find the component-wise maxima.
  • y (Vec) -- Input vectors to find the component-wise maxima.

None

SEE ALSO:

pointwiseMin, pointwiseMax, petsc.VecPointwiseMaxAbs


Source code at petsc4py/PETSc/Vec.pyx:2538


Compute and store the component-wise minimum of two vectors.

Logically collective.

Equivalent to w[i] = min(x[i], y[i]).

  • x (Vec) -- Input vectors to find the component-wise minima.
  • y (Vec) -- Input vectors to find the component-wise minima.

None

SEE ALSO:

pointwiseMax, pointwiseMaxAbs, petsc.VecPointwiseMin


Source code at petsc4py/PETSc/Vec.pyx:2500


Compute and store the component-wise multiplication of two vectors.

Logically collective.

Equivalent to w[i] = x[i] * y[i].

  • x (Vec) -- Input vectors to multiply component-wise.
  • y (Vec) -- Input vectors to multiply component-wise.

None

SEE ALSO:

pointwiseDivide, petsc.VecPointwiseMult


Source code at petsc4py/PETSc/Vec.pyx:2460


Replace each entry in the vector by its reciprocal.

Logically collective.

SEE ALSO:

petsc.VecReciprocal


Source code at petsc4py/PETSc/Vec.pyx:2106



Reset the vector to use its default array.

Not collective.

force (bool) -- Force the calling of petsc.VecResetArray even if no user array has been placed with placeArray.
The array previously provided by the user with placeArray. Can be None if force is True and no array was placed before.
ArrayScalar

SEE ALSO:

placeArray, petsc.VecResetArray


Source code at petsc4py/PETSc/Vec.pyx:1383


Restore a pointer to the OpenCL buffer obtained with getCLMemHandle.

Not collective.

SEE ALSO:

getCLMemHandle, petsc.VecViennaCLRestoreCLMemWrite


Source code at petsc4py/PETSc/Vec.pyx:1692



Restore a pointer to the device buffer obtained with getCUDAHandle.

Not collective.

  • handle (Any) -- CUDA device pointer.
  • mode (AccessModeSpec) -- Access mode.

None

SEE ALSO:

getCUDAHandle, petsc.VecCUDARestoreArray, petsc.VecCUDARestoreArrayRead, petsc.VecCUDARestoreArrayWrite


Source code at petsc4py/PETSc/Vec.pyx:1480


Restore a pointer to the device buffer obtained with getHIPHandle.

Not collective.

  • handle (Any) -- HIP device pointer.
  • mode (AccessModeSpec) -- Access mode.

None

SEE ALSO:

getHIPHandle, petsc.VecHIPRestoreArray, petsc.VecHIPRestoreArrayRead, petsc.VecHIPRestoreArrayWrite


Source code at petsc4py/PETSc/Vec.pyx:1554


Unmap a local access obtained with getLocalVector.

Logically collective.

  • lvec (Vec) -- The local vector.
  • readonly (bool) -- Request read-only access.

None

SEE ALSO:

createLocalVector, getLocalVector, petsc.VecRestoreLocalVectorRead, petsc.VecRestoreLocalVector


Source code at petsc4py/PETSc/Vec.pyx:1263


Restore a subvector extracted using getSubVector.

Collective.

  • iset (IS) -- Index set describing the indices represented by the subvector.
  • subvec (Vec) -- Subvector to be restored.

None

SEE ALSO:

getSubVector, petsc.VecRestoreSubVector


Source code at petsc4py/PETSc/Vec.pyx:3287


Scale all entries of the vector.

Collective.

This method sets each entry (xₙ) in the vector to ɑ·xₙ.

alpha (Scalar) -- The scaling factor.
None

SEE ALSO:

shift, petsc.VecScale


Source code at petsc4py/PETSc/Vec.pyx:2264


Set all components of the vector to the same value.

Collective.

SEE ALSO:

zeroEntries, isset, petsc.VecSet


Source code at petsc4py/PETSc/Vec.pyx:2231

alpha (Scalar) --
None


Set values for the local portion of the vector.

Logically collective.

SEE ALSO:

placeArray


Source code at petsc4py/PETSc/Vec.pyx:1350

array (Sequence[Scalar]) --
None


Set the block size of the vector.

Logically collective.

SEE ALSO:

petsc.VecSetBlockSize


Source code at petsc4py/PETSc/Vec.pyx:1153

bsize (int) --
None


Associate a DM to the vector.

Not collective.

SEE ALSO:

getDM, petsc.VecSetDM


Source code at petsc4py/PETSc/Vec.pyx:3363

dm (DM) --
None


Configure the vector from the options database.

Collective.

SEE ALSO:

Working with PETSc options (TODO), petsc.VecSetFromOptions


Source code at petsc4py/PETSc/Vec.pyx:1059



Set the local-to-global mapping.

Logically collective.

This allows users to insert vector entries using a local numbering with setValuesLocal.

SEE ALSO:

setValues, setValuesLocal, getLGMap, petsc.VecSetLocalToGlobalMapping


Source code at petsc4py/PETSc/Vec.pyx:2749

lgmap (LGMap) --
None


Set the ghost points for a ghosted vector.

Collective.

ghosts (Sequence[int]) -- Global indices of ghost points.
None

SEE ALSO:

createGhost


Source code at petsc4py/PETSc/Vec.pyx:3240


Set the component vectors at specified indices in the nested vector.

Not collective.

  • sx (Sequence[Vec]) -- Array of component vectors.
  • idxm (Sequence[int] | None) -- Indices of the component vectors, defaults to range(len(sx)).

None

SEE ALSO:

getNestSubVecs, petsc.VecNestSetSubVecs


Source code at petsc4py/PETSc/Vec.pyx:3328


Set option.

Collective.

SEE ALSO:

petsc.VecSetOption


Source code at petsc4py/PETSc/Vec.pyx:1084

  • option (Option) --
  • flag (bool) --

None


Set the prefix used for searching for options in the database.

Logically collective.

SEE ALSO:

Working with PETSc options (TODO), getOptionsPrefix, petsc.VecSetOptionsPrefix


Source code at petsc4py/PETSc/Vec.pyx:1017

prefix (str) --
None


Set all components of the vector to random numbers.

Collective.

random (Random | None) -- Random number generator. If None then one will be created internally.
None

SEE ALSO:

petsc.VecSetRandom


Source code at petsc4py/PETSc/Vec.pyx:2178


Set the local and global sizes of the vector.

Collective.

  • size (LayoutSizeSpec) -- Vector size.
  • bsize (int | None) -- Vector block size. If None, bsize = 1.

None

SEE ALSO:

getSizes, petsc.VecSetSizes


Source code at petsc4py/PETSc/Vec.pyx:221


Set the vector type.

Collective.

vec_type (Type | str) -- The vector type.
None

SEE ALSO:

create, getType, petsc.VecSetType


Source code at petsc4py/PETSc/Vec.pyx:202


Set up the internal data structures for using the vector.

Collective.

SEE ALSO:

create, destroy, petsc.VecSetUp


Source code at petsc4py/PETSc/Vec.pyx:1071



Insert or add a single value in the vector.

Not collective.

  • index (int) -- Location to write to. Negative indices are ignored.
  • value (Scalar) -- Value to insert at index.
  • addv (InsertModeSpec) -- Insertion mode.

None

Notes

The values may be cached so assemblyBegin and assemblyEnd must be called after all calls of this method are completed.

Multiple calls to setValue cannot be made with different values for addv without intermediate calls to assemblyBegin and assemblyEnd.

SEE ALSO:

setValues, petsc.VecSetValues


Source code at petsc4py/PETSc/Vec.pyx:2633


Insert or add a single value in the vector using a local numbering.

Not collective.

  • index (int) -- Location to write to.
  • value (Scalar) -- Value to insert at index.
  • addv (InsertModeSpec) -- Insertion mode.


Notes

The values may be cached so assemblyBegin and assemblyEnd must be called after all calls of this method are completed.

Multiple calls to setValueLocal cannot be made with different values for addv without intermediate calls to assemblyBegin and assemblyEnd.

SEE ALSO:

setValuesLocal, petsc.VecSetValuesLocal


Source code at petsc4py/PETSc/Vec.pyx:2779


Insert or add multiple values in the vector.

Not collective.

  • indices (Sequence[int]) -- Locations to write to. Negative indices are ignored.
  • values (Sequence[Scalar]) -- Values to insert at indices.
  • addv (InsertModeSpec) -- Insertion mode.

None

Notes

The values may be cached so assemblyBegin and assemblyEnd must be called after all calls of this method are completed.

Multiple calls to setValues cannot be made with different values for addv without intermediate calls to assemblyBegin and assemblyEnd.

SEE ALSO:

setValue, petsc.VecSetValues


Source code at petsc4py/PETSc/Vec.pyx:2671


Insert or add blocks of values in the vector.

Not collective.

Equivalent to x[bs*indices[i]+j] = y[bs*i+j] for 0 <= i < len(indices), 0 <= j < bs and bs block_size.

  • indices (Sequence[int]) -- Block indices to write to. Negative indices are ignored.
  • values (Sequence[Scalar]) -- Values to insert at indices. Should have length len(indices) * vec.block_size.
  • addv (InsertModeSpec) -- Insertion mode.

None

Notes

The values may be cached so assemblyBegin and assemblyEnd must be called after all calls of this method are completed.

Multiple calls to setValuesBlocked cannot be made with different values for addv without intermediate calls to assemblyBegin and assemblyEnd.

SEE ALSO:

setValues, petsc.VecSetValuesBlocked


Source code at petsc4py/PETSc/Vec.pyx:2706


Insert or add blocks of values in the vector with a local numbering.

Not collective.

Equivalent to x[bs*indices[i]+j] = y[bs*i+j] for 0 <= i < len(indices), 0 <= j < bs and bs block_size.

  • indices (Sequence[int]) -- Local block indices to write to.
  • values (Sequence[Scalar]) -- Values to insert at indices. Should have length len(indices) * vec.block_size.
  • addv (InsertModeSpec) -- Insertion mode.

None

Notes

The values may be cached so assemblyBegin and assemblyEnd must be called after all calls of this method are completed.

Multiple calls to setValuesBlockedLocal cannot be made with different values for addv without intermediate calls to assemblyBegin and assemblyEnd.

SEE ALSO:

setValuesBlocked, setValuesLocal, petsc.VecSetValuesBlockedLocal


Source code at petsc4py/PETSc/Vec.pyx:2852


Insert or add multiple values in the vector with a local numbering.

Not collective.

  • indices (Sequence[int]) -- Locations to write to.
  • values (Sequence[Scalar]) -- Values to insert at indices.
  • addv (InsertModeSpec) -- Insertion mode.

None

Notes

The values may be cached so assemblyBegin and assemblyEnd must be called after all calls of this method are completed.

Multiple calls to setValuesLocal cannot be made with different values for addv without intermediate calls to assemblyBegin and assemblyEnd.

SEE ALSO:

setValues, petsc.VecSetValuesLocal


Source code at petsc4py/PETSc/Vec.pyx:2817


Not implemented.

Source code at petsc4py/PETSc/Vec.pyx:2745



Shift all entries in the vector.

Collective.

This method sets each entry (xₙ) in the vector to xₙ + ɑ.

alpha (Scalar) -- The shift to apply to the vector values.
None

SEE ALSO:

scale, petsc.VecShift


Source code at petsc4py/PETSc/Vec.pyx:2284


Replace each entry (xₙ) in the vector by √|xₙ|.

Logically collective.

SEE ALSO:

petsc.VecSqrtAbs


Source code at petsc4py/PETSc/Vec.pyx:2142



Insert component values into a single-component vector.

Collective.

The current vector is expected to be multi-component (block_size greater than 1) and the target vector is expected to be single-component.

  • field (int) -- Component index. Must be between 0 and vec.block_size.
  • vec (Vec) -- Single-component vector to be inserted into.
  • addv (InsertModeSpec) -- Insertion mode.

None

SEE ALSO:

strideScatter, petsc.VecStrideScatter


Source code at petsc4py/PETSc/Vec.pyx:3101


Return the maximum of entries in a subvector.

Collective.

Equivalent to max(x[field], x[field+bs], x[field+2*bs], ...) where bs is block_size.

field (int) -- Component index. Must be between 0 and vec.block_size.
  • int -- Location of maximum.
  • float -- Maximum value.

tuple[int, float]

SEE ALSO:

strideScale, strideSum, strideMin, petsc.VecStrideMax


Source code at petsc4py/PETSc/Vec.pyx:3005


Return the minimum of entries in a subvector.

Collective.

Equivalent to min(x[field], x[field+bs], x[field+2*bs], ...) where bs is block_size.

field (int) -- Component index. Must be between 0 and vec.block_size.
  • int -- Location of minimum.
  • float -- Minimum value.

tuple[int, float]

SEE ALSO:

strideScale, strideSum, strideMax, petsc.VecStrideMin


Source code at petsc4py/PETSc/Vec.pyx:2974


Return the norm of entries in a subvector.

Collective.

Equivalent to norm(x[field], x[field+bs], x[field+2*bs], ...) where bs is block_size.

  • field (int) -- Component index. Must be between 0 and vec.block_size.
  • norm_type (NormTypeSpec) -- The norm type.

float | tuple[float, float]

SEE ALSO:

norm, strideScale, strideSum, petsc.VecStrideNorm


Source code at petsc4py/PETSc/Vec.pyx:3036


Scale a component of the vector.

Logically collective.

  • field (int) -- Component index. Must be between 0 and vec.block_size.
  • alpha (Scalar) -- Factor to multiple the component entries by.

None

SEE ALSO:

strideSum, strideMin, strideMax, petsc.VecStrideScale


Source code at petsc4py/PETSc/Vec.pyx:2930


Scatter entries into a component of another vector.

Collective.

The current vector is expected to be single-component (block_size of 1) and the target vector is expected to be multi-component.

  • field (int) -- Component index. Must be between 0 and vec.block_size.
  • vec (Vec) -- Multi-component vector to be scattered into.
  • addv (InsertModeSpec) -- Insertion mode.

None

SEE ALSO:

strideGather, petsc.VecStrideScatter


Source code at petsc4py/PETSc/Vec.pyx:3069


Sum subvector entries.

Collective.

Equivalent to sum(x[field], x[field+bs], x[field+2*bs], ...) where bs is block_size.

field (int) -- Component index. Must be between 0 and vec.block_size.
Scalar

SEE ALSO:

strideScale, strideMin, strideMax, petsc.VecStrideSum


Source code at petsc4py/PETSc/Vec.pyx:2951


Return the sum of all the entries of the vector.

Collective.

SEE ALSO:

petsc.VecSum


Source code at petsc4py/PETSc/Vec.pyx:2027

Scalar


Swap the content of two vectors.

Logically collective.

vec (Vec) -- The vector to swap data with.
None

SEE ALSO:

petsc.VecSwap


Source code at petsc4py/PETSc/Vec.pyx:2304


Return the indefinite dot product with vec.

Collective.

This computes yᵀ·x with self as x, vec as y and where yᵀ denotes the transpose of y.

vec (Vec) -- Vector to compute the indefinite dot product with.
Scalar

SEE ALSO:

tDotBegin, tDotEnd, dot, petsc.VecTDot


Source code at petsc4py/PETSc/Vec.pyx:1868


Begin computing the indefinite dot product.

Collective.

This should be paired with a call to tDotEnd.

vec (Vec) -- Vector to compute the indefinite dot product with.
None

SEE ALSO:

tDotEnd, tDot, petsc.VecTDotBegin


Source code at petsc4py/PETSc/Vec.pyx:1890


Finish computing the indefinite dot product initiated with tDotBegin.

Collective.

SEE ALSO:

tDotBegin, tDot, petsc.VecTDotEnd


Source code at petsc4py/PETSc/Vec.pyx:1910

vec (Vec) --
Scalar


Return a DLPack PyCapsule wrapping the vector data.

Collective.

mode (AccessModeSpec) -- Access mode for the vector.
Capsule of a DLPack tensor wrapping a Vec.
PyCapsule

Notes

It is important that the access mode is respected by the consumer as this is not enforced internally.

SEE ALSO:

createWithDLPack


Source code at petsc4py/PETSc/Vec.pyx:739


Display the vector.

Collective.

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

SEE ALSO:

load, petsc.VecView


Source code at petsc4py/PETSc/Vec.pyx:147


Compute and store w = ɑ·x + y.

Logically collective.

  • alpha (Scalar) -- Scale factor.
  • x (Vec) -- First input vector.
  • y (Vec) -- Second input vector.

None

SEE ALSO:

axpy, aypx, axpby, maxpy, petsc.VecWAXPY


Source code at petsc4py/PETSc/Vec.pyx:2408


Set all entries in the vector to zero.

Logically collective.

SEE ALSO:

set, petsc.VecZeroEntries


Source code at petsc4py/PETSc/Vec.pyx:2219



Attributes Documentation

Alias for array_w.

Source code at petsc4py/PETSc/Vec.pyx:3451


Read-only ndarray containing the local portion of the vector.

Source code at petsc4py/PETSc/Vec.pyx:3441


Writeable ndarray containing the local portion of the vector.

Source code at petsc4py/PETSc/Vec.pyx:3433


The block size.

Source code at petsc4py/PETSc/Vec.pyx:3408


Alias for buffer_w.

Source code at petsc4py/PETSc/Vec.pyx:3446


Read-only buffered view of the local portion of the vector.

Source code at petsc4py/PETSc/Vec.pyx:3428


Writeable buffered view of the local portion of the vector.

Source code at petsc4py/PETSc/Vec.pyx:3423


The local vector size.

Source code at petsc4py/PETSc/Vec.pyx:3403


The locally owned range of indices in the form [low, high).

Source code at petsc4py/PETSc/Vec.pyx:3413


The range of indices owned by each process.

Source code at petsc4py/PETSc/Vec.pyx:3418


The global vector size.

Source code at petsc4py/PETSc/Vec.pyx:3398


The local and global vector sizes.

Source code at petsc4py/PETSc/Vec.pyx:3391




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:

petsc.PetscViewer


Enumerations

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

petsc4py.PETSc.Viewer.DrawSize

Bases: object

Window size.

Attributes Summary

FULL Constant FULL of type int
FULL_SIZE Constant FULL_SIZE of type int
HALF Constant HALF of type int
HALF_SIZE Constant HALF_SIZE of type int
QUARTER Constant QUARTER of type int
QUARTER_SIZE Constant QUARTER_SIZE of type int
THIRD Constant THIRD of type int
THIRD_SIZE Constant THIRD_SIZE of type int

Attributes Documentation

Constant FULL of type int

Constant FULL_SIZE of type int

Constant HALF of type int

Constant HALF_SIZE of type int

Constant QUARTER of type int

Constant QUARTER_SIZE of type int

Constant THIRD of type int

Constant THIRD_SIZE of type int


petsc4py.PETSc.Viewer.FileMode

Bases: object

Viewer file mode.

Attributes Summary

A Constant A of type int
APPEND Constant APPEND of type int
APPEND_UPDATE Constant APPEND_UPDATE of type int
AU Constant AU of type int
R Constant R of type int
READ Constant READ of type int
U Constant U of type int
UA Constant UA of type int
UPDATE Constant UPDATE of type int
W Constant W of type int
WRITE Constant WRITE of type int

Attributes Documentation

Constant A of type int

Constant APPEND of type int

Constant APPEND_UPDATE of type int

Constant AU of type int

Constant R of type int

Constant READ of type int

Constant U of type int

Constant UA of type int

Constant UPDATE of type int

Constant W of type int

Constant WRITE of type int


petsc4py.PETSc.Viewer.Format

Bases: object

Viewer format.

Attributes Summary

ASCII_COMMON Constant ASCII_COMMON of type int
ASCII_CSV Constant ASCII_CSV of type int
ASCII_DENSE Constant ASCII_DENSE of type int
ASCII_FACTOR_INFO Constant ASCII_FACTOR_INFO of type int
ASCII_GLVIS Constant ASCII_GLVIS of type int
ASCII_IMPL Constant ASCII_IMPL of type int
ASCII_INDEX Constant ASCII_INDEX of type int
ASCII_INFO Constant ASCII_INFO of type int
ASCII_INFO_DETAIL Constant ASCII_INFO_DETAIL of type int
ASCII_LATEX Constant ASCII_LATEX of type int
ASCII_MATHEMATICA Constant ASCII_MATHEMATICA of type int
ASCII_MATLAB Constant ASCII_MATLAB of type int
ASCII_MATRIXMARKET Constant ASCII_MATRIXMARKET of type int
ASCII_PCICE Constant ASCII_PCICE of type int
ASCII_PYTHON Constant ASCII_PYTHON of type int
ASCII_SYMMODU Constant ASCII_SYMMODU of type int
ASCII_VTK Constant ASCII_VTK of type int
ASCII_VTK_CELL Constant ASCII_VTK_CELL of type int
ASCII_VTK_COORDS Constant ASCII_VTK_COORDS of type int
ASCII_XML Constant ASCII_XML of type int
BINARY_MATLAB Constant BINARY_MATLAB of type int
DEFAULT Constant DEFAULT of type int
DRAW_BASIC Constant DRAW_BASIC of type int
DRAW_CONTOUR Constant DRAW_CONTOUR of type int
DRAW_LG Constant DRAW_LG of type int
DRAW_LG_XRANGE Constant DRAW_LG_XRANGE of type int
DRAW_PORTS Constant DRAW_PORTS of type int
FAILED Constant FAILED of type int
HDF5_MAT Constant HDF5_MAT of type int
HDF5_PETSC Constant HDF5_PETSC of type int
HDF5_VIZ Constant HDF5_VIZ of type int
HDF5_XDMF Constant HDF5_XDMF of type int
LOAD_BALANCE Constant LOAD_BALANCE of type int
NATIVE Constant NATIVE of type int
NOFORMAT Constant NOFORMAT of type int
VTK_VTR Constant VTK_VTR of type int
VTK_VTS Constant VTK_VTS of type int
VTK_VTU Constant VTK_VTU of type int

Attributes Documentation

Constant ASCII_COMMON of type int

Constant ASCII_CSV of type int

Constant ASCII_DENSE of type int

Constant ASCII_FACTOR_INFO of type int

Constant ASCII_GLVIS of type int

Constant ASCII_IMPL of type int

Constant ASCII_INDEX of type int

Constant ASCII_INFO of type int

Constant ASCII_INFO_DETAIL of type int

Constant ASCII_LATEX of type int

Constant ASCII_MATHEMATICA of type int

Constant ASCII_MATLAB of type int

Constant ASCII_MATRIXMARKET of type int

Constant ASCII_PCICE of type int

Constant ASCII_PYTHON of type int

Constant ASCII_SYMMODU of type int

Constant ASCII_VTK of type int

Constant ASCII_VTK_CELL of type int

Constant ASCII_VTK_COORDS of type int

Constant ASCII_XML of type int

Constant BINARY_MATLAB of type int

Constant DEFAULT of type int

Constant DRAW_BASIC of type int

Constant DRAW_CONTOUR of type int

Constant DRAW_LG of type int

Constant DRAW_LG_XRANGE of type int

Constant DRAW_PORTS of type int

Constant FAILED of type int

Constant HDF5_MAT of type int

Constant HDF5_PETSC of type int

Constant HDF5_VIZ of type int

Constant HDF5_XDMF of type int

Constant LOAD_BALANCE of type int

Constant NATIVE of type int

Constant NOFORMAT of type int

Constant VTK_VTR of type int

Constant VTK_VTS of type int

Constant VTK_VTU of type int


petsc4py.PETSc.Viewer.Type

Bases: object

Viewer type.

Attributes Summary

ADIOS Object ADIOS of type str
ASCII Object ASCII of type str
BINARY Object BINARY of type str
DRAW Object DRAW of type str
EXODUSII Object EXODUSII of type str
GLVIS Object GLVIS of type str
HDF5 Object HDF5 of type str
MATHEMATICA Object MATHEMATICA of type str
MATLAB Object MATLAB of type str
SAWS Object SAWS of type str
SOCKET Object SOCKET of type str
STRING Object STRING of type str
VTK Object VTK of type str
VU Object VU of type str

Attributes Documentation

Object ADIOS of type str

Object ASCII of type str

Object BINARY of type str

Object DRAW of type str

Object EXODUSII of type str

Object GLVIS of type str

Object HDF5 of type str

Object MATHEMATICA of type str

Object MATLAB of type str

Object SAWS of type str

Object SOCKET of type str

Object STRING of type str

Object VTK of type str

Object VU of type str


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.
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.
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.
setType(vwr_type) Set the type of the viewer.
subtractASCIITab(tabs) Decrement the ASCII tab level.
useASCIITabs(flag) Enable/disable the use of ASCII tabs.
view([obj]) View the viewer.

Methods Documentation

Return an ASCII viewer associated with the communicator.

Collective.

  • name (str) -- The filename.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Viewer

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


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

Collective.

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

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


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

Collective.

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

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


Return the standard error viewer associated with the communicator.

Collective.

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

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


Return the standard output viewer associated with the communicator.

Collective.

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

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


Increment the ASCII tab level.

Collective.

SEE ALSO:

petsc.PetscViewerASCIIAddTab


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

tabs (int) --


Reset graphics.

Not collective.

SEE ALSO:

petsc.PetscViewerDrawClear


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



Create a viewer.

Collective.

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

SEE ALSO:

Sys.getDefaultComm, petsc.PetscViewerCreate


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


Create a viewer of type Type.ASCII.

Collective.

  • name (str) -- The filename associated with the viewer.
  • mode (FileMode | str | None) -- The mode type.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

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


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


Create a viewer of type Type.BINARY.

Collective.

  • name (str) -- The filename associated with the viewer.
  • mode (FileMode | str | None) -- The mode type.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

create, setType, setFileMode, setFileName, Sys.getDefaultComm


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


Create a Type.DRAW viewer.

Collective.

  • 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.

Self

SEE ALSO:

Sys.getDefaultComm, petsc.PetscViewerDrawOpen


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


Create a viewer of type Type.HDF5.

Collective.

  • name (str) -- The filename associated with the viewer.
  • mode (FileMode | str | None) -- The mode type.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

create, setType, setFileMode, setFileName, Sys.getDefaultComm


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


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

Collective.

  • name (str) -- The filename associated with the viewer.
  • mode (FileMode | str | None) -- The mode type.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

create, setType, setFileMode, setFileName, Sys.getDefaultComm


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


Create a viewer of type Type.VTK.

Collective.

  • name (str) -- The filename associated with the viewer.
  • mode (FileMode | str | None) -- The mode type.
  • comm (Comm | None) -- MPI communicator, defaults to Sys.getDefaultComm.

Self

SEE ALSO:

create, setType, setFileMode, setFileName, Sys.getDefaultComm


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


Destroy the viewer.

Collective.

SEE ALSO:

petsc.PetscViewerDestroy


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



Flush the viewer.

Collective.

SEE ALSO:

petsc.PetscViewerFlush


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



Return the ASCII tab level.

Not collective.

SEE ALSO:

setASCIITab, petsc.PetscViewerASCIIGetTab


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



Return the file mode.

Not collective.

SEE ALSO:

setFileMode, petsc.PetscViewerFileGetMode


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

FileMode


Return file name.

Not collective.

SEE ALSO:

setFileName, petsc.PetscViewerFileGetName


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



Return the format of the viewer.

Not collective.

SEE ALSO:

pushFormat, popFormat, petsc.PetscViewerGetFormat


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

Format


Return a viewer defined on a subcommunicator.

Collective.

comm (Comm | None) -- The subcommunicator. If None, uses COMM_SELF.
Viewer

Notes

Users must call restoreSubViewer when done.

SEE ALSO:

restoreSubViewer, petsc.PetscViewerGetSubViewer


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


Return the type of the viewer.

Not collective.

SEE ALSO:

setType, petsc.PetscViewerGetType


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



Disallow ASCII synchronized calls.

Collective.

SEE ALSO:

printfASCIISynchronized, pushASCIISynchronized, petsc.PetscViewerASCIIPopSynchronized


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



Pop an additional tab level pushed via pushASCIITab.

Collective.

SEE ALSO:

pushASCIITab, petsc.PetscViewerASCIIPopTab


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



Pop format from the viewer.

Collective.

SEE ALSO:

pushFormat, petsc.PetscViewerPopFormat


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



Print a message.

Collective.

SEE ALSO:

petsc.PetscViewerASCIIPrintf


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

msg (str) --
None


Print a synchronized message.

Collective.

SEE ALSO:

pushASCIISynchronized, petsc.PetscViewerASCIISynchronizedPrintf


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

msg (str) --
None


Allow ASCII synchronized calls.

Collective.

SEE ALSO:

printfASCIISynchronized, popASCIISynchronized, petsc.PetscViewerASCIIPushSynchronized


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



Push an additional tab level.

Collective.

SEE ALSO:

popASCIITab, petsc.PetscViewerASCIIPushTab


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



Push format to the viewer.

Collective.

SEE ALSO:

popFormat, petsc.PetscViewerPushFormat


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

format (Format) --
None


Restore a viewer defined on a subcommunicator.

Collective.

sub (Viewer) -- The subviewer obtained from getSubViewer.
None

SEE ALSO:

getSubViewer, petsc.PetscViewerRestoreSubViewer


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


Set ASCII tab level.

Collective.

SEE ALSO:

getASCIITab, petsc.PetscViewerASCIISetTab


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

tabs (int) --
None


Set window information for a Type.DRAW viewer.

Collective.

  • 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.

None

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


Set file mode.

Collective.

SEE ALSO:

getFileMode, petsc.PetscViewerFileSetMode


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

mode (FileMode | str) --
None


Set file name.

Collective.

SEE ALSO:

getFileName, petsc.PetscViewerFileSetName


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

name (str) --
None


Set the type of the viewer.

Logically collective.

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

SEE ALSO:

getType, petsc.PetscViewerSetType


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


Decrement the ASCII tab level.

Collective.

SEE ALSO:

petsc.PetscViewerASCIISubtractTab


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

tabs (int) --
None


Enable/disable the use of ASCII tabs.

Collective.

SEE ALSO:

petsc.PetscViewerASCIIUseTabs


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

flag (bool) --
None


View the viewer.

Collective.

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.
None

Notes

SEE ALSO:

petsc.PetscViewerView


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




petsc4py.PETSc.ViewerHDF5

Bases: Viewer

Methods Summary

create(name[, mode, comm]) Source code at petsc4py/PETSc/Viewer.pyx:908
getGroup() Source code at petsc4py/PETSc/Viewer.pyx:946
getTimestep() Source code at petsc4py/PETSc/Viewer.pyx:927
incrementTimestep() Source code at petsc4py/PETSc/Viewer.pyx:935
popGroup() Source code at petsc4py/PETSc/Viewer.pyx:943
popTimestepping() Source code at petsc4py/PETSc/Viewer.pyx:924
pushGroup(group) Source code at petsc4py/PETSc/Viewer.pyx:938
pushTimestepping() Source code at petsc4py/PETSc/Viewer.pyx:921
setTimestep(timestep) Source code at petsc4py/PETSc/Viewer.pyx:932

Methods Documentation

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

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

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

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

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

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

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

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

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


Exceptions

Error PETSc Error.

petsc4py.PETSc.Error

PETSc Error.
PETSc error code.
int



Functions

garbage_cleanup([comm]) Clean up unused PETSc objects.
garbage_view([comm]) Print summary of the garbage PETSc objects.

petsc4py.PETSc.garbage_cleanup

Clean up unused PETSc objects.

Collective.

Notes

If the communicator comm if not provided or it is None, then COMM_WORLD is used.

Source code at petsc4py/PETSc/cyclicgc.pxi:41


petsc4py.PETSc.garbage_view

Print summary of the garbage PETSc objects.

Collective.

Notes

Print out garbage summary on each rank of the communicator comm. If no communicator is provided then COMM_WORLD is used.

Source code at petsc4py/PETSc/cyclicgc.pxi:64


Attributes

DECIDE Constant DECIDE of type int
DEFAULT Constant DEFAULT of type int
DETERMINE Constant DETERMINE of type int
INFINITY Object INFINITY of type float
NINFINITY Object NINFINITY of type float
PINFINITY Object PINFINITY of type float
COMM_NULL Object COMM_NULL of type Comm
COMM_SELF Object COMM_SELF of type Comm
COMM_WORLD Object COMM_WORLD of type Comm

petsc4py.PETSc.DECIDE

Constant DECIDE of type int

petsc4py.PETSc.DEFAULT

Constant DEFAULT of type int

petsc4py.PETSc.DETERMINE

Constant DETERMINE of type int

petsc4py.PETSc.INFINITY

Object INFINITY of type float

petsc4py.PETSc.NINFINITY

Object NINFINITY of type float

petsc4py.PETSc.PINFINITY

Object PINFINITY of type float

petsc4py.PETSc.COMM_NULL

Object COMM_NULL of type Comm

petsc4py.PETSc.COMM_SELF

Object COMM_SELF of type Comm

petsc4py.PETSc.COMM_WORLD

Object COMM_WORLD of type Comm

PETSC PYTHON TYPES

Here we discuss details about Python-aware PETSc types that can be used within the library.

In particular, we discuss matrices, preconditioners, Krylov solvers, nonlinear solvers and ODE integrators.

The low-level, Cython implementation exposing the Python methods is contained in

$PETSC_DIR/src/binding/petsc4py/src/petsc4py/PETSc/libpetsc4py.pyx

The scripts can be found in $PETSC_DIR/src/binding/petsc4py/demo/python_types.

PETSc Python matrix type

PETSc provides a convenient way to compute the action of linear operators coded in Python through the petsc4py.PETSc.Mat.Type.PYTHON type.

In addition to the matrix action, the implementation can expose additional methods for use within the library. A template class for the supported methods is given below.

from petsc4py.typing import Scalar
from petsc4py.PETSc import Mat
from petsc4py.PETSc import Vec
from petsc4py.PETSc import IS
from petsc4py.PETSc import InsertMode
from petsc4py.PETSc import NormType
from petsc4py.PETSc import Viewer
# A template class with the Python methods supported by MATPYTHON
class MatPythonProtocol:

def mult(self, A: Mat, x: Vec, y: Vec) -> None:
"""Matrix vector multiplication: y = A @ x."""
...
def multAdd(self, A: Mat, x: Vec, y: Vec, z: Vec) -> None:
"""Matrix vector multiplication: z = A @ x + y."""
...
def multTranspose(self, A: Mat, x: Vec, y: Vec) -> None:
"""Transposed matrix vector multiplication: y = A^T @ x."""
...
def multTransposeAdd(self, A: Mat, x: Vec, y: Vec, z: Vec) -> None:
"""Transposed matrix vector multiplication: z = A^T @ x + y."""
...
def multHermitian(self, A: Mat, x: Vec, y: Vec) -> None:
"""Hermitian matrix vector multiplication: y = A^H @ x."""
...
def multHermitianAdd(self, A: Mat, x: Vec, y: Vec, z: Vec) -> None:
"""Hermitian matrix vector multiplication: z = A^H @ x + y."""
...
def view(self, A: Mat, viewer: Viewer) -> None:
"""View the matrix."""
...
def setFromOptions(self, A: Mat) -> None:
"""Process command line for customization."""
...
def multDiagonalBlock(self, A: Mat, x: Vec, y: Vec) -> None:
"""Perform the on-process matrix vector multiplication."""
...
def createVecs(self, A: Mat) -> tuple[Vec, Vec]:
"""Return tuple of vectors (x,y) suitable for A @ x = y."""
...
def scale(self, A: Mat, s: Scalar) -> None:
"""Scale the matrix by a scalar."""
...
def shift(self, A: Mat, s: Scalar) -> None:
"""Shift the matrix by a scalar."""
...
def createSubMatrix(self, A: Mat, r: IS, c: IS, out: Mat) -> Mat:
"""Return the submatrix corresponding to r rows and c columns.
Matrix out must be reused if not None.
"""
...
def zeroRowsColumns(self, A: Mat, r: IS, diag: Scalar, x: Vec, b: Vec) -> None:
"""Zero rows and columns of the matrix corresponding to the index set r.
Insert diag on the diagonal and modify vectors x and b accordingly if not None.
"""
...
def getDiagonal(self, A: Mat, d: Vec) -> None:
"""Compute the diagonal of the matrix: d = diag(A)."""
...
def setDiagonal(self, A: Mat, d: Vec, im: InsertMode) -> None:
"""Set the diagonal of the matrix."""
...
def missingDiagonal(self, A: Mat, d: Vec, im: InsertMode) -> tuple[bool, int]:
"""Return a flag indicating if the matrix is missing a diagonal entry and the location."""
...
def diagonalScale(self, A: Mat, L: Vec, R: Vec) -> None:
"""Perform left and right diagonal scaling if vectors are not None.
A = diag(L)@A@diag(R).
"""
...
def getDiagonalBlock(self, A: Mat) -> Mat:
"""Return the on-process matrix."""
...
def setUp(self, A: Mat) -> None:
"""Perform the required setup."""
...
def duplicate(self, A: Mat, op: Mat.DuplicateOption) -> Mat:
"""Duplicate the matrix."""
...
def copy(self, A: Mat, B: Mat, op: Mat.Structure) -> None:
"""Copy the matrix: B = A."""
...
def productSetFromOptions(self, A: Mat, prodtype: str, X: Mat, Y: Mat, Z: Mat) -> bool:
"""The boolean flag indicating if the matrix supports prodtype."""
...
def productSymbolic(self, A: Mat, product: Mat, producttype: str, X: Mat, Y: Mat, Z: Mat) -> None:
"""Perform the symbolic stage of the requested matrix product."""
...
def productNumeric(self, A: Mat, product: Mat, producttype: str, X: Mat, Y: Mat, Z: Mat) -> None:
"""Perform the numeric stage of the requested matrix product."""
...
def zeroEntries(self, A: Mat) -> None:
"""Set the matrix to zero."""
...
def norm(self, A: Mat, normtype: NormType) -> float:
"""Compute the norm of the matrix."""
...
def solve(self, A: Mat, y: Vec, x: Vec) -> None:
"""Solve the equation: x = inv(A) y."""
...
def solveAdd(self, A: Mat, y: Vec, z: Vec, x: Vec) -> None:
"""Solve the equation: x = inv(A) y + z."""
...
def solveTranspose(self, A: Mat, y: Vec, x: Vec) -> None:
"""Solve the equation: x = inv(A)^T y."""
...
def solveTransposeAdd(self, A: Mat, y: Vec, z: Vec, x: Vec) -> None:
"""Solve the equation: x = inv(A)^T y + z."""
...
def SOR(self, A: Mat, b: Vec, omega: float, sortype: Mat.SORType,
shift: float, its: int, lits: int, x: Vec) -> None:
"""Perform SOR iterations."""
...
def conjugate(self, A: Mat) -> None:
"""Perform the conjugation of the matrix: A = conj(A)."""
...
def imagPart(self, A: Mat) -> None:
"""Set real part to zero. A = imag(A)."""
...
def realPart(self, A: sMat) -> None:
"""Set imaginary part to zero. A = real(A)."""
...


In the example below, we create an operator that applies the Laplacian operator on a two-dimensional grid, and use it to solve the associated linear system. The default preconditioner in the script is petsc4py.PETSc.PC.Type.JACOBI which needs to access the diagonal of the matrix.

# ------------------------------------------------------------------------
#
#  Poisson problem. This problem is modeled by the partial
#  differential equation
#
#          -Laplacian(u) = 1,  0 < x,y < 1,
#
#  with boundary conditions
#
#           u = 0  for  x = 0, x = 1, y = 0, y = 1
#
#  A finite difference approximation with the usual 7-point stencil
#  is used to discretize the boundary value problem to obtain a
#  nonlinear system of equations. The problem is solved in a 2D
#  rectangular domain, using distributed arrays (DAs) to partition
#  the parallel grid.
#
# ------------------------------------------------------------------------
# We first import petsc4py and sys to initialize PETSc
import sys, petsc4py
petsc4py.init(sys.argv)
# Import the PETSc module
from petsc4py import PETSc
# Here we define a class representing the discretized operator
# This allows us to apply the operator "matrix-free"
class Poisson2D:

def __init__(self, da):
assert da.getDim() == 2
self.da = da
self.localX = da.createLocalVec()
# This is the method that PETSc will look for when applying
# the operator. `X` is the PETSc input vector, `Y` the output vector,
# while `mat` is the PETSc matrix holding the PETSc datastructures.
def mult(self, mat, X, Y):
# Grid sizes
mx, my = self.da.getSizes()
hx, hy = [1.0/m for m in [mx, my]]
# Bounds for the local part of the grid this process owns
(xs, xe), (ys, ye) = self.da.getRanges()
# Map global vector to local vectors
self.da.globalToLocal(X, self.localX)
# We can access the vector data as NumPy arrays
x = self.da.getVecArray(self.localX)
y = self.da.getVecArray(Y)
# Loop on the local grid and compute the local action of the operator
for j in range(ys, ye):
for i in range(xs, xe):
u = x[i, j] # center
u_e = u_w = u_n = u_s = 0
if i > 0: u_w = x[i-1, j] # west
if i < mx-1: u_e = x[i+1, j] # east
if j > 0: u_s = x[i, j-1] # south
if j < ny-1: u_n = x[i, j+1] # north
u_xx = (-u_e + 2*u - u_w)*hy/hx
u_yy = (-u_n + 2*u - u_s)*hx/hy
y[i, j] = u_xx + u_yy
# This is the method that PETSc will look for when the diagonal of the matrix is needed.
def getDiagonal(self, mat, D):
mx, my = self.da.getSizes()
hx, hy = [1.0/m for m in [mx, my]]
(xs, xe), (ys, ye) = self.da.getRanges()
d = self.da.getVecArray(D)
# Loop on the local grid and compute the diagonal
for j in range(ys, ye):
for i in range(xs, xe):
d[i, j] = 2*hy/hx + 2*hx/hy
# The class can contain other methods that PETSc won't use
def formRHS(self, B):
b = self.da.getVecArray(B)
mx, my = self.da.getSizes()
hx, hy = [1.0/m for m in [mx, my]]
(xs, xe), (ys, ye) = self.da.getRanges()
for j in range(ys, ye):
for i in range(xs, xe):
b[i, j] = 1*hx*hy # Access the option database and read options from the command line OptDB = PETSc.Options() n = OptDB.getInt('n', 16) # Read `-n <int>`, defaults to 16 nx = OptDB.getInt('nx', n) ny = OptDB.getInt('ny', n) # Create the distributed memory implementation for structured grid da = PETSc.DMDA().create([nx, ny], stencil_width=1) # Create vectors to hold the solution and the right-hand side x = da.createGlobalVec() b = da.createGlobalVec() # Instantiate an object of our Poisson2D class pde = Poisson2D(da) # Create a PETSc matrix of type Python using `pde` as context A = PETSc.Mat().create(comm=da.comm) A.setSizes([x.getSizes(), b.getSizes()]) A.setType(PETSc.Mat.Type.PYTHON) A.setPythonContext(pde) A.setUp() # Create a Conjugate Gradient Krylov solver ksp = PETSc.KSP().create() ksp.setType(PETSc.KSP.Type.CG) # Use diagonal preconditioning ksp.getPC().setType(PETSc.PC.Type.JACOBI) # Allow command-line customization ksp.setFromOptions() # Assemble right-hand side and solve the linear system pde.formRHS(b) ksp.setOperators(A) ksp.solve(b, x) # Here we programmatically visualize the solution if OptDB.getBool('plot', True):
# Modify the option database: keep the X window open for 1 second
OptDB['draw_pause'] = 1
# Obtain a viewer of type DRAW
draw = PETSc.Viewer.DRAW(x.comm)
# View the vector in the X window
draw(x) # We can also visualize the solution by command line options # For example, we can dump a VTK file with: # # $ python poisson2d.py -plot 0 -view_solution vtk:sol.vts: # # or obtain the same visualization as programmatically done above as: # # $ python poisson2d.py -plot 0 -view_solution draw -draw_pause 1 # x.viewFromOptions('-view_solution')


PETSc Python preconditioner type

The protocol for the petsc4py.PETSc.PC.Type.PYTHON preconditioner is:

from petsc4py.PETSc import KSP
from petsc4py.PETSc import PC
from petsc4py.PETSc import Mat
from petsc4py.PETSc import Vec
from petsc4py.PETSc import Viewer
# A template class with the Python methods supported by PCPYTHON
class PCPythonProtocol:

def apply(self, pc: PC, b: Vec, x: Vec) -> None:
"""Apply the preconditioner on vector b, return in x."""
...
def applySymmetricLeft(self, pc: PC, b: Vec, x: Vec) -> None:
"""Apply the symmetric left part of the preconditioner on vector b, return in x."""
...
def applySymmetricRight(self, pc: PC, b: Vec, x: Vec) -> None:
"""Apply the symmetric right part of the preconditioner on vector b, return in x."""
...
def applyTranspose(self, pc: PC, b: Vec, x: Vec) -> None:
"""Apply the transposed preconditioner on vector b, return in x."""
...
def applyMat(self, pc: PC, B: Mat, X: Mat) -> None:
"""Apply the preconditioner on a block of right-hand sides B, return in X."""
...
def preSolve(self, pc: PC, ksp: KSP, b: Vec, x: Vec) -> None:
"""Callback called at the beginning of a Krylov method.
This method is allowed to modify the right-hand side b and the initial guess x.
"""
...
def postSolve(self, pc: PC, ksp: KSP, b: Vec, x: Vec) -> None:
"""Callback called at the end of a Krylov method.
This method is allowed to modify the right-hand side b and the solution x.
"""
def view(self, pc: PC, viewer: Viewer) -> None:
"""View the preconditioner."""
...
def setFromOptions(self, pc: PC) -> None:
"""Process command line for customization."""
...
def setUp(self, pc: PC) -> None:
"""Perform the required setup."""
...
def reset(self, pc: PC) -> None:
"""Reset the preconditioner."""
...


In the example below, we create a Jacobi preconditioner, which needs to access the diagonal of the matrix. The action of the preconditioner consists of the pointwise multiplication of the inverse diagonal with the input vector.

# The user-defined Python class implementing the Jacobi method.
class myJacobi:

# Setup the internal data. In this case, we access the matrix diagonal.
def setUp(self, pc):
_, P = pc.getOperators()
self.D = P.getDiagonal()
# Apply the preconditioner
def apply(self, pc, x, y):
y.pointwiseDivide(x, self.D)


We can run the script used to test our matrix class and use command line arguments to specify that our preconditioner should be used:

$ python mat.py -pc_type python -pc_python_type pc.myJacobi -ksp_view
KSP Object: 1 MPI process

type: cg
maximum iterations=10000, initial guess is zero
tolerances: relative=1e-05, absolute=1e-50, divergence=10000.
left preconditioning
using PRECONDITIONED norm type for convergence test PC Object: 1 MPI process
type: python
Python: pc.myJacobi
linear system matrix = precond matrix:
Mat Object: 1 MPI process
type: python
rows=256, cols=256
Python: __main__.Poisson2D


PETSc Python linear solver type

The protocol for the petsc4py.PETSc.KSP.Type.PYTHON Krylov solver is:

from petsc4py.PETSc import KSP
from petsc4py.PETSc import Mat
from petsc4py.PETSc import Vec
from petsc4py.PETSc import Viewer
# A template class with the Python methods supported by KSPPYTHON
class KSPPythonProtocol:

def solve(self, ksp: KSP, b: Vec, x: Vec) -> None:
"""Solve the linear system with right-hand side b. Return solution in x."""
...
def solveTranspose(self, ksp: KSP, b: Vec, x: Vec) -> None:
"""Solve the transposed linear system with right-hand side b. Return solution in x."""
...
def view(self, ksp: KSP, viewer: Viewer) -> None:
"""View the Krylov solver."""
...
def setFromOptions(self, ksp: KSP) -> None:
"""Process command line for customization."""
...
def setUp(self, ksp: KSP) -> None:
"""Perform the required setup."""
...
def buildSolution(self, ksp: KSP, x: Vec) -> None:
"""Compute the solution vector."""
...
def buildResidual(self, ksp: KSP, t: Vec, r: Vec) -> None:
"""Compute the residual vector, return it in r. t is a scratch working vector."""
...
def reset(self, ksp: KSP) -> None:
"""Reset the Krylov solver."""
...


PETSc Python nonlinear solver type (TODO)

PETSc Python ode-integrator type (TODO)

PETSc Python optimization solver type (TODO)

WORKING WITH PETSC OPTIONS (TODO)

PETSC4PY DEMOS

DOCUMENTATION STANDARDS FOR PETSC4PY

Subject to exceptions given below, new contributions to PETSc4py must include type annotations for function parameters and results, and docstrings on every class, function and method.

The documentation should be consistent with the corresponding C API documentation, including copying text where this is appropriate. More in-depth documentation from the C API (such as extended discussions of algorithmic or performance factors) should not be copied.

Docstring standards

Docstrings are to be written in Style guide format.

The first line of a function or method docstring must be a short description of the method in imperative mood ("Return the norm of the matrix.") "Return" is to be preferred over "Get" in this sentence. A blank line must follow this description. Use one-liner descriptions for properties.

If the corresponding C API documentation lists a function as being collective, then this information must be repeated on the next line of the docstring. Valid strings are: "Not collective.", "Logically collective.", "Collective.", or "Neighborwise collective.".

The initial description section can contain more information if this is useful. In particular, if there is a PETSc manual chapter about a class, then this should be referred to from here.

Use double backticks around literals (like strings and numbers). E.g. ``2``, ``"foo"``.

Reference PETSc functions simply using backticks. eg: petsc.KSP. refers to the PETSc C documentation for KSP. Do not use URLs in docstrings. Always use Intersphinx references.

The following sections describe the use of numpydoc sections. Other sections allowed by numpydoc may be included if they are useful.

Parameters

This is required unless there are no parameters, or it will be completely obvious to even a novice user what the parameters do.

Types should only be specified in this section if for some reason the types provided by typing prove to be inadequate. If no type is being specified, do not include a colon (:) to the right of the parameter name.

Use Sys.getDefaultComm when specifying the default communicator.

Returns

This should only be specified if the return value is not obvious from the initial description and typing.

If a "Returns" section is required, the type of the returned items must be specified, even if this duplicates typing information.

See Also

If any of the following apply, then this section is required. The order of entries is as follows. Other links are permitted in this section if they add information useful to users.

Every setFromOptions must include the link `petsc_options`.

Any closely related part of the PETSc4py API not already linked in the docstring should appear (e.g. setters and getters should cross-refer).

If there is a corresponding C API documentation page, this must be linked from the "See also" section. E.g. `petsc.MatSetValues`.

End docstring with an empty line - "closing three quotation marks must be on a line by itself, preferably preceded by a blank line"

WARNING:

The docstrings must not cause Sphinx warnings.


Type hint standards

If returning self, use -> Self in function signature.

Type hints are not required when the static type signature includes a PETSc type (e.g. Vec x). These will be automatically generated. This will also work for = None. When using type hints, use spacing around the equals in any = None.

Communicators in type signatures must use Python typing instead of c-typing (i.e. comm: Comm not Comm comm). This is because communicators can come from mpi4py and not just the petsc4py.PETSc.Comm class.

For petsc4py native types that are can be strings, the type is argument: KSP.Type | str (not eg: KSPType argument). If the type is strictly an enum the | str can be omitted. Full signature example:

def setType(self, ksp_type: KSP.Type | str) -> None:


If a NumPy is returned, use ArrayInt/ArrayReal/ArrayScalar as the return type.

AUTHOR

Lisandro Dalcin

COPYRIGHT

2024, Lisandro Dalcin

March 14, 2024 3.20