Commits

Lisandro Dalcin committed b2dc36f

Update after changes in petsc-dev to MatStructure

  • Participants
  • Parent commits 207c624

Comments (0)

Files changed (25)

File demo/AdaptiveL2Projection.c

  */
 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 #define SQ(A) (A)*(A)
 
 PetscScalar Function(PetscReal x, PetscReal y, PetscReal z)
 
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
 
 
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
   

File demo/AdvectionDiffusion.c

  */
 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 typedef struct {
   PetscReal wind[3];
 } AppCtx;
 
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
 

File demo/BoundaryIntegral.c

  */
 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 typedef struct {
   PetscInt axis;
   PetscInt side;
 
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
 

File demo/ClassicalShell.c

  */
 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 typedef struct {
   PetscReal nu,E,t,k;
 } AppCtx;
 
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
 

File demo/Elasticity3D.c

  */
 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 typedef struct {
   PetscReal lambda,mu;
 } AppCtx;
   // Solve
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
   

File demo/L2Proj1D.c

 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 PetscScalar Line(PetscReal x)
 {
   return x;
 
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
 

File demo/L2Proj2D.c

 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 PetscScalar Paraboloid(PetscReal x, PetscReal y)
 {
   return 1.0 - (x*x + y*y);
 
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
 

File demo/L2Projection.c

 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 PetscScalar Function(PetscReal x, PetscReal y, PetscReal z)
 {
   return (x-0.75)*x*(x+0.75) + (y-0.50)*y*(y+0.50) + (z-0.25)*z*(z+0.25);
 
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
 

File demo/Laplace.c

 
 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 PETSC_STATIC_INLINE
 PetscReal DOT(PetscInt dim,const PetscReal a[],const PetscReal b[])
 {
 
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
 

File demo/LoggChallenge.c

 */
 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 PetscReal Forcing(PetscReal x, PetscReal y)
 {
   PetscReal pi = M_PI;
 
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
 
   PetscLogDouble ts1,ts2,ts;

File demo/Neumann.c

 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 #define pi M_PI
 
 PetscReal Exact(PetscReal x[3])
   ierr = IGACreateVec(iga,&x);CHKERRQ(ierr);
   ierr = IGACreateVec(iga,&b);CHKERRQ(ierr);
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   if (!iga->collocation) {
     ierr = IGASetFormSystem(iga,SystemGalerkin,NULL);CHKERRQ(ierr);
     ierr = MatSetOption(A,MAT_SYMMETRIC,PETSC_TRUE);CHKERRQ(ierr);

File demo/Poisson.c

 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 PETSC_STATIC_INLINE
 PetscReal DOT(PetscInt dim,const PetscReal a[],const PetscReal b[])
 {
 
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
 

File demo/Poisson1D.c

  */
 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 #undef  __FUNCT__
 #define __FUNCT__ "System"
 PetscErrorCode System(IGAPoint p,PetscScalar *K,PetscScalar *F,void *ctx)
 
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
 

File demo/Poisson2D.c

 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 #undef  __FUNCT__
 #define __FUNCT__ "System"
 PetscErrorCode System(IGAPoint p,PetscScalar *K,PetscScalar *F,void *ctx)
   
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
 

File demo/Poisson3D.c

 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 #undef  __FUNCT__
 #define __FUNCT__ "System"
 PetscErrorCode System(IGAPoint p,PetscScalar *K,PetscScalar *F,void *ctx)
   
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
 

File demo/Richards.c

 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 #define SQ(A) ((A)*(A))
 
 typedef struct {
 
   KSP ksp;
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetType(ksp,KSPCG);CHKERRQ(ierr);
 
   ierr = KSPSetOptionsPrefix(ksp,"l2p_");CHKERRQ(ierr);

File include/petscts2.h

 #include <petscts.h>
 
 typedef PetscErrorCode (*TSIFunction2)(TS,PetscReal,Vec,Vec,Vec,Vec,void*);
-typedef PetscErrorCode (*TSIJacobian2)(TS,PetscReal,Vec,Vec,Vec,PetscReal,PetscReal,Mat*,Mat*,MatStructure*,void*);
+typedef PetscErrorCode (*TSIJacobian2)(TS,PetscReal,Vec,Vec,Vec,PetscReal,PetscReal,Mat,Mat,void*);
 PETSC_EXTERN PetscErrorCode TSSetIFunction2(TS,Vec,TSIFunction2,void*);
 PETSC_EXTERN PetscErrorCode TSSetIJacobian2(TS,Mat,Mat,TSIJacobian2,void*);
 PETSC_EXTERN PetscErrorCode TSComputeIFunction2(TS,PetscReal,Vec,Vec,Vec,Vec,PetscBool);
-PETSC_EXTERN PetscErrorCode TSComputeIJacobian2(TS,PetscReal,Vec,Vec,Vec,PetscReal,PetscReal,Mat*,Mat*,MatStructure*,PetscBool);
+PETSC_EXTERN PetscErrorCode TSComputeIJacobian2(TS,PetscReal,Vec,Vec,Vec,PetscReal,PetscReal,Mat,Mat,PetscBool);
 PETSC_EXTERN PetscErrorCode TSSetSolution2(TS,Vec,Vec);
 PETSC_EXTERN PetscErrorCode TSGetSolution2(TS,Vec*,Vec*);
 PETSC_EXTERN PetscErrorCode TSSolve2(TS,Vec,Vec);

File src/petigapc.c

 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define PCGetOperators(pc,A,B) PCGetOperators(pc,A,B,NULL)
+#endif
+
 /* ---------------------------------------------------------------- */
 
 PETSC_STATIC_INLINE
   PetscValidHeaderSpecific(pc,PC_CLASSID,2);
   IGACheckSetUp(iga,1);
 
-  ierr = PCGetOperators(pc,NULL,&mat,NULL);CHKERRQ(ierr);
+  ierr = PCGetOperators(pc,NULL,&mat);CHKERRQ(ierr);
   ierr = PetscObjectQueryFunction((PetscObject)mat,"MatISGetLocalMat_C",&f);CHKERRQ(ierr);
   if (!f) PetscFunctionReturn(0);
   ierr = PetscObjectQueryFunction((PetscObject)pc,"PCBDDCSetLocalAdjacencyGraph_C",&f);CHKERRQ(ierr);
   PetscFunctionBegin;
   PetscValidHeaderSpecific(pc,PC_CLASSID,1);
   if (PetscOptionsPublishCount != 1) PetscFunctionReturn(0);
-  ierr = PCGetOperators(pc,NULL,&mat,NULL);CHKERRQ(ierr);
+  ierr = PCGetOperators(pc,NULL,&mat);CHKERRQ(ierr);
   if (!mat) PetscFunctionReturn(0);
   PetscValidHeaderSpecific(mat,MAT_CLASSID,1);
   ierr = PetscObjectQuery((PetscObject)mat,"IGA",(PetscObject*)&iga);CHKERRQ(ierr);

File src/petigasnes.c

 }
 
 PETSC_EXTERN PetscErrorCode IGASNESFormFunction(SNES,Vec,Vec,void*);
-PETSC_EXTERN PetscErrorCode IGASNESFormJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
+PETSC_EXTERN PetscErrorCode IGASNESFormJacobian(SNES,Vec,Mat,Mat,void*);
 
 #undef  __FUNCT__
 #define __FUNCT__ "IGASNESFormFunction"
 
 #undef  __FUNCT__
 #define __FUNCT__ "IGASNESFormJacobian"
-PetscErrorCode IGASNESFormJacobian(SNES snes,Vec U,Mat *J, Mat *P,MatStructure *m,void *ctx)
+PetscErrorCode IGASNESFormJacobian(SNES snes,Vec U,Mat J,Mat P,void *ctx)
 {
   IGA            iga = (IGA)ctx;
   PetscErrorCode ierr;
   PetscFunctionBegin;
   PetscValidHeaderSpecific(snes,SNES_CLASSID,1);
   PetscValidHeaderSpecific(U,VEC_CLASSID,2);
-  PetscValidPointer(J,3);
-  PetscValidHeaderSpecific(*J,MAT_CLASSID,3);
-  PetscValidPointer(P,4);
-  PetscValidHeaderSpecific(*P,MAT_CLASSID,4);
-  PetscValidPointer(m,5);
+  PetscValidHeaderSpecific(J,MAT_CLASSID,3);
+  PetscValidHeaderSpecific(P,MAT_CLASSID,4);
   PetscValidHeaderSpecific(iga,IGA_CLASSID,6);
-  ierr = IGAComputeJacobian(iga,U,*P);CHKERRQ(ierr);
-  if (*J != * P) {
-    ierr = MatAssemblyBegin(*J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
-    ierr = MatAssemblyEnd(*J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+  ierr = IGAComputeJacobian(iga,U,P);CHKERRQ(ierr);
+  if (J != P) {
+    ierr = MatAssemblyBegin(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+    ierr = MatAssemblyEnd(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
   }
-  *m = SAME_NONZERO_PATTERN;
   PetscFunctionReturn(0);
 }
 
+#if PETSC_VERSION_LT(3,5,0)
+PETSC_EXTERN PetscErrorCode IGASNESFormJacobian_Legacy(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
+PetscErrorCode IGASNESFormJacobian_Legacy(SNES snes,Vec U,Mat *J,Mat *P,MatStructure *m,void *ctx)
+{*m = SAME_NONZERO_PATTERN;return IGASNESFormJacobian(snes,U,*J,*P,ctx);}
+#define IGASNESFormJacobian IGASNESFormJacobian_Legacy
+#endif
+
 #undef  __FUNCT__
 #define __FUNCT__ "IGACreateSNES"
-PetscErrorCode IGACreateSNES(IGA iga, SNES *snes)
+PetscErrorCode IGACreateSNES(IGA iga,SNES *snes)
 {
   MPI_Comm       comm;
   Vec            F;

File src/petigats.c

 }
 
 PETSC_EXTERN PetscErrorCode IGATSFormIFunction(TS,PetscReal,Vec,Vec,Vec,void*);
-PETSC_EXTERN PetscErrorCode IGATSFormIJacobian(TS,PetscReal,Vec,Vec,PetscReal,Mat*,Mat*,MatStructure*,void*);
+PETSC_EXTERN PetscErrorCode IGATSFormIJacobian(TS,PetscReal,Vec,Vec,PetscReal,Mat,Mat,void*);
 
 #undef  __FUNCT__
 #define __FUNCT__ "IGATSFormIFunction"
 
 #undef  __FUNCT__
 #define __FUNCT__ "IGATSFormIJacobian"
-PetscErrorCode IGATSFormIJacobian(TS ts,PetscReal t,Vec U,Vec V,PetscReal shift,Mat *J,Mat *P,MatStructure *m,void *ctx)
+PetscErrorCode IGATSFormIJacobian(TS ts,PetscReal t,Vec U,Vec V,PetscReal shift,Mat J,Mat P,void *ctx)
 {
   IGA            iga = (IGA)ctx;
   PetscReal      dt,a=shift;
   PetscValidHeaderSpecific(ts,TS_CLASSID,1);
   PetscValidHeaderSpecific(U,VEC_CLASSID,3);
   PetscValidHeaderSpecific(V,VEC_CLASSID,4);
-  PetscValidPointer(J,6);
-  PetscValidHeaderSpecific(*J,MAT_CLASSID,6);
-  PetscValidPointer(P,7);
-  PetscValidHeaderSpecific(*P,MAT_CLASSID,7);
-  PetscValidPointer(m,8);
+  PetscValidHeaderSpecific(J,MAT_CLASSID,6);
+  PetscValidHeaderSpecific(P,MAT_CLASSID,7);
   PetscValidHeaderSpecific(iga,IGA_CLASSID,9);
   ierr = TSGetTimeStep(ts,&dt);CHKERRQ(ierr);
   if (iga->form->ops->IEJacobian) {
     ierr = TSGetTime(ts,&t0);CHKERRQ(ierr);
     ierr = TSGetSolution(ts,&U0);CHKERRQ(ierr);
-    ierr = IGAComputeIEJacobian(iga,dt,a,V,t,U,t0,U0,*P);CHKERRQ(ierr);
+    ierr = IGAComputeIEJacobian(iga,dt,a,V,t,U,t0,U0,P);CHKERRQ(ierr);
   } else {
-    ierr = IGAComputeIJacobian(iga,dt,a,V,t,U,*P);CHKERRQ(ierr);
+    ierr = IGAComputeIJacobian(iga,dt,a,V,t,U,P);CHKERRQ(ierr);
   }
-  if (*J != * P) {
-    ierr = MatAssemblyBegin(*J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
-    ierr = MatAssemblyEnd(*J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+  if (J != P) {
+    ierr = MatAssemblyBegin(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+    ierr = MatAssemblyEnd(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
   }
-  *m = SAME_NONZERO_PATTERN;
   PetscFunctionReturn(0);
 }
 
+#if PETSC_VERSION_LT(3,5,0)
+PETSC_EXTERN PetscErrorCode IGATSFormIJacobian_Legacy(TS,PetscReal,Vec,Vec,PetscReal,Mat*,Mat*,MatStructure*,void*);
+PetscErrorCode IGATSFormIJacobian_Legacy(TS ts,PetscReal t,Vec U,Vec V,PetscReal shift,Mat *J,Mat *P,MatStructure *m,void *ctx)
+{*m = SAME_NONZERO_PATTERN; return IGATSFormIJacobian(ts,t,U,V,shift,*J,*P,ctx);}
+#define IGATSFormIJacobian IGATSFormIJacobian_Legacy
+#endif
+
 #undef  __FUNCT__
 #define __FUNCT__ "IGACreateTS"
 /*@
 
 .keywords: IGA, create, TS
 @*/
-PetscErrorCode IGACreateTS(IGA iga, TS *ts)
+PetscErrorCode IGACreateTS(IGA iga,TS *ts)
 {
   MPI_Comm       comm;
   Vec            U;

File src/petigats2.c

 }
 
 PETSC_EXTERN PetscErrorCode IGATSFormIFunction (TS,PetscReal,Vec,Vec,Vec,void*);
-PETSC_EXTERN PetscErrorCode IGATSFormIJacobian (TS,PetscReal,Vec,Vec,PetscReal,Mat*,Mat*,MatStructure*,void*);
+PETSC_EXTERN PetscErrorCode IGATSFormIJacobian (TS,PetscReal,Vec,Vec,PetscReal,Mat,Mat,void*);
 PETSC_EXTERN PetscErrorCode IGATSFormIFunction2(TS,PetscReal,Vec,Vec,Vec,Vec,void*);
-PETSC_EXTERN PetscErrorCode IGATSFormIJacobian2(TS,PetscReal,Vec,Vec,Vec,PetscReal,PetscReal,Mat*,Mat*,MatStructure*,void*);
+PETSC_EXTERN PetscErrorCode IGATSFormIJacobian2(TS,PetscReal,Vec,Vec,Vec,PetscReal,PetscReal,Mat,Mat,void*);
 
 #undef  __FUNCT__
 #define __FUNCT__ "IGATSFormIFunction2"
 
 #undef  __FUNCT__
 #define __FUNCT__ "IGATSFormIJacobian2"
-PetscErrorCode IGATSFormIJacobian2(TS ts,PetscReal t,Vec U,Vec V,Vec A,PetscReal shiftV,PetscReal shiftA,Mat *J,Mat *P,MatStructure *m,void *ctx)
+PetscErrorCode IGATSFormIJacobian2(TS ts,PetscReal t,Vec U,Vec V,Vec A,PetscReal shiftV,PetscReal shiftA,Mat J,Mat P,void *ctx)
 {
   IGA            iga = (IGA)ctx;
   PetscReal      dt,a=shiftA,v=shiftV;
   PetscValidHeaderSpecific(U,VEC_CLASSID,3);
   PetscValidHeaderSpecific(V,VEC_CLASSID,4);
   PetscValidHeaderSpecific(A,VEC_CLASSID,5);
-  PetscValidPointer(J,8);
-  PetscValidHeaderSpecific(*J,MAT_CLASSID,8);
-  PetscValidPointer(P,9);
-  PetscValidHeaderSpecific(*P,MAT_CLASSID,9);
-  PetscValidPointer(m,10);
+  PetscValidHeaderSpecific(J,MAT_CLASSID,8);
+  PetscValidHeaderSpecific(P,MAT_CLASSID,9);
   PetscValidHeaderSpecific(iga,IGA_CLASSID,10);
   ierr = TSGetTimeStep(ts,&dt);CHKERRQ(ierr);
-  ierr = IGAComputeIJacobian2(iga,dt,a,A,v,V,t,U,*P);CHKERRQ(ierr);
-  if (*J != *P) {
-    ierr = MatAssemblyBegin(*J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
-    ierr = MatAssemblyEnd(*J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+  ierr = IGAComputeIJacobian2(iga,dt,a,A,v,V,t,U,P);CHKERRQ(ierr);
+  if (J != P) {
+    ierr = MatAssemblyBegin(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+    ierr = MatAssemblyEnd  (J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
   }
-  *m = SAME_NONZERO_PATTERN;
   PetscFunctionReturn(0);
 }
 
+#if PETSC_VERSION_LT(3,5,0)
+PETSC_EXTERN PetscErrorCode IGATSFormIJacobian_Legacy(TS,PetscReal,Vec,Vec,PetscReal,Mat*,Mat*,MatStructure*,void*);
+#define IGATSFormIJacobian  IGATSFormIJacobian_Legacy
+#endif
+
 #undef  __FUNCT__
 #define __FUNCT__ "IGACreateTS2"
 /*@
 
 .keywords: IGA, create, TS
 @*/
-PetscErrorCode IGACreateTS2(IGA iga, TS *ts)
+PetscErrorCode IGACreateTS2(IGA iga,TS *ts)
 {
   MPI_Comm       comm;
   Vec            U,V;

File src/tsalpha2.c

 
 #undef __FUNCT__
 #define __FUNCT__ "SNESTSFormJacobian_Alpha2"
-static PetscErrorCode SNESTSFormJacobian_Alpha2(SNES snes,Vec X,Mat *J,Mat *P,MatStructure *str,TS ts)
+static PetscErrorCode SNESTSFormJacobian_Alpha2(SNES snes,Vec X,
+#if PETSC_VERSION_LT(3,5,0)
+                                                Mat *J,Mat *P,MatStructure *m,
+#else
+                                                Mat J,Mat P,
+#endif
+                                                TS ts)
 {
   TS_Alpha2      *th = (TS_Alpha2*)ts->data;
   PetscErrorCode ierr;
-
   PetscFunctionBegin;
   ierr = th->StageVecs(ts,X);CHKERRQ(ierr);
   if (th->Jacobian) {
     PetscReal ta = th->stage_time;
     Vec       Xa = th->Xa, Va = th->Va, Aa = th->Aa;
     PetscReal dVdX = th->shift_V, dAdX = th->shift_A;
-    ierr = TSComputeIJacobian2(ts,ta,Xa,Va,Aa,dVdX,dAdX,J,P,str,PETSC_FALSE);CHKERRQ(ierr);
+#if PETSC_VERSION_LT(3,5,0)
+    *m = SAME_NONZERO_PATTERN;
+    ierr = TSComputeIJacobian2(ts,ta,Xa,Va,Aa,dVdX,dAdX,*J,*P,PETSC_FALSE);CHKERRQ(ierr);
+#else
+    ierr = TSComputeIJacobian2(ts,ta,Xa,Va,Aa,dVdX,dAdX,J,P,PETSC_FALSE);CHKERRQ(ierr);
+#endif
   } else {
     /* J,P = Jacobian(ta,Xa,Aa) */
     PetscReal ta = th->stage_time;
     Vec       Xa = th->Xa, Aa = th->Aa;
     PetscReal dAdX = th->shift_A;
-    ierr = TSComputeIJacobian(ts,ta,Xa,Aa,dAdX,J,P,str,PETSC_FALSE);CHKERRQ(ierr);
+#if PETSC_VERSION_LT(3,5,0)
+    ierr = TSComputeIJacobian(ts,ta,Xa,Aa,dAdX,J,P,m,PETSC_FALSE);CHKERRQ(ierr);
+#else
+    ierr = TSComputeIJacobian(ts,ta,Xa,Aa,dAdX,J,P,PETSC_FALSE);CHKERRQ(ierr);
+#endif
   }
-  PetscValidHeaderSpecific(*J,MAT_CLASSID,3);
-  PetscValidHeaderSpecific(*P,MAT_CLASSID,4);
   PetscFunctionReturn(0);
 }
 
 
 #undef __FUNCT__
 #define __FUNCT__ "TSComputeIJacobian2_Alpha2"
-PetscErrorCode TSComputeIJacobian2_Alpha2(TS ts,PetscReal t,Vec X,Vec V,Vec A,PetscReal shiftV,PetscReal shiftA,Mat *J,Mat *P,MatStructure *str,PetscBool imex)
+PetscErrorCode TSComputeIJacobian2_Alpha2(TS ts,PetscReal t,Vec X,Vec V,Vec A,PetscReal shiftV,PetscReal shiftA,Mat J,Mat P,PetscBool imex)
 {
   TS_Alpha2      *th = (TS_Alpha2*)ts->data;
   PetscErrorCode ierr;
 
   PetscFunctionBegin;
   if (!th->Jacobian) SETERRQ(((PetscObject)ts)->comm,PETSC_ERR_USER,"Must call TSSetIJacobian2()");
-  *str = DIFFERENT_NONZERO_PATTERN;
-  ierr = PetscLogEventBegin(TS_JacobianEval,ts,X,V,*J);CHKERRQ(ierr);
+  ierr = PetscLogEventBegin(TS_JacobianEval,ts,X,V,J);CHKERRQ(ierr);
   PetscStackPush("TS user implicit Jacobian");
-  ierr = (*th->Jacobian)(ts,t,X,V,A,shiftV,shiftA,J,P,str,th->JacCtx);CHKERRQ(ierr);
+  ierr = (*th->Jacobian)(ts,t,X,V,A,shiftV,shiftA,J,P,th->JacCtx);CHKERRQ(ierr);
   PetscStackPop;
-  ierr = PetscLogEventEnd(TS_JacobianEval,ts,X,V,*J);CHKERRQ(ierr);
-  PetscValidHeaderSpecific(*J,MAT_CLASSID,8);
-  PetscValidHeaderSpecific(*P,MAT_CLASSID,9);
+  ierr = PetscLogEventEnd(TS_JacobianEval,ts,X,V,J);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
 
 
 #undef __FUNCT__
 #define __FUNCT__ "TSComputeIJacobian2"
-PetscErrorCode TSComputeIJacobian2(TS ts,PetscReal t,Vec X,Vec V,Vec A,PetscReal shiftV,PetscReal shiftA,Mat *J,Mat *P,MatStructure *str,PetscBool imex)
+PetscErrorCode TSComputeIJacobian2(TS ts,PetscReal t,Vec X,Vec V,Vec A,PetscReal shiftV,PetscReal shiftA,Mat J,Mat P,PetscBool imex)
 {
   PetscErrorCode ierr;
   PetscFunctionBegin;
   PetscValidHeaderSpecific(X,VEC_CLASSID,3);
   PetscValidHeaderSpecific(V,VEC_CLASSID,4);
   PetscValidHeaderSpecific(A,VEC_CLASSID,5);
-  PetscValidPointer(J,8);
-  PetscValidHeaderSpecific(*J,MAT_CLASSID,8);
-  PetscValidPointer(P,9);
-  PetscValidHeaderSpecific(*P,MAT_CLASSID,9);
-  PetscValidPointer(str,10);
+  PetscValidHeaderSpecific(J,MAT_CLASSID,8);
+  PetscValidHeaderSpecific(P,MAT_CLASSID,9);
   ierr = PetscUseMethod(ts,"TSComputeIJacobian2_C",
-                        (TS,PetscReal,Vec,Vec,Vec,PetscReal,PetscReal,Mat*,Mat*,MatStructure*,PetscBool),
-                        (ts,t,X,V,A,shiftV,shiftA,J,P,str,imex));CHKERRQ(ierr);
+                        (TS,PetscReal,Vec,Vec,Vec,PetscReal,PetscReal,Mat,Mat,PetscBool),
+                        (ts,t,X,V,A,shiftV,shiftA,J,P,imex));CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
 

File test/FixTable.c

 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 PETSC_STATIC_INLINE
 PetscReal DOT(PetscInt dim,const PetscReal a[],const PetscReal b[])
 {
   {
     KSP ksp;
     ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-    ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+    ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
     ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
     ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
     ierr = KSPDestroy(&ksp);CHKERRQ(ierr);
   {
     KSP ksp;
     ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
-    ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+    ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
     ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);
     ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
     ierr = KSPDestroy(&ksp);CHKERRQ(ierr);

File test/IGACreate.c

 #include "petiga.h"
 
+#if PETSC_VERSION_LT(3,5,0)
+#define KSPSetOperators(ksp,A,B) KSPSetOperators(ksp,A,B,SAME_NONZERO_PATTERN)
+#endif
+
 #undef  __FUNCT__
 #define __FUNCT__ "Scalar"
 PetscErrorCode Scalar(IGAPoint p,const PetscScalar U[],PetscInt n,PetscScalar *S,void *ctx)
   ierr = KSPSetType(ksp,KSPCG);CHKERRQ(ierr);
   ierr = IGASetFormSystem(iga,System,0);CHKERRQ(ierr);
   ierr = IGAComputeSystem(iga,A,b);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);;CHKERRQ(ierr);
   ierr = KSPSetTolerances(ksp,1e-6,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
   ierr = IGAComputeVector(iga,b);CHKERRQ(ierr);
   ierr = IGASetFormMatrix(iga,Matrix,0);CHKERRQ(ierr);
   ierr = IGAComputeMatrix(iga,A);CHKERRQ(ierr);
-  ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
+  ierr = KSPSetOperators(ksp,A,A);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);;CHKERRQ(ierr);
   ierr = KSPSetTolerances(ksp,1e-6,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT);CHKERRQ(ierr);
   ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);

File test/Oscillator.c

 
 #undef  __FUNCT__
 #define __FUNCT__ "Tangent1"
-PetscErrorCode Tangent1(TS ts,PetscReal t,Vec X,Vec A,PetscReal shiftA,Mat *J,Mat *P,MatStructure *m,void *ctx)
+PetscErrorCode Tangent1(TS ts,PetscReal t,Vec X,Vec A,PetscReal shiftA,Mat J,Mat P,void *ctx)
 {
   UserParams *user = (UserParams *)ctx;
   PetscReal Omega = user->Omega;
 
   T = shiftA + (Omega*Omega);
 
-  ierr = MatSetValue(*P,0,0,T,INSERT_VALUES);CHKERRQ(ierr);
-  ierr = MatAssemblyBegin(*P,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
-  ierr = MatAssemblyEnd  (*P,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
-  if (*J != * P) {
-    ierr = MatAssemblyBegin(*J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
-    ierr = MatAssemblyEnd(*J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+  ierr = MatSetValue(P,0,0,T,INSERT_VALUES);CHKERRQ(ierr);
+  ierr = MatAssemblyBegin(P,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+  ierr = MatAssemblyEnd  (P,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+  if (J != P) {
+    ierr = MatAssemblyBegin(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+    ierr = MatAssemblyEnd(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
   }
-  *m = SAME_NONZERO_PATTERN;
 
   PetscFunctionReturn(0);
 }
+#if PETSC_VERSION_LT(3,5,0)
+PetscErrorCode Tangent1_Legacy(TS ts,PetscReal t,Vec U,Vec V,PetscReal shift,Mat *J,Mat *P,MatStructure *m,void *ctx)
+{*m = SAME_NONZERO_PATTERN; return Tangent1(ts,t,U,V,shift,*J,*P,ctx);}
+#define Tangent1 Tangent1_Legacy
+#endif
 
 #undef  __FUNCT__
 #define __FUNCT__ "Residual2"
 
 #undef  __FUNCT__
 #define __FUNCT__ "Tangent2"
-PetscErrorCode Tangent2(TS ts,PetscReal t,Vec X,Vec V,Vec A,PetscReal shiftV,PetscReal shiftA,Mat *J,Mat *P,MatStructure *m,void *ctx)
+PetscErrorCode Tangent2(TS ts,PetscReal t,Vec X,Vec V,Vec A,PetscReal shiftV,PetscReal shiftA,Mat J,Mat P,void *ctx)
 {
   UserParams *user = (UserParams *)ctx;
   PetscReal Omega = user->Omega, Xi = user->Xi;
 
   T = shiftA + shiftV * (2*Xi*Omega) + (Omega*Omega);
 
-  ierr = MatSetValue(*P,0,0,T,INSERT_VALUES);CHKERRQ(ierr);
-  ierr = MatAssemblyBegin(*P,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
-  ierr = MatAssemblyEnd  (*P,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
-  if (*J != * P) {
-    ierr = MatAssemblyBegin(*J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
-    ierr = MatAssemblyEnd(*J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+  ierr = MatSetValue(P,0,0,T,INSERT_VALUES);CHKERRQ(ierr);
+  ierr = MatAssemblyBegin(P,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+  ierr = MatAssemblyEnd  (P,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+  if (J != P) {
+    ierr = MatAssemblyBegin(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+    ierr = MatAssemblyEnd(J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
   }
-  *m = SAME_NONZERO_PATTERN;
 
   PetscFunctionReturn(0);
 }