Nonlinear calculate velocity

Clearly defined bug reports and their fixes
Post Reply
barnburnr
Posts: 9
Joined: 15 Jun 2011, 19:43
Antispam: Yes

Nonlinear calculate velocity

Post by barnburnr »

Hi,

This is my second Elmer model so please excuse any naivety. I was running into a segmentation fault when trying to compute the velocity (using 'Nonlinear Calculate Velocity = Logical True' in my solver section) of the dependent variable of a transient heat equation. The primary issue is in MainUtils.f90 where the velocity variable is only added for the steady state case:

IF( ListGetLogical( Solver % Values,'Calculate Velocity',Found) THEN

where, I believe, it should also add the variable in the transient case:

IF( ListGetLogical( Solver % Values,'Calculate Velocity',Found) &
.OR. ListGetLogical( Solver % Values, 'Nonlinear Calculate Velocity', Found) ) THEN

or however you want to code it. The segmentation fault was occurring in SolverUtils.f90 on the call:

VeloVar => VariableGet( Solver % Mesh % Variables, str )

because 'heat velocity' (or whatever you name the variable) was never created AND because the variable linked list appears to end tragically. While this is easily solved using the above fix, I hope that someone can take a look at how some of these linked lists are being terminated so perhaps we can stop the program a bit more graciously -- tracking down seg faults is time consuming for me since I am admittedly an amateur fortran programmer. In any case, hope this is all helpful.

Kevin
Juha
Site Admin
Posts: 357
Joined: 21 Aug 2009, 15:11

Re: Nonlinear calculate velocity

Post by Juha »

Hi Kevin,

thanks for the report, we'll have a look.

As for the linked lists, the VariableGet() should just return Null(), if the variable is not
found. Just the check for this , i.e. something like

Code: Select all

   IF(.NOT.ASSOCIATED(VeloVar)) CALL Fatal('Velocity variable not found')
is missing.
Regards, Juha
barnburnr
Posts: 9
Joined: 15 Jun 2011, 19:43
Antispam: Yes

Re: Nonlinear calculate velocity

Post by barnburnr »

Juha,

I agree that is should return Null() but it doesn't. It seg faults before the return. I can work on narrowing it down if you can help me figure out the fix. I suspect that the problem is in the creation of the list and not actually in VariableGet() and I'm not familiar with the code base.

Thanks,
Kevin
Juha
Site Admin
Posts: 357
Joined: 21 Aug 2009, 15:11

Re: Nonlinear calculate velocity

Post by Juha »

Hi,

i don't see any troubles after either creating the "VeloVar" variable, when the
"Nonlinear Calculate Velocity" flag is given, or checking that the "VeloVar" is
actually present before accessing it, or both. Running "valgrind ElmerSolver"
(a memory access checking program) doesn't reveal anything either.

If you have an example case that still behaves badly, could you please share
it?

Regards,Juha
Post Reply