[petsc-users] TS question 1: how to stop explicit methods because they do not use SNES(VI)?
Emil Constantinescu
emconsta at mcs.anl.gov
Tue Feb 14 14:55:42 CST 2017
On 2/14/17 2:33 PM, Zhang, Hong wrote:
> I think many users (including me) would like to start with academic examples, e.g. u_t=f(u)+g(u), when they try to learn PETSc TS solvers. This simple form allows for easy switch between all kinds of different integration methods.
Right, but then you can just write an if statement along the lines in
ex31.c: (this was before RHSJacobian and it's not intended for IMEX)
TSGetType(ts,&time_scheme);
if ((!strcmp(time_scheme,TSEULER)) || (!strcmp(time_scheme,TSRK)) ||
(!strcmp(time_scheme,TSSSP))) {
/* Explicit time-integration -> specify right-hand side function ydot =
f(y) */
TSSetRHSFunction(ts,NULL,RHSFunction,&ptype[0]);
} else if ((!strcmp(time_scheme,TSTHETA)) ||...
(!strcmp(time_scheme,TSARKIMEX))) {
/* Implicit time-integration -> specify left-hand side function
ydot-f(y) = 0 */
/* and its Jacobian function */
TSSetIFunction(ts,NULL,IFunction,&ptype[0]);
TSSetIJacobian(ts,Jac,Jac,IJacobian,&ptype[0]);
}
This should not be a performance bottleneck. IFunction can be a wrapper
of the RHSFunction so not too much extra coding.
Emil
> Experienced users or experts who need to solve DAEs or complicate problems involving nontrivial mass matrix should be encouraged to try IFunction/IJacobian. Of course, we need better documentation to help them realize the switching is not always possible. Personally it took me a long time to get used to the IFunction business since I had been using u_t=f(u)+g(u) for a couple years before I jumped on PETSc. If we add support for this simple form, the learning curve would be less steep than it currently is.
>
> Hong (Mr.)
>
>> On Feb 14, 2017, at 11:55 AM, Jed Brown <jed at jedbrown.org> wrote:
>>
>> Barry Smith <bsmith at mcs.anl.gov> writes:
>>> Hence my suggestion to have TSSetLeftHandSideFunction() (or Jed's suggestion to have multiple Right Hand side functions) this will allow comparison of implicit, explicit, imex without recompiling (which we don't have currently) for the case with no mass matrix. With a mass matrix, unless we use mass lumping and have a TSSetMassMatrix() you cannot switch to full explicit, but that is due to mathematics, not the interface.
>>
>> Who in reality has a problem that looks like
>>
>> u_t = f(u) + g(u) + h(u)
>>
>> where it may make sense to move some of this to the left (implicit)?
>> I'm concerned that this isn't natural for many applications so adding an
>> interface would be solving a problem that doesn't really exist outside
>> perhaps a few academic examples.
More information about the petsc-users
mailing list