Thanks. I see the example in petsc 
(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?

Thanks
Miguel

From: Barry Smith <[email protected]>
Date: Wednesday, September 30, 2020 at 10:19 AM
To: "Salazar De Troya, Miguel" <[email protected]>, "Abhyankar, Shrirang 
G" <[email protected]>, Emil Constantinescu <[email protected]>
Cc: Satish Balay via petsc-users <[email protected]>
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 
<[email protected]<mailto:[email protected]>> 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

Reply via email to