<div dir="ltr"><div dir="ltr">On Fri, Apr 8, 2022 at 1:34 AM 高亚贺 <<a href="mailto:gaoyahe@buaa.edu.cn">gaoyahe@buaa.edu.cn</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p class="MsoNormal">
        Dear
Mr./Ms.,
</p>
<p class="MsoNormal">
        <br>
</p>
<p class="MsoNormal">
        In
fact, I want to solve a discretized equation like this
</p>
<p class="MsoNormal" style="text-align:center">
        <img src="cid:18009439d311d390f431" width="470" height="83" title="" align="" alt="">
</p>
<p class="MsoNormal" align="center" style="text-align:center">
        <span></span>
</p>
<p class="MsoNormal">
        where <b>K, U=</b>[<i>u</i><sub>1</sub><b> </b><i>u</i><sub>2 </sub><b>…</b><i>u<sub>n</sub></i>]<sup>T</sup><b> </b>and <b>F </b>are fields sit on the vertices,
and can easily be created by ‘DMCreateMatrix’ or ‘DMCreateGlobalVector’. <b>λ</b> is the Lagrange
multiplier vector. </p></blockquote><div><br></div><div>How is lambda discretized?</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p class="MsoNormal">The augmented <b>Q </b>(non-square)
is the constraint coefficient matrix and has the form as
</p>
<p class="MsoNormal" style="text-align:center">
        <img src="cid:18009439d318b935ce42">
</p>
<br>
<p class="MsoNormal">
        The <b>Q</b> is employed here to satisfy the
following constraints
</p>
<p class="MsoNormal" style="text-align:center">
        <img src="cid:18009439d314bd330aa3">
</p>
<p class="MsoNormal" align="center" style="text-align:center">
        <br>
</p>
<p class="MsoNormal">
        So how to build
the entire system in-place in one big matrix<b> (K</b><sub>λ</sub>)? Could you give me more specific suggestions on this
problem?
</p>
<p class="MsoNormal">
        <br>
</p>
<p class="MsoNormal">
        Thank you very
much!
</p>
<p class="MsoNormal">
        <br>
</p>
<p class="MsoNormal">
        Best
regards,
</p>
<p class="MsoNormal">
        Yahe
</p>
<br>
<br>
<br>
<blockquote name="replyContent" style="padding-left:5px;margin-left:5px;border-left:2px solid rgb(182,182,182);margin-right:0px">
        -----原始邮件-----<br>
<b>发件人:</b><span id="gmail-m_-5923204124870628910rc_from">"Barry Smith" <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>></span><br>
<b>发送时间:</b><span id="gmail-m_-5923204124870628910rc_senttime">2022-04-07 23:10:20 (星期四)</span><br>
<b>收件人:</b> "Matthew Knepley" <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>><br>
<b>抄送:</b> "高亚贺" <<a href="mailto:gaoyahe@buaa.edu.cn" target="_blank">gaoyahe@buaa.edu.cn</a>>, PETSc <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>><br>
<b>主题:</b> Re: [petsc-users] question<br>
<br>
        <div>
                <br>
        </div>
  DMStag may also be useful for your needs (and far simpler to use than DMPLEX) depending on where your Lagrange multipliers live. Note that regardless you should not need to be copying entire large submatrices around into bigger matrices; you can build the entire system in-place in one big matrix. MatNest is also a possibility depending on exactly what you are doing. 
        <div>
                <br>
        </div>
        <div>
                  If you explain what your Lagrange multipliers are (the constraints) we may be able to make more specific suggestions.<br>
                <div>
                        <br>
                </div>
                <div>
                        Barry
                </div>
                <div>
                        <br>
                        <div>
                                <br>
                        </div>
                        <div>
                                <br>
                                <div>
                                        <br>
                                        <blockquote type="cite">
                                                <div>
                                                        On Apr 7, 2022, at 8:26 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:
                                                </div>
<br>
                                                <div>
                                                        <div dir="ltr">
                                                                <div dir="ltr">
                                                                        On Thu, Apr 7, 2022 at 8:16 AM 高亚贺 via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br>
                                                                </div>
                                                                <div class="gmail_quote">
                                                                        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                                                                                <div>
                                                                                        <br>
                                                                                </div>
                                                                                <p class="MsoNormal">
                                                                                        Dear
Mr./Ms.,
                                                                                </p>
                                                                                <p class="MsoNormal">
                                                                                        <br>
                                                                                </p>
                                                                                <p class="MsoNormal" style="text-indent:24pt">
                                                                                        I have used
‘DMCreateMatrix’
to create a matrix <b>K</b>, and also the ‘DMCreateGlobalVector’
to create two vectors <b>U</b> (to be solved)
and <b>F </b>(right-hand side), i.e. <b>KU</b>=<b>F</b>.
Now, I want to add some complex constraints to this system through lagrangian
multiplier method, and the constraint matrix is <b>Q</b>. The <b>KU</b>=<b>F </b>transforms to
                                                                                </p>
                                                                                <p class="MsoNormal" style="text-align:center;text-indent:24pt">
                                                                                        <span id="gmail-m_-5923204124870628910cid:18003fc0abddc604b1a1"><1649328463919.png></span> 
                                                                                </p>
                                                                                <p class="MsoNormal" align="center" style="text-align:center">
                                                                                        <b></b> 
                                                                                </p>
                                                                                <p class="MsoNormal">
                                                                                           How
to create <b>K</b><b><sub>λ</sub></b>, and how to effectively copy values<b> K</b> and <b>Q</b> to <b>K</b><b><sub>λ</sub></b>? Does the newly created <b>K</b><b><sub>λ</sub></b> and <b>F</b><b><sub>λ </sub></b>still have an advantage
of DMDA? Or do you have any other good suggestions for this kind of problem? 
                                                                                </p>
                                                                        </blockquote>
                                                                        <div>
                                                                                <br>
                                                                        </div>
                                                                        <div>
                                                                                DMDA can only really handle collocated discretizations, meaning all fields sit on the vertices. If you can discretize your problem this way, then just give it two fields and assemble K_\lambda as normal. If not, then you might look at DMPlex which supports a wider range of discretizations.
                                                                        </div>
                                                                        <div>
                                                                                <br>
                                                                        </div>
                                                                        <div>
                                                                                  Thanks,
                                                                        </div>
                                                                        <div>
                                                                                <br>
                                                                        </div>
                                                                        <div>
                                                                                     Matt
                                                                        </div>
                                                                        <div>
                                                                                 
                                                                        </div>
                                                                        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                                                                                <p class="MsoNormal">
                                                                                        Thank you very
much!
                                                                                </p>
                                                                                <p class="MsoNormal">
                                                                                        <br>
                                                                                </p>
                                                                                <p class="MsoNormal">
                                                                                        Best
regards,
                                                                                </p>
                                                                                <p class="MsoNormal">
                                                                                        A
PETSc user
                                                                                </p>
                                                                        </blockquote>
                                                                </div>
<br clear="all">
                                                                <div>
                                                                        <br>
                                                                </div>
-- <br>
                                                                <div dir="ltr">
                                                                        <div dir="ltr">
                                                                                <div>
                                                                                        <div dir="ltr">
                                                                                                <div>
                                                                                                        <div dir="ltr">
                                                                                                                <div>
                                                                                                                        What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
                                                                                                                </div>
                                                                                                                <div>
                                                                                                                        <br>
                                                                                                                </div>
                                                                                                                <div>
                                                                                                                        <a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
                                                                                                                </div>
                                                                                                        </div>
                                                                                                </div>
                                                                                        </div>
                                                                                </div>
                                                                        </div>
                                                                </div>
                                                        </div>
                                                </div>
                                        </blockquote>
                                </div>
<br>
                        </div>
                </div>
        </div>
</blockquote></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>