[petsc-users] petsc4py

Smith, Barry F. bsmith at mcs.anl.gov
Wed Oct 25 15:44:57 CDT 2017


   Since the matrix changes size you will need to create a new matrix, fill it up, solve with it, destroy it for each time-step. No big deal.

   
> On Oct 25, 2017, at 1:52 PM, Cetinbas, Cankur Firat <ccetinbas at anl.gov> wrote:
> 
> Hi,
>  
> We have a code in python to solve for 3D water transport in a nano scale pore geometry obtained by tomography image at APS.
>  
> The code generates a sparse matrix with csr_matrix method in Python and solve the corresponding linear system with linsolve in Python. For small domains our code runs well but we need to make these two steps (sparse matrix generation and solving the linear system) parallel to be able run the code on realistic size domains.
>  
> I know the diagonal values and the non-diagonal values with corresponding positions (positions are not regular, it is not like 5 point stencil). These values and locations change every time step and the matrix size grows (as water moves in pores).

>  
> I checked the attached presentation, I was wondering if there is an easy way to generate a parallel sparse matrix from row, column and corresponding values as in Python csr? Since my off diagonal locations are not generic for each processor, it is not so trivial to me as a beginner in petsc. 

   Each process will call MatSetValues() with "its" nonzero entries. 
>  
> By the way, in the matrix generation example (in the attached pdf), when I use the “getOwnershipRange” comment both Istart and Iend returns 0. How can generate the same matrix with multiple nodes in petsc4py?

   You call MatCreate() with the MPI_COMM world communicator and that single matrix is owned by all the processes. 

   Did you set the matrix size before calling getOwnershipRange? 

   If you still have trouble with getOwnershipRange() returning all zeros on all processes you will need to email the sample code that produces the problem.

  Barry



>  
> Thanks for your help in advance.
>  
> Regards,
>  
> Firat
>  
> <Lisandro-Dalcin-petsc4py.pdf>



More information about the petsc-users mailing list