<div>I check the  memory leak with Valgrind. This is where the code stopped. </div><div>Amir</div><div>--23154-- VALGRIND INTERNAL ERROR: Valgrind received a signal 11 (SIGSEGV) - exiting</div><div>--23154-- si_code=128;  Faulting address: 0x0;  sp: 0x1002cade00</div><br><div>valgrind: the 'impossible' happened:</div><div>   Killed by fatal signal</div><br><div>host stacktrace:</div><div>==23154==    at 0x58052522: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)</div><div>==23154==    by 0x5800B8CC: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)</div><div>==23154==    by 0x5800BAD7: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)</div><div>==23154==    by 0x5800BDA4: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)</div><div>==23154==    by 0x5809F5DC: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)</div><div>==23154==    by 0x580AED50: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)</div><br><div>sched status:</div><div>  running_tid=1</div><br><div>Thread 1: status = VgTs_Runnable (lwpid 23154)</div><div>==23154==    at 0x4C320A6: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)</div><div>==23154==    by 0x4FA68E0: PetscMallocAlign (mal.c:42)</div><div>==23154==    by 0x4FA6EEA: PetscMallocA (mal.c:390)</div><div>==23154==    by 0x50FFBAF: VecCreate (veccreate.c:35)</div><div>==23154==    by 0x54E77BB: DMCreateGlobalVector_DA (dadist.c:36)</div><div>==23154==    by 0x5463DDD: DMCreateGlobalVector (dm.c:928)</div><div>==23154==    by 0x54E7613: VecDuplicate_MPI_DA (dadist.c:16)</div><div>==23154==    by 0x50FC014: VecDuplicate (vector.c:375)</div><div>==23154==    by 0x593ED55: SNESSolve (snes.c:4296)</div><div>==23154==    by 0x59D9519: TSStep_Pseudo (posindep.c:151)</div><div>==23154==    by 0x59B8A88: TSStep (ts.c:3548)</div><div>==23154==    by 0x59C383D: TSSolve (ts.c:3731)</div><div>==23154==    by 0x115BEC: main (1d.c:1253)</div><br><br><div>Note: see also the FAQ in the source distribution.</div><div>It contains workarounds to several common problems.</div><div>In particular, if Valgrind aborted or crashed after</div><div>identifying problems in your program, there's a good chance</div><div>that fixing those problems will prevent Valgrind aborting or</div><div>crashing, especially if it happened in m_mallocfree.c.</div><br><div>If that doesn't help, please report this bug to: www.valgrind.org</div><br><div>In the bug report, send all the above text, the valgrind</div><div>version, and what OS and version you are using.  Thanks.</div><br><div class="gmail_quote_attribution">On Jul 6 2018, at 1:47 am, Smith, Barry F. <bsmith@mcs.anl.gov> wrote:</div><blockquote><br><div><br><div>Is this a memory leak? Please send the entire valgrind message.</div><br><div>If a memory leak it just means you did not destroy all the vectors that you accessed in the code.</div><br><div>Barry</div><br><br><blockquote><div>On Jul 5, 2018, at 12:26 PM, Amir <mhbaghaei@mail.sjtu.edu.cn> wrote:</div><br><div>This is what I get from Valgrind. I think there is a problem in setting TS in the loop. But I am not sure what it really is. Sorry for may be confusing you.</div><br><div>Amir</div><br><div>Thread 1: status = VgTs_Runnable (lwpid 23154)</div><div>==23154== at 0x4C320A6: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)</div><div>==23154== by 0x4FA68E0: PetscMallocAlign (mal.c:42)</div><div>==23154== by 0x4FA6EEA: PetscMallocA (mal.c:390)</div><div>==23154== by 0x50FFBAF: VecCreate (veccreate.c:35)</div><div>==23154== by 0x54E77BB: DMCreateGlobalVector_DA (dadist.c:36)</div><div>==23154== by 0x5463DDD: DMCreateGlobalVector (dm.c:928)</div><div>==23154== by 0x54E7613: VecDuplicate_MPI_DA (dadist.c:16)</div><div>==23154== by 0x50FC014: VecDuplicate (vector.c:375)</div><div>==23154== by 0x593ED55: SNESSolve (snes.c:4296)</div><div>==23154== by 0x59D9519: TSStep_Pseudo (posindep.c:151)</div><div>==23154== by 0x59B8A88: TSStep (ts.c:3548)</div><div>==23154== by 0x59C383D: TSSolve (ts.c:3731)</div><div>==23154== by 0x115BEC: main (1d.c:1253)</div><br><div>On Jul 6 2018, at 1:20 am, Smith, Barry F. <bsmith@mcs.anl.gov> wrote:</div><br><br><div>When it exits the loop will depend on your criteria for adapativitiy so I have no way of knowing if it is enough, surely you can tighten your criteria so that it requires several refinements in the loop.</div><br><div>Barry</div><br><br><div>On Jul 5, 2018, at 5:38 AM, Amir <mhbaghaei@mail.sjtu.edu.cn> wrote:</div><br><div>Hello</div><div>Trying to loop over the TSolve() to apply the refinement, I used the below procedure. However, this only goes 1 level of refinement and then it exits. Do you think this is a right algorithm?</div><div>Thanks for your great time.</div><div>Amir</div><br><div>PetscInt GRID=1;</div><div>for (GRID=1;GRID<GRID_MAX;){</div><div>//</div><div>// FIND THE ADAPTED SOLUTION</div><div>// USING PREVIOUS SOLUTION VECTORS</div><div>//</div><div>//</div><div>// BUILDING THE ADAPTED SOLUTION AND DM</div><div>//</div><div>DMDACreate1d();</div><div>DMSetFromOptions();</div><div>DMSetUp();</div><div>DMCreateGlobalVector();</div><div>//</div><div>// INTERPOLATE FROM COARSE TO REFINE</div><div>//</div><div>// DESTROYING THE FINE TEMPERORAY VECS AND</div><div>// RESETTING THE COARSE VECS WITH REFINED NEW VECS</div><div>//</div><div>//</div><div>// BUILDING TS</div><div>//</div><div>TSCreate();</div><div>TSSetApplicationContext();</div><div>TSSetDM();</div><div>TSSetProblemType(ts,TS_NONLINEAR);</div><div>TSSetType(ts,TSPSEUDO);</div><div>TSSetIFunction();</div><div>TSSetTimeStep();</div><div>//</div><div>TSSolve();</div><div>//</div><div>TSDestroy();</div><div>DMDestroy();</div><div>//</div><div>GRID=GRID+1;</div><div>//</div><div>}//end GRID-loop</div></blockquote></div></blockquote><img class="mailspring-open" alt="Open Tracking" width="0" height="0" style="border:0; width:0; height:0;" src="https://link.getmailspring.com/open/1530812945.local-2dcc1bb3-202a-v1.2.2-96fb3a99@getmailspring.com?recipient=cGV0c2MtdXNlcnNAbWNzLmFubC5nb3Y%3D">