Commits

Shrirang Abhyankar committed 4f9b241

DAE semi-explicit solver: More feature addition

Added fully implicit method for DAESimple.
Updated example tests/ex11.c
Moved daesimplexxxfunction function pointers from TS_DAESimple to DMTS. Also moved
their corresponding contexts.
Still some issues with setting the daesimple method dynamically via -ts_type option.

Comments (0)

Files changed (11)

include/petsc-private/tsimpl.h

 
   PetscErrorCode (*destroy)(DMTS);
   PetscErrorCode (*duplicate)(DMTS,DMTS);
+
+  PetscErrorCode (*daesimplerhsfunction)(PetscReal,Vec,Vec,Vec,void*);
+  PetscErrorCode (*daesimpleifunction)(PetscReal,Vec,Vec,Vec,void*);
 };
 
 struct _p_DMTS {
   void *solutionctx;
   void *forcingctx;
 
+  void *daesimplerhsfunctionctx;
+  void *daesimpleifunctionctx;
+
   void *data;
 
   /* This is NOT reference counted. The DM on which this context was first created is cached here to implement one-way

include/petscts.h

 #define TSARKIMEX         "arkimex"
 #define TSROSW            "rosw"
 #define TSEIMEX           "eimex"
-#define TSDAESIMPLE       "daesimple"
+#define TSDAESIMPLERED    "daesimplered"
+#define TSDAESIMPLEFULL   "daesimplefull"
 
 /*E
     TSProblemType - Determines the type of problem this TS object is to be used to solve
 PETSC_EXTERN PetscErrorCode DMTSSetIFunctionSerialize(DM,PetscErrorCode (*)(void*,PetscViewer),PetscErrorCode (*)(void**,PetscViewer));
 PETSC_EXTERN PetscErrorCode DMTSSetIJacobianSerialize(DM,PetscErrorCode (*)(void*,PetscViewer),PetscErrorCode (*)(void**,PetscViewer));
 
+PETSC_EXTERN PetscErrorCode DMTSSetDAESimpleRHSFunction(DM,PetscErrorCode (*)(PetscReal,Vec,Vec,Vec,void*),void*);
+PETSC_EXTERN PetscErrorCode DMTSSetDAESimpleIFunction(DM,PetscErrorCode (*)(PetscReal,Vec,Vec,Vec,void*),void*);
+PETSC_EXTERN PetscErrorCode DMTSGetDAESimpleRHSFunction(DM,PetscErrorCode (**)(PetscReal,Vec,Vec,Vec,void*),void**);
+PETSC_EXTERN PetscErrorCode DMTSGetDAESimpleIFunction(DM,PetscErrorCode (**)(PetscReal,Vec,Vec,Vec,void*),void**);
+
 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*DMDATSRHSFunctionLocal)(DMDALocalInfo*,PetscReal,void*,void*,void*);
 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*DMDATSRHSJacobianLocal)(DMDALocalInfo*,PetscReal,void*,Mat,Mat,MatStructure*,void*);
 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*DMDATSIFunctionLocal)(DMDALocalInfo*,PetscReal,void*,void*,void*,void*);

src/ts/examples/tests/ex11.c

   Vec            U,V,Usolution;
 
   PetscInitialize(&argc,&argv,(char*)0,help);
-  ierr = TSCreate(PETSC_COMM_WORLD,&ts);CHKERRQ(ierr);
-  ierr = TSSetType(ts,TSDAESIMPLE);CHKERRQ(ierr);
+
   ierr = VecCreateMPI(PETSC_COMM_WORLD,1,PETSC_DETERMINE,&U);CHKERRQ(ierr);
   ierr = VecCreateMPI(PETSC_COMM_WORLD,1,PETSC_DETERMINE,&V);CHKERRQ(ierr);
 
   ierr = VecDuplicate(U,&Usolution);CHKERRQ(ierr);
   ierr = VecSet(Usolution,1.0);CHKERRQ(ierr);
+  ierr = VecSet(V,1.0);CHKERRQ(ierr);
 
+  ierr = TSCreate(PETSC_COMM_WORLD,&ts);CHKERRQ(ierr);
+  ierr = TSSetType(ts,TSDAESIMPLERED);CHKERRQ(ierr);
   ierr = TSDAESimpleSetRHSFunction(ts,Usolution,f,NULL);CHKERRQ(ierr);
   ierr = TSDAESimpleSetIFunction(ts,V,F,NULL);CHKERRQ(ierr);
 

src/ts/impls/semiexplicit/full/full.c

+
+#include <../src/ts/impls/semiexplicit/semiexplicit.h>
+
+/* ----------------------------------------------------------------------------*/
+
+/*                                                                                                                                         
+      Integrates the system by integrating directly the entire DAE system                                                                  
+*/
+
+typedef struct {
+  TS         ts;
+  Vec        UV,UF,VF;
+  VecScatter scatterU,scatterV;
+} TS_DAESimple_Full;
+
+#undef __FUNCT__
+#define __FUNCT__ "TSDAESimple_Full_TSRHSFunction"
+/*                                                                                                                                                      
+   Defines the RHS function that is passed to the time-integrator.                                                                                      
+                                                                                                                                                        
+   f(U,V)                                                                                                                                               
+   0                                                                                                                                                    
+                                                                                                                                                        
+*/
+PetscErrorCode TSDAESimple_Full_TSRHSFunction(TS tsinner,PetscReal t,Vec UV,Vec F,void *actx)
+{
+  TS                ts = (TS)actx;
+  TS_DAESimple      *tsdae = (TS_DAESimple*)ts->data;
+  TS_DAESimple_Full *full = (TS_DAESimple_Full*)tsdae->data;
+  PetscErrorCode    ierr;
+  DM                dm;
+  PetscErrorCode    (*rhsfunction)(PetscReal,Vec,Vec,Vec,void*);
+  void              *rhsfunctionctx;
+
+  PetscFunctionBegin;
+  ierr = VecSet(F,0.0);CHKERRQ(ierr);
+  ierr = VecScatterBegin(full->scatterU,UV,tsdae->U,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
+  ierr = VecScatterEnd(full->scatterU,UV,tsdae->U,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
+  ierr = VecScatterBegin(full->scatterV,UV,tsdae->V,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
+  ierr = VecScatterEnd(full->scatterV,UV,tsdae->V,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
+  ierr   = TSGetDM(ts,&dm);CHKERRQ(ierr);
+  ierr   = DMTSGetDAESimpleRHSFunction(dm,&rhsfunction,&rhsfunctionctx);CHKERRQ(ierr);
+  ierr   = (*rhsfunction)(t,tsdae->U,tsdae->V,full->UF,rhsfunctionctx);CHKERRQ(ierr);
+  ierr = VecScatterBegin(full->scatterU,full->UF,F,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
+  ierr = VecScatterEnd(full->scatterU,full->UF,F,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
+  PetscFunctionReturn(0);
+}
+
+#undef __FUNCT__
+#define __FUNCT__ "TSDAESimple_Full_TSIFunction"
+/*                                                                                                                                                      
+   Defines the nonlinear function that is passed to the nonlinear solver                                                                                
+                                                                                                                                                        
+   \dot{U}                                                                                                                                              
+   F(U,V)                                                                                                                                               
+                                                                                                                                                        
+*/
+PetscErrorCode TSDAESimple_Full_TSIFunction(TS tsinner,PetscReal t,Vec UV,Vec UVdot,Vec F,void *actx)
+{
+  TS                ts = (TS)actx;
+  TS_DAESimple      *tsdae = (TS_DAESimple*)ts->data;
+  TS_DAESimple_Full *full = (TS_DAESimple_Full*)tsdae->data;
+  PetscErrorCode    ierr;
+  DM                dm;
+  PetscErrorCode    (*ifunction)(PetscReal,Vec,Vec,Vec,void*);
+  void              *ifunctionctx;
+
+  PetscFunctionBegin;
+  ierr = VecCopy(UVdot,F);CHKERRQ(ierr);
+  ierr = VecScatterBegin(full->scatterU,UV,tsdae->U,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
+  ierr = VecScatterEnd(full->scatterU,UV,tsdae->U,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
+  ierr = VecScatterBegin(full->scatterV,UV,tsdae->V,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
+  ierr = VecScatterEnd(full->scatterV,UV,tsdae->V,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
+  ierr = TSGetDM(ts,&dm);CHKERRQ(ierr);
+  ierr = DMTSGetDAESimpleIFunction(dm,&ifunction,&ifunctionctx);
+  ierr = (*ifunction)(t,tsdae->U,tsdae->V,full->VF,ifunctionctx);CHKERRQ(ierr);
+  ierr = VecScatterBegin(full->scatterV,full->VF,F,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
+  ierr = VecScatterEnd(full->scatterV,full->VF,F,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
+  PetscFunctionReturn(0);
+}
+
+#undef __FUNCT__
+#define __FUNCT__ "TSReset_DAESimple_Full"
+PetscErrorCode TSReset_DAESimple_Full(TS ts)
+{
+  TS_DAESimple *dae=(TS_DAESimple*)ts->data;
+  TS_DAESimple_Full *full = (TS_DAESimple_Full*)dae->data;
+  PetscErrorCode ierr;
+
+  PetscFunctionBegin;
+  ierr = TSDestroy(&full->ts);CHKERRQ(ierr);
+  ierr = VecDestroy(&full->UV);CHKERRQ(ierr);
+  ierr = VecDestroy(&full->UF);CHKERRQ(ierr);
+  ierr = VecDestroy(&full->VF);CHKERRQ(ierr);
+  ierr = VecScatterDestroy(&full->scatterU);CHKERRQ(ierr);
+  ierr = VecScatterDestroy(&full->scatterV);CHKERRQ(ierr);
+  PetscFunctionReturn(0);
+}
+
+#undef __FUNCT__
+#define __FUNCT__ "TSDestroy_DAESimple_Full"
+PetscErrorCode TSDestroy_DAESimple_Full(TS ts)
+{
+  TS_DAESimple    *dae = (TS_DAESimple*)ts->data;
+  TS_DAESimple_Full *full = (TS_DAESimple_Full*)dae->data;
+  PetscErrorCode ierr;
+
+  PetscFunctionBegin;
+  ierr = TSReset_DAESimple_Full(ts);CHKERRQ(ierr);
+  ierr = PetscFree(full);CHKERRQ(ierr);
+  PetscFunctionReturn(0);
+}
+
+#undef __FUNCT__
+#define __FUNCT__ "TSSetFromOptions_DAESimple_Full"
+PetscErrorCode TSSetFromOptions_DAESimple_Full(TS ts)
+{
+
+  PetscFunctionBegin;
+  PetscFunctionReturn(0);
+}
+
+#undef __FUNCT__
+#define __FUNCT__ "TSSolve_DAESimple_Full"
+PetscErrorCode TSSolve_DAESimple_Full(TS ts)
+{
+  PetscErrorCode      ierr;
+  TS_DAESimple        *tsdae = (TS_DAESimple*)ts->data;
+  TS_DAESimple_Full   *full = (TS_DAESimple_Full*)tsdae->data;
+
+  PetscFunctionBegin;
+  ierr = VecScatterBegin(full->scatterU,tsdae->U,full->UV,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
+  ierr = VecScatterEnd(full->scatterU,tsdae->U,full->UV,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
+  ierr = VecScatterBegin(full->scatterV,tsdae->V,full->UV,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
+  ierr = VecScatterEnd(full->scatterV,tsdae->V,full->UV,INSERT_VALUES,SCATTER_FORWARD);CHKERRQ(ierr);
+  ierr = TSSolve(full->ts,full->UV);CHKERRQ(ierr);
+  ierr = VecScatterBegin(full->scatterU,full->UV,tsdae->U,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
+  ierr = VecScatterEnd(full->scatterU,full->UV,tsdae->U,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
+  ierr = VecScatterBegin(full->scatterV,full->UV,tsdae->V,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
+  ierr = VecScatterEnd(full->scatterV,full->UV,tsdae->V,INSERT_VALUES,SCATTER_REVERSE);CHKERRQ(ierr);
+  PetscFunctionReturn(0);
+}
+
+#undef __FUNCT__
+#define __FUNCT__ "TSSetUp_DAESimple_Full"
+PetscErrorCode TSSetUp_DAESimple_Full(TS ts)
+{
+  PetscErrorCode       ierr;
+  TS_DAESimple         *tsdae = (TS_DAESimple*)ts->data;
+  TS_DAESimple_Full    *full = (TS_DAESimple_Full*)tsdae->data;
+  Vec                  tsrhs;
+  PetscInt             nU,nV,UVstart;
+  IS                   is;
+
+  PetscFunctionBegin;
+  ierr = TSCreate(PetscObjectComm((PetscObject)ts),&full->ts);CHKERRQ(ierr);
+  ierr = TSSetOptionsPrefix(full->ts,"dae_full_");CHKERRQ(ierr);
+  ierr = TSSetProblemType(full->ts,TS_NONLINEAR);CHKERRQ(ierr);
+  ierr = TSSetType(full->ts,TSROSW);CHKERRQ(ierr);
+  ierr = VecDuplicate(tsdae->U,&full->UF);CHKERRQ(ierr);
+  ierr = VecDuplicate(tsdae->V,&full->VF);CHKERRQ(ierr);
+
+  ierr = VecGetLocalSize(tsdae->U,&nU);CHKERRQ(ierr);
+  ierr = VecGetLocalSize(tsdae->V,&nV);CHKERRQ(ierr);
+  ierr = VecCreateMPI(PetscObjectComm((PetscObject)ts),nU+nV,PETSC_DETERMINE,&tsrhs);CHKERRQ(ierr);
+  ierr = VecDuplicate(tsrhs,&full->UV);CHKERRQ(ierr);
+
+  ierr = VecGetOwnershipRange(tsrhs,&UVstart,NULL);CHKERRQ(ierr);
+  ierr = ISCreateStride(PetscObjectComm((PetscObject)ts),nU,UVstart,1,&is);CHKERRQ(ierr);
+  ierr = VecScatterCreate(tsdae->U,NULL,tsrhs,is,&full->scatterU);CHKERRQ(ierr);
+  ierr = ISDestroy(&is);CHKERRQ(ierr);
+  ierr = ISCreateStride(PetscObjectComm((PetscObject)ts),nV,UVstart+nU,1,&is);CHKERRQ(ierr);
+  ierr = VecScatterCreate(tsdae->V,NULL,tsrhs,is,&full->scatterV);CHKERRQ(ierr);
+  ierr = ISDestroy(&is);CHKERRQ(ierr);
+  ierr = TSSetRHSFunction(full->ts,tsrhs,TSDAESimple_Full_TSRHSFunction,ts);CHKERRQ(ierr);
+  ierr = TSSetIFunction(full->ts,NULL,TSDAESimple_Full_TSIFunction,ts);CHKERRQ(ierr);
+  ierr = TSSetFromOptions(full->ts);CHKERRQ(ierr);
+  ierr = VecDestroy(&tsrhs);CHKERRQ(ierr);
+  PetscFunctionReturn(0);
+}
+
+/* ------------------------------------------------------------ */
+/*MC
+      TSDAESimple - Semi-explicit DAE solver
+
+   Level: advanced
+
+.seealso:  TSCreate(), TS, TSSetType(), TSCN, TSBEULER, TSThetaSetTheta(), TSThetaSetEndpoint()
+
+M*/
+#undef __FUNCT__
+#define __FUNCT__ "TSCreate_DAESimple_Full"
+PETSC_EXTERN PetscErrorCode TSCreate_DAESimple_Full(TS ts)
+{
+  TS_DAESimple    *tsdae;
+  TS_DAESimple_Full *full;
+  PetscErrorCode  ierr;
+
+  PetscFunctionBegin;
+  ts->ops->reset          = TSReset_DAESimple_Full;
+  ts->ops->destroy        = TSDestroy_DAESimple_Full;
+  ts->ops->setup          = TSSetUp_DAESimple_Full;
+  ts->ops->setfromoptions = TSSetFromOptions_DAESimple;
+  ts->ops->solve          = TSSolve_DAESimple;
+
+  ierr = PetscNewLog(ts,TS_DAESimple,&tsdae);CHKERRQ(ierr);
+  ts->data = (void*)tsdae;
+
+  tsdae->setfromoptions = TSSetFromOptions_DAESimple_Full;
+  tsdae->solve          = TSSolve_DAESimple_Full;
+  tsdae->destroy        = TSDestroy_DAESimple_Full;
+
+  ierr = PetscMalloc(sizeof(TS_DAESimple_Full),&full);CHKERRQ(ierr);
+  tsdae->data = full;
+
+  PetscFunctionReturn(0);
+}

src/ts/impls/semiexplicit/full/makefile

+
+ALL: lib
+
+CFLAGS   =
+FFLAGS   =
+SOURCEC  = full.c
+SOURCEF  =
+SOURCEH  =
+LIBBASE  = libpetscts
+MANSEC   = TS
+DIRS     = 
+LOCDIR   = src/ts/impls/semiexplicit/full
+
+include ${PETSC_DIR}/conf/variables
+include ${PETSC_DIR}/conf/rules
+include ${PETSC_DIR}/conf/test
+
+

src/ts/impls/semiexplicit/makefile

 SOURCEH  =
 LIBBASE  = libpetscts
 MANSEC   = TS
-DIRS     = reduced
+DIRS     = reduced full
 LOCDIR   = src/ts/impls/semiexplicit/
 
 include ${PETSC_DIR}/conf/variables

src/ts/impls/semiexplicit/reduced/reduced.c

    Solves F(U,V) for V and then computes f(U,V)
 
 */
-PetscErrorCode TSDAESimple_Reduced_TSFunction(TS ts,PetscReal t,Vec U,Vec F,void *actx)
+PetscErrorCode TSDAESimple_Reduced_TSFunction(TS tsinner,PetscReal t,Vec U,Vec F,void *actx)
 {
-  TS_DAESimple         *tsdae = (TS_DAESimple*)actx;
+  TS                   ts = (TS)actx;
+  TS_DAESimple         *tsdae = (TS_DAESimple*)ts->data;
   TS_DAESimple_Reduced *red = (TS_DAESimple_Reduced*)tsdae->data;
   PetscErrorCode       ierr;
+  DM                   dm;
+  PetscErrorCode       (*rhsfunction)(PetscReal,Vec,Vec,Vec,void*);
+  void                 *rhsfunctionctx;
 
-  PetscFunctionBeginUser;
+  PetscFunctionBegin;
   red->t = t;
   red->U = U;
   ierr   = SNESSolve(red->snes,NULL,tsdae->V);CHKERRQ(ierr);
-  ierr   = (*tsdae->f)(t,U,tsdae->V,F,tsdae->fctx);CHKERRQ(ierr);
+  ierr   = TSGetDM(ts,&dm);CHKERRQ(ierr);
+  ierr   = DMTSGetDAESimpleRHSFunction(dm,&rhsfunction,&rhsfunctionctx);CHKERRQ(ierr);
+  ierr   = (*rhsfunction)(t,U,tsdae->V,F,rhsfunctionctx);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
 
 */
 PetscErrorCode TSDAESimple_Reduced_SNESFunction(SNES snes,Vec V,Vec F,void *actx)
 {
-  TS_DAESimple         *tsdae = (TS_DAESimple*)actx;
+  TS                   ts=(TS)actx;
+  TS_DAESimple         *tsdae = (TS_DAESimple*)ts->data;
   TS_DAESimple_Reduced *red = (TS_DAESimple_Reduced*)tsdae->data;
   PetscErrorCode       ierr;
+  DM                   dm;
+  PetscErrorCode       (*ifunction)(PetscReal,Vec,Vec,Vec,void*);
+  void                 *ifunctionctx;
 
-  PetscFunctionBeginUser;
-  ierr = (*tsdae->F)(red->t,red->U,V,F,tsdae->Fctx);CHKERRQ(ierr);
+  PetscFunctionBegin;
+  ierr = TSGetDM(ts,&dm);CHKERRQ(ierr);
+  ierr = DMTSGetDAESimpleIFunction(dm,&ifunction,&ifunctionctx);
+  ierr = (*ifunction)(red->t,red->U,V,F,ifunctionctx);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
 
   Vec                  tsrhs;
 
   PetscFunctionBegin;
-
+  ierr = VecCopy(ts->vec_sol,tsdae->U);CHKERRQ(ierr);
   ierr = TSCreate(PetscObjectComm((PetscObject)ts),&red->ts);CHKERRQ(ierr);
+  ierr = TSSetOptionsPrefix(red->ts,"dae_reduced_ode_");CHKERRQ(ierr);
   ierr = TSSetProblemType(red->ts,TS_NONLINEAR);CHKERRQ(ierr);
   ierr = TSSetType(red->ts,TSEULER);CHKERRQ(ierr);
   ierr = VecDuplicate(tsdae->U,&tsrhs);CHKERRQ(ierr);
-  ierr = TSSetRHSFunction(red->ts,tsrhs,TSDAESimple_Reduced_TSFunction,tsdae);CHKERRQ(ierr);
+  ierr = TSSetRHSFunction(red->ts,tsrhs,TSDAESimple_Reduced_TSFunction,ts);CHKERRQ(ierr);
   ierr = TSSetFromOptions(red->ts);CHKERRQ(ierr);
   ierr = VecDestroy(&tsrhs);CHKERRQ(ierr);
 
   ierr = SNESCreate(PetscObjectComm((PetscObject)ts),&red->snes);CHKERRQ(ierr);
-  ierr = SNESSetOptionsPrefix(red->snes,"tsdaesimple_");CHKERRQ(ierr);
-  ierr = SNESSetFunction(red->snes,NULL,TSDAESimple_Reduced_SNESFunction,tsdae);CHKERRQ(ierr);
-  ierr = SNESSetJacobian(red->snes,NULL,NULL,SNESComputeJacobianDefault,tsdae);CHKERRQ(ierr);
+  ierr = SNESSetOptionsPrefix(red->snes,"dae_reduced_alg_");CHKERRQ(ierr);
+  ierr = SNESSetFunction(red->snes,NULL,TSDAESimple_Reduced_SNESFunction,ts);CHKERRQ(ierr);
+  ierr = SNESSetJacobian(red->snes,NULL,NULL,SNESComputeJacobianDefault,ts);CHKERRQ(ierr);
   ierr = SNESSetFromOptions(red->snes);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }

src/ts/impls/semiexplicit/semiexplicit.c

 {
   TS_DAESimple *tsdae = (TS_DAESimple*)ts->data;
   PetscErrorCode ierr;
+  DM             dm;
 
   PetscFunctionBegin;
-  tsdae->f    = f;
+  ierr = TSGetDM(ts,&dm);CHKERRQ(ierr);
+  ierr = DMTSSetDAESimpleRHSFunction(dm,f,ctx);CHKERRQ(ierr);
   tsdae->U    = U;
   ierr        = PetscObjectReference((PetscObject)U);CHKERRQ(ierr);
-  tsdae->fctx = ctx;
   PetscFunctionReturn(0);
 }
 
 {
   TS_DAESimple *tsdae = (TS_DAESimple*)ts->data;
   PetscErrorCode ierr;
+  DM             dm;
 
   PetscFunctionBegin;
-  tsdae->F    = F;
+  ierr = TSGetDM(ts,&dm);CHKERRQ(ierr);
+  ierr = DMTSSetDAESimpleIFunction(dm,F,ctx);CHKERRQ(ierr);
   tsdae->V    = V;
   ierr        = PetscObjectReference((PetscObject)V);CHKERRQ(ierr);
-  tsdae->Fctx = ctx;
   PetscFunctionReturn(0);
 }
 

src/ts/impls/semiexplicit/semiexplicit.h

   PetscErrorCode (*solve)(TS);
   PetscErrorCode (*destroy)(TS);
   PetscErrorCode (*view)(TS,PetscViewer);
-  PetscErrorCode (*f)(PetscReal,Vec,Vec,Vec,void*);
-  PetscErrorCode (*F)(PetscReal,Vec,Vec,Vec,void*);
   void           *fctx,*Fctx;
   void           *data;
 }TS_DAESimple;

src/ts/interface/tsregall.c

 PETSC_EXTERN PetscErrorCode TSCreate_RosW(TS);
 PETSC_EXTERN PetscErrorCode TSCreate_EIMEX(TS);
 PETSC_EXTERN PetscErrorCode TSCreate_DAESimple_Reduced(TS);
+PETSC_EXTERN PetscErrorCode TSCreate_DAESimple_Full(TS);
 
 #undef __FUNCT__
 #define __FUNCT__ "TSRegisterAll"
   ierr = TSRegister(TSARKIMEX,  TSCreate_ARKIMEX);CHKERRQ(ierr);
   ierr = TSRegister(TSROSW,     TSCreate_RosW);CHKERRQ(ierr);
   ierr = TSRegister(TSEIMEX,    TSCreate_EIMEX);CHKERRQ(ierr);
-  ierr = TSRegister(TSDAESIMPLE, TSCreate_DAESimple_Reduced);CHKERRQ(ierr);
+  ierr = TSRegister(TSDAESIMPLERED, TSCreate_DAESimple_Reduced);CHKERRQ(ierr);
+  ierr = TSRegister(TSDAESIMPLEFULL, TSCreate_DAESimple_Full);CHKERRQ(ierr);
   PetscFunctionReturn(0);
 }
 

src/ts/utils/dmts.c

 }
 
 #undef __FUNCT__
+#define __FUNCT__ "DMTSSetDAESimpleIFunction"
+/*@C
+   DMTSSetDAESimpleIFunction - set the nonlinear algebraic function for the semi-explicit TS solver
+
+   Not Collective
+
+   Input Arguments:
++  dm - DM to be used with TS
+.  func - nonlinear algebraic function, see TSSetDAESimpleSetIFunction() for calling sequence
+-  ctx - context for residual evaluation
+
+   Level: advanced
+
+   Note:
+   TSSetDAESimpleIFunction() is normally used, but it calls this function internally because the user context is actually
+   associated with the DM.  This makes the interface consistent regardless of whether the user interacts with a DM or
+   not. If DM took a more central role at some later date, this could become the primary method of setting the residual.
+
+.seealso: DMTSSetContext(), TSSetFunction(), DMTSSetJacobian()
+@*/
+PetscErrorCode DMTSSetDAESimpleIFunction(DM dm,PetscErrorCode (*func)(PetscReal,Vec,Vec,Vec,void*),void *ctx)
+{
+  PetscErrorCode ierr;
+  DMTS           tsdm;
+
+  PetscFunctionBegin;
+  PetscValidHeaderSpecific(dm,DM_CLASSID,1);
+  ierr = DMGetDMTSWrite(dm,&tsdm);CHKERRQ(ierr);
+  if (func) tsdm->ops->daesimpleifunction = func;
+  if (ctx)  tsdm->daesimpleifunctionctx = ctx;
+  PetscFunctionReturn(0);
+}
+
+#undef __FUNCT__
 #define __FUNCT__ "DMTSGetIFunction"
 /*@C
    DMTSGetIFunction - get TS implicit residual evaluation function
   PetscFunctionReturn(0);
 }
 
+#undef __FUNCT__
+#define __FUNCT__ "DMTSGetDAESimpleIFunction"
+/*@C
+   DMTSGetDAESimpleRHSFunction - gets nonlinear residual evaluation function for the algebraic part of the semi-explicit TS solver
+
+   Not Collective
+
+   Input Argument:
+.  dm - DM to be used with TS
+
+   Output Arguments:
++  func - residual evaluation function, see TSSetDAESimpleIFunction() for calling sequence
+-  ctx - context for residual evaluation
+
+   Level: advanced
+
+.seealso: DMTSSetContext(), DMTSSetFunction(), TSSetFunction()
+@*/
+PetscErrorCode DMTSGetDAESimpleIFunction(DM dm,PetscErrorCode (**func)(PetscReal,Vec,Vec,Vec,void*),void **ctx)
+{
+  PetscErrorCode ierr;
+  DMTS           tsdm;
+
+  PetscFunctionBegin;
+  PetscValidHeaderSpecific(dm,DM_CLASSID,1);
+  ierr = DMGetDMTS(dm,&tsdm);CHKERRQ(ierr);
+  if (func) *func = tsdm->ops->daesimpleifunction;
+  if (ctx)  *ctx = tsdm->daesimpleifunctionctx;
+  PetscFunctionReturn(0);
+}
 
 #undef __FUNCT__
 #define __FUNCT__ "DMTSSetRHSFunction"
 }
 
 #undef __FUNCT__
+#define __FUNCT__ "DMTSSetDAESimpleRHSFunction"
+/*@C
+   DMTSSetDAESimpleIFunction - set the ODE function for the semi-explicit TS solver
+
+   Not Collective
+
+   Input Arguments:
++  dm - DM to be used with TS
+.  func - ODE function for the semi-explicit solver, see TSSetDAESimpleSetRHSFunction() for calling sequence
+-  ctx - context for residual evaluation
+
+   Level: advanced
+
+   Note:
+   TSSetDAESimpleRHSFunction() is normally used, but it calls this function internally because the user context is actually
+   associated with the DM.  This makes the interface consistent regardless of whether the user interacts with a DM or
+   not. If DM took a more central role at some later date, this could become the primary method of setting the residual.
+
+.seealso: DMTSSetContext(), TSSetFunction(), DMTSSetJacobian()
+@*/
+PetscErrorCode DMTSSetDAESimpleRHSFunction(DM dm,PetscErrorCode (*func)(PetscReal,Vec,Vec,Vec,void*),void *ctx)
+{
+  PetscErrorCode ierr;
+  DMTS           tsdm;
+
+  PetscFunctionBegin;
+  PetscValidHeaderSpecific(dm,DM_CLASSID,1);
+  ierr = DMGetDMTSWrite(dm,&tsdm);CHKERRQ(ierr);
+  if (func) tsdm->ops->daesimplerhsfunction = func;
+  if (ctx)  tsdm->daesimplerhsfunctionctx = ctx;
+  PetscFunctionReturn(0);
+}
+
+#undef __FUNCT__
 #define __FUNCT__ "DMTSGetSolutionFunction"
 /*@C
    DMTSGetSolutionFunction - gets the TS solution evaluation function
 }
 
 #undef __FUNCT__
+#define __FUNCT__ "DMTSGetDAESimpleRHSFunction"
+/*@C
+   DMTSGetDAESimpleRHSFunction - gets residual evaluation function for the ODE part of the semi-explicit TS solver
+
+   Not Collective
+
+   Input Argument:
+.  dm - DM to be used with TS
+
+   Output Arguments:
++  func - residual evaluation function, see TSSetDAESimpleRHSFunction() for calling sequence
+-  ctx - context for residual evaluation
+
+   Level: advanced
+
+.seealso: DMTSSetContext(), DMTSSetFunction(), TSSetFunction()
+@*/
+PetscErrorCode DMTSGetDAESimpleRHSFunction(DM dm,PetscErrorCode (**func)(PetscReal,Vec,Vec,Vec,void*),void **ctx)
+{
+  PetscErrorCode ierr;
+  DMTS           tsdm;
+
+  PetscFunctionBegin;
+  PetscValidHeaderSpecific(dm,DM_CLASSID,1);
+  ierr = DMGetDMTS(dm,&tsdm);CHKERRQ(ierr);
+  if (func) *func = tsdm->ops->daesimplerhsfunction;
+  if (ctx)  *ctx = tsdm->daesimplerhsfunctionctx;
+  PetscFunctionReturn(0);
+}
+
+#undef __FUNCT__
 #define __FUNCT__ "DMTSSetIJacobian"
 /*@C
    DMTSSetIJacobian - set TS Jacobian evaluation function
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.