<div dir="ltr">Thanks! That worked.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 20, 2020 at 11:10 AM Barry Smith <<a href="mailto:bsmith@petsc.dev">bsmith@petsc.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
   If you are running sequentially you likely want the first routine, in parallel the third routine.<br>
<br>
MatCreateSeqAIJWithArrays()<br>
PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocationCSR(Mat,const PetscInt [],const PetscInt [],const PetscScalar []);<br>
PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat,const PetscInt[],const PetscInt[],const PetscScalar[]);<br>
<br>
<br>
PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);<br>
PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);<br>
PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);<br>
PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);<br>
<br>
<br>
<br>
> On Jul 20, 2020, at 7:38 AM, Adolfo Rodriguez <<a href="mailto:adantra@gmail.com" target="_blank">adantra@gmail.com</a>> wrote:<br>
> <br>
> I am trying to use PETSc to solve a non-linear problem. The problem I am facing is that I already have the Jacobian matrix formed in CSR format. Now I am trying to define a function FormJacobian which takes this preexisting matrix and writes it in PETSc format. For a small problem, I can use MatSetValue, looping over all non-zero elements one at a time. However, this turns out too slow for larger problems. <br>
> <br>
> In my current implementation, I am using MatCreateSeqAIJ which works great. However, this approach does not seem to work to set the Jacobian.<br>
> <br>
> Any suggestions?<br>
> <br>
> Regards,<br>
> <br>
> Adolfo<br>
<br>
</blockquote></div>