[petsc-users] Re-use the matrix in petsc
Edoardo alinovi
edoardo.alinovi at gmail.com
Fri Nov 24 14:47:02 CST 2017
Dear petsc users,
I am new to petsc, but I am really enjoying it.
I am developing a CFD code in fortran and I have a (newby) question for you.
I have a subroutine that assembles the matrices arising from the finite
volume method. They are sparse and the coefficients change every time step,
but their sparsity remains unchanged (i.e. non-zeros entries are always in
the same position).
In the subroutine, which is called every time step, I am basically
following the manual and I do something like:
- call MatCreate(PETSC_COMM_WORLD,A,ierr)
- call MatSetSizes(A,lm,lm,M,M,ierr)
- call MatSetType(A, myType,ierr)
- call MatMPIAIJSetPreallocation(A,d_nz,PETSC_NULL_INTEGER, o_nz,
PETSC_NULL_INTEGER,ierr)
call MatSetUp(A,ierr)
- call MatSetValues
- call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr)
- call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr)
- Solve the system
- call MatDestroy
Here is my question:
As you can note, every time step, I allocate the matrix, fill it, use it
and the destroy it. Is there a way to avoid the matrix preallocation every
time? I just would like to change matrix the entries and avoid the
preallocation.
Thank you for the help that you can give me,
Edoardo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20171124/c68d7e1a/attachment.html>
More information about the petsc-users
mailing list