petsc_linear_solver.h File Reference

Go to the source code of this file.

Classes

class  libMesh::PetscMatrix< T >
 SparseMatrix interface to PETSc Mat. More...
 
class  libMesh::PetscLinearSolver< T >
 

Namespaces

 libMesh
 

Functions

PetscErrorCode libmesh_petsc_preconditioner_setup (void *ctx)
 
PetscErrorCode libmesh_petsc_preconditioner_apply (void *ctx, Vec x, Vec y)
 
PetscErrorCode libmesh_petsc_preconditioner_setup (PC)
 
PetscErrorCode libmesh_petsc_preconditioner_apply (PC, Vec x, Vec y)
 
PetscErrorCode __libmesh_petsc_preconditioner_setup (void *ctx)
 
PetscErrorCode __libmesh_petsc_preconditioner_apply (void *ctx, Vec x, Vec y)
 
PetscErrorCode __libmesh_petsc_preconditioner_setup (PC)
 
PetscErrorCode __libmesh_petsc_preconditioner_apply (PC, Vec x, Vec y)
 

Function Documentation

◆ __libmesh_petsc_preconditioner_apply() [1/2]

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 110 of file petsc_linear_solver.C.

References libMesh::libmesh_petsc_preconditioner_apply().

111  {
112  libmesh_deprecated();
113  return libmesh_petsc_preconditioner_apply(ctx, x, y);
114  }
PetscErrorCode libmesh_petsc_preconditioner_apply(PC pc, Vec x, Vec y)

◆ __libmesh_petsc_preconditioner_apply() [2/2]

PetscErrorCode __libmesh_petsc_preconditioner_apply ( PC  ,
Vec  x,
Vec  y 
)

Definition at line 123 of file petsc_linear_solver.C.

References libMesh::libmesh_petsc_preconditioner_apply().

124  {
125  libmesh_deprecated();
126  return libmesh_petsc_preconditioner_apply(pc, x, y);
127  }
PetscErrorCode libmesh_petsc_preconditioner_apply(PC pc, Vec x, Vec y)

◆ __libmesh_petsc_preconditioner_setup() [1/2]

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 104 of file petsc_linear_solver.C.

References libMesh::libmesh_petsc_preconditioner_setup().

105  {
106  libmesh_deprecated();
108  }
PetscErrorCode libmesh_petsc_preconditioner_setup(PC pc)

◆ __libmesh_petsc_preconditioner_setup() [2/2]

PetscErrorCode __libmesh_petsc_preconditioner_setup ( PC  )

Definition at line 117 of file petsc_linear_solver.C.

References libMesh::libmesh_petsc_preconditioner_setup().

118  {
119  libmesh_deprecated();
121  }
PetscErrorCode libmesh_petsc_preconditioner_setup(PC pc)

◆ libmesh_petsc_preconditioner_apply() [1/2]

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 61 of file petsc_linear_solver.C.

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

62  {
63  Preconditioner<Number> * preconditioner = static_cast<Preconditioner<Number> *>(ctx);
64 
65  PetscVector<Number> x_vec(x, preconditioner->comm());
66  PetscVector<Number> y_vec(y, preconditioner->comm());
67 
68  preconditioner->apply(x_vec,y_vec);
69 
70  return 0;
71  }

◆ libmesh_petsc_preconditioner_apply() [2/2]

PetscErrorCode libmesh_petsc_preconditioner_apply ( PC  ,
Vec  x,
Vec  y 
)

Definition at line 87 of file petsc_linear_solver.C.

References CHKERRQ(), and ierr.

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

◆ libmesh_petsc_preconditioner_setup() [1/2]

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 48 of file petsc_linear_solver.C.

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

49  {
50  Preconditioner<Number> * preconditioner = static_cast<Preconditioner<Number> *>(ctx);
51 
52  if (!preconditioner->initialized())
53  libmesh_error_msg("Preconditioner not initialized! Make sure you call init() before solve!");
54 
55  preconditioner->setup();
56 
57  return 0;
58  }

◆ libmesh_petsc_preconditioner_setup() [2/2]

PetscErrorCode libmesh_petsc_preconditioner_setup ( PC  )

Definition at line 73 of file petsc_linear_solver.C.

References CHKERRQ(), and ierr.

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