KSP/SNES do not automatically assemble the linear system, that is the 
responsibility of DMPLEX in this case. Thus the process for assembling the 
matrix is largely the same whether done with KSP or SNES and DMPLEX. The 
difference is, of course, that constructing the linear matrix does not depend 
on some “solution” vector as with SNES. 

Note also you can simply use SNES for a linear problem by selecting the 
SNESType of SNESKSP; this will just as efficient as using KSP directly.

  You should be able to locate a SNES example and extract the calls for 
defining the mesh and building the matrix but using them with KSP.

  Barry





> On Mar 14, 2023, at 8:48 AM, Jonathan Davud Razi Seyed Mirpourian via 
> petsc-users <petsc-users@mcs.anl.gov> wrote:
> 
> Dear Petsc team,
>  
> I am trying to use DMplex in combination with PetscFE and KSP to solve a 
> linear system.
>  
> I have struggled to do so, as all the examples I found ( for 
> example:https://petsc.org/release/src/snes/tutorials/ex26.c.html) use SNES.
>  
> Is there a way to avoid this? Optimally I would like to use dmplex for the 
> mesh management, then create the discretization with PetscFE and then get KSP 
> to automatically
> assemble the system matrix A.  
>  
> I hope my questions is reasonable.
>  
> All the best,
>  
> Jonathan 

Reply via email to