<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi everybody,<div>I'm building a Poisson solver for a cfd code in a structured grid using fortran 90. Substantially I need to solve a linear system in a cycle with a fixed matrix and a variable rhs.&nbsp;</div><div>I'm working with DAs and (being new to Petsc!) I have a problem.&nbsp;</div><div>I have built my matrix with :&nbsp;</div><div><br></div><div><span class="Apple-style-span" style="font-family: Menlo; font-size: 14px; ">...</span></div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; ">call DACreate3d(...)</div></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; ">....</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; ">call DAGetMatrix(da,MATAIJ,A,err)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; ">......</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; color: rgb(255, 255, 255); "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000">&nbsp; &nbsp; call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,err)</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000">&nbsp; &nbsp; call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,err)</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000">......</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><font class="Apple-style-span" color="#000000">and I've got a matrix A ordered in a Petsc ordering: rows and variables have a sequential numbering relative to each processor.</font></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><font class="Apple-style-span" color="#000000"><br></font></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><font class="Apple-style-span" color="#000000">On the other hand building the rhs with&nbsp;</font></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><font class="Apple-style-span" color="#000000"><br></font></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><font class="Apple-style-span" color="#000000"><span class="Apple-style-span" style="font-family: Menlo; font-size: 14px; white-space: pre; ">......</span></font></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000">call DACreateLocalVector(da,qloc,err)</font></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; min-height: 16px; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span><font class="Apple-style-span" color="#000000"><br class="webkit-block-placeholder"></font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000">call DAGlobalToLocalBegin(da,q,INSERT_VALUES,qloc,err)</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000">call DAGlobalToLocalEnd(da,q,INSERT_VALUES,qloc,err)</font></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; min-height: 16px; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span><font class="Apple-style-span" color="#000000"><br class="webkit-block-placeholder"></font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000"><span class="Apple-style-span" style="white-space: pre;"><br></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; min-height: 16px; "><font class="Apple-style-span" color="#000000"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000">call VecGetArrayF90(qloc,qloc_a,err)</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; min-height: 16px; "><font class="Apple-style-span" color="#000000"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; min-height: 16px; "><font class="Apple-style-span" color="#000000"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span><font class="Apple-style-span" color="#000000">cont=0</font><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span><font class="Apple-style-span" color="#000000">do k=gzs,gzs+gzm-1</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">                </font></span><font class="Apple-style-span" color="#000000">do j=gys,gys+gym-1</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">                        </font></span><font class="Apple-style-span" color="#000000">do i=gxs,gxs+gxm-1</font></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; min-height: 16px; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">                        </font></span><font class="Apple-style-span" color="#000000"><br class="webkit-block-placeholder"></font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">                        </font></span><font class="Apple-style-span" color="#000000">if (&nbsp;<span class="Apple-style-span" style="white-space: pre; ">......</span>&nbsp;) then</font></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; min-height: 16px; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">                        </font></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; min-height: 16px; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000"></font></span><font class="Apple-style-span" color="#000000">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cont=cont+1 &nbsp;&nbsp;<br class="webkit-block-placeholder"></font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">                        </font></span><span class="Apple-style-span" style="color: rgb(0, 0, 0); white-space: pre; ">qloc_a(cont)=....</span></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; min-height: 16px; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">                        </font></span><font class="Apple-style-span" color="#000000"> &nbsp; &nbsp;<br class="webkit-block-placeholder"></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; min-height: 16px; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">                                </font></span><font class="Apple-style-span" color="#000000"><br class="webkit-block-placeholder"></font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">                        </font></span><font class="Apple-style-span" color="#000000">else</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000"><br></font></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">                        </font></span><span class="Apple-style-span" style="color: rgb(0, 0, 0); white-space: pre; ">......</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); white-space: pre; "><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">                        </font></span><font class="Apple-style-span" color="#000000">endif</font></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; min-height: 16px; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">                                        </font></span><font class="Apple-style-span" color="#000000">&nbsp;<br class="webkit-block-placeholder"></font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">                        </font></span><font class="Apple-style-span" color="#000000">enddo</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">                </font></span><font class="Apple-style-span" color="#000000">enddo</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span><font class="Apple-style-span" color="#000000">enddo</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; min-height: 16px; "><font class="Apple-style-span" color="#000000"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000">call VecRestoreArrayF90(qloc,qloc_a,err)</font></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; min-height: 16px; "><font class="Apple-style-span" color="#000000"><span class="Apple-style-span" style="white-space: pre;"><br></span></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; min-height: 16px; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><span class="Apple-style-span" style="font-family: Menlo; font-size: 14px; "><font class="Apple-style-span" color="#000000">call</font></span><span class="Apple-style-span" style="font-family: Menlo; font-size: 14px; "><font class="Apple-style-span" color="#000000"> DALocalToGlobal(da,qloc,INSERT_VALUES,q,err)</font></span><font class="Apple-style-span" color="#000000">&nbsp;&nbsp;</font></span></p><div><br></div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><font class="Apple-style-span" color="#000000">I end up with a vector q ordered in the natural ordering (as if it is built with one processor). The questions are:</font></span></div></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000" face="Helvetica"><span class="Apple-style-span" style="font-size: medium;">Is there a way to end up with the same ordering for both the matrix and the rhs ?</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000" face="Helvetica"><span class="Apple-style-span" style="font-size: medium;"><br></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000" face="Helvetica"><span class="Apple-style-span" style="font-size: medium;">If the only way is to use the AO mapping obtained with DAGetAO(), is there an example code that shows how to use the resulting ao to remap the vector (or the matrix) in the Petsc (or the natural) order?</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000" face="Helvetica"><span class="Apple-style-span" style="font-size: medium;">I've seen that I can have the remapping indices but then I haven't understood how to use them to remap the vector (or the matrix).</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000" face="Helvetica"><span class="Apple-style-span" style="font-size: medium;"><br></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000" face="Helvetica"><span class="Apple-style-span" style="font-size: medium;">Regards&nbsp;</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000" face="Helvetica"><span class="Apple-style-span" style="font-size: medium;">Valerio Grazioso&nbsp;</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000" face="Helvetica"><span class="Apple-style-span" style="font-size: medium;"><br></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000" face="Helvetica"><span class="Apple-style-span" style="font-size: medium;">&nbsp;</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><font class="Apple-style-span" color="#000000"><br></font></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><font class="Apple-style-span" color="#000000"><br></font></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><font class="Apple-style-span" color="#000000"><br></font></span></div><div><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><font class="Apple-style-span" color="#000000"><br></font></span></div><div><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 14px/normal Menlo; "><font class="Apple-style-span" color="#000000"><br></font></div></div></div></body></html>