<div dir="ltr">You cannot use a member function as a callback. You can (with almost all compilers) use a _static_ member function. Note that static member functions do not have a "this" pointer. The void* argument in the callback should be set to the class so that you can use it as a "this" pointer.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Mar 20, 2013 at 4:47 PM, Jin, Shuangshuang <span dir="ltr"><<a href="mailto:Shuangshuang.Jin@pnnl.gov" target="_blank">Shuangshuang.Jin@pnnl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<font face="Calibri, sans-serif">
<div>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:</div>
<div><font face="Times New Roman, serif"> </font></div>
<div>[d3m956@olympus ss00]$ make</div>
<div>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</div>
<div>simulation.C: In member function ‘PetscErrorCode Simulation::simu(_p_Mat*, _p_Mat*, _p_Mat*)’:</div>
<div>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*)’</div>
<div>make: *** [simulation.o] Error 1</div>
<div><font face="Times New Roman, serif"> </font></div>
<div>What does it mean?</div>
<div><font face="Times New Roman, serif"> </font></div>
<div>The IFunction is copied from ex19.c,</div>
<div><font face="Times New Roman, serif"> </font></div>
<div>PetscErrorCode Simulation::IFunction(TS ts,PetscReal t,Vec X,Vec Xdot,Vec F,void *ctx)</div>
<div>{</div>
<div> PetscErrorCode ierr;</div>
<div> PetscScalar *x,*xdot,*f;</div>
<div> </div>
<div> PetscFunctionBegin;</div>
<div> ierr = VecGetArray(X,&x);CHKERRQ(ierr);</div>
<div> ierr = VecGetArray(Xdot,&xdot);CHKERRQ(ierr);</div>
<div> ierr = VecGetArray(F,&f);CHKERRQ(ierr);</div>
<div> f[0] = xdot[0] + x[1];</div>
<div> f[1] = (x[1]*x[1]*x[1]/3 - x[1])-x[0];</div>
<div> ierr = VecRestoreArray(X,&x);CHKERRQ(ierr);</div>
<div> ierr = VecRestoreArray(Xdot,&xdot);CHKERRQ(ierr);</div>
<div> ierr = VecRestoreArray(F,&f);CHKERRQ(ierr);</div>
<div> PetscFunctionReturn(0);</div>
<div>}</div>
<div><font face="Times New Roman, serif"> </font></div>
<div>And in Simulation::simu(Mat f1, Mat f2, Mat f3), I have: </div>
<div><font face="Times New Roman, serif"> </font></div>
<div>ierr = TSSetIFunction(ts,NULL,IFunction,&user);CHKERRQ(ierr);</div>
<div><font face="Times New Roman, serif"> </font></div>
<div>Thanks,</div>
<div>Shuangshuang</div>
<div><font face="Times New Roman, serif"> </font></div>
<div><font face="Times New Roman, serif"> </font></div>
</font>
</div>
</blockquote></div><br></div>