> On Nov 21, 2016, at 10:33 AM, Massoud Rezavand <[email protected]> 
> wrote:
> 
> Dear all,
> 
> I am going to use PETSc in an Incompressible SPH code to solve the pressure 
> Poisson equation as a linear system of equations.
> 
> In my old sequential code I used the PCG method or the BiCGSTAB with jacobi 
> preconditioner.
> I used to store the coefficient matrix (A) in CSR (AIJ) format and solve it.
> 
> My question is that how should I import the CSR metrix and the known vector 
> (b) into the library to be solved? Is there an example to show how to import 
> and external system of eqs. into PETSc?

   For sequential code it is straightforward.

   If you already have the matrix in CSR format you can call 
MatCreateSeqAIJWithArrays() to create the PETSc matrix without copying the 
data. You can use VecCreateSeqWithArray() to provide the vector. Or you can use 
VecPlaceArray() to use the array of vector values you provide.

> 
> In my case, the computational domain is decomposed by another library, so 
> does it effect the performance of PETSc?

   I read this to mean you want the new code to be parallel (but the old one is 
sequential)? 

   If you don't currently have matrix generation in parallel I urge you 
strongly to directly use MatSetValues() to generate your matrix, do not first 
put the matrix entries into some kind of parallel CSR format. If you already 
have the matrix in "parallel" CSR format you can use 
MatCreateMPIAIJWithArrays() to copy the matrix over to CSR format.

   It is my understanding that SPH can produce matrices with very unbalance 
sparsity. It is important to take this into account if you wish to run in 
parallel since if you end up with some processes having many more nonzeros than 
other processes you will get very poor performance. 


   Barry


> 
> With the best regards,
> Massoud
> 

Reply via email to