[petsc-users] Solution update is not working in TS

Konstantinos Kontzialis ckontzialis at lycos.com
Mon Nov 7 08:02:20 CST 2011


Dear all,

  I have moved to petsc version 3.2 from 3.1 and I did the modifications 
needed
for running my code. However, I see that some things are not working in 
v3.2.

For instance, if I want to apply and explicit euler method to the Euler 
equations of
gas dynamics discretized with a high order method I do the following:

/* Initialize the solution vector */
     ierr = VecCreateGhost(sys.comm, sys.ldof, sys.gdof, sys.ghdof,
             sys.dof_gloInd, &sys.gsv);
     CHKERRQ(ierr);

/* Initialize the residual vector*/
ierr = VecCreateMPI(sys.comm, sys.ldof, sys.gdof, &sys.gres0);
     CHKERRQ(ierr);


/*Apply the initial conditions*/

/* Set up TS*/
         ierr = TSCreate(sys.comm, &sys.ts);
     CHKERRQ(ierr);

     ierr = TSSetProblemType(sys.ts, TS_NONLINEAR);
     CHKERRQ(ierr);

     ierr = TSSetSolution(sys.ts, sys.gsv);
     CHKERRQ(ierr);

     ierr = TSSetRHSFunction(sys.ts, sys.gres0, base_residual_explicit, 
&sys);
     CHKERRQ(ierr);

     ierr = TSSetInitialTimeStep(sys.ts, sys.con->tm, sys.con->dt);
     CHKERRQ(ierr);

     ierr = TSSetDuration(sys.ts, 100e+6, sys.con->etime);
     CHKERRQ(ierr);

     ierr = TSSetFromOptions(sys.ts);
     CHKERRQ(ierr);

     ierr = TSMonitorSet(sys.ts, monitor, &sys, PETSC_NULL);
     CHKERRQ(ierr);

     ierr = TSSolve(sys.ts, sys.gsv, &sys.con->etime);
     CHKERRQ(ierr);

I run with:

mpiexec -n 8 valgrind ./hoac cylinder -llf_flux -n_out 5 -end_time 1.0 
-dt 0.01 -ts_type euler -gl

and I get:

Timestep   0: dt = 0.01, T = 0, Res[rho] = 0.0647535, Res[rhou] = 
0.0561559, Res[rhov] = 0.0327505, Res[E] = 0.162518, CFL = 0.414652


Timestep   1: dt = 0.01, T = 0.01, Res[rho] = 0.0647535, Res[rhou] = 
0.0561559, Res[rhov] = 0.0327505, Res[E] = 0.162518, CFL = 0.414652


Timestep   2: dt = 0.01, T = 0.02, Res[rho] = 0.0647535, Res[rhou] = 
0.0561559, Res[rhov] = 0.0327505, Res[E] = 0.162518, CFL = 0.414652


Timestep   3: dt = 0.01, T = 0.03, Res[rho] = 0.0647535, Res[rhou] = 
0.0561559, Res[rhov] = 0.0327505, Res[E] = 0.162518, CFL = 0.414652


Timestep   4: dt = 0.01, T = 0.04, Res[rho] = 0.0647535, Res[rhou] = 
0.0561559, Res[rhov] = 0.0327505, Res[E] = 0.162518, CFL = 0.414652


Timestep   5: dt = 0.01, T = 0.05, Res[rho] = 0.0647535, Res[rhou] = 
0.0561559, Res[rhov] = 0.0327505, Res[E] = 0.162518, CFL = 0.414652


Timestep   6: dt = 0.01, T = 0.06, Res[rho] = 0.0647535, Res[rhou] = 
0.0561559, Res[rhov] = 0.0327505, Res[E] = 0.162518, CFL = 0.414652


Timestep   7: dt = 0.01, T = 0.07, Res[rho] = 0.0647535, Res[rhou] = 
0.0561559, Res[rhov] = 0.0327505, Res[E] = 0.162518, CFL = 0.414652


Timestep   8: dt = 0.01, T = 0.08, Res[rho] = 0.0647535, Res[rhou] = 
0.0561559, Res[rhov] = 0.0327505, Res[E] = 0.162518, CFL = 0.414652


Timestep   9: dt = 0.01, T = 0.09, Res[rho] = 0.0647535, Res[rhou] = 
0.0561559, Res[rhov] = 0.0327505, Res[E] = 0.162518, CFL = 0.414652


Timestep  10: dt = 0.01, T = 0.1, Res[rho] = 0.0647535, Res[rhou] = 
0.0561559, Res[rhov] = 0.0327505, Res[E] = 0.162518, CFL = 0.414652

which seems that my solution vector sys.gsv is not updated at every 
step, and moreover, when I print the solution ,I see the values got from 
the initial conditions.

What am I doing wrong?

Thanks

Kostas


More information about the petsc-users mailing list