<html xmlns:v="urn:schemas-microsoft-com:vml" 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=us-ascii"><meta name=Generator content="Microsoft Word 14 (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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hi,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I am just getting started with PETSc and am having difficulty with setting up my MATSBAIJ matrix. I’m adapting the ksp/ex23.c example to my 3D FEM calculation; in my case the equation to solve is K*x = b.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>For serial execution, the following works fine and gives the correct answer.<o:p></o:p></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'> ierr = MatCreate(PETSC_COMM_WORLD,&K);CHKERRQ(ierr);<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'> ierr = MatSetSizes(K,vlocal,vlocal,neqns,neqns);CHKERRQ(ierr);<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'> ierr = MatSetType(K,MATSBAIJ);CHKERRQ(ierr); // symmetric, block, sparse<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'> ierr = MatSetOption(K,MAT_SPD,PETSC_TRUE);CHKERRQ(ierr); // K is symmetric, positive-definite, sparse<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'> ierr = MatSetOption(K,MAT_IGNORE_LOWER_TRIANGULAR,PETSC_TRUE);CHKERRQ(ierr); // so only top tri is needed<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'> ierr = MatSetUp(K);CHKERRQ(ierr);<o:p></o:p></span></p><p class=MsoNormal>where <span style='font-size:9.0pt;font-family:"Courier New"'>vlocal </span>is the result from the call to <span style='font-size:9.0pt;font-family:"Courier New"'>VecGetLocalSize(x,&vlocal) </span>for the solution vector (obviously the full size in the serial case).<o:p></o:p></p><p class=MsoNormal>However, for parallel execution the above crashes on a 11 SEGV Segmentation Violation Error on entry to the function <span style='font-size:9.0pt;font-family:"Courier New"'>MatSetOption_MPISBAIJ()</span>, according to TotalView.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>So instead I have been trying the following for parallel.<o:p></o:p></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'> PetscInt blockSize = 1; // use a block size of 1 since K is NOT block symmetric<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'> PetscInt diagNZ = 5; // # of non-zeros per row in upper diagonal portion of local submatrix<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'> PetscInt offdiagNZ = 8; // max # of non-zeros per row in off-diagonal portion of local submatrix<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'> ierr = MatCreateSBAIJ(PETSC_COMM_WORLD,blockSize,vlocal,vlocal,neqns,neqns,diagNZ,NULL,offdiagNZ,NULL,&K);CHKERRQ(ierr);<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'> ierr = MatSetOption(K,MAT_SPD,PETSC_TRUE);CHKERRQ(ierr); // K is symmetric, positive-definite, sparse<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'> ierr = MatSetOption(K,MAT_IGNORE_LOWER_TRIANGULAR,PETSC_TRUE);CHKERRQ(ierr); // so only top tri is needed<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'> ierr = MatSetUp(K);CHKERRQ(ierr);<o:p></o:p></span></p><p class=MsoNormal>However, this fails during the process of setting matrix values (<span style='font-size:9.0pt;font-family:"Courier New"'>MatSetValue()</span>) with the following error:<o:p></o:p></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'>[0]PETSC ERROR: Argument out of range<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'>[0]PETSC ERROR: new nonzero at (0,26) caused a malloc<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'>…<o:p></o:p></span></p><p class=MsoNormal>(Note that in this case the matrix size is 96x96 split over 2 processors (vlocal = 48).)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>If someone would please point me to the correct way to set up the (MATSBAIJ) matrix for a perfectly symmetric, positive-definite, sparse system, I’d appreciate it.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thanks,<o:p></o:p></p><p class=MsoNormal>Matt Overholt<o:p></o:p></p><p class=MsoNormal>CapeSym, Inc.<o:p></o:p></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'><o:p> </o:p></span></p></div><br />
<table style="border-top: 1px solid #aaabb6;">
<tr>
<td style="width: 55px; padding-top: 18px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=oa-2115-v2-b" target="_blank"><img src="https://ipmcdn.avast.com/images/2016/icons/icon-envelope-tick-round-orange-v1.png" /></a></td>
<td style="width: 470px; padding-top: 20px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=oa-2115-v2-b" target="_blank" style="color: #4453ea;">www.avast.com</a>
</td>
</tr>
</table></body></html>