<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Aptos;
panose-1:2 11 0 4 2 2 2 2 2 4;}
@font-face
{font-family:Menlo;
panose-1:2 11 6 9 3 8 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:10.0pt;
font-family:"Calibri",sans-serif;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
font-size:10.0pt;
font-family:"Calibri",sans-serif;}
span.grame
{mso-style-name:grame;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:631789592;
mso-list-type:hybrid;
mso-list-template-ids:1970559532 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></style>
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word;line-break:after-white-space">
<div class="WordSection1">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Thank <span class="grame">you, Barry</span>. Sorry for the late response.</span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Yes, I was referring to the same text. I am using a star stencil. However, I don’t think the mirror condition is implemented for star stencil either.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt">TLDR version</span></b><span style="font-size:11.0pt"> of the whole message typed below –<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I think DM_BOUNDARY_GHOSTED is not implemented correctly in 3D. It appears that ghost nodes are mirrored with boundary nodes themselves. They should mirror with the nodes next to boundary.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt">Long version</span></b><span style="font-size:11.0pt"> -<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Here’s what I’m trying to do –
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Step 1 - Create a 3D DM<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.5pt;background:#1F1F1F"><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">ierr
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#DCDCAA">DMDACreate3d</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">(PETSC_COMM_WORLD, DM_BOUNDARY_MIRROR, DM_BOUNDARY_MIRROR, DM_BOUNDARY_MIRROR, DMDA_STENCIL_STAR, num_pts,
num_pts, num_pts, PETSC_DECIDE, PETSC_DECIDE, PETSC_DECIDE, </span><span style="font-size:9.0pt;font-family:Menlo;color:#B5CEA8">1</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">,
</span><span style="font-size:9.0pt;font-family:Menlo;color:#B5CEA8">1</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">,
</span><span style="font-size:9.0pt;font-family:Menlo;color:#569CD6">NULL</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">,
</span><span style="font-size:9.0pt;font-family:Menlo;color:#569CD6">NULL</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">,
</span><span style="font-size:9.0pt;font-family:Menlo;color:#569CD6">NULL</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">,
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">&</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">da);
</span><span style="font-size:9.0pt;font-family:Menlo;color:#DCDCAA">CHKERRQ</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">(ierr);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Note - num_pts = 4 in my code.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> Step 2 – Create a Matrix from DM ( a FDM stiffness matrix)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.5pt;background:#1F1F1F"><span style="font-size:9.0pt;font-family:Menlo;color:#DCDCAA">DMCreateMatrix</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">(da,
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">&</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">K);<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.5pt;background:#1F1F1F"><span style="font-size:9.0pt;font-family:Menlo;color:#DCDCAA">globalKMat</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">(K, info);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">“globalKMat” is a user-defined function. Here’s a snippet from this function:<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.5pt;background:#1F1F1F"><span style="font-size:9.0pt;font-family:Menlo;color:#C586C0">for</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"> (</span><span style="font-size:9.0pt;font-family:Menlo;color:#569CD6">int</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
i </span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">info</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">.</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">xs</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">;
i </span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4"><</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"> (</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">info</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">.</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">xs</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">+</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">info</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">.</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">xm</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">);
i</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">++</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">){<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.5pt;background:#1F1F1F"><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#C586C0">for</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">(</span><span style="font-size:9.0pt;font-family:Menlo;color:#569CD6">int</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
j </span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">info</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">.</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">ys</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">;
j </span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4"><</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"> (</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">info</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">.</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">ys</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">+</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">info</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">.</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">ym</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">);
j</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">++</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">){<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.5pt;background:#1F1F1F"><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#C586C0">for</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"> (</span><span style="font-size:9.0pt;font-family:Menlo;color:#569CD6">int</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
k </span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">info</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">.</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">zs</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">;
k </span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4"><</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"> (</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">info</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">.</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">zs</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">+</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">info</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">.</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">zm</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">);
k</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">++</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">){<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.5pt;background:#1F1F1F"><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"> ncols
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#B5CEA8">0</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.5pt;background:#1F1F1F"><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">row</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">.</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">i</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"> i;
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">row</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">.</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">j</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"> j;
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">row</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">.</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">k</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"> k;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.5pt;background:#1F1F1F"><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:13.5pt;background:#1F1F1F"><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">col</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">[</span><span style="font-size:9.0pt;font-family:Menlo;color:#B5CEA8">0</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">].</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">i</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"> i;
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">col</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">[</span><span style="font-size:9.0pt;font-family:Menlo;color:#B5CEA8">0</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">].</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">j</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"> j;
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">col</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">[</span><span style="font-size:9.0pt;font-family:Menlo;color:#B5CEA8">0</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">].</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">k</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"> k;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.5pt;background:#1F1F1F"><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">vals</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">[ncols</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">++</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">]
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">-</span><span style="font-size:9.0pt;font-family:Menlo;color:#B5CEA8">6.</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">;</span><span style="font-size:9.0pt;font-family:Menlo;color:#6A9955">
//ncols=1</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.5pt;background:#1F1F1F"><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:13.5pt;background:#1F1F1F"><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">col</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">[ncols].</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">i</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"> i</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">-</span><span style="font-size:9.0pt;font-family:Menlo;color:#B5CEA8">1</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">;
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">col</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">[ncols].</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">j</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"> j;
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">col</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">[ncols].</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">k</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"> k;<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.5pt;background:#1F1F1F"><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#9CDCFE">vals</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">[ncols</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">++</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">]
</span><span style="font-size:9.0pt;font-family:Menlo;color:#D4D4D4">=</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">
</span><span style="font-size:9.0pt;font-family:Menlo;color:#B5CEA8">1.</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC">;</span><span style="font-size:9.0pt;font-family:Menlo;color:#6A9955">//ncols=2</span><span style="font-size:9.0pt;font-family:Menlo;color:#CCCCCC"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">There are total 7 “ncols”. Other than the first one all ncols have value 1 (first one is set to -6). As you can see, this step is to only build the FDM stiffness matrix. I use “ADD_VALUES” at the end in the
above function.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Step 3 – View the stiffness matrix to check the values. I use MatView for this.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Here are the results –<o:p></o:p></span></p>
<ol style="margin-top:0in" start="1" type="1">
<li class="MsoListParagraph" style="margin-left:0in;mso-list:l0 level1 lfo1"><span style="font-size:11.0pt">3D DM (showing first few rows of the stiffness matrix here, the original matrix is 64x64)-<o:p></o:p></span></li></ol>
<p class="MsoListParagraph"><span style="font-size:11.0pt">Mat Object: 1 MPI processes<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt"> type: seqaij<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt">row 0: (0, -3.) (1, 1.) (4, 1.) (16, 1.)
<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt">row 1: (0, 1.) (1, -4.) (2, 1.) (5, 1.) (17, 1.)
<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt">row 2: (1, 1.) (2, -4.) (3, 1.) (6, 1.) (18, 1.)
<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt">row 3: (2, 1.) (3, -3.) (7, 1.) (19, 1.)
<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt">row 4: (0, 1.) (4, -4.) (5, 1.) (8, 1.) (20, 1.)
<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt">row 5: (1, 1.) (4, 1.) (5, -5.) (6, 1.) (9, 1.) (21, 1.)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<ol style="margin-top:0in" start="2" type="1">
<li class="MsoListParagraph" style="margin-left:0in;mso-list:l0 level1 lfo1"><span style="font-size:11.0pt">Repeat the same steps for a 2D DM to show the difference (the entire matrix is now 16x16)<o:p></o:p></span></li></ol>
<p class="MsoListParagraph"><span style="font-size:11.0pt">Mat Object: 1 MPI processes<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt"> type: seqaij<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt">row 0: (0, -4.) (1, 2.) (4, 2.)
<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt">row 1: (0, 1.) (1, -4.) (2, 1.) (5, 2.)
<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt">row 2: (1, 1.) (2, -4.) (3, 1.) (6, 2.)
<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt">row 3: (2, 2.) (3, -4.) (7, 2.)
<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt">row 4: (0, 1.) (4, -4.) (5, 2.) (8, 1.)
<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt">row 5: (1, 1.) (4, 1.) (5, -4.) (6, 1.) (9, 1.)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I suspect that when using “DM_BOUNDARY_MIRROR” in 3D, the ghost node value is added to the boundary node itself, which would explain why row 0 of the stiffness matrix has -3 instead of -6. In principle the
ghost node value should be mirrored with the node next to boundary.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Clearly, there’s no issue with the 2D implementation of the mirror boundary. The row 0 values are -4, 2, and 2 as expected.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Let me know if I should give any other information about this. I also thought about using DM_BOUNDARY_GHOSTED and implement the mirror boundary in 3D from scratch but I would really appreciate some resources
on how to do that.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Thank you.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Gourav<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div id="mail-editor-reference-message-container">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">From:
</span></b><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">Barry Smith <bsmith@petsc.dev><br>
<b>Date: </b>Thursday, January 4, 2024 at 12:24</span><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black"> </span><span style="font-size:12.0pt;font-family:"Aptos",sans-serif;color:black">PM<br>
<b>To: </b>Gourav Kumbhojkar <gourav.kumbhojkar@gmail.com><br>
<b>Cc: </b>petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov><br>
<b>Subject: </b>Re: [petsc-users] Neumann Boundary Condition with DMDACreate3D</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt"> Are you referring to the text?</span></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">. `DM_BOUNDARY_MIRROR` - the ghost value is the same as the value 1 grid point in; that is, the 0th grid point in the real mesh acts like a mirror to define</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> the ghost point value; not yet implemented for 3d</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> Looking at the code for DMSetUp_DA_3D() I see</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> PetscCheck(stencil_type != DMDA_STENCIL_BOX || (bx != DM_BOUNDARY_MIRROR && by != DM_BOUNDARY_MIRROR && bz != DM_BOUNDARY_MIRROR), PetscObjectComm((PetscObject)da), PETSC_ERR_SUP, "Mirror boundary and box
stencil");</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">which seems (to me) to indicate the mirroring is not done for box stencils but should work for star stencils.</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Are you using a star stencil or a box stencil?</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">I believe the code is not complete for box stencil because the code to determine the location of the "mirrored point" for extra "box points" is messy in 3d and no one wrote it. You can compare DMSetUp_DA_2D()
and DMSetUp_DA_3D() to see what is missing and see if you can determine how to add it for 3d.</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> Barry</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><o:p> </o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">On Jan 4, 2024, at 1:08 PM, Gourav Kumbhojkar <gourav.kumbhojkar@gmail.com> wrote:</span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Hi,</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">I am trying to implement a No-flux boundary condition for a 3D domain. I previously modeled a no flux boundary in 2D domain using DMDACreate2D and “PETSC_BOUNDARY_MIRROR” which worked well.</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">However, the manual pages say that the Mirror Boundary is not supported for 3D.</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Could you please point me to the right resources to implement no flux boundary condition in 3D domains?</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Regards,</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Gourav K.</span></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt"> </span></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>