<div dir="ltr">Hi,<div><br></div><div>I looked at the example /petsc/src/ts/examples/tutorials/ex1.c, which is to solve a 2D Bratu nonlinear PDE  with pseudo-timestepping. </div><div><br></div><div><div>  ierr = TSSetRHSFunction(ts,NULL,<b>FormFunction</b>,&user);CHKERRQ(ierr);</div></div><div><br></div><div><b>Q1:In the FormFunction(), I do not understand why this example uses 1D array, not 2D array x[j][i]? Is it necessary to use 1D array when we use the pseudo-timestepping method?</b></div><div><br></div><div><div>#undef __FUNCT__</div><div>#define __FUNCT__ "FormFunction"</div><div>PetscErrorCode FormFunction(TS ts,PetscReal t,Vec X,Vec F,void *ptr)</div><div>{</div></div><div><br></div><div>…….</div><div><div>  for (j=0; j<my; j++) {</div><div>    for (i=0; i<mx; i++) {</div><div>      row = i + j*mx;</div><div>      if (i == 0 || j == 0 || i == mx-1 || j == my-1) {</div><div>        f[row] = x[row];</div><div>        continue;</div><div>      }</div><div>      u      = x[row];</div><div>      ub     = x[row - mx];</div><div>      ul     = x[row - 1];</div><div>      ut     = x[row + mx];</div><div>      ur     = x[row + 1];</div><div>      uxx    = (-ur + two*u - ul)*hydhx;</div><div>      uyy    = (-ut + two*u - ub)*hxdhy;</div><div>      f[row] = -uxx + -uyy + sc*lambda*PetscExpScalar(u);</div><div>    }</div><div>  }</div></div><div>……..</div><div>}</div><div><br></div><div><b>Q2: I try to modify this function  using local 2D array x[j][i], but got some errors:</b></div><div><div>[0]PETSC ERROR:   </div><div>[0]PETSC ERROR: Must call DMShellSetLocalVector() or DMShellSetCreateLocalVector()</div><div>[0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.</div><div>[0]PETSC ERROR: Petsc Release Version 3.5.1, Jul, 24, 2014 </div><div>[0]PETSC ERROR: ./test on a arch-darwin-c-debug named kl-12681.local by liul Sun Sep 14 18:42:38 2014</div><div>[0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-fblaslapack --download-mpich</div><div>[0]PETSC ERROR: #1 DMCreateLocalVector_Shell() line 271 in /Users/liul/soft/petsc-3.5.1/petsc/src/dm/impls/shell/dmshell.c</div><div>[0]PETSC ERROR: #2 DMCreateLocalVector() line 709 in /Users/liul/soft/petsc-3.5.1/petsc/src/dm/interface/dm.c</div><div>[0]PETSC ERROR: #3 DMGetLocalVector() line 49 in /Users/liul/soft/petsc-3.5.1/petsc/src/dm/interface/dmget.c</div><div>[0]PETSC ERROR: #4 FormFunction() line 253 in /Users/liul/Desktop/Combustion/test.c</div><div>[0]PETSC ERROR: #5 TSComputeRHSFunction() line 475 in /Users/liul/soft/petsc-3.5.1/petsc/src/ts/interface/ts.c</div><div>[0]PETSC ERROR: #6 TSComputeIFunction() line 688 in /Users/liul/soft/petsc-3.5.1/petsc/src/ts/interface/ts.c</div><div>[0]PETSC ERROR: #7 TSPseudoMonitorDefault() line 330 in /Users/liul/soft/petsc-3.5.1/petsc/src/ts/impls/pseudo/posindep.c</div><div>[0]PETSC ERROR: #8 TSMonitor() line 2809 in /Users/liul/soft/petsc-3.5.1/petsc/src/ts/interface/ts.c</div><div>[0]PETSC ERROR: #9 TSSolve() line 2751 in /Users/liul/soft/petsc-3.5.1/petsc/src/ts/interface/ts.c</div><div>[0]PETSC ERROR: #10 main() line 162 in /Users/liul/Desktop/Combustion/test.c</div></div><div><br></div></div>

<br>
<div><hr></div><font face="Arial" size="1">This message and its contents, including attachments are intended solely for the original recipient. If you are not the intended recipient or have received this message in error, please notify me immediately and delete this message from your computer system. Any unauthorized use or distribution is prohibited. Please consider the environment before printing this email.</font>