[petsc-users] [petsc4py] a problem with computeRHSFunctionLinear interface?

Lisandro Dalcin dalcinl at gmail.com
Thu Aug 18 02:20:59 CDT 2016


Dear Francesco, sorry for the late answer, I missed your email.

You have to do it this way:

        ts.setRHSFunction(PETSc.TS.computeRHSFunctionLinear)
        ts.setRHSJacobian(PETSc.TS.computeRHSJacobianConstant, J=A, P=A)

I.e, you have to set unbound methods, not instance methods as you did
in your original code. Additionally, do not pass "args" nor "kargs".


On 11 August 2016 at 10:36, Francesco Caimmi <francesco.caimmi at polimi.it> wrote:
> Dear all,
>
> I was trying to reproduce /ts/examples/tutorials/ex4.c in python to learn how
> to use TS solvers; the example uses the function TSComputeRHSFunctionLinear.
> However I get an error when running my code (attached in case you want to look
> at it), when I call ts.solve.
>
> Here is the trace:
> [fcaimmi at Wotan 2645] > ./ts_ex4.py
> Solving a linear TS problem, number of processors =  1
> Timestep  0 : time = 0.0  2-norm error = 1.14956855594e-08  max norm error = 0
> Traceback (most recent call last):
>   File "./ts_ex4.py", line 473, in <module>
>     main(m = m, debug = debug)
>   File "./ts_ex4.py", line 340, in main
>     ts.solve(u)
>   File "PETSc/TS.pyx", line 568, in petsc4py.PETSc.TS.solve
> (src/petsc4py.PETSc.c:188927)
>   File "PETSc/petscts.pxi", line 221, in petsc4py.PETSc.TS_RHSFunction
> (src/petsc4py.PETSc.c:35490)
>   File "PETSc/TS.pyx", line 189, in petsc4py.PETSc.TS.computeRHSFunctionLinear
> (src/petsc4py.PETSc.c:181611)
> TypeError: computeRHSFunctionLinear() takes exactly 3 positional arguments (5
> given)
>
> I cannot understand if there is a problem with my code or if the problem is in
> computeRHSFunctionLinear interface.
>
>  I checked https://bitbucket.org/petsc/petsc4py/ and the interface to
> computeRHSFunctionLinear  has three arguments, however I am not that much into
> petsc4py to tell how it gets called.
>
> I am on Petsc Release Version 3.7.3
>
> Thank you for your time.
>
> Best,
> --
> Francesco Caimmi
>
> Laboratorio di Ingegneria dei Polimeri
> http://www.chem.polimi.it/polyenglab/
>
> Politecnico di Milano - Dipartimento di Chimica,
> Materiali e Ingegneria Chimica “Giulio Natta”
>
> P.zza Leonardo da Vinci, 32
> I-20133 Milano
> Tel. +39.02.2399.4711
> Fax +39.02.7063.8173
>
> francesco.caimmi at polimi.it
> Skype: fmglcaimmi (please arrange meetings by e-mail)



-- 
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


More information about the petsc-users mailing list