Vec Interface

Vec Interface

The purpose of the functions on this page is to provide a set of functions that are implemented efficiently for both AbstractVector and PetscVec. In some cases Base functions are extended with new methods for PetscVec, in other cases new functions are created and defined for both AbstractVector and PetscVec. Using these functions enables some amount of generic programming, particularly when an operation is applied to either the local portion of a parallel vector or when an operation is applied uniformly across all processors.

PETSc2.PetscVecMethod.

Create a PetscVec, setting both the type and the format. Users can specify either the local or global dimensions

source
PETSc2.PetscVecMethod.

Create a vector of a given size. Users can specify either the global dimension or the local dimension

source

PetscDestroy for AbstractVector. No-op

source
PETSc2.PetscViewFunction.

Print non-Petsc vector to a given IO (a Julia IO, not a Petsc IO). Defaults to printing to STDOUT.

Inputs

  • b: AbstractVector

  • f: IO, defaults to STDOUT

source

Calls VecAssemblyBegin. No-op for Julia vectors

Inputs

  • vec: AbstractVector

source

Calls VecAssemblyEnd. No-op for Julia vectors

Inputs

  • vec: AbstractVector

source

Add a given value to all elements of the vector

Inputs

  • A: AbstractVector

  • a: number to shift by

source
PETSc2.fill_zero!Method.

Fill a vector with zeros

Inputs

  • A: AbstractVector

source

Method for AbstractVector

source

Like set_values1! but for retrieving values. Note that Petsc only supports retrieving values from the local part of the vector

Inputs

  • vec: a vector, can be a julia vector or a Petsc vector.

Inputs/Outputs

  • idx: indices to retrieve

  • vals: array to put the values into

source

Length of global vector

Inputs

  • A: AbstractVector

source

Length of local part of vector

Inputs

  • A: AbstractVector

source

Returns a UnitRange containing the (1-based) global indices owned by this process.

Inputs

  • A: AbstractVector

Outputs

  • rng: UnitRange

source
PETSc2.set_values1!Function.

1-based indexing for both regular vectors and Petsc vector

Inputs

  • vals: values to add/insert into the vector, must be length(idx)

  • flag: INSERT_VALUES or ADD_VALUES

Inputs/Outputs

  • vec: the vector, can be a Petsc vector or a julia vector

  • idx: (global) indices to add/insert vals into

idx is listed as input/output because it may be modified during the function. It will be returned to its original values when the function exits. This is necessary to accomodate Petscs zero-based indexing interface

source

Method for AbstractVector

source
PETSc2.size_globalMethod.

Size of global vector

Inputs

  • A: AbstractVector

source
PETSc2.size_localMethod.

Size of local part of vector

Inputs

  • A: AbstractVector

source
Base.LinAlg.dotMethod.

Base.dot

Dot product where the first vector is conjugated. This is is the reverse of VecDot, where the second vector is conjugated

source
Base.LinAlg.normFunction.

Base.norm

source
Base.LinAlg.scale!Method.

Base.scale!

source
Base.copy!Method.

Base.copy!

source
Base.copyMethod.

Base.copy

source
Base.fill!Method.

Base.fill! for Petsc vectors

source
Base.maximumMethod.

Base.maximum

source
Base.minimumMethod.

Base.minimum

source
Base.sumMethod.

Base.sum

source