<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle"></style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">After reading some documentation, I figured it out myself. MATAIJ can be MATSEQAIJ or MATMPIAIJ, depending on the number of processors involved. Thus, I need to include the command
MatSeqAIJSetPreallocation as well, to cover both cases.
<div>
<div><br>
</div>
<div>Best, </div>
<div>Hui</div>
<div><br>
</div>
<div><br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div id="divRpF311595" style="direction: ltr;"><font face="Tahoma" size="2" color="#000000"><b>From:</b> Sun, Hui<br>
<b>Sent:</b> Wednesday, December 03, 2014 11:09 PM<br>
<b>To:</b> petsc-users@mcs.anl.gov<br>
<b>Subject:</b> Question about preallocation and getOwnership functions<br>
</font><br>
</div>
<div></div>
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">Hello,
<div><br>
</div>
<div>The following lines of code give me trouble because PETSc gives me an error message saying the object A is in a wrong state, and <span style="font-family:Menlo; font-size:11px">Must call MatXXXSetPreallocation() or MatSetUp() on argument 1 "mat" before
MatGetOwnershipRange()</span><span style="font-size:10pt">.</span></div>
<div><span style="font-size:10pt"><br>
</span></div>
<div><span style="font-size:10pt">Here is part of the code: </span></div>
<div>
<div><br>
</div>
<div>
<p style="margin-right:0px; margin-left:0px; font-size:11px; font-family:Menlo"> ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr);</p>
<p style="margin-right:0px; margin-left:0px; font-size:11px; font-family:Menlo"> ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,<span style="color:#272ad8">2</span>*nx*ny,<span style="color:#272ad8">2</span>*nx*ny);CHKERRQ(ierr);</p>
<p style="margin-right:0px; margin-left:0px; font-size:11px; font-family:Menlo"> ierr = MatSetType(A,MATAIJ);CHKERRQ(ierr);</p>
<p style="margin-right:0px; margin-left:0px; font-size:11px; font-family:Menlo"> ierr = MatMPIAIJSetPreallocation(A,<font color="#272ad8">9</font>,<span style="color:rgb(187,44,162)">NULL</span>,<span style="color:rgb(39,42,216)">9</span>,<span style="color:rgb(187,44,162)">NULL</span>);CHKERRQ(ierr);</p>
<p style="margin-right:0px; margin-left:0px; font-size:11px; font-family:Menlo"> ierr = MatGetOwnershipRange(A, &start, &end);CHKERRQ(ierr);</p>
<p style="margin-right:0px; margin-left:0px; font-size:11px; font-family:Menlo"><br>
</p>
<p style="margin-right:0px; margin-left:0px">I think I have called <span style="font-family:Menlo; font-size:11px">MatMPIAIJSetPreallocation, </span><span style="font-size:10pt">so what might be causing the problem here? </span></p>
<p style="margin-right:0px; margin-left:0px"><span style="font-size:10pt"><br>
</span></p>
<p style="margin-right:0px; margin-left:0px">Best,</p>
<p style="margin-right:0px; margin-left:0px">Hui</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>