Page 1 of 1

Can't use subroutine to define thermal conductivity

Posted: Tue Feb 12, 2019 11:48 am
by Jundi He
Hi Code Saturne developers:

I was going to use the subroutine to define the local thermal conductivity of some special regions of the fluid. This is my subroutine, the calculations before line 331 can be neglected, from line 331 to line 334, I do loop to all the elements, and define the thermal conductivity of all the elements. When I comment line 331 to 334, the simulation can be run without error, but when I uncomment line 331 to 334, the simulation crashed, anyone knows the reason?

I've also done a test, if you comment line 331 to 334, and uncomment line 337 to 339, it's doing a loop to all the element indexes and calling the x coordinates of these cells, still the simulation crashes, which means I can not do loop to all the elements in this subroutine. Anyone got some clues about what's the problem? Many thanks!

Regards!

Re: Can't use subroutine to define thermal conductivity

Posted: Tue Feb 12, 2019 12:25 pm
by Yvan Fournier
Hello,

You did not call field_get_val_s on cpro_scalt, so it is probably not initialized, which can explain the crash.

Regards,

Yvan

Re: Can't use subroutine to define thermal conductivity

Posted: Tue Feb 12, 2019 1:43 pm
by Jundi He
Hi Yvan:

But even if I don't define the thermal conductivity, I just make a simple do loop to all the cell:

do iel=1, ncel
enddo

The simulation still crashes. It seems that it's not the issue of initialization.

Regards!
Jundi

Re: Can't use subroutine to define thermal conductivity

Posted: Tue Feb 12, 2019 2:08 pm
by Jundi He
Hi Yvan:

I've put

call field_get_val_s(ifcvsl, cpro_vscal)

to call the field, and when I run the simulation, it comes with this error file, seems there is a field that hasn't been defined.

Regards!
Jundi

Re: Can't use subroutine to define thermal conductivity

Posted: Tue Feb 12, 2019 2:20 pm
by Jundi He
Hi Yvan:

I've tested a simple subroutine to define the thermal conductivity, and I didn't call any field in this subroutine, the simulation can be run smoothly, but does it change the local thermal conductivity? I've already given equations to calculate the thermal conductivity in the GUI.

Regards!
Jundi

Re: Can't use subroutine to define thermal conductivity

Posted: Tue Feb 12, 2019 3:41 pm
by Yvan Fournier
Hello,

For the undefined field, you probably did not define ifcvsl correctly.

As for your simple subroutine, since you did not initialize cpro_vscal, it can fail or crash in strange manners, but is not correct.

If you defined the thermal conductivity in the GUI, you do not need a user subroutine for this (and should avoid it if you are not too familiar with user subroutines or field values access).

Regards,

Yvan

Re: Can't use subroutine to define thermal conductivity

Posted: Tue Feb 12, 2019 4:23 pm
by Jundi He
Hi Yvan:

How should I define ifcvsl corrently? Is it like this:

call field_get_key_int(ivarfl(isca(iscal)), kivisl, ifcvsl)
call field_get_val_s(ifcvsl, cpro_vscal)

I need to define the thermal conductivity by the subroutine, the reason I define it in the GUI is that I can't leave it empty in the GUI, I must ether define it constant or variable in the GUI.

Regards!
Jundi

Re: Can't use subroutine to define thermal conductivity

Posted: Tue Feb 12, 2019 6:57 pm
by Yvan Fournier
Hello,

This seems ok, but I recommend checking (for example printing) your value of ifcvsl first. If it is not correct, checj values from which it is built (isca, iscal(isca), ...).

Regards,

Yvan

Re: Can't use subroutine to define thermal conductivity

Posted: Wed Feb 13, 2019 12:51 pm
by Jundi He
Hi Yvan:

I've correct the subroutine according to one of the subroutine used by my colleague, thanks!

Regards!
Jundi