Access to temperature gradient C_T_G
Hi,
I wanted to define a shear boundary condition as a function of temperature gradient. Following is the UDF I wrote for this purpose. The UDF only returns the the constant value of 0.0 since the temperature gradient is not accessible. However, from the contour plots, I can see that temperature gradients are available after the first iteration. If I remove the "if" statement, I receive this error: Error: received a fatal signal (Segmentation fault). Error Object: #f I should mention that I keep temporary solver memory from being freed. Any help to solve this problem is highly appreciated. #include "udf.h" #include "mem.h" DEFINE_PROFILE(WSS, t, i) { face_t f; cell_t c; real TG; begin_c_loop(c,t) { if (NNULLP(THREAD_STORAGE(t, SV_T_G))) { printf("Gradient of Temperature is available \n "); TG = NV_MAG(C_T_G(c,t)); C_PROFILE(c,t,i)=-0.0001*TG; } else { C_PROFILE(c,t,i)=0.; } } end_c_loop(c,t) } |
Quote:
Alloc_Storage_Vars(domain, SV_T_RG, SV_T_G, SV_NULL); T_derivatives(domain); ......... your code.... ......... Free_Storage_Vars(domain, SV_T_RG, SV_NULL); Free_Storage_Vars(domain, SV_T_G, SV_NULL); |
Quote:
what are the arguments for this macros for accessing species mass fraction? |
Quote:
|
from manual
Quote:
|
Quote:
now I have used C_UDSI_G to calculate current density successfully in a cas, it can be seen in post-processing, then I write cas and dat. Now I read cas, and when I read dat it shows: https://cmct.xyz/images/2020/10/06/S...6_10-17-16.png the process of fluent has already down. I've know the reason for it:when I read dat, it can't access the value of C_UDSI_G immediately because I used define_profile macros and it would first be called: https://cmct.xyz/images/2020/10/06/1.png now if I change the value to constant like this: https://cmct.xyz/images/2020/10/06/2.png and also need to calcalate for one iteration,until then it won't get wrong when I read dat.:(:(:( so I wonder if there's a way to read dat normally without these procedure... |
unfortunately, no idea, how to deal with it.
try to remove reading from .dat step. simulate everything without exit from fluent |
Quote:
|
use SV_UDS_I, SV_UDSI_G; SV_T_G, SV_H_G
Quote:
Code:
DEFINE_ADJUST(adjust_sources,d) Best |
Quote:
|
Quote:
Hi, Yes, I have checked its effectiveness and in fact I am working on a problem where 3 UDSIs are present and I am using gradients of 2 UDSIs. Without that "if(NULL!=....)" statement my UDF was not working because no memory was allocated to them and when I call them in UDF (i.e., for example C_UDSI_G(c,t,0)[0]), it threw the segmentation fault. When I used that statement my UDF worked fine. Also I checked those gradients by storing them in UDMI's, I and found reasonable results. Quote:
Ok, what I meant was to use the following (I am directly copying from the code I am using): Code:
if (NULL != THREAD_STORAGE(t, SV_UDS_I(0)) && rest your wish, I just thought to respond to this thread, although I was not linked to this thread. And I only write on those problems in cfdonline forums in which I too have faced problem at certain stage. |
Quote:
|
Quote:
Code:
begin_f_loop(f,f_thread) |
You forgot to put brackets after your if statement. Indentation is only for the programmer, not relevant for the compiler.
|
Quote:
Code:
begin_f_loop(f,f_thread) |
you can prevent the solver from freeing up memory by issuing the text command solve/set/expert yes
you will find the result after computation |
All times are GMT -4. The time now is 23:54. |