Although TSMonitor may also work, I would suggest to use TSPostStep for the 
customized convergence check. TSPostStep allows to modify the system or change 
the solver settings. It skips the time steps that are rolled back (e.g. 
rejected time steps), but TSMonitor is applied to every time step including the 
rejected ones.

For time derivative, I would just do a RHS function evaluation if the extra 
cost is acceptable. If not, then I would consider caching the current solution 
in TSPostStep.

Hong (Mr.)

On Apr 30, 2021, at 6:36 PM, Salazar De Troya, Miguel via petsc-users 
<[email protected]<mailto:[email protected]>> wrote:

Thanks, can you elaborate on computing the time derived? TSMonitor only gives 
me the information at the current time step. I guess I could store a copy of 
the solution in the context so I can use it in the next call to compute the 
difference. On the other hand, I could also store the norm of the RHS function 
(since this is equal to the time derivative \frac{\partial \phi}{\partial t}).

Miguel

From: Mark Adams <[email protected]<mailto:[email protected]>>
Date: Friday, April 30, 2021 at 3:56 PM
To: "Salazar De Troya, Miguel" 
<[email protected]<mailto:[email protected]>>
Cc: "Zhang, Hong via petsc-users" 
<[email protected]<mailto:[email protected]>>
Subject: Re: [petsc-users] Detecting steady-state with TS

You could add a 
https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSMonitorSet.html<https://urldefense.us/v3/__https:/www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSMonitorSet.html__;!!G2kpM7uM-TzIFchu!hG6eR--4AkxoFHnPn3N8DJF2pPoVkaJT0f6vy9E2qTLMZ0TiqDR_kr5wbAbwapvuLtnSGw$>
 method, compute the time derived and decide how to declare converged.

Then set converged 
(https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSSetConvergedReason.html<https://urldefense.us/v3/__https:/www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSSetConvergedReason.html__;!!G2kpM7uM-TzIFchu!hG6eR--4AkxoFHnPn3N8DJF2pPoVkaJT0f6vy9E2qTLMZ0TiqDR_kr5wbAbwaptYI8kTFA$>)
 with TS_CONVERGED_USER

That should cause TS to wrap up the solve and exit cleanly.

Mark


On Thu, Apr 29, 2021 at 3:27 PM Salazar De Troya, Miguel via petsc-users 
<[email protected]<mailto:[email protected]>> wrote:
I am solving the signed distance equation

\frac{\partial \phi}{\partial t} + sign (\phi_{0})(|\nabla \phi| - 1) = 0

using a Local Discontinuous Galerkin (LDG) method as described in 
https://www.sciencedirect.com/science/article/pii/S0021999110005255<https://urldefense.us/v3/__https:/www.sciencedirect.com/science/article/pii/S0021999110005255__;!!G2kpM7uM-TzIFchu!hG6eR--4AkxoFHnPn3N8DJF2pPoVkaJT0f6vy9E2qTLMZ0TiqDR_kr5wbAbwapsr29KQOw$>

I am interested in solving it close to steady state. I was hoping I could 
measure how close to steady state the solution is by using the 
TSSetEventHandler infrastructure, but the handler does not have information on 
the time derivative. I looked at TSPSEUDO, but it forces me to use an implicit 
method, which I cannot provide because how the LDG method works (it calculates 
the fluxes solving additional equations). This makes me wonder if the LDG 
method is the best choice, so I am open to suggestions.

Given my current progress with the LDG approach, I am wondering if there is a 
way to solve to steady state using explicit algorithms such as Runge-Kutta.

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