<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
Great, thanks so much for the explanations!<br>
<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
<span id="OutlookSignature">
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
»ρΘ‘ <a href="https://aka.ms/ghei36">Outlook for Android</a></div>
</span><br>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Jed Brown <jed@jedbrown.org><br>
<b>Sent:</b> Monday, March 16, 2020 9:22:16 PM<br>
<b>To:</b> Yuyun Yang <yyang85@stanford.edu>; petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov><br>
<b>Subject:</b> Re: [petsc-users] Using DMDA with regular matrices</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Yuyun Yang <yyang85@stanford.edu> writes:<br>
<br>
> Hello team,<br>
><br>
> Hope you're staying healthy amid the coronavirus craziness.<br>
><br>
> Just want to ask a basic question: if my grid is managed by DMDA, then<br>
> do matrices in all my intermediate steps have to be compatible with<br>
> DMDA and formed in a special way, or can I just form them as usual<br>
> (i.e. do MatCreate, MatMPIAIJSetPreallocation, MatSetValue etc.)? <br>
<br>
DMCreateMatrix does the creation and preallocation for you, and enables<br>
you to use MatSetValuesStencil. It's otherwise the same.<br>
<br>
Sometimes people use auxiliary DMs to describe distribution of values<br>
that aren't the same size/shape as solution variables (e.g.,<br>
cell-centered tensor-valued coefficients), though usually those are<br>
accessed in your residual and Jacobian assembly functions, not via<br>
matrices.<br>
<br>
> Asking this because I'm using a mix of matrix-free and matrix-based<br>
> operations, and MatShell seems to require the use of DMDA.<br>
<br>
MatShell has no dependence on DMDA. It's entirely in your hands, via<br>
the callback(s) that you implement.<br>
</div>
</span></font></div>
</body>
</html>