[petsc-users] Adaptive time stepping for implicit solvers

Barry Smith bsmith at petsc.dev
Wed Sep 30 14:27:32 CDT 2020



> On Sep 30, 2020, at 2:05 PM, Salazar De Troya, Miguel <salazardetro1 at llnl.gov> wrote:
> 
> Thanks. I see the example in petsc (https://www.mcs.anl.gov/petsc/petsc-current/src/ts/tutorials/ex40.c.html <https://www.mcs.anl.gov/petsc/petsc-current/src/ts/tutorials/ex40.c.html>) modifies the solution vector in the PostEventFunction(), but there is no straightforward way to modify the RHSFunction(). Can one call TSSetRHSFunction() inside PostEventFunction() and set it for another routine? Maybe one can just change a variable in the context which is also used in the original RHSFunction(). Even if I could, such a sudden change in the RHS can make the current solution oscillate heavily. Will the TS solver adapt the time step to accommodate for this drastic change?

  You should be able to do any of those things to change the function.

   Since PETSc uses multi-stage methods after the event is detected the new ODE is now solved with an initial time of the located event time so it will just start solving the new ODE "from scratch" and hence won't see the old ODE so I don't think the solution should oscillate (unless your new ODE has large oscillations and needs a much smaller time step), if you need a smaller time step after the event then you can just set the new smaller tilmestep in your post event function.

   Barry


>  
> Thanks
> Miguel
>  
> From: Barry Smith <bsmith at petsc.dev <mailto:bsmith at petsc.dev>>
> Date: Wednesday, September 30, 2020 at 10:19 AM
> To: "Salazar De Troya, Miguel" <salazardetro1 at llnl.gov <mailto:salazardetro1 at llnl.gov>>, "Abhyankar, Shrirang G" <shrirang.abhyankar at pnnl.gov <mailto:shrirang.abhyankar at pnnl.gov>>, Emil Constantinescu <emconsta at mcs.anl.gov <mailto:emconsta at mcs.anl.gov>>
> Cc: Satish Balay via petsc-users <petsc-users at mcs.anl.gov <mailto:petsc-users at mcs.anl.gov>>
> Subject: Re: [petsc-users] Adaptive time stepping for implicit solvers
>  
>  
>   You might consider using the Event feature of TS to manage this. It detects when your "indicator function" changes sign and stops the integration right at that point allowing you to change your ODE or do what ever you need. It allows managing discontinuous changes in the ODE without needing smoothing (that messes up the solution). 
>  
>   You would write an indicator function that depends on "solution of heat equation equal to a given parameter"
>  
> I am including Shri and Emil on this message because they understand the event handling the best (Shri wrote it).
>   
>   Barry
>  
> 
> 
>> On Sep 30, 2020, at 11:58 AM, Salazar De Troya, Miguel via petsc-users <petsc-users at mcs.anl.gov <mailto:petsc-users at mcs.anl.gov>> wrote:
>>  
>> Hello,
>>  
>> I have a heat equation with a right-hand side coefficient that changes sign when a certain condition is met (solution of heat equation equal to a given parameter). I am thinking of modeling the sign change with a smoothed-out Heaviside approximation and let the solver adjust the time step to capture the sudden transition. Given that it is a heat equation, I am interested in using an implicit solver. Which ones in the TS suite also have adaptive capabilities?
>>  
>> Thanks
>> Miguel
>>  
>> Miguel A. Salazar de Troya
>> Postdoctoral Researcher, Lawrence Livermore National Laboratory
>> B141
>> Rm: 1085-5
>> Ph: 1(925) 422-6411

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200930/a40b274a/attachment.html>


More information about the petsc-users mailing list