On Tue, Apr 18, 2023 at 5:24 AM Karthikeyan Chockalingam - STFC UKRI via petsc-users <petsc-users@mcs.anl.gov> wrote:
> Hello, > > > > I'm solving a problem using the Lagrange multiplier, the matrix has the > form > > > > K = [A P^T > > P 0] > > > > I am familiar with constructing K using MATMPIAIJ. However, I would like > to know if had [A], can I augment it with [P], [P^T] and [0] of type > MATMPIAIJ? Likewise for vectors as well. > > > > Can you please point me to the right resource, if it is a common operation > in PETSc? > You can do this at least 2 ways: 1) Assemble you submatrices directly into the larger matrix by constructing local-to-global maps for the emplacement. so that you do not change your assembly code, except to change MatSetValues() to MatSetValuesLocal(). This is usually preferable. 2) Use MATNEST and VecNEST to put pointers to submatrices and subvectors directly in. Thanks, Matt > Many thanks. > > > > Kind regards, > > Karthik. > > > > > > > > > -- 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/>