[petsc-dev] MatSetValuesStencil analogue in petsc4py

Lisandro Dalcin dalcinl at gmail.com
Thu Nov 19 07:01:01 CST 2015

On 19 November 2015 at 11:41, Chris Eldred <chris.eldred at gmail.com> wrote:
> Hey Jed,
> I will give that a look today and see what I can do.
> On a more general note, what I would really like to be able to do is
> use petsc4py as a driver script that just calls PETSc functions, and
> do the computationally expensive parts such as stiffness matrix
> assembly and load vector assembly in C.
> To this end, is it possible to create a PETSc matrix or vector in
> Python, and then pass them to a C function that modifies them? Then
> MatSetValues would be called in C, but the AssemblyBegin/AssemblyEnd
> pairs (and Matrix creation, etc) could be called in Python.

Please look at the example in demo/wrap-swig and demo/wrap-cython

Lisandro Dalcin
Research Scientist
Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
Numerical Porous Media Center (NumPor)
King Abdullah University of Science and Technology (KAUST)

4700 King Abdullah University of Science and Technology
al-Khawarizmi Bldg (Bldg 1), Office # 4332
Thuwal 23955-6900, Kingdom of Saudi Arabia

Office Phone: +966 12 808-0459

More information about the petsc-dev mailing list