Allows the user to override a particular vector operation.


#include "petscvec.h"   
PetscErrorCode VecSetOperation(Vec vec, VecOperation op, void (*f)(void))

Logically Collective; No Fortran Support

Input Parameters#

  • vec - The vector to modify

  • op - The name of the operation

  • f - The function that provides the operation.


f may be NULL to remove the operation from vec. Depending on the operation this may be allowed, however some always expect a valid function. In these cases an error will be raised when calling the interface routine in question.

See VecOperation for an up-to-date list of override-able operations. The operations listed there have the form VECOP_<OPERATION>, where <OPERATION> is the suffix (in all capital letters) of the public interface routine (e.g., VecView() -> VECOP_VIEW).

Overriding a particular Vec’s operation has no affect on any other Vecs past, present, or future. The user should also note that overriding a method is “destructive”; the previous method is not retained in any way.

Example Usage#

  // some new VecView() implementation, must have the same signature as the function it seeks
  // to replace
  PetscErrorCode UserVecView(Vec x, PetscViewer viewer)
    // ...

  // Create a VECMPI which has a pre-defined VecView() implementation
  VecCreateMPI(comm, n, N, &x);
  // Calls the VECMPI implementation for VecView()
  VecView(x, viewer);

  VecSetOperation(x, VECOP_VIEW, (void (*)(void))UserVecView);
  // Now calls UserVecView()
  VecView(x, viewer);

See Also#

Vectors and Parallel Data, Vec, VecCreate(), MatShellSetOperation()





Index of all Vec routines
Table of Contents for all manual pages
Index of all manual pages