Skip to content

Commit 3f9bb5f

Browse files
committed
Deprecate dunder methods.
1 parent 09586d6 commit 3f9bb5f

File tree

4 files changed

+188
-51
lines changed

4 files changed

+188
-51
lines changed

include/solvers/petsc_linear_solver.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@
4545
// Give them an obscure name to avoid namespace pollution.
4646
extern "C"
4747
{
48+
#if PETSC_RELEASE_LESS_THAN(3,0,1)
49+
/**
50+
* This function is called by PETSc to initialize the preconditioner.
51+
* ctx will hold the Preconditioner.
52+
*/
53+
PetscErrorCode libmesh_petsc_preconditioner_setup (void * ctx);
54+
55+
/**
56+
* This function is called by PETSc to actually apply the preconditioner.
57+
* ctx will hold the Preconditioner.
58+
*/
59+
PetscErrorCode libmesh_petsc_preconditioner_apply(void * ctx, Vec x, Vec y);
60+
#else
61+
PetscErrorCode libmesh_petsc_preconditioner_setup (PC);
62+
PetscErrorCode libmesh_petsc_preconditioner_apply(PC, Vec x, Vec y);
63+
#endif
64+
65+
#if LIBMESH_ENABLE_DEPRECATED
4866
#if PETSC_RELEASE_LESS_THAN(3,0,1)
4967
/**
5068
* This function is called by PETSc to initialize the preconditioner.
@@ -61,6 +79,7 @@ extern "C"
6179
PetscErrorCode __libmesh_petsc_preconditioner_setup (PC);
6280
PetscErrorCode __libmesh_petsc_preconditioner_apply(PC, Vec x, Vec y);
6381
#endif
82+
#endif
6483
} // end extern "C"
6584

6685

include/solvers/petsc_nonlinear_solver.h

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,31 @@ class ResidualContext;
4040
// need access to these most of the time as they are used internally by this object.
4141
extern "C"
4242
{
43+
PetscErrorCode libmesh_petsc_snes_monitor (SNES, PetscInt its, PetscReal fnorm, void *);
44+
PetscErrorCode libmesh_petsc_snes_residual (SNES, Vec x, Vec r, void * ctx);
45+
PetscErrorCode libmesh_petsc_snes_fd_residual (SNES, Vec x, Vec r, void * ctx);
46+
PetscErrorCode libmesh_petsc_snes_mffd_residual (SNES snes, Vec x, Vec r, void * ctx);
47+
PetscErrorCode libmesh_petsc_snes_mffd_interface (void * ctx, Vec x, Vec r);
48+
#if PETSC_RELEASE_LESS_THAN(3,5,0)
49+
PetscErrorCode libmesh_petsc_snes_jacobian (SNES, Vec x, Mat * jac, Mat * pc, MatStructure * msflag, void * ctx);
50+
#else
51+
PetscErrorCode libmesh_petsc_snes_jacobian (SNES, Vec x, Mat jac, Mat pc, void * ctx);
52+
#endif
53+
54+
PetscErrorCode libmesh_petsc_snes_postcheck(
55+
#if PETSC_VERSION_LESS_THAN(3,3,0)
56+
SNES, Vec x, Vec y, Vec w, void * context, PetscBool * changed_y, PetscBool * changed_w
57+
#else
58+
SNESLineSearch, Vec x, Vec y, Vec w, PetscBool * changed_y, PetscBool * changed_w, void * context
59+
#endif
60+
);
61+
PetscErrorCode libmesh_petsc_linesearch_shellfunc(SNESLineSearch linesearch, void * ctx);
62+
63+
#ifdef LIBMESH_ENABLE_DEPRECATED
4364
PetscErrorCode __libmesh_petsc_snes_monitor (SNES, PetscInt its, PetscReal fnorm, void *);
4465
PetscErrorCode __libmesh_petsc_snes_residual (SNES, Vec x, Vec r, void * ctx);
4566
PetscErrorCode __libmesh_petsc_snes_fd_residual (SNES, Vec x, Vec r, void * ctx);
4667
PetscErrorCode __libmesh_petsc_snes_mffd_interface (void * ctx, Vec x, Vec r);
47-
PetscErrorCode __libmesh_petsc_snes_mffd_residual (SNES, Vec x, Vec r, void * ctx);
4868
#if PETSC_RELEASE_LESS_THAN(3,5,0)
4969
PetscErrorCode __libmesh_petsc_snes_jacobian (SNES, Vec x, Mat * jac, Mat * pc, MatStructure * msflag, void * ctx);
5070
#else
@@ -58,7 +78,7 @@ extern "C"
5878
SNESLineSearch, Vec x, Vec y, Vec w, PetscBool * changed_y, PetscBool * changed_w, void * context
5979
#endif
6080
);
61-
PetscErrorCode libmesh_petsc_linesearch_shellfunc(SNESLineSearch linesearch, void * ctx);
81+
#endif
6282
}
6383

6484
/**
@@ -226,14 +246,13 @@ class PetscNonlinearSolver : public NonlinearSolver<T>
226246
#endif
227247
private:
228248
friend ResidualContext libmesh_petsc_snes_residual_helper (SNES snes, Vec x, void * ctx);
229-
friend PetscErrorCode __libmesh_petsc_snes_residual (SNES snes, Vec x, Vec r, void * ctx);
230-
friend PetscErrorCode __libmesh_petsc_snes_fd_residual (SNES snes, Vec x, Vec r, void * ctx);
231-
friend PetscErrorCode __libmesh_petsc_snes_mffd_interface (void * ctx, Vec x, Vec r);
232-
friend PetscErrorCode __libmesh_petsc_snes_mffd_residual (SNES snes, Vec x, Vec r, void * ctx);
249+
friend PetscErrorCode libmesh_petsc_snes_residual (SNES snes, Vec x, Vec r, void * ctx);
250+
friend PetscErrorCode libmesh_petsc_snes_fd_residual (SNES snes, Vec x, Vec r, void * ctx);
251+
friend PetscErrorCode libmesh_petsc_snes_mffd_residual (SNES snes, Vec x, Vec r, void * ctx);
233252
#if PETSC_RELEASE_LESS_THAN(3,5,0)
234-
friend PetscErrorCode __libmesh_petsc_snes_jacobian (SNES snes, Vec x, Mat * jac, Mat * pc, MatStructure * msflag, void * ctx);
253+
friend PetscErrorCode libmesh_petsc_snes_jacobian (SNES snes, Vec x, Mat * jac, Mat * pc, MatStructure * msflag, void * ctx);
235254
#else
236-
friend PetscErrorCode __libmesh_petsc_snes_jacobian (SNES snes, Vec x, Mat jac, Mat pc, void * ctx);
255+
friend PetscErrorCode libmesh_petsc_snes_jacobian (SNES snes, Vec x, Mat jac, Mat pc, void * ctx);
237256
#endif
238257
};
239258

src/solvers/petsc_linear_solver.C

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace libMesh
4242
extern "C"
4343
{
4444
#if PETSC_RELEASE_LESS_THAN(3,0,1)
45-
PetscErrorCode __libmesh_petsc_preconditioner_setup (void * ctx)
45+
PetscErrorCode libmesh_petsc_preconditioner_setup (void * ctx)
4646
{
4747
Preconditioner<Number> * preconditioner = static_cast<Preconditioner<Number> *>(ctx);
4848

@@ -55,7 +55,7 @@ extern "C"
5555
}
5656

5757

58-
PetscErrorCode __libmesh_petsc_preconditioner_apply(void * ctx, Vec x, Vec y)
58+
PetscErrorCode libmesh_petsc_preconditioner_apply(void * ctx, Vec x, Vec y)
5959
{
6060
Preconditioner<Number> * preconditioner = static_cast<Preconditioner<Number> *>(ctx);
6161

@@ -67,7 +67,7 @@ extern "C"
6767
return 0;
6868
}
6969
#else
70-
PetscErrorCode __libmesh_petsc_preconditioner_setup (PC pc)
70+
PetscErrorCode libmesh_petsc_preconditioner_setup (PC pc)
7171
{
7272
void * ctx;
7373
PetscErrorCode ierr = PCShellGetContext(pc,&ctx);CHKERRQ(ierr);
@@ -81,7 +81,7 @@ extern "C"
8181
return 0;
8282
}
8383

84-
PetscErrorCode __libmesh_petsc_preconditioner_apply(PC pc, Vec x, Vec y)
84+
PetscErrorCode libmesh_petsc_preconditioner_apply(PC pc, Vec x, Vec y)
8585
{
8686
void * ctx;
8787
PetscErrorCode ierr = PCShellGetContext(pc,&ctx);CHKERRQ(ierr);
@@ -95,6 +95,35 @@ extern "C"
9595
return 0;
9696
}
9797
#endif
98+
99+
#ifdef LIBMESH_ENABLE_DEPRECATED
100+
#if PETSC_RELEASE_LESS_THAN(3,0,1)
101+
PetscErrorCode __libmesh_petsc_preconditioner_setup (void * ctx)
102+
{
103+
libmesh_deprecated();
104+
return libmesh_petsc_preconditioner_setup(ctx);
105+
}
106+
107+
PetscErrorCode __libmesh_petsc_preconditioner_apply(void * ctx, Vec x, Vec y)
108+
{
109+
libmesh_deprecated();
110+
return libmesh_petsc_preconditioner_apply(ctx, x, y);
111+
}
112+
113+
#else
114+
PetscErrorCode __libmesh_petsc_preconditioner_setup (PC pc)
115+
{
116+
libmesh_deprecated();
117+
return libmesh_petsc_preconditioner_setup(pc);
118+
}
119+
120+
PetscErrorCode __libmesh_petsc_preconditioner_apply(PC pc, Vec x, Vec y)
121+
{
122+
libmesh_deprecated();
123+
return libmesh_petsc_preconditioner_apply(pc, x, y);
124+
}
125+
#endif
126+
#endif
98127
} // end extern "C"
99128

100129
/*----------------------- functions ----------------------------------*/
@@ -227,8 +256,8 @@ void PetscLinearSolver<T>::init (const char * name)
227256
{
228257
this->_preconditioner->init();
229258
PCShellSetContext(_pc,(void *)this->_preconditioner);
230-
PCShellSetSetUp(_pc,__libmesh_petsc_preconditioner_setup);
231-
PCShellSetApply(_pc,__libmesh_petsc_preconditioner_apply);
259+
PCShellSetSetUp(_pc,libmesh_petsc_preconditioner_setup);
260+
PCShellSetApply(_pc,libmesh_petsc_preconditioner_apply);
232261
}
233262
}
234263
}
@@ -330,8 +359,8 @@ void PetscLinearSolver<T>::init (PetscMatrix<T> * matrix,
330359
this->_preconditioner->set_matrix(*matrix);
331360
this->_preconditioner->init();
332361
PCShellSetContext(_pc,(void *)this->_preconditioner);
333-
PCShellSetSetUp(_pc,__libmesh_petsc_preconditioner_setup);
334-
PCShellSetApply(_pc,__libmesh_petsc_preconditioner_apply);
362+
PCShellSetSetUp(_pc,libmesh_petsc_preconditioner_setup);
363+
PCShellSetApply(_pc,libmesh_petsc_preconditioner_apply);
335364
}
336365
}
337366
}

0 commit comments

Comments
 (0)