<div dir="ltr">Hi Stefano<div><br></div><div>I used case B) to not change the current code significantly. Nevertheless case A) is worth to look when the number of domains grow. In case B) I noticed that the l2g passing to <span style="font-size:12.8px">MatSetLocalToGlobalMapping must also contain the off-proc entries, in order to assemble correctly. As you said, calling MatSetValues with non-owned dof will raise error, so we have to include that in the current sub-domain. I used v3.7.4 though.</span></div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks all for the help.<br clear="all"><div><div class="gmail_signature"><div dir="ltr">Giang</div></div></div>
<br><div class="gmail_quote">On Wed, Jun 7, 2017 at 3:35 PM, Stefano Zampini <span dir="ltr"><<a href="mailto:stefano.zampini@gmail.com" target="_blank">stefano.zampini@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word">Which version of PETSc are you using? If you use the dev version and try to call MatSetValues on a MATIS with a non-owned (subdomain-wise) dof it will raise an error, as MATIS does not implement any caching mechanisms for off-proc entries.<div><div>Off-proc entries are a concept related with the AIJ format.</div><div><br></div><div>The local row and columns distribution of a Mat (any type, MATAIJ, MATIS or whatever type you want to use) are related with the local sizes of the vectors used in MatMult;</div><div>for MATIS, the size of the subdomain problem (call it nl) is inferred from the size of the ISLocalToGlobalMapping object used in the constructor (or passed in via MatSetLocalToGlobalMapping).</div><div><br></div><div>So, you can either do</div><div><br></div><div>A) loop over elements and call MatSetValuesLocal(A,element_<wbr>dofs_in_subdomain_ordering…)</div><div><div>B) loop over elements and call MatSetValues(A,element_dofs_<wbr>in_global_ordering…)</div></div><div><br></div><div>in case A), if you want a code independent on the matrix type (AIJ or IS), you need to call MatSetLocalToGlobalMapping(A,<wbr>l2g,l2g) before being able to call MatSetValuesLocal. The l2g map should map dofs from subdomain (0 to nl) to global ordering</div><div><br></div><div>in case B), the l2g map is only needed to create the MATIS object; in this case, when you call MatSetValues, the dofs in global ordering are mapped back to the subdomain ordering via ISGlobalToLocalMappingApply, that may not be memory scalable. So this is why Barry suggested you to use approach A).</div><div><br></div><div><br></div><div>You may want to take a look at <a href="http://epubs.siam.org/doi/abs/10.1137/15M1025785" target="_blank">http://epubs.siam.org/doi/<wbr>abs/10.1137/15M1025785</a> to better understand how MATIS works.</div><div> </div><div><div><blockquote type="cite"><div>On Jun 7, 2017, at 3:18 PM, Hoang Giang Bui <<a href="mailto:hgbk2008@gmail.com" target="_blank">hgbk2008@gmail.com</a>> wrote:</div><br class="gmail-m_-4356658988650192393Apple-interchange-newline"><div><span id="gmail-m_-4356658988650192393cid:6572F5C2-6457-40BB-9261-CB246290A6F3"><A00.ps></span></div></blockquote></div><br></div></div></div></blockquote></div><br></div></div>