Can't use subroutine to define thermal conductivity

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
Jundi He
Posts: 106
Joined: Fri Jan 13, 2017 3:23 pm

Can't use subroutine to define thermal conductivity

Post 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!
Attachments
cs_user_physical_properties.f90
(10.39 KiB) Downloaded 178 times
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Can't use subroutine to define thermal conductivity

Post 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
Jundi He
Posts: 106
Joined: Fri Jan 13, 2017 3:23 pm

Re: Can't use subroutine to define thermal conductivity

Post 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
Jundi He
Posts: 106
Joined: Fri Jan 13, 2017 3:23 pm

Re: Can't use subroutine to define thermal conductivity

Post 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
Attachments
error.txt
(915 Bytes) Downloaded 168 times
cs_user_physical_properties.f90
(10.44 KiB) Downloaded 177 times
Jundi He
Posts: 106
Joined: Fri Jan 13, 2017 3:23 pm

Re: Can't use subroutine to define thermal conductivity

Post 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
Attachments
cs_user_physical_properties.f90
(2 KiB) Downloaded 180 times
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Can't use subroutine to define thermal conductivity

Post 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
Jundi He
Posts: 106
Joined: Fri Jan 13, 2017 3:23 pm

Re: Can't use subroutine to define thermal conductivity

Post 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
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Can't use subroutine to define thermal conductivity

Post 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
Jundi He
Posts: 106
Joined: Fri Jan 13, 2017 3:23 pm

Re: Can't use subroutine to define thermal conductivity

Post by Jundi He »

Hi Yvan:

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

Regards!
Jundi
Post Reply