<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div> 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. <div><br></div><div><div>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.</div></div><div><br></div><div> 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.</div><div><br></div><div> Barry</div><div><br></div><div><br></div><div><div><br></div><div><br><div><br><blockquote type="cite"><div>On Mar 14, 2023, at 8:48 AM, Jonathan Davud Razi Seyed Mirpourian via petsc-users <petsc-users@mcs.anl.gov> wrote:</div><br class="Apple-interchange-newline"><div><meta charset="UTF-8"><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">Dear Petsc team,<o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">I am trying to use DMplex in combination with PetscFE and KSP to solve a linear system.<o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">I have struggled to do so, as all the examples I found ( for example:<a href="https://petsc.org/release/src/snes/tutorials/ex26.c.html" style="color: rgb(5, 99, 193); text-decoration: underline;">https://petsc.org/release/src/snes/tutorials/ex26.c.html</a>) use SNES.<o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">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<o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">assemble the system matrix A. <o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">I hope my questions is reasonable.<o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span>All the best,<o:p></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span><o:p> </o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span>Jonathan<span class="Apple-converted-space"> </span></span></div></div></div></blockquote></div><br></div></div></body></html>