static char help[] = "Solves DAE with integrator only on non-algebraic terms \n"; #include /* \dot{U} = f(U,V) F(U,V) = 0 Same as ex6.c and ex7.c except calls the TSROSW integrator on the entire DAE */ /* f(U,V) = U + V */ PetscErrorCode f(PetscReal t,Vec UV,Vec F) { const PetscScalar *u,*v; PetscScalar *f; PetscInt n,i; PetscFunctionBeginUser; PetscCall(VecGetLocalSize(UV,&n)); n = n/2; PetscCall(VecGetArrayRead(UV,&u)); v = u + n; PetscCall(VecGetArrayWrite(F,&f)); for (i=0; if)(t,UV,F)); PetscFunctionReturn(0); } /* Defines the nonlinear function that is passed to the time-integrator */ PetscErrorCode TSFunctionI(TS ts,PetscReal t,Vec UV,Vec UVdot,Vec F,void *actx) { AppCtx *ctx = (AppCtx*)actx; PetscFunctionBeginUser; PetscCall(VecCopy(UVdot,F)); PetscCall((*ctx->F)(t,UV,F)); PetscFunctionReturn(0); } /*TEST test: args: -ts_view test: suffix: 2 args: -snes_lag_jacobian 2 -ts_view TEST*/