I check the memory leak with Valgrind. This is where the code stopped. Amir --23154-- VALGRIND INTERNAL ERROR: Valgrind received a signal 11 (SIGSEGV) - exiting --23154-- si_code=128; Faulting address: 0x0; sp: 0x1002cade00
valgrind: the 'impossible' happened: Killed by fatal signal host stacktrace: ==23154== at 0x58052522: ??? (in /usr/lib/valgrind/memcheck-amd64-linux) ==23154== by 0x5800B8CC: ??? (in /usr/lib/valgrind/memcheck-amd64-linux) ==23154== by 0x5800BAD7: ??? (in /usr/lib/valgrind/memcheck-amd64-linux) ==23154== by 0x5800BDA4: ??? (in /usr/lib/valgrind/memcheck-amd64-linux) ==23154== by 0x5809F5DC: ??? (in /usr/lib/valgrind/memcheck-amd64-linux) ==23154== by 0x580AED50: ??? (in /usr/lib/valgrind/memcheck-amd64-linux) sched status: running_tid=1 Thread 1: status = VgTs_Runnable (lwpid 23154) ==23154== at 0x4C320A6: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==23154== by 0x4FA68E0: PetscMallocAlign (mal.c:42) ==23154== by 0x4FA6EEA: PetscMallocA (mal.c:390) ==23154== by 0x50FFBAF: VecCreate (veccreate.c:35) ==23154== by 0x54E77BB: DMCreateGlobalVector_DA (dadist.c:36) ==23154== by 0x5463DDD: DMCreateGlobalVector (dm.c:928) ==23154== by 0x54E7613: VecDuplicate_MPI_DA (dadist.c:16) ==23154== by 0x50FC014: VecDuplicate (vector.c:375) ==23154== by 0x593ED55: SNESSolve (snes.c:4296) ==23154== by 0x59D9519: TSStep_Pseudo (posindep.c:151) ==23154== by 0x59B8A88: TSStep (ts.c:3548) ==23154== by 0x59C383D: TSSolve (ts.c:3731) ==23154== by 0x115BEC: main (1d.c:1253) Note: see also the FAQ in the source distribution. It contains workarounds to several common problems. In particular, if Valgrind aborted or crashed after identifying problems in your program, there's a good chance that fixing those problems will prevent Valgrind aborting or crashing, especially if it happened in m_mallocfree.c. If that doesn't help, please report this bug to: www.valgrind.org In the bug report, send all the above text, the valgrind version, and what OS and version you are using. Thanks. On Jul 6 2018, at 1:47 am, Smith, Barry F. <[email protected]> wrote: > > > Is this a memory leak? Please send the entire valgrind message. > If a memory leak it just means you did not destroy all the vectors that you > accessed in the code. > Barry > > > On Jul 5, 2018, at 12:26 PM, Amir <[email protected]> wrote: > > 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. > > Amir > > Thread 1: status = VgTs_Runnable (lwpid 23154) > > ==23154== at 0x4C320A6: memalign (in > > /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) > > ==23154== by 0x4FA68E0: PetscMallocAlign (mal.c:42) > > ==23154== by 0x4FA6EEA: PetscMallocA (mal.c:390) > > ==23154== by 0x50FFBAF: VecCreate (veccreate.c:35) > > ==23154== by 0x54E77BB: DMCreateGlobalVector_DA (dadist.c:36) > > ==23154== by 0x5463DDD: DMCreateGlobalVector (dm.c:928) > > ==23154== by 0x54E7613: VecDuplicate_MPI_DA (dadist.c:16) > > ==23154== by 0x50FC014: VecDuplicate (vector.c:375) > > ==23154== by 0x593ED55: SNESSolve (snes.c:4296) > > ==23154== by 0x59D9519: TSStep_Pseudo (posindep.c:151) > > ==23154== by 0x59B8A88: TSStep (ts.c:3548) > > ==23154== by 0x59C383D: TSSolve (ts.c:3731) > > ==23154== by 0x115BEC: main (1d.c:1253) > > > > On Jul 6 2018, at 1:20 am, Smith, Barry F. <[email protected]> wrote: > > > > 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. > > Barry > > > > On Jul 5, 2018, at 5:38 AM, Amir <[email protected]> wrote: > > Hello > > 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? > > Thanks for your great time. > > Amir > > > > PetscInt GRID=1; > > for (GRID=1;GRID<GRID_MAX;){ > > // > > // FIND THE ADAPTED SOLUTION > > // USING PREVIOUS SOLUTION VECTORS > > // > > // > > // BUILDING THE ADAPTED SOLUTION AND DM > > // > > DMDACreate1d(); > > DMSetFromOptions(); > > DMSetUp(); > > DMCreateGlobalVector(); > > // > > // INTERPOLATE FROM COARSE TO REFINE > > // > > // DESTROYING THE FINE TEMPERORAY VECS AND > > // RESETTING THE COARSE VECS WITH REFINED NEW VECS > > // > > // > > // BUILDING TS > > // > > TSCreate(); > > TSSetApplicationContext(); > > TSSetDM(); > > TSSetProblemType(ts,TS_NONLINEAR); > > TSSetType(ts,TSPSEUDO); > > TSSetIFunction(); > > TSSetTimeStep(); > > // > > TSSolve(); > > // > > TSDestroy(); > > DMDestroy(); > > // > > GRID=GRID+1; > > // > > }//end GRID-loop > >
