[petsc-users] question about MatSetLocalToGlobalMapping
Pierre Jolivet
pierre.jolivet at lip6.fr
Thu Apr 20 11:58:35 CDT 2023
Hong,
1) Is there any hope to get PDIPDM to use a MatNest?
2) Is this fixed https://lists.mcs.anl.gov/pipermail/petsc-dev/2020-September/026398.html ?
I cannot get users to transition away from Ipopt because of these two missing features.
Thanks,
Pierre
> On 20 Apr 2023, at 5:47 PM, Zhang, Hong via petsc-users <petsc-users at mcs.anl.gov> wrote:
>
> Karthik,
> We built a KKT matrix in TaoSNESJacobian_PDIPM() (see petsc/src/tao/constrained/impls/ipm/pdipm.c) which assembles several small matrices into a large KKT matrix in mpiaij format. You could take the same approach to insert P and P^T into your K.
> FYI, I attached our paper.
> Hong
> From: petsc-users <petsc-users-bounces at mcs.anl.gov> on behalf of Matthew Knepley <knepley at gmail.com>
> Sent: Thursday, April 20, 2023 5:37 AM
> To: Karthikeyan Chockalingam - STFC UKRI <karthikeyan.chockalingam at stfc.ac.uk>
> Cc: petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
> Subject: Re: [petsc-users] question about MatSetLocalToGlobalMapping
>
> On Thu, Apr 20, 2023 at 6:13 AM Karthikeyan Chockalingam - STFC UKRI via petsc-users <petsc-users at mcs.anl.gov <mailto:petsc-users at mcs.anl.gov>> wrote:
> Hello,
>
> I created a new thread, thought would it be more appropriate (and is a continuation of my previous post). I want to construct the below K matrix (which is composed of submatrices)
>
> K = [A P^T
> P 0]
>
> Where K is of type MatMPIAIJ. I first constructed the top left [A] using MatSetValues().
>
> Now, I would like to construct the bottom left [p] and top right [p^T] using MatSetValuesLocal().
>
> To use MatSetValuesLocal(), I first have to create a local-to-global mapping using ISLocalToGlobalMappingCreate. I have created two mapping row_mapping and column_mapping.
>
> I do not understand why they are not the same map. Maybe I was unclear before. It looks like you have two fields, say phi and lambda, where lambda is a Lagrange multiplier imposing some constraint. Then you get a saddle point like this. You can imagine matrices
>
> (phi, phi) --> A
> (phi, lambda) --> P^T
> (lambda, phi) --> P
>
> So you make a L2G map for the phi field and the lambda field. Oh, you are calling them row and col map, but they are my phi and lambda
> maps. I do not like the row and col names since in P they reverse.
>
> Q1) At what point should I declare MatSetLocalToGlobalMapping – is it just before I use MatSetValuesLocal()?
>
> Okay, it is good you are asking this because my thinking was somewhat confused. I think the precise steps are:
>
> 1) Create the large saddle point matrix K
>
> 1a) We must call https://petsc.org/main/manualpages/Mat/MatSetLocalToGlobalMapping/ on it. In the simplest case, this just maps
> the local rows numbers [0, Nrows) to the global rows numbers [rowStart, rowStart + Nrows).
>
> 2) To form each piece:
>
> 2a) Extract that block using https://petsc.org/main/manualpages/Mat/MatGetLocalSubMatrix/
>
> This gives back a Mat object that you subsequently restore using https://petsc.org/main/manualpages/Mat/MatRestoreLocalSubMatrix/
>
> 2b) Insert values using https://petsc.org/main/manualpages/Mat/MatSetValuesLocal/
>
> The local indices used for insertion here are indices relative to the block itself, and the L2G map for this matrix
> has been rewritten to insert into that block in the larger matrix. Thus this looks like just calling MatSetValuesLocal()
> on the smaller matrix block, but inserts correctly into the larger matrix.
>
> Therefore, the code you write code in 2) could work equally well making the large matrix from 1), or independent smaller matrix blocks.
>
> Does this make sense?
>
> Thanks,
>
> Matt
>
> I will use MatSetLocalToGlobalMapping(K, row_mapping, column_mapping) to build the bottom left [P].
>
>
> Q2) Can now I reset the mapping as MatSetLocalToGlobalMapping(K, column_mapping, row_mapping) to build the top right [P^T]?
>
>
> 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/>
> <IET Generation Trans Dist - 2022 - Sundermann - Parallel primal‐dual interior point method for the solution of dynamic.pdf>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230420/1b2c4b59/attachment.html>
More information about the petsc-users
mailing list