[petsc-users] petsc error disappears when I print something in the function

Dave May dave.mayhem23 at gmail.com
Tue Apr 21 09:50:49 CDT 2020


On Tue 21. Apr 2020 at 16:47, Matthew Knepley <knepley at gmail.com> wrote:

> You are overwriting memory somewhere. The prints just move it around. I
> suggest running with valgrind.
>

Matt is right. However, judging by the code snippet I bet all the arrays in
question are statically allocated, thus valgrind may be of somewhat limited
use.

If you send the entire function, or all the related pieces of code, someone
in the list might spot the error.

Thanks
Dave




>   Thanks,
>
>     Matt
>
> On Tue, Apr 21, 2020 at 10:44 AM Kaushik Vijaykumar <kaushikv318 at gmail.com>
> wrote:
>
>> Hello group,
>>
>> I have been trying to navigate a weird error that I have found in my FEA
>> code that I am developing using PetSc. The error occurs when, i execute a
>> call to stiffness generation of a Tetrahederal element. The code returns an
>> memory error if I don't print the following statements in the function,
>> (see the ierr print statements below):
>>
>> for (i1=1; i1<4; i1++)  // Loop 6b
>>       {
>>         for (j1=1; j1<4; j1++) // Loop 7b
>>       {
>>       for (k1=1; k1<4; k1++) // Loop 8
>> {
>>         for (l1=1; l1<4; l1++) // Loop 9
>> {
>>   s[ii1+i1-1][jj1+j1-1] =
>> s[ii1+i1-1][jj1+j1-1]+C4[i1][k1][j1][l1]*w[k1][l1]*weight;
>>   ierr = PetscFPrintf(PETSC_COMM_WORLD,outfile,"C4 %f
>> \n",C4[i1][k1][j1][l1]);CHKERRQ(ierr);
>>   ierr = PetscFPrintf(PETSC_COMM_WORLD,outfile,"w %f
>> \n",w[k1][l1]);CHKERRQ(ierr);
>>   ierr = PetscFPrintf(PETSC_COMM_WORLD,outfile,"weight %f
>> \n",weight);CHKERRQ(ierr);
>> }   // Loop 9
>> }  // Loop 8
>>       } // Loop 7b
>>         } // Loop 6b
>>
>>
>> Any help on this is really appreciated.
>>
>> Thanks
>> Kaushik
>>
>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>
> https://www.cse.buffalo.edu/~knepley/
> <http://www.cse.buffalo.edu/~knepley/>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200421/1681b883/attachment.html>


More information about the petsc-users mailing list