libMesh
Classes | Namespaces | Functions
petsc_linear_solver.h File Reference

Go to the source code of this file.

Classes

class  libMesh::PetscMatrix< T >
 
class  libMesh::PetscLinearSolver< T >
 This class provides an interface to PETSc iterative solvers that is compatible with the libMesh LinearSolver<> More...
 

Namespaces

 libMesh
 The libMesh namespace provides an interface to certain functionality in the library.
 

Functions

PetscErrorCode __libmesh_petsc_preconditioner_setup (void *ctx)
 This function is called by PETSc to initialize the preconditioner. More...
 
PetscErrorCode __libmesh_petsc_preconditioner_apply (void *ctx, Vec x, Vec y)
 This function is called by PETSc to actually apply the preconditioner. More...
 
PetscErrorCode __libmesh_petsc_preconditioner_setup (PC)
 
PetscErrorCode __libmesh_petsc_preconditioner_apply (PC, Vec x, Vec y)
 

Function Documentation

PetscErrorCode __libmesh_petsc_preconditioner_apply ( void *  ctx,
Vec  x,
Vec  y 
)

This function is called by PETSc to actually apply the preconditioner.

ctx will hold the Preconditioner.

Definition at line 58 of file petsc_linear_solver.C.

References libMesh::Preconditioner< T >::apply(), libMesh::ParallelObject::comm(), and libMesh::ctx.

Referenced by libMesh::PetscNonlinearSolver< T >::init(), and libMesh::PetscLinearSolver< T >::init().

59  {
60  Preconditioner<Number> * preconditioner = static_cast<Preconditioner<Number> *>(ctx);
61 
62  PetscVector<Number> x_vec(x, preconditioner->comm());
63  PetscVector<Number> y_vec(y, preconditioner->comm());
64 
65  preconditioner->apply(x_vec,y_vec);
66 
67  return 0;
68  }
PetscErrorCode Vec x
PetscErrorCode Vec Mat Mat void * ctx
PetscErrorCode __libmesh_petsc_preconditioner_apply ( PC  ,
Vec  x,
Vec  y 
)

Definition at line 84 of file petsc_linear_solver.C.

References libMesh::Preconditioner< T >::apply(), CHKERRQ(), libMesh::ParallelObject::comm(), libMesh::ctx, and ierr.

85  {
86  void * ctx;
87  PetscErrorCode ierr = PCShellGetContext(pc,&ctx);CHKERRQ(ierr);
88  Preconditioner<Number> * preconditioner = static_cast<Preconditioner<Number> *>(ctx);
89 
90  PetscVector<Number> x_vec(x, preconditioner->comm());
91  PetscVector<Number> y_vec(y, preconditioner->comm());
92 
93  preconditioner->apply(x_vec,y_vec);
94 
95  return 0;
96  }
PetscErrorCode Vec Mat Mat pc
PetscErrorCode Vec x
PetscErrorCode Vec Mat Mat void * ctx
PetscErrorCode ierr
CHKERRQ(ierr)
PetscErrorCode __libmesh_petsc_preconditioner_setup ( void *  ctx)

This function is called by PETSc to initialize the preconditioner.

ctx will hold the Preconditioner.

Definition at line 45 of file petsc_linear_solver.C.

References libMesh::ctx, libMesh::Preconditioner< T >::initialized(), and libMesh::Preconditioner< T >::setup().

Referenced by libMesh::PetscNonlinearSolver< T >::init(), and libMesh::PetscLinearSolver< T >::init().

46  {
47  Preconditioner<Number> * preconditioner = static_cast<Preconditioner<Number> *>(ctx);
48 
49  if (!preconditioner->initialized())
50  libmesh_error_msg("Preconditioner not initialized! Make sure you call init() before solve!");
51 
52  preconditioner->setup();
53 
54  return 0;
55  }
PetscErrorCode Vec Mat Mat void * ctx
PetscErrorCode __libmesh_petsc_preconditioner_setup ( PC  )

Definition at line 70 of file petsc_linear_solver.C.

References CHKERRQ(), libMesh::ctx, ierr, libMesh::Preconditioner< T >::initialized(), and libMesh::Preconditioner< T >::setup().

71  {
72  void * ctx;
73  PetscErrorCode ierr = PCShellGetContext(pc,&ctx);CHKERRQ(ierr);
74  Preconditioner<Number> * preconditioner = static_cast<Preconditioner<Number> *>(ctx);
75 
76  if (!preconditioner->initialized())
77  libmesh_error_msg("Preconditioner not initialized! Make sure you call init() before solve!");
78 
79  preconditioner->setup();
80 
81  return 0;
82  }
PetscErrorCode Vec Mat Mat pc
PetscErrorCode Vec Mat Mat void * ctx
PetscErrorCode ierr
CHKERRQ(ierr)