<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif;font-size:13px"><div id="yui_3_16_0_ym19_1_1487414548429_17390"><span>Hello,</span></div><div id="yui_3_16_0_ym19_1_1487414548429_17390"><span><br></span></div><div id="yui_3_16_0_ym19_1_1487414548429_17390" dir="ltr"><span id="yui_3_16_0_ym19_1_1487414548429_17415">trying my first PETSc program, some matrices ok, but this one showing error:</span></div><div id="yui_3_16_0_ym19_1_1487414548429_17390" dir="ltr"><span><br></span></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_17444">Linear solve did not converge due to DIVERGED_PCSETUP_FAILED iterations 0</div><div id="yui_3_16_0_ym19_1_1487414548429_17390" dir="ltr"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_17445"> PCSETUP_FAILED due to FACTOR_NUMERIC_ZEROPIVOT</div><div id="yui_3_16_0_ym19_1_1487414548429_17390" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1487414548429_17390" dir="ltr">Not sure what I can try (I tried PC and GMRES, both no good) ?</div><div id="yui_3_16_0_ym19_1_1487414548429_17390" dir="ltr"><br></div><div id="yui_3_16_0_ym19_1_1487414548429_17390" dir="ltr"><br></div><div></div><div id="yui_3_16_0_ym19_1_1487414548429_17389"><div id="yui_3_16_0_ym19_1_1487414548429_17537">/*</div><div id="yui_3_16_0_ym19_1_1487414548429_17538"> * Matrix A</div><div id="yui_3_16_0_ym19_1_1487414548429_17539"> * 1 0 0 1 1 1</div><div id="yui_3_16_0_ym19_1_1487414548429_17540"> * 0 1 1 1 0 1</div><div id="yui_3_16_0_ym19_1_1487414548429_17541"> * 1 0 0 0 1 1</div><div id="yui_3_16_0_ym19_1_1487414548429_17542"> * 0 0 -1 0 1 1</div><div id="yui_3_16_0_ym19_1_1487414548429_17543"> * 1 1 0 1 1 1</div><div id="yui_3_16_0_ym19_1_1487414548429_17544"> * 0 1 1 1 0 0</div><div id="yui_3_16_0_ym19_1_1487414548429_17545"> *</div><div id="yui_3_16_0_ym19_1_1487414548429_17546"> * Expected inverse result</div><div id="yui_3_16_0_ym19_1_1487414548429_17547"> *<span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_17548"> </span> 0 0 0 -1 1 -1</div><div id="yui_3_16_0_ym19_1_1487414548429_17549"> *<span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_17550"> </span>-1 0 0 0 1 0</div><div id="yui_3_16_0_ym19_1_1487414548429_17551"> *<span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_17552"> </span> 0 0 1 0 -1 1</div><div id="yui_3_16_0_ym19_1_1487414548429_17553"> *<span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_17554"> </span> 1 0 -1 0 0 0</div><div id="yui_3_16_0_ym19_1_1487414548429_17555"> *<span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_17556"> </span> 0 -1 1 1 -1 2</div><div id="yui_3_16_0_ym19_1_1487414548429_17557"> *<span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_17558"> </span> 0 1 0 0 0 -1</div><div id="yui_3_16_0_ym19_1_1487414548429_17559"> *</div><div id="yui_3_16_0_ym19_1_1487414548429_17560"> */</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_17561"><br id="yui_3_16_0_ym19_1_1487414548429_17562"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_17561">Here is my code:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_17561"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_17561"><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18096"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18097"> </span>Vec x,b;<span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18098"> </span> </div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18099"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18100"> </span>Mat A; <span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18101"> </span> </div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18102"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18103"> </span>KSP solver; </div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18104"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18105"> </span>PC pc; </div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18106"><br id="yui_3_16_0_ym19_1_1487414548429_18107"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18108"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18109"> </span>PetscMPIInt size;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18110"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18118"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18119"> </span>int mpi_rank;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18120"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18121"> </span>bool is_mpi_root = FALSE;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18122"><br id="yui_3_16_0_ym19_1_1487414548429_18123"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18124"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18125"> </span>/*</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18126"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18127"> </span> * initialize PETSc and MPI</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18128"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18129"> </span> */</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18130"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18131"> </span>PetscInitialize ( &argc, &argv, (char*)0, USAGE);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18132"><br id="yui_3_16_0_ym19_1_1487414548429_18133"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18134"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18146"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18147"> </span>int col_index [6][6] = {</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18148"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18149"> </span>{0, 1, 2, 3, 4, 5},</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18150"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18151"> </span>{0, 1, 2, 3, 4, 5},</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18152"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18153"> </span>{0, 1, 2, 3, 4, 5},</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18154"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18155"> </span>{0, 1, 2, 3, 4, 5},</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18156"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18157"> </span>{0, 1, 2, 3, 4, 5},</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18158"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18159"> </span>{0, 1, 2, 3, 4, 5}</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18160"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18161"> </span>};</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18162"><br id="yui_3_16_0_ym19_1_1487414548429_18163"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18164"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18165"> </span>double v [6][6] = {</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18166"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18167"> </span>{1., 0., 0., 1., 1., 1.},</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18168"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18169"> </span>{0., 1., 1., 1., 0., 1.},</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18170"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18171"> </span>{1., 0., 0., 0., 1., 1.},</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18172"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18173"> </span>{0., 0., -1., 0., 1., 1.},</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18174"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18175"> </span>{1., 1., 0., 1., 1., 1.},</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18176"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18177"> </span>{0., 1., 1., 1., 0., 0.}</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18178"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18179"> </span>};</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18180"><br id="yui_3_16_0_ym19_1_1487414548429_18181"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18182"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18183"> </span>int nz_rows [] = {6, 6, 6, 6, 6, 6};</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18184"><span style="white-space:pre-wrap;"><br></span></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18184"><span id="yui_3_16_0_ym19_1_1487414548429_18191" style="white-space: pre-wrap;"> </span>int N = 6;<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18192"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18193"> </span>int row, col;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18194"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18195"> </span>double value = 1.;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18196"><br id="yui_3_16_0_ym19_1_1487414548429_18197"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18198"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18199"> </span>int m, n;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18200"><br id="yui_3_16_0_ym19_1_1487414548429_18201"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18202"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18203"> </span>int b_start, b_end;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18204"><br id="yui_3_16_0_ym19_1_1487414548429_18205"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18206"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18207"> </span>// create x</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18208"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18209"> </span>VecCreate ( PETSC_COMM_WORLD, &x );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18210"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18211"> </span>VecSetSizes ( x, PETSC_DECIDE, N );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18212"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18213"> </span>VecSetType ( x, VECMPI );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18214"><br id="yui_3_16_0_ym19_1_1487414548429_18215"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18216"><br id="yui_3_16_0_ym19_1_1487414548429_18217"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18218"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18219"> </span>// create b</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18220"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18221"> </span>VecCreate ( PETSC_COMM_WORLD, &b );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18222"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18223"> </span>VecSetSizes ( b, PETSC_DECIDE, N );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18224"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18225"> </span>VecSetType ( b, VECMPI );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18226"><br id="yui_3_16_0_ym19_1_1487414548429_18227"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18228"><span style="white-space: pre-wrap;"><br></span></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18228"><span id="yui_3_16_0_ym19_1_1487414548429_18237" style="white-space: pre-wrap;"> </span>// create A<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18238"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18239"> </span>MatCreate ( PETSC_COMM_WORLD, &A );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18240"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18241"> </span>MatSetSizes ( A, PETSC_DECIDE, PETSC_DECIDE, N, N );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18242"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18250"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18251"> </span>MatSetUp ( A );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18252"><br id="yui_3_16_0_ym19_1_1487414548429_18253"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18254"><span id="yui_3_16_0_ym19_1_1487414548429_18257" style="white-space: pre-wrap;"> </span>for ( row = 0; row < N; row++ ) {<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18258"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18259"> </span>MatSetValues ( A, 1, &row, nz_rows[row], col_index[row], v[row], INSERT_VALUES );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18260"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18261"> </span>}</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18262"><span id="yui_3_16_0_ym19_1_1487414548429_18265" style="white-space: pre-wrap;"> </span>MatAssemblyBegin ( A, MAT_FINAL_ASSEMBLY ) ;<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18266"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18267"> </span>MatAssemblyEnd ( A, MAT_FINAL_ASSEMBLY ) ;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18268"><br id="yui_3_16_0_ym19_1_1487414548429_18269"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18270"><span id="yui_3_16_0_ym19_1_1487414548429_18275" style="white-space: pre-wrap;"> </span>MatView ( A, PETSC_VIEWER_STDOUT_WORLD );<br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18276"><br id="yui_3_16_0_ym19_1_1487414548429_18277"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18278"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18279"> </span>/*</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18280"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18281"> </span> * setting up KSP</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18282"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18283"> </span> */</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18284"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18285"> </span>KSPCreate ( PETSC_COMM_WORLD, &solver );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18286"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18287"> </span>KSPSetOperators ( solver, A, A );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18288"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18289"> </span>// KSPSetType ( solver, KSPCG );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18290"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18291"> </span>KSPSetType ( solver, KSPGMRES );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18292"><br id="yui_3_16_0_ym19_1_1487414548429_18293"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18294"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18295"> </span>for ( col = 0; col < N; col++ ) {</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18296"><br id="yui_3_16_0_ym19_1_1487414548429_18297"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18298"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18299"> </span>// set b in root process</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18300"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18301"> </span>VecGetOwnershipRange ( b , &b_start , &b_end ) ;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18302"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18306"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18307"> </span>// clear all values</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18308"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18309"> </span>VecSet ( b, 0 );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18310"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18311"> </span>// set 1 in the correct process.</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18312"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18313"> </span>// each process owns a block of b : [b_start, b_end)</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18314"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18315"> </span>// index starts from 0</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18316"><br id="yui_3_16_0_ym19_1_1487414548429_18317"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18318"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18319"> </span>if ( col >= b_start && col < b_end )</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18320"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18321"> </span>VecSetValues ( b, 1, &col, &value, INSERT_VALUES );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18322"><br id="yui_3_16_0_ym19_1_1487414548429_18323"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18324"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18325"> </span>// distribute b</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18326"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18327"> </span>VecAssemblyBegin ( b ) ;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18328"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18329"> </span>VecAssemblyEnd ( b ) ;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18330"><br id="yui_3_16_0_ym19_1_1487414548429_18331"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18332"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18333"> </span>// must be called from all processes</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18334"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18335"> </span>//VecView ( b, PETSC_VIEWER_STDOUT_WORLD );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18336"><br id="yui_3_16_0_ym19_1_1487414548429_18337"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18338"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18339"> </span>KSPSolve ( solver, b, x );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18340"><br id="yui_3_16_0_ym19_1_1487414548429_18341"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18342"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18343"> </span>VecView ( x, PETSC_VIEWER_STDOUT_WORLD );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18344"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18345"> </span>}</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18346"><br id="yui_3_16_0_ym19_1_1487414548429_18347"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18348"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18349"> </span>/*</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18350"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18351"> </span> * destroy KSP</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18352"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18353"> </span> */</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18354"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18355"> </span>VecDestroy ( &b );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18356"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18357"> </span>VecDestroy ( &x );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18358"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18359"> </span>MatDestroy ( &A );</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18360"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18361"> </span>KSPDestroy(&solver);</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18362"><br id="yui_3_16_0_ym19_1_1487414548429_18363"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18364"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18365"> </span>/*</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18366"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18367"> </span> * finalize PETSc</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18368"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18369"> </span> */</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18370"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18371"> </span>PetscFinalize();</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18372"><br id="yui_3_16_0_ym19_1_1487414548429_18373"></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18374"><span style="white-space:pre-wrap;" id="yui_3_16_0_ym19_1_1487414548429_18375"> </span>return 0;</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18376"><br id="yui_3_16_0_ym19_1_1487414548429_18377"></div></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_17561">I am running this with one MPI process, and the output seems to indicate that the A matrix is set correctly:</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_17561"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_17561"><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18502">Mat Object: 1 MPI processes</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18503"> type: seqaij</div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18504">row 0: (0, 1.) (1, 0.) (2, 0.) (3, 1.) (4, 1.) (5, 1.) </div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18505">row 1: (0, 0.) (1, 1.) (2, 1.) (3, 1.) (4, 0.) (5, 1.) </div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18506">row 2: (0, 1.) (1, 0.) (2, 0.) (3, 0.) (4, 1.) (5, 1.) </div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18507">row 3: (0, 0.) (1, 0.) (2, -1.) (3, 0.) (4, 1.) (5, 1.) </div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18508">row 4: (0, 1.) (1, 1.) (2, 0.) (3, 1.) (4, 1.) (5, 1.) </div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18509">row 5: (0, 0.) (1, 1.) (2, 1.) (3, 1.) (4, 0.) (5, 0.) </div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_18510"><br id="yui_3_16_0_ym19_1_1487414548429_18511"></div></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_17561"><br></div><div dir="ltr" id="yui_3_16_0_ym19_1_1487414548429_17561">Thanks for any help !</div></div><div id="yui_3_16_0_ym19_1_1487414548429_17389"> </div><div class="signature" id="yui_3_16_0_ym19_1_1487414548429_17388">rgds<br>LX</div></div></body></html>