|
[Sponsors] |
August 17, 2017, 14:05 |
Access to temperature gradient C_T_G
|
#1 |
New Member
Join Date: Aug 2017
Posts: 21
Rep Power: 9 |
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) } |
|
August 31, 2017, 05:15 |
|
#2 | |
Senior Member
Join Date: Feb 2010
Posts: 164
Rep Power: 17 |
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); |
||
February 29, 2020, 05:33 |
|
#3 | |
Senior Member
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6 |
Quote:
what are the arguments for this macros for accessing species mass fraction? |
||
October 4, 2020, 06:52 |
|
#4 | |
Senior Member
Join Date: Feb 2020
Posts: 114
Rep Power: 6 |
Quote:
|
||
October 5, 2020, 02:19 |
|
#5 | |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
from manual
Quote:
__________________
best regards ****************************** press LIKE if this message was helpful |
||
October 5, 2020, 23:26 |
|
#6 |
Senior Member
Join Date: Feb 2020
Posts: 114
Rep Power: 6 |
I've already tried this,not working.please let me introduce my situation:
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: 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: now if I change the value to constant like this: 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... |
|
October 6, 2020, 04:46 |
|
#7 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
unfortunately, no idea, how to deal with it.
try to remove reading from .dat step. simulate everything without exit from fluent
__________________
best regards ****************************** press LIKE if this message was helpful |
|
October 6, 2020, 06:54 |
|
#8 |
Senior Member
Join Date: Feb 2020
Posts: 114
Rep Power: 6 |
OK,thanks.BTW, will this situation happen when using other macros of gradient,such as C_T_G? or it just goes wrong when using UDS gradient.
|
|
November 23, 2020, 23:53 |
use SV_UDS_I, SV_UDSI_G; SV_T_G, SV_H_G
|
#9 | |
Member
Join Date: Dec 2009
Location: Kanpur, India
Posts: 54
Rep Power: 17 |
Quote:
Code:
DEFINE_ADJUST(adjust_sources,d) { Thread *t; cell_t c; double del_psi_delx, del_psi_dely; thread_loop_c(t,d) { if (NULL != THREAD_STORAGE(t, SV_UDS_I) && NULL != T_STORAGE_R_NV(t,SV_UDSI_G) ) begin_c_loop(c,t) { del_psi_delx = C_UDSI_G(c,t,0)[0]; del_psi_dely = C_UDSI_G(c,t,0)[1]; } } Best Last edited by Shoonya; November 24, 2020 at 06:32. Reason: corrected few more lines |
||
November 24, 2020, 22:41 |
|
#10 | |
Senior Member
Join Date: Feb 2020
Posts: 114
Rep Power: 6 |
Quote:
|
||
November 25, 2020, 00:56 |
|
#11 | ||
Member
Join Date: Dec 2009
Location: Kanpur, India
Posts: 54
Rep Power: 17 |
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)) && NULL != T_STORAGE_R_NV(t,SV_UDSI_G(0)) && NULL != THREAD_STORAGE(t, SV_UDS_I(1)) && NULL != T_STORAGE_R_NV(t,SV_UDSI_G(1)) && NULL != THREAD_STORAGE(t, SV_UDS_I(2)) && NULL != T_STORAGE_R_NV(t,SV_UDSI_G(2))) 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. |
|||
November 25, 2020, 06:27 |
|
#12 | |
Senior Member
Join Date: Feb 2020
Posts: 114
Rep Power: 6 |
Quote:
|
||
November 25, 2020, 09:15 |
|
#13 | |
Senior Member
Join Date: Feb 2020
Posts: 114
Rep Power: 6 |
Quote:
Code:
begin_f_loop(f,f_thread) { c0=F_C0(f,f_thread); t0=THREAD_T0(f_thread); c1=F_C1(f,f_thread); t1=THREAD_T1(f_thread); tem3=C_T(c0,t0); diff=33400*exp(-10300/tem3); if (NULL != THREAD_STORAGE(t0, SV_UDS_I(0)) && NULL != T_STORAGE_R_NV(t0,SV_UDSI_G(0))) NV_V(J0,=,C_UDSI_G(c0,t0,0)); ja=diff*NV_MAG(J0); concen0=1000*C_R(c1,t1)*C_YI(c1,t1,0)/2; concen1=1000*C_R(c1,t1)*C_YI(c1,t1,1)/18; nesta=(8.31447*tem3/(2*96485))*log((concen1*11.555)/(concen0*0.3573778)); acta=8.31447*tem3/2/96485*ja/20000*11.555/concen0*0.3573/concen1; uright=1.11-nesta; C_UDMI(c0,t0,0)=ja; C_UDMI(c0,t0,1)=uright; C_UDMI(c0,t0,2)=nesta; C_UDMI(c1,t1,3)=ja/2/96485/(1e-4)*0.002; C_UDMI(c0,t0,4)=acta; |
||
November 25, 2020, 15:27 |
|
#14 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
You forgot to put brackets after your if statement. Indentation is only for the programmer, not relevant for the compiler.
|
|
November 26, 2020, 06:58 |
|
#15 | |
Senior Member
Join Date: Feb 2020
Posts: 114
Rep Power: 6 |
Quote:
Code:
begin_f_loop(f,f_thread) { c0=F_C0(f,f_thread); t0=THREAD_T0(f_thread); c1=F_C1(f,f_thread); t1=THREAD_T1(f_thread); tem3=C_T(c0,t0); diff=33400*exp(-10300/tem3); if (NULL != THREAD_STORAGE(t0, SV_UDS_I(0)) && NULL != T_STORAGE_R_NV(t0,SV_UDSI_G(0))) { NV_V(J0,=,C_UDSI_G(c0,t0,0)); ja=diff*NV_MAG(J0); concen0=1000*C_R(c1,t1)*C_YI(c1,t1,0)/2; concen1=1000*C_R(c1,t1)*C_YI(c1,t1,1)/18; nesta=(8.31447*tem3/(2*96485))*log((concen1*11.555)/(concen0*0.3573778)); acta=8.31447*tem3/2/96485*ja/20000*11.555/concen0*0.3573/concen1; uright=1.11-nesta; C_UDMI(c0,t0,0)=ja; C_UDMI(c0,t0,1)=uright; C_UDMI(c0,t0,2)=nesta; C_UDMI(c1,t1,3)=ja/2/96485/(1e-4)*0.002; C_UDMI(c0,t0,4)=acta; F_PROFILE(f,f_thread,position)=C_UDMI(c0,t0,1); } } end_f_loop(f,f_thread) |
||
December 13, 2020, 19:27 |
|
#16 |
New Member
amine
Join Date: Dec 2020
Posts: 7
Rep Power: 6 |
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 |
|
Tags |
boundary condition, c_t_g, temperature gradients, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
CFX, temperature gradient inside particles | hmdl | CFX | 3 | January 30, 2016 05:40 |
Temperature gradient in FLUENT | abhi084 | FLUENT | 0 | December 4, 2015 06:27 |
specified shear at wall - temperature gradient - UDF - access violation error | senD | Fluent UDF and Scheme Programming | 9 | September 18, 2014 08:29 |
how to perform temperature gradient on a particle (Thermophoretic Force) | wwt650420 | FLUENT | 3 | March 23, 2011 03:10 |
Wall correction for the temperature gradient | Hagen | OpenFOAM | 0 | March 7, 2011 21:04 |