[petsc-users] Coupled system of equations on unstructured mesh
Matthew Knepley
knepley at gmail.com
Sat Sep 23 09:14:05 CDT 2023
On Sat, Sep 23, 2023 at 9:32 AM Karthikeyan Chockalingam - STFC UKRI <
karthikeyan.chockalingam at stfc.ac.uk> wrote:
> Sorry, you didn’t answer my first equation.
>
> 1)The M and N, in MatCreateBIJ, refer to the actual number of *global *rows/cols
> or *global blocke*d rows/cols?
>
I did answer. It is global rows/cols.
> 2) The row indexes used in MatZeroRowsColumnsIS, would refer to the
> actual row or the blocked row?
>
Actual rows and cols.
> Below is your response to my previous email:
>
> “You would use the actual row numbers instead of block rows. You can use
> either.” How can I use either (or switch)?
>
I believe I meant you can use either the array or IS forms.
Thanks,
Matt
> Thanks,
>
> Karthik,
>
>
>
> *From: *Matthew Knepley <knepley at gmail.com>
> *Date: *Saturday, 23 September 2023 at 14:23
> *To: *Chockalingam, Karthikeyan (STFC,DL,HC) <
> karthikeyan.chockalingam at stfc.ac.uk>
> *Cc: *petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
> *Subject: *Re: [petsc-users] Coupled system of equations on unstructured
> mesh
>
> On Sat, Sep 23, 2023 at 6:00 AM Karthikeyan Chockalingam - STFC UKRI <
> karthikeyan.chockalingam at stfc.ac.uk> wrote:
>
> I just would like to clarify a couple of things.
>
>
>
> 1)The M and N, in MatCreateBIJ, refer to the actual number of global
> rows/cols or global blocked rows/cols?
>
>
>
> But d_nz and o_nz only refer to blocked rows.
>
>
>
> Yes.
>
>
>
> 2) In MatZeroRowsColumnsIS, you mentioned I could use the actual row
> numbers instead of block rows. Is there any option to SWITCH between the
> two, when using MatZeroRowsColumnsIS?
>
>
>
> I do not understand the question. When would switching happen?
>
>
>
> Thanks,
>
>
>
> Matt
>
>
>
> Thank you,
>
> Karthik.
>
>
>
> *From: *Matthew Knepley <knepley at gmail.com>
> *Date: *Sunday, 10 September 2023 at 22:03
> *To: *Chockalingam, Karthikeyan (STFC,DL,HC) <
> karthikeyan.chockalingam at stfc.ac.uk>
> *Subject: *Re: [petsc-users] Coupled system of equations on unstructured
> mesh
>
> On Sun, Sep 10, 2023 at 5:00 PM Karthikeyan Chockalingam - STFC UKRI <
> karthikeyan.chockalingam at stfc.ac.uk> wrote:
>
> I get it.
>
>
>
> Q1) In other words when using MatSetValuesBlocked, for bs = 2, I could
> pass all 64 entrees of the element matrix row-oriented by setting m = n =
> 4 (along with the respective idxm and idxn)?
>
>
>
> Yes.
>
>
>
> Q2) However, at a given node variable u can fixed while v is free. In that
> case, while using MatZeroRowsColumns I need to know the global index of the
> variable u (i.e. row/column index in the system matrix A). Here, block size
> does not come in handy as it did when using MatSetValuesBlocked.
>
>
>
> You would use the actual row numbers instead of block rows. You can use
> either.
>
>
>
> Q3) When assembling the system matrix A in this way, would it allow me to
> use PCFIELDSPLIT for coupled systems?
>
>
>
> Yes.
>
>
>
> Thanks,
>
>
>
> Matt
>
>
>
> Kind regards,
>
> Karthik.
>
>
>
>
>
>
>
>
>
> *From: *Matthew Knepley <knepley at gmail.com>
> *Date: *Sunday, 10 September 2023 at 21:23
> *To: *Chockalingam, Karthikeyan (STFC,DL,HC) <
> karthikeyan.chockalingam at stfc.ac.uk>
> *Cc: *petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
> *Subject: *Re: [petsc-users] Coupled system of equations on unstructured
> mesh
>
> On Sun, Sep 10, 2023 at 4:16 PM Karthikeyan Chockalingam - STFC UKRI <
> karthikeyan.chockalingam at stfc.ac.uk> wrote:
>
> Thank you. I almost got it and have a couple of questions.
>
>
>
> Let me summarize, I have an element Jacobian matrix of size 8 x 8 for
> QAUD4 (for variables u and v) ordered such that the degrees of freedom at a
> node are grouped together i.e. [u1 v1 u2 v2 u3 v3 u4 v4].
>
>
>
> Q1) But this ordering of element Jacobian matrix of size 8 x 8, does not
> have an on-diagonal and off-diagonal block structure? Does it not matter?
>
>
>
> It does have block structure in that each entry in your original matrix is
> now a 2x2 block entry in the matrix for 2 fields.
>
>
>
> When assembling the element Jacobian into the system matrix A, I would
> make use of MatSetValues. For each element, I *presume* m = 8 and n = 8
> along with idxm and idxn, are passed to MatSetValues. Meaning I have to
> figure out the global index (say idxm) set of size 8 corresponding to the
> system matrix A.
>
>
>
> What you can do is call
>
>
>
> https://petsc.org/main/manualpages/Mat/MatSetValuesBlocked/
>
>
>
> and give the same indices that you would have given for the original
> matrix, but instead of a value at each location, we now have a 2x2 block.
>
>
>
> Q2) What does setting the block size bs = 2 accomplish? Because the way to
> assemble the Jacobian into the system matrix A seems to me no different
> than I did for the single variable scalar problem.
>
>
>
> This is answered above.
>
>
>
> Thanks,
>
>
>
> Matt
>
>
>
> Kind regards,
>
> Karthik.
>
>
>
>
>
> *From: *Matthew Knepley <knepley at gmail.com>
> *Date: *Sunday, 10 September 2023 at 20:18
> *To: *Chockalingam, Karthikeyan (STFC,DL,HC) <
> karthikeyan.chockalingam at stfc.ac.uk>
> *Cc: *petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
> *Subject: *Re: [petsc-users] Coupled system of equations on unstructured
> mesh
>
> On Sun, Sep 10, 2023 at 3:15 PM Karthikeyan Chockalingam - STFC UKRI <
> karthikeyan.chockalingam at stfc.ac.uk> wrote:
>
> I don’t see an option to give block size.
>
> https://petsc.org/release/manualpages/Mat/MatCreateAIJ/
>
>
>
> https://petsc.org/release/manualpages/Mat/MatSetBlockSize/
>
>
>
> Thanks,
>
>
>
> Matt
>
>
>
>
>
> Many thanks,
>
> Karthik.
>
>
>
>
>
> *From: *Matthew Knepley <knepley at gmail.com>
> *Date: *Sunday, 10 September 2023 at 20:09
> *To: *Chockalingam, Karthikeyan (STFC,DL,HC) <
> karthikeyan.chockalingam at stfc.ac.uk>
> *Cc: *petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
> *Subject: *Re: [petsc-users] Coupled system of equations on unstructured
> mesh
>
> On Sun, Sep 10, 2023 at 3:01 PM Karthikeyan Chockalingam - STFC UKRI <
> karthikeyan.chockalingam at stfc.ac.uk> wrote:
>
> I will solve the coupled problem in a non-linear fashion using SNES, so I
> will have one residual for each variable R(u1) and R(u2) and the resulting
> Jacobian matrix
>
>
>
> J = [J11 J12
>
> J21 J22] for each element.
>
>
>
> For first-order Lagrange elements (in 2D) will have four nodes, then J
> would be of size 8 x 8. Let's say the variables are u and v. The order
> would be [u1 u2 u3 u4 v1 v2 v3 v4].
>
>
>
> Or should I rearrange the above entrées in the element Jacobian so as to
> have [u1 v1 u2 v2 u3 v3 u4 v4] ordering? In that case, the Jacobian will
> not have block ordering I guess.
>
>
>
> This is the correct order to get block matrices.
>
>
>
> In my case, the discretization of the u and v are from the same element
> space.
>
> Can you please elaborate when you say, “Just enlarge the block size of
> your matrix”?
>
> I have never used block size before and not sure what it accomplishes.
>
> Do you mean to say, I should use MATBAIJ instead of MATAIJ?
>
>
>
> You do not need to change the type, just give the AIJ matrix a blocksize
> of 2.
>
>
>
> Thanks,
>
>
>
> Matt
>
>
>
> Kind regards,
>
> Karthik.
>
>
>
> *From: *Matthew Knepley <knepley at gmail.com>
> *Date: *Sunday, 10 September 2023 at 19:03
> *To: *Chockalingam, Karthikeyan (STFC,DL,HC) <
> karthikeyan.chockalingam at stfc.ac.uk>
> *Cc: *petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
> *Subject: *Re: [petsc-users] Coupled system of equations on unstructured
> mesh
>
> On Sun, Sep 10, 2023 at 1:48 PM Karthikeyan Chockalingam - STFC UKRI via
> petsc-users <petsc-users at mcs.anl.gov> wrote:
>
> Hello,
>
>
>
> I have so far solved scalar field problems using finite elements on a
> given (*unstructured*) mesh. I made use of MATMPIAIJ to create matrixes,
> MatCreateVecs(A, &b, &x) to create vectors, and MatZeroRowsColumnsIS to
> set boundary conditions.
>
>
>
> Now, I would like to solve a coupled system of equations for the
> quantities u1 and u2 on the (*unstructured*) mesh. I.e., the matrix
> should get the double number of rows and columns,
>
>
>
> A = [A00 A01
>
> A10 A11]
>
>
>
> This is usually not a good way to think of it. This division means that
> all variables of one field come before
>
> all those of another. It is much more common to group together all the
> unknowns at a given point.
>
>
>
> You could, if the discretizations of u1 and u2 are the same, just enlarge
> the blocksize of your matrix. Then you set u1 and u2 for each vec location,
> or a 2x2 block for each Jacobian location.
>
>
>
> Thanks,
>
>
>
> Matt
>
>
>
> the vectors contain twice the number of entries (e.g. first all u1s and
> then all u2s). I would like to be sure that the entries of u1 and u2, which
> are associated with the same element are located on the same processor.
>
>
>
> Is a pre-defined structure already available within PETSc to enlarge such
> a single equation to store the entries of coupled equations?
>
>
>
> -\Delta u_1+c_{11} u_1+c_{12} u_2=f_1
>
> -\Delta u_2+c_{21} u_1+c_{22} u_2=f_2
>
>
>
> Would I still be able to use MatZeroRowsColumnsIS u1 and u2 independently
> to enforce boundary conditions? MatZeroRowsColumnsIS(A, is, 1, x, b);
>
>
>
> I don’t know where to begin. I have so far only been exposed to using MATMPIAIJ
> and MatSetValues to create and assign values to matrix entries
> respectively. I would be grateful if you could provide the stepwise guide.
>
>
>
> Kind regards,
>
> Karthik.
>
>
>
> --
>
> *Karthik Chockalingam, Ph.D.*
>
> Senior Research Software Engineer
>
> High Performance Systems Engineering Group
>
> Hartree Centre | Science and Technology Facilities Council
>
> karthikeyan.chockalingam at stfc.ac.uk
>
>
>
> *Error! Filename not specified.*
>
>
>
>
>
>
> --
>
> 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/>
>
>
>
>
> --
>
> 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/>
>
>
>
>
> --
>
> 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/>
>
>
>
>
> --
>
> 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/>
>
>
>
>
> --
>
> 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/>
>
>
>
>
> --
>
> 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/>
>
--
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/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230923/46401917/attachment-0001.html>
More information about the petsc-users
mailing list