Without having seen your code, it sounds to me like the best strategy here is to:
1) Produce a mirror of your mesh using DMStag 2) Use that DM to construct the linear block problems, which can then be solved by PETSc Since the PETSc grid matches your own, you can share the solution vectors between your code and PETSc, so it will fit nicely into your existing structure. Once that works, if the entire mesh is Cartesian, you could use DMStag to model that and let PETSc handle parallel decomposition. At the same stage, you could decide to let PETSc SNES handle the nonlinear problem, rather than just the linear parts. Thanks, Matt On Sun, Oct 13, 2019 at 5:25 AM Pierre Gubernatis via petsc-users < petsc-users@mcs.anl.gov> wrote: > Hello all, > > It souds that the best way to introduce petsc in a code is not to > introduce it, but develop the code over the petsc structure. > > It is probably true but my problem is that my existing code already is > equipped with a domain decomposition based on MPI (a typical themal > hydraulic with cartesian staggered mesh) > > The user can slice the domain in sub-domains and construct a linear > problem by block: each sub-domain assembles its part of the operator and > its part of the RHS. > > I am wondering what is the best way now to introduce petsc (considering > that I don’t want to assemble a global operator on a given proc). Is there > an example that would show how to introduce petsc in this situation ? > Thank you, Pierre > -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>