[petsc-users] TSSetIFunction
Jin, Shuangshuang
Shuangshuang.Jin at pnnl.gov
Wed Mar 20 16:47:51 CDT 2013
Hi, I use src\ts\examples\tutorials\ex19.c as an example to use PETSc DAE solver. I get the following problem while running my code:
[d3m956 at olympus ss00]$ make
mpicxx -I/pic/projects/ds/petsc-dev/include -I/pic/projects/ds/petsc-dev/arch-complex/include -I/share/apps/openmpi/1.5.4/gcc/4.1.2/include -g -c -o simulation.o simulation.C
simulation.C: In member function �PetscErrorCode Simulation::simu(_p_Mat*, _p_Mat*, _p_Mat*)’:
simulation.C:80: error: argument of type �PetscErrorCode (Simulation::)(_p_TS*, PetscReal, _p_Vec*, _p_Vec*, _p_Vec*, void*)’ does not match �PetscErrorCode (*)(_p_TS*, PetscReal, _p_Vec*, _p_Vec*, _p_Vec*, void*)’
make: *** [simulation.o] Error 1
What does it mean?
The IFunction is copied from ex19.c,
PetscErrorCode Simulation::IFunction(TS ts,PetscReal t,Vec X,Vec Xdot,Vec F,void *ctx)
{
PetscErrorCode ierr;
PetscScalar *x,*xdot,*f;
PetscFunctionBegin;
ierr = VecGetArray(X,&x);CHKERRQ(ierr);
ierr = VecGetArray(Xdot,&xdot);CHKERRQ(ierr);
ierr = VecGetArray(F,&f);CHKERRQ(ierr);
f[0] = xdot[0] + x[1];
f[1] = (x[1]*x[1]*x[1]/3 - x[1])-x[0];
ierr = VecRestoreArray(X,&x);CHKERRQ(ierr);
ierr = VecRestoreArray(Xdot,&xdot);CHKERRQ(ierr);
ierr = VecRestoreArray(F,&f);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
And in Simulation::simu(Mat f1, Mat f2, Mat f3), I have:
ierr = TSSetIFunction(ts,NULL,IFunction,&user);CHKERRQ(ierr);
Thanks,
Shuangshuang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130320/c96264e5/attachment-0001.html>
More information about the petsc-users
mailing list