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