<div dir="ltr"><div><div>I agree that he meant implicit method. The code works as expected now. I must have erronously used Forward euler instead of backwards euler.<br><br></div>Thanks again,<br></div>Scott Dossa<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 9, 2016 at 2:34 PM, Hong Zhang <span dir="ltr"><<a href="mailto:hongzhang@anl.gov" target="_blank">hongzhang@anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I guess Barry meant “implicit method”.<br>
<br>
To use backward Euler, change TSEULER to TSBEULER in the function call of TSSetType().<br>
<span class="HOEnZb"><font color="#888888"><br>
Hong<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> On Aug 9, 2016, at 2:13 PM, Barry Smith <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br>
><br>
><br>
>   The Euler method is an explicit method that does not require the Jacobian. Hence the Jacobian you provide is never used.<br>
><br>
>    If you use any implement method, for example backward Euler beuler then you will see the Jacobian being used.<br>
><br>
>   Barry<br>
><br>
>> On Aug 9, 2016, at 2:08 PM, Scott Dossa <<a href="mailto:doss0032@umn.edu">doss0032@umn.edu</a>> wrote:<br>
>><br>
>> Hi all,<br>
>><br>
>> I adapted ex13.c from .../ts/examples/tutorials/<wbr>ex13.c to solve a 1D TD PDE (swift-hohenberg).<br>
>> Long story short: the function which sets the Jacobian is never being called despite being assigned by TSSetRHSJacobian().<br>
>><br>
>> I create the TS environment with the following commands (omitting some code before and after -- Full code attached):<br>
>><br>
>> ------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>---------------<br>
>>  ierr = DMDACreate1d(PETSC_COMM_WORLD, DM_BOUNDARY_NONE, 15, 1, 1, NULL, &da); CHKERRQ(ierr);<br>
>><br>
>>  /*============================<wbr>==============================<wbr>========<br>
>>    Let DMDA create vector<br>
>>    ==============================<wbr>==============================<wbr>======*/<br>
>><br>
>>  ierr = DMCreateGlobalVector(da, &x);CHKERRQ(ierr);<br>
>><br>
>>  /*============================<wbr>==============================<wbr>========<br>
>>    Create timestepper context which will use Euler Method<br>
>>    ==============================<wbr>==============================<wbr>======*/<br>
>><br>
>>  ierr = TSCreate(PETSC_COMM_WORLD,&ts)<wbr>;CHKERRQ(ierr);<br>
>>  ierr = TSSetDM(ts, da);CHKERRQ(ierr);<br>
>>  ierr = TSSetType(ts, TSEULER);CHKERRQ(ierr);<br>
>><br>
>>  ierr = TSSetRHSFunction(ts, x, RHSFunction, NULL);CHKERRQ(ierr);<br>
>><br>
>>  /*============================<wbr>==============================<wbr>=======<br>
>>    Create Jacobian for Euler Method<br>
>>    ==============================<wbr>==============================<wbr>=====*/<br>
>>  ierr = DMSetMatType(da, MATAIJ);CHKERRQ(ierr);<br>
>>  ierr = DMCreateMatrix(da,&J);CHKERRQ(<wbr>ierr);<br>
>>  ierr = TSSetRHSJacobian(ts,J,J,<wbr>RHSJacobian,NULL); CHKERRQ(ierr)<br>
>> ------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>---------------<br>
>><br>
>> I define the function RHSJacobian later, PetscPrintf(PETSC_COMM_WORLD, "Jacobian function called") is used to see if the function is ever called.<br>
>><br>
>> Neither is the message ever called, nor is the Jacobian matrix ever non-zero. The J matrix is checked with MatView( ). No error messages are produced either at compiling nor runtime.<br>
>><br>
>> Has anyone else run into such an issue or have any advice of how best to probe the problem?<br>
>> Thanks so much!<br>
>> -Scott Dossa<br>
>><br>
>><br>
>> <swift.cpp><br>
><br>
<br>
</div></div></blockquote></div><br></div>