[petsc-users] TS for explicit equations

Alejandro D Otero aotero at fi.uba.ar
Thu Jul 6 09:10:40 CDT 2017


Hello,
I'trying to solve an ODE system using PETSc TS through its wrapper
petsc4py, and I'm having problems with the setting. The problem is of the
kind: u_t = G(t, u) with u being a vector with DoF from a FEM problem and G
is computed by a series of matrix operations and manipulations, which are
implemented for distributed domains.
I set up the problem as explicit using the TSSetRHSFunction, but when I try
to solve it using explicit solvers I got a weird behavior: the unknown
variable (u above) is never updated (I checked it inside the RHS function I
provided), despite having a non null evaluation of f = G(t, u). This
happens for RK, SSP, SUNDIALS (adams), but strangely not for FE (where u is
updated in every step). That is what disturbs me, because I'd like to use
the more sophisticated solvers.

I followed this steps in order to get the time evolution of u:

# Create and Setup time stepper
ts = PETSc.TS().create(comm=self.comm)

# Set problem type
ts.setProblemType(ts.ProblemType.NONLINEAR)

# Set solver type
ts.setType(ts.Type.RK)

# Set initial time
ts.setTime(sTime)

# Set max time or max number of iterations
ts.setDuration(eTime, max_steps=maxSteps)

# Set how to treat the final step
ts.setExactFinalTime(ts.ExactFinalTime.INTERPOLATE)

# Allocate variables for internal computations of the RHS
vector 'U' for the solution
vector 'f' for the RHS evaluation

# Set rhs function
ts.setRHSFunction(self.evalRHSFunction, self.g)
(where evalRHSFunction has the form f(self, ts, t, Vort, f))

# Set fuction to be run after each step
ts.setPostStep(convergedStepFunction)

# Set from other command line options
ts.setFromOptions()

# Set initial conditions in vector 'U'

# Run TS
ts.solve(U)

Is there anything am I doing wrong?
Thanks in advance,

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


More information about the petsc-users mailing list