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 ARKIMEX integrator on the entire DAE */ /* f(U,V) = U + V */ PetscErrorCode f(PetscReal t,Vec UV,Vec F) { PetscErrorCode ierr; const PetscScalar *u,*v; PetscScalar *f; PetscInt n,i; PetscFunctionBeginUser; ierr = VecGetLocalSize(UV,&n);CHKERRQ(ierr); n = n/2; ierr = VecGetArrayRead(UV,&u);CHKERRQ(ierr); v = u + n; ierr = VecGetArray(F,&f);CHKERRQ(ierr); for (i=0; if)(t,UV,F);CHKERRQ(ierr); 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; PetscErrorCode ierr; PetscFunctionBeginUser; ierr = VecCopy(UVdot,F);CHKERRQ(ierr); ierr = (*ctx->F)(t,UV,F);CHKERRQ(ierr); PetscFunctionReturn(0); }