[petsc-users] Array of KSP contexts
    Barry Smith 
    bsmith at mcs.anl.gov
       
    Tue Oct 16 14:06:38 CDT 2012
    
    
  
   KSP   *ksps;
   ierr = PetscMalloc(n*sizeof(KSP),&ksps);
   for (i=0; i<n; i++) {
      ierr = KSPCreate(comm,&ksps[i]);
      ….
   }
   ….
   for (i=0; i<n; i++) {
       ierr = KSPDestroy(comm,&ksps[i]);
  }
  ierr = PetscFree(&ksps);
  
 
On Oct 16, 2012, at 1:54 PM, tibo at berkeley.edu wrote:
> Hi,
> 
> I was wondering if it was possible to create arrays of KSP contexts, and
> if so, if someone could redirect me to an example or more info (I was not
> able to find this in the petsc manual).
> 
> Some explanation:  at some point in my code, I would like each processor
> to compute the LU factorization of a few sparse matrices each (using
> either mumps or superLU interface to petsc), store this using the KSP/PC
> tools, and be able to reuse it later in the code to solve some linear
> systems.
> 
> The number of matrices that each processor has to factorize is dynamic so
> I can not create a different KSP context from the start, ideally I would
> like to have an array of KSP that I can allocate dynamically (I am a
> fortran user btw).
> 
> thank you for your help,
> 
> Tibo
> 
    
    
More information about the petsc-users
mailing list