petsc4py.PETSc.Scatter
- class petsc4py.PETSc.Scatter
Bases:
Object
Scatter object.
The object used to perform data movement between vectors. Scatter is described in the
PETSc manual
.Enumerations
Scatter mode.
Scatter type.
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.
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(vec_from, vec_to, addv=None, mode=None)
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, seescatter
.Source code at petsc4py/PETSc/Scatter.pyx:263
- Parameters:
vec_from (Vec) –
vec_to (Vec) –
addv (InsertModeSpec) –
mode (ScatterModeSpec) –
- Return type:
- copy()
Return a copy of the scatter.
Source code at petsc4py/PETSc/Scatter.pyx:200
- Return type:
- create(vec_from, is_from, vec_to, is_to)
Create a scatter object.
Collective.
- Parameters:
- Return type:
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
- destroy()
Destroy the scatter.
Collective.
See also
petsc.VecScatterDestroy
Source code at petsc4py/PETSc/Scatter.pyx:77
- Return type:
- end(vec_from, vec_to, addv=None, mode=None)
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, seescatter
.Source code at petsc4py/PETSc/Scatter.pyx:287
- Parameters:
vec_from (Vec) –
vec_to (Vec) –
addv (InsertModeSpec) –
mode (ScatterModeSpec) –
- Return type:
- getType()
Return the type of the scatter.
Not collective.
See also
setType
,petsc.VecScatterGetType
Source code at petsc4py/PETSc/Scatter.pyx:161
- Return type:
- scatter(vec_from, vec_to, addv=None, mode=None)
Perform a generalized scatter from one vector into another.
Collective.
- Parameters:
vec_from (Vec) – The source vector.
vec_to (Vec) – The destination vector.
addv (InsertModeSpec) – Insertion mode.
mode (ScatterModeSpec) – Scatter mode.
- Return type:
- setFromOptions()
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
- Return type:
- setType(scatter_type)
Set the type of the scatter.
Logically collective.
See also
getType
,petsc.VecScatterSetType
- setUp()
Set up the internal data structures for using the scatter.
Collective.
See also
petsc.VecScatterSetUp
Source code at petsc4py/PETSc/Scatter.pyx:187
- Return type:
- classmethod toAll(vec)
Create a scatter that communicates a vector to all sharing processes.
Collective.
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
- classmethod toZero(vec)
Create a scatter that communicates a vector to rank zero.
Collective.
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