<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:7a16cc49$1$18007a94a81$Coremail$gaoyahe$buaa.edu.cn" 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. 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:6c20363c$2$18007a94a81$Coremail$gaoyahe$buaa.edu.cn">
</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:5bc1a62c$3$18007a94a81$Coremail$gaoyahe$buaa.edu.cn">
</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" class="ReferenceQuote" style="padding-left:5px;margin-left:5px;border-left:#b6b6b6 2px solid;margin-right:0;">
        -----原始邮件-----<br>
<b>发件人:</b><span id="rc_from">"Barry Smith" <bsmith@petsc.dev></span><br>
<b>发送时间:</b><span id="rc_senttime">2022-04-07 23:10:20 (星期四)</span><br>
<b>收件人:</b> "Matthew Knepley" <knepley@gmail.com><br>
<b>抄送:</b> "高亚贺" <gaoyahe@buaa.edu.cn>, PETSc <petsc-users@mcs.anl.gov><br>
<b>主题:</b> Re: [petsc-users] question<br>
<br>
        <div class="">
                <br class="">
        </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 class="">
                <br class="">
        </div>
        <div class="">
                  If you explain what your Lagrange multipliers are (the constraints) we may be able to make more specific suggestions.<br class="">
                <div class="">
                        <br class="">
                </div>
                <div class="">
                        Barry
                </div>
                <div class="">
                        <br class="">
                        <div class="">
                                <br class="">
                        </div>
                        <div class="">
                                <br class="">
                                <div>
                                        <br class="">
                                        <blockquote type="cite" class="">
                                                <div class="">
                                                        On Apr 7, 2022, at 8:26 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>> wrote:
                                                </div>
<br class="Apple-interchange-newline">
                                                <div class="">
                                                        <div dir="ltr" class="">
                                                                <div dir="ltr" class="">
                                                                        On Thu, Apr 7, 2022 at 8:16 AM 高亚贺 via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" class="">petsc-users@mcs.anl.gov</a>> wrote:<br class="">
                                                                </div>
                                                                <div class="gmail_quote">
                                                                        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid #CCCCCC;padding-left:1ex;">
                                                                                <div class="">
                                                                                        <br class="webkit-block-placeholder">
                                                                                </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 class="">K</b>, and also the ‘DMCreateGlobalVector’
to create two vectors <b class="">U</b> (to be solved)
and <b class="">F </b>(right-hand side), i.e. <b class="">KU</b>=<b class="">F</b>.
Now, I want to add some complex constraints to this system through lagrangian
multiplier method, and the constraint matrix is <b class="">Q</b>. The <b class="">KU</b>=<b class="">F </b>transforms to
                                                                                </p>
                                                                                <p class="MsoNormal" style="text-align:center;text-indent:24pt;">
                                                                                        <span id="cid:18003fc0abddc604b1a1"><1649328463919.png></span> 
                                                                                </p>
                                                                                <p class="MsoNormal" align="center" style="text-align:center;">
                                                                                        <b class=""></b> 
                                                                                </p>
                                                                                <p class="MsoNormal">
                                                                                           How
to create <b class="">K</b><b class=""><sub class="">λ</sub></b>, and how to effectively copy values<b class=""> K</b> and <b class="">Q</b> to <b class="">K</b><b class=""><sub class="">λ</sub></b>? Does the newly created <b class="">K</b><b class=""><sub class="">λ</sub></b> and <b class="">F</b><b class=""><sub class="">λ </sub></b>still have an advantage
of DMDA? Or do you have any other good suggestions for this kind of problem? 
                                                                                </p>
                                                                        </blockquote>
                                                                        <div class="">
                                                                                <br class="">
                                                                        </div>
                                                                        <div class="">
                                                                                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 class="">
                                                                                <br class="">
                                                                        </div>
                                                                        <div class="">
                                                                                  Thanks,
                                                                        </div>
                                                                        <div class="">
                                                                                <br class="">
                                                                        </div>
                                                                        <div class="">
                                                                                     Matt
                                                                        </div>
                                                                        <div class="">
                                                                                 
                                                                        </div>
                                                                        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid #CCCCCC;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" class="">
                                                                <div class="">
                                                                        <br class="">
                                                                </div>
-- <br class="">
                                                                <div dir="ltr" class="gmail_signature">
                                                                        <div dir="ltr" class="">
                                                                                <div class="">
                                                                                        <div dir="ltr" class="">
                                                                                                <div class="">
                                                                                                        <div dir="ltr" class="">
                                                                                                                <div class="">
                                                                                                                        What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">
-- Norbert Wiener
                                                                                                                </div>
                                                                                                                <div class="">
                                                                                                                        <br class="">
                                                                                                                </div>
                                                                                                                <div class="">
                                                                                                                        <a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" class="">https://www.cse.buffalo.edu/~knepley/</a><br class="">
                                                                                                                </div>
                                                                                                        </div>
                                                                                                </div>
                                                                                        </div>
                                                                                </div>
                                                                        </div>
                                                                </div>
                                                        </div>
                                                </div>
                                        </blockquote>
                                </div>
<br class="">
                        </div>
                </div>
        </div>
</blockquote>