<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Dave,<div class=""><br class=""></div><div class="">Thanks a lot for your prompt reply! This is even easier than I thought (and that is most likely the reason, why I could not think into this direction) :)</div><div class="">And yes, I might/should upgrade our PETSc version used (3.1), but it will take me some days to check the full code package.</div><div class=""><br class=""></div><div class="">Now, I will create my DA (now in 3.6 called DMDA) for the coupled system via</div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">DACreate3d(</span>PETSC_COMM_WORLD, Periodicity, DA_STENCIL_BOX, <span style="font-variant-ligatures: no-common-ligatures;" class="">Nx,</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> Ny, Nz, Px, Py, Pz, 4, 1, </span>lx, ly, lz, &MyDA);</div></div><div class="">instead of</div><div class=""><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">DACreate3d(</span>PETSC_COMM_WORLD, Periodicity, DA_STENCIL_BOX, <span style="font-variant-ligatures: no-common-ligatures;" class="">Nx,</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> Ny, Nz, Px, Py, Pz, 1, 1, </span>lx, ly, lz, &MyDA);</div></div></div><div class="">which I have used for the single equation.</div><div class=""><br class=""></div><div class="">I would like to ask one follow-up question:</div><div class="">Currently, I loop over my matrix (and vectors) via three for-loops over the 3 spatial directions, and set the columns indices in the following way:</div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">for(k){</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">        row.k    = k;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">        col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">0</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].k = k;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">        col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">1</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].k = k;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">        col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">2</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].k = k;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">        col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">3</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].k = k;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">        col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">4</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].k = k+</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">1</span><span style="font-variant-ligatures: no-common-ligatures;" class="">;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">        col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">5</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].k = k-</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">1</span><span style="font-variant-ligatures: no-common-ligatures;" class="">;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">        for(j){</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">            row.j    = j;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">            col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">0</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].j = j;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">            col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">1</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].j = j;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">            col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">2</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].j = j+</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">1</span><span style="font-variant-ligatures: no-common-ligatures;" class="">;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">            col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">3</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].j = j-</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">1</span><span style="font-variant-ligatures: no-common-ligatures;" class="">;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">            col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">4</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].j = j;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">            col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">5</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].j = j;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">            for(i){</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">                row.i    = i;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">                col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">0</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].i = i+</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">1</span><span style="font-variant-ligatures: no-common-ligatures;" class="">;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">                col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">1</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].i = i-</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">1</span><span style="font-variant-ligatures: no-common-ligatures;" class="">;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">                col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">2</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].i = i;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">                col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">3</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].i = i;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">                col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">4</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].i = i;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">                col[</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">5</span><span style="font-variant-ligatures: no-common-ligatures;" class="">].i = i;</span></div></div><div class="">Now for the coupled equations, I should overall additionally loop over the number of DOFs (just 2 in my previous email example). Could you give me an easy example or pseudo-code for the associated assignment of columns (I have the same stencil in each of the submatrices, so for the 2 DOFs in 3D, I would get 7+6=13 column entries per row)? Or can you link me to an existing example within the PETSc help?</div><div class=""><br class=""></div><div class="">Again, Thanks a lot!</div><div class="">Rolf</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div></div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">Am 24.11.2016 um 22:30 schrieb Dave May <<a href="mailto:dave.mayhem23@gmail.com" class="">dave.mayhem23@gmail.com</a>>:</div><br class="Apple-interchange-newline"><div class=""><div style="white-space:pre-wrap" class="">When you create the DMDA, set the number of DOFs (degrees of freedom) per point to be 2 instead of 1. <br class=""><br class="">You must be using and ancient version of petsc given the function names you quoted. Consider upgrading to 3.7<br class=""><br class="">Thanks,<br class="">  Dave</div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, 24 Nov 2016 at 20:24, Rolf Kuiper <<a href="mailto:kuiper@mpia.de" class="">kuiper@mpia.de</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg">Dear PETSc users,</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">maybe this is an easy question, but I can’t find the information right away in the user’s guide nor online.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">What I am currently doing and which works fine:</div><div class="gmail_msg">To solve a partial differential equation for the quantity q on a parallel distributed grid, which is represented by the Distributed Array MyDA, I am currently creating the associated sparse matrix for the KSP solver via</div><div class="gmail_msg"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">DAGetMatrix(MyDA, MATMPIAIJ, &MyMatrix);</span></div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">The solution vector and right hand side vector are created via</div><div class="gmail_msg"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">DACreateGlobalVector(MyDA, &MyRightHandSideVector);</span></div></div><div class="gmail_msg"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">VecDuplicate(MyRightHandSideVector, &GlobalSolutionVector);</span></div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">The DA is constructed using <span style="font-family:Menlo;font-size:11px;font-variant-ligatures:no-common-ligatures" class="gmail_msg">DACreate3d()</span><span style="font-family:Menlo;font-size:11px" class="gmail_msg"> </span>with the corresponding regular structured grid information. </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">And here is my problem:</div><div class="gmail_msg">Now, I would like to solve a coupled system of equations for the quantities q1 and q2 on the same grid. I.e., the matrix should just get the double number of rows and columns, the vectors contain twice the number of entries (e.g. first all q1s and then all q2s). And I would like to be sure that the entries of q1 and q2, which are associated with the same grid cell are located on the same processor.</div><div class="gmail_msg">Is there already a pre-defined structures available (such as <span style="font-family:Menlo;font-size:11px" class="gmail_msg">MATMPIAIJ</span>) within PETSc to enlarge such a single equation to store the entries of coupled equations? Such as</div><div class="gmail_msg"><span style="font-family:Menlo;font-size:11px" class="gmail_msg">DACreateTwiceTheGlobalVector()</span>?</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">The equation is (simplified) of the form</div><div class="gmail_msg">d/dt q1 + grad q2 = 0</div><div class="gmail_msg">d/dt q2 + f(q1) = 0</div><div class="gmail_msg">with an arbitrary function f depending on q1.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Thanks a lot for your help in advance,</div><div class="gmail_msg">Rolf</div></div></blockquote></div>
</div></blockquote></div><br class=""></div></body></html>