Re: [petsc-users] TS for explicit equations

2017-07-07 Thread Lisandro Dalcin
On 6 July 2017 at 17:10, Alejandro D Otero  wrote:
>
> # Set rhs function
> ts.setRHSFunction(self.evalRHSFunction, self.g)
> (where evalRHSFunction has the form f(self, ts, t, Vort, f))
>

Please double check that the RHS function "outputs" the result in the
passed-in vector "f", my guess is that you are just returning a new
vector that is eventually ignored.


-- 
Lisandro Dalcin

Research Scientist
Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
Extreme Computing Research Center (ECRC)
King Abdullah University of Science and Technology (KAUST)
http://ecrc.kaust.edu.sa/

4700 King Abdullah University of Science and Technology
al-Khawarizmi Bldg (Bldg 1), Office # 0109
Thuwal 23955-6900, Kingdom of Saudi Arabia
http://www.kaust.edu.sa

Office Phone: +966 12 808-0459


[petsc-users] TS for explicit equations

2017-07-06 Thread Alejandro D Otero
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