[petsc-users] TSSetTimeStep or -ts_dt not working
    Ali Berk Kahraman 
    aliberkkahraman at yahoo.com
       
    Wed Oct 11 12:12:50 CDT 2017
    
    
  
Hello All,
I am trying to use timesteppers, however I have a problem. Whenever I 
want to set a dt for the timstepping integration, I cannot succeed. 
Neither the function TSSetTimeStep nor the command line option seems to 
work. Using either of them(but not at the same time) and setting it to 
1, when I call TSGetTimeStep to learn the value of dt, it gives me the 
answer 0.002871. Perhaps this is the default value, however I cannot 
work with this, since the equation I have is slowly evolving.
Any ideas what might be causing this?
The part of the code I use,
PetscReal time=0, timestep=1;
     int maxsteps=30;
     float maxtime=300;
         TS ts;
         ierr= TSCreate(PETSC_COMM_WORLD,&ts);
         CHKERRQ(ierr);
         ierr= TSSetProblemType(ts,TS_LINEAR);
         CHKERRQ(ierr);
         ierr= TSSetSolution(ts, dummyvec);
         CHKERRQ(ierr);
         ierr= TSSetType(ts,TSRK);
         CHKERRQ(ierr);
         ierr= TSSetTime(ts,time);
         CHKERRQ(ierr);
         ierr= TSSetTimeStep(ts,timestep);
         CHKERRQ(ierr);
         ierr=TSSetExactFinalTime(ts,TS_EXACTFINALTIME_STEPOVER);
         CHKERRQ(ierr);
         TSSetMaxSteps(ts,maxsteps);
         TSSetMaxTime(ts,maxtime);
         ierr=TSSetFromOptions(ts);CHKERRQ(ierr);
         TSSetRHSFunction(ts,residual,
                          FormRHSFunction,&mycontext);
         ierr= TSSolve(ts,uJi);
         CHKERRQ(ierr);
         TSView(ts,PETSC_VIEWER_STDOUT_SELF);
         TSConvergedReason reason;
         ierr=TSGetConvergedReason(ts,&reason);CHKERRQ(ierr);
         printf("Why Converged: %d\n",reason);
         PetscReal usedtimestep;
         TSGetTimeStep(ts,&usedtimestep);
         printf("Used timestep: %f\n",usedtimestep);
    
    
More information about the petsc-users
mailing list