[petsc-dev] MatSetValuesStencil analogue in petsc4py

Chris Eldred chris.eldred at gmail.com
Thu Nov 19 02:41:56 CST 2015


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.

-Chris

On Wed, Nov 18, 2015 at 8:27 PM, Jed Brown <jed at jedbrown.org> wrote:
> Nathan Collier <nathaniel.collier at gmail.com> writes:
>> ack MatSetValuesStencil
>>
>> returns
>>
>> src/PETSc/petscmat.pxi
>> 222:    int
>> MatSetValuesStencil(PetscMat,PetscInt,PetscMatStencil[],PetscInt,PetscMatStencil[],PetscScalar[],PetscInsertMode)
>> 1027:        CHKERR( MatSetValuesStencil(A,
>>
>> but 'ack MatSetValueStencil' returns nothing. Hope it helps,
>
> Mat.pyx defines Mat.setValueStencil which calls petscmat.pxi's
> matsetvaluestencil which calls PETSc's MatSetValuesStencil with an array
> of length 1.  I can't think of any reason not to generalize this to set
> many values at once.  Chris, would you like to take a pass at adding
> this?



-- 
Chris Eldred
Postdoctoral Fellow, LAGA, University of Paris 13
PhD, Atmospheric Science, Colorado State University, 2015
DOE Computational Science Graduate Fellow (Alumni)
B.S. Applied Computational Physics, Carnegie Mellon University, 2009
chris.eldred at gmail.com



More information about the petsc-dev mailing list