Commits

Lisandro Dalcin committed 6427e42

Change interface for IGAFormI[E]{Function|Jacobian}()

Comments (0)

Files changed (2)

 PETSC_EXTERN PetscErrorCode IGAFormIFunction(IGA iga,PetscReal dt,
                                              PetscReal a,Vec V,
                                              PetscReal t,Vec U,
-                                             Vec F,IGAUserIFunction IFunction,void *ctx);
+                                             Vec F);
 PETSC_EXTERN PetscErrorCode IGAFormIJacobian(IGA iga,PetscReal dt,
                                              PetscReal a,Vec V,
                                              PetscReal t,Vec U,
-                                             Mat J,IGAUserIJacobian IJacobian,void *ctx);
+                                             Mat J);
 PETSC_EXTERN PetscErrorCode IGAFormIEFunction(IGA iga,PetscReal dt,
                                               PetscReal a,Vec V,
                                               PetscReal t,Vec U,
                                               PetscReal t0,Vec U0,
-                                              Vec F,IGAUserIEFunction IEFunction,void *ctx);
+                                              Vec F);
 PETSC_EXTERN PetscErrorCode IGAFormIEJacobian(IGA iga,PetscReal dt,
                                               PetscReal a,Vec V,
                                               PetscReal t,Vec U,
                                               PetscReal t0,Vec U0,
-                                              Mat J,IGAUserIEJacobian IEJacobian,void *ctx);
+                                              Mat J);
 
 /* ---------------------------------------------------------------- */
 
 PetscErrorCode IGAFormIFunction(IGA iga,PetscReal dt,
                                 PetscReal a,Vec vecV,
                                 PetscReal t,Vec vecU,
-                                Vec vecF,IGAUserIFunction IFunction,void *ctx)
+                                Vec vecF)
 {
   Vec               localV;
   Vec               localU;
   const PetscScalar *arrayU;
   IGAElement        element;
   IGAPoint          point;
+  IGAUserIFunction  IFunction;
+  void              *IFunCtx;
   PetscErrorCode    ierr;
   PetscFunctionBegin;
   PetscValidHeaderSpecific(iga,IGA_CLASSID,1);
   PetscValidHeaderSpecific(vecU,VEC_CLASSID,6);
   PetscValidHeaderSpecific(vecF,VEC_CLASSID,7);
   IGACheckSetUp(iga,1);
+  IGACheckUserOp(iga,1,IFunction);
+
+  IFunction = iga->userops->IFunction;
+  IFunCtx   = iga->userops->IFunCtx;
 
   /* Clear global vector F */
   ierr = VecZeroEntries(vecF);CHKERRQ(ierr);
     while (IGAPointNext(point)) {
       PetscScalar *R;
       ierr = IGAPointGetWorkVec(point,&R);CHKERRQ(ierr);
-      ierr = IFunction(point,dt,a,V,t,U,R,ctx);CHKERRQ(ierr);
+      ierr = IFunction(point,dt,a,V,t,U,R,IFunCtx);CHKERRQ(ierr);
       ierr = IGAPointAddVec(point,R,F);CHKERRQ(ierr);
     }
     /* */
 PetscErrorCode IGAFormIJacobian(IGA iga,PetscReal dt,
                                 PetscReal a,Vec vecV,
                                 PetscReal t,Vec vecU,
-                                Mat matJ,IGAUserIJacobian IJacobian,void *ctx)
+                                Mat matJ)
 {
   Vec               localV;
   Vec               localU;
   const PetscScalar *arrayU;
   IGAElement        element;
   IGAPoint          point;
+  IGAUserIJacobian  IJacobian;
+  void              *IJacCtx;
   PetscErrorCode    ierr;
   PetscFunctionBegin;
   PetscValidHeaderSpecific(iga,IGA_CLASSID,1);
   PetscValidHeaderSpecific(vecU,VEC_CLASSID,6);
   PetscValidHeaderSpecific(matJ,MAT_CLASSID,7);
   IGACheckSetUp(iga,1);
+  IGACheckUserOp(iga,1,IJacobian);
+
+  IJacobian = iga->userops->IJacobian;
+  IJacCtx   = iga->userops->IJacCtx;
 
   /* Clear global matrix J*/
   ierr = MatZeroEntries(matJ);CHKERRQ(ierr);
     while (IGAPointNext(point)) {
       PetscScalar *K;
       ierr = IGAPointGetWorkMat(point,&K);CHKERRQ(ierr);
-      ierr = IJacobian(point,dt,a,V,t,U,K,ctx);CHKERRQ(ierr);
+      ierr = IJacobian(point,dt,a,V,t,U,K,IJacCtx);CHKERRQ(ierr);
       ierr = IGAPointAddMat(point,K,J);CHKERRQ(ierr);
     }
     /* */
                                  PetscReal a,Vec vecV,
                                  PetscReal t,Vec vecU,
                                  PetscReal t0,Vec vecU0,
-                                 Vec vecF,IGAUserIEFunction IEFunction,void *ctx)
+                                 Vec vecF)
 {
   Vec               localV;
   Vec               localU;
   const PetscScalar *arrayU0;
   IGAElement        element;
   IGAPoint          point;
+  IGAUserIEFunction IEFunction;
+  void              *IEFunCtx;
   PetscErrorCode    ierr;
   PetscFunctionBegin;
   PetscValidHeaderSpecific(iga,IGA_CLASSID,1);
   PetscValidHeaderSpecific(vecU0,VEC_CLASSID,7);
   PetscValidHeaderSpecific(vecF,VEC_CLASSID,8);
   IGACheckSetUp(iga,1);
+  IGACheckUserOp(iga,1,IEFunction);
+
+  IEFunction = iga->userops->IEFunction;
+  IEFunCtx   = iga->userops->IEFunCtx;
 
   /* Clear global vector F */
   ierr = VecZeroEntries(vecF);CHKERRQ(ierr);
     while (IGAPointNext(point)) {
       PetscScalar *R;
       ierr = IGAPointGetWorkVec(point,&R);CHKERRQ(ierr);
-      ierr = IEFunction(point,dt,a,V,t,U,t0,U0,R,ctx);CHKERRQ(ierr);
+      ierr = IEFunction(point,dt,a,V,t,U,t0,U0,R,IEFunCtx);CHKERRQ(ierr);
       ierr = IGAPointAddVec(point,R,F);CHKERRQ(ierr);
     }
     /* */
                                  PetscReal a,Vec vecV,
                                  PetscReal t,Vec vecU,
                                  PetscReal t0,Vec vecU0,
-                                 Mat matJ,IGAUserIEJacobian IEJacobian,void *ctx)
+                                 Mat matJ)
 {
   Vec               localV;
   Vec               localU;
   const PetscScalar *arrayU0;
   IGAElement        element;
   IGAPoint          point;
+  IGAUserIEJacobian IEJacobian;
+  void              *IEJacCtx;
   PetscErrorCode    ierr;
   PetscFunctionBegin;
   PetscValidHeaderSpecific(iga,IGA_CLASSID,1);
   PetscValidHeaderSpecific(vecU0,VEC_CLASSID,7);
   PetscValidHeaderSpecific(matJ,MAT_CLASSID,0);
   IGACheckSetUp(iga,1);
+  IGACheckUserOp(iga,1,IEJacobian);
+
+  IEJacobian = iga->userops->IEJacobian;
+  IEJacCtx   = iga->userops->IEJacCtx;
 
   /* Clear global matrix J*/
   ierr = MatZeroEntries(matJ);CHKERRQ(ierr);
     while (IGAPointNext(point)) {
       PetscScalar *K;
       ierr = IGAPointGetWorkMat(point,&K);CHKERRQ(ierr);
-      ierr = IEJacobian(point,dt,a,V,t,U,t0,U0,K,ctx);CHKERRQ(ierr);
+      ierr = IEJacobian(point,dt,a,V,t,U,t0,U0,K,IEJacCtx);CHKERRQ(ierr);
       ierr = IGAPointAddMat(point,K,J);CHKERRQ(ierr);
     }
     /* */
   PetscValidHeaderSpecific(V,VEC_CLASSID,4);
   PetscValidHeaderSpecific(F,VEC_CLASSID,5);
   PetscValidHeaderSpecific(iga,IGA_CLASSID,6);
-  if (!iga->userops->IFunction && !iga->userops->IEFunction)
-    SETERRQ(((PetscObject)ts)->comm,PETSC_ERR_USER,"Must call IGASetUserIFunction()");
   ierr = TSGetTimeStep(ts,&dt);CHKERRQ(ierr);
   if (iga->userops->IEFunction) {
     PetscReal t0;
     Vec       U0;
     ierr = TSGetTime(ts,&t0);CHKERRQ(ierr);
     ierr = TSGetSolution(ts,&U0);CHKERRQ(ierr);
-    ierr = IGAFormIEFunction(iga,dt,a,V,t,U,t0,U0,F,
-                             iga->userops->IEFunction,
-                             iga->userops->IEFunCtx);CHKERRQ(ierr);
+    ierr = IGAFormIEFunction(iga,dt,a,V,t,U,t0,U0,F);CHKERRQ(ierr);
   } else {
-    ierr = IGAFormIFunction(iga,dt,a,V,t,U,F,
-                            iga->userops->IFunction,
-                            iga->userops->IFunCtx);CHKERRQ(ierr);
+    ierr = IGAFormIFunction(iga,dt,a,V,t,U,F);CHKERRQ(ierr);
   }
   PetscFunctionReturn(0);
 }
   PetscValidHeaderSpecific(*P,MAT_CLASSID,7);
   PetscValidPointer(m,8);
   PetscValidHeaderSpecific(iga,IGA_CLASSID,9);
-  if (!iga->userops->IJacobian && !iga->userops->IEJacobian)
-    SETERRQ(((PetscObject)ts)->comm,PETSC_ERR_USER,"Must call IGASetUserIJacobian()");
   ierr = TSGetTimeStep(ts,&dt);CHKERRQ(ierr);
   if (iga->userops->IEJacobian) {
     PetscReal t0;
     Vec       U0;
     ierr = TSGetTime(ts,&t0);CHKERRQ(ierr);
     ierr = TSGetSolution(ts,&U0);CHKERRQ(ierr);
-    ierr = IGAFormIEJacobian(iga,dt,a,V,t,U,t0,U0,*P,
-                             iga->userops->IEJacobian,
-                             iga->userops->IEJacCtx);CHKERRQ(ierr);
+    ierr = IGAFormIEJacobian(iga,dt,a,V,t,U,t0,U0,*P);CHKERRQ(ierr);
   } else {
-    ierr = IGAFormIJacobian(iga,dt,a,V,t,U,*P,
-                            iga->userops->IJacobian,
-                            iga->userops->IJacCtx);CHKERRQ(ierr);
+    ierr = IGAFormIJacobian(iga,dt,a,V,t,U,*P);CHKERRQ(ierr);
   }
   if (*J != * P) {
     ierr = MatAssemblyBegin(*J,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);