|
[Sponsors] |
August 12, 2005, 12:55 |
UDF problems
|
#1 |
Guest
Posts: n/a
|
Hi,
I am trying to calculate the intersection angle between the velocity and the gradient of the temperature using UDF. My short code is as follows: #include "udf.h" DEFINE_ADJUST(Angle,domain) { Thread *thread; cell_t c; float TX,TY,TZ,TG; float U,V,W,Vel; thread_loop_c(thread,domain) { begin_c_loop(c, thread) { TX = C_T_G(c,thread)[0]; TY = C_T_G(c,thread)[1]; TZ = C_T_G(c,thread)[2]; TG = sqrt(pow(TX,2.0)+pow(TY,2.0)+pow(TZ,2.0)); U = C_U(c,thread); V = C_V(c,thread); W = C_W(c,thread); Vel = sqrt(pow(U,2.0)+pow(V,2.0)+pow(W,2.0)); C_UDMI(c,thread,0) = acos((U*TX+V*TY+W*TZ)/TG/Vel); } end_c_loop(c, thread) } } The compile was good but when I calculated for several iterations and tried to plot the result, the values are zero everywhere. Can anyone please please help me with this program or give me some advice? Thank you so much. I am nearly exhausted by this problem. Winnie |
|
August 12, 2005, 13:09 |
Re: UDF problems
|
#2 |
Guest
Posts: n/a
|
hmm, they (fluent) recommend running some ScalarReconstruction routine to allocate memory internally when calculating the gradients of volume fraction. I'm not sure whether this is applicable to temperature gradients as well but it is worth a try. If you have access to the OTS, please check solution 982 to see what I mean.
|
|
August 12, 2005, 13:32 |
Re: UDF problems
|
#3 |
Guest
Posts: n/a
|
Thank you!
Forgive my ignorance, what is OTS? Winnie |
|
August 12, 2005, 13:33 |
Re: UDF problems
|
#4 |
Guest
Posts: n/a
|
Online Technical Support (http://clarify.fluent.com/eSupport)
|
|
August 12, 2005, 13:47 |
Re: UDF problems
|
#5 |
Guest
Posts: n/a
|
Thanks.
I tried the reconstruction gradient and it still doesn't work. I don't have an account of OTS since I am a student. Can you provide more information? Thanks again. Winnie |
|
August 12, 2005, 13:48 |
Re: UDF problems
|
#6 |
Guest
Posts: n/a
|
Here is an example:
#include "udf.h" #define CON 1 DEFINE_ADJUST(store_gradient, domain) { Thread *t; Thread **pt; cell_t c; int phase_domain_index = 0.; Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index); { Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_N ULL); Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL); Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG, Vof_Deriv_Accumulate); } mp_thread_loop_c (t,domain,pt) if (FLUID_THREAD_P(t)) { Thread *ppt = pt[phase_domain_index]; begin_c_loop (c,t) { C_UDMI(c,t,0) = C_VOF_G(c,ppt)[0]; } end_c_loop (c,t) } Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NU LL); } |
|
August 12, 2005, 13:55 |
Re: UDF problems
|
#7 |
Guest
Posts: n/a
|
The temperature gradient is not stored by default. In the TUI go to "solve set expert" and disable "keep temporary solver memory from being freed". Then you should be able to use temperature gradients.
Dirk |
|
August 12, 2005, 13:57 |
Re: UDF problems
|
#8 |
Guest
Posts: n/a
|
Hi,
Thanks a lot! I think this case is quite more complex than mine since I am working on single phase flow. I have got a converged solution for my problem, but I need know the intersection angle, therefore, I used UDF. I allocate a user defined memory, and compiles this code into FLUENT. Is DEFINE_ADJUST macro used right? Can you give me some other advices other than the method I used? Thank you. Winnie |
|
August 12, 2005, 14:00 |
Re: UDF problems
|
#9 |
Guest
Posts: n/a
|
Try what dirk says first.
When you use the UDF, are you also hooking up the adjust function to the solver? |
|
August 12, 2005, 14:03 |
Re: UDF problems
|
#10 |
Guest
Posts: n/a
|
Do you mean 'disable'?
I checked it, it is 'no'. Any more suggestions? Thank you Winnie |
|
August 12, 2005, 14:08 |
Re: UDF problems
|
#11 |
Guest
Posts: n/a
|
Sorry, it has to be "enable", so you have to set it to "yes".
|
|
August 12, 2005, 14:10 |
Re: UDF problems
|
#12 |
Guest
Posts: n/a
|
No, it didn't work.
I didn't change the default set in FLUENT. I think adjust function is not hookedto the solver. Winnie |
|
August 12, 2005, 14:12 |
Re: UDF problems
|
#13 |
Guest
Posts: n/a
|
I tried both. But it didn't work.
What does that mean? If I disabled it, then the temperature gradient will not be calcualted by solver? Thanks. Winnie |
|
August 12, 2005, 14:19 |
Re: UDF problems
|
#14 |
Guest
Posts: n/a
|
The temperature gradient is calculated but you can only access it while energy equation is solved. If you let Fluent store the gradients with the command I told then you can access the gradients at any time. But you have to make at least one iteration after you set that command and then execute your UDF. It should work then in my opinion.
Dirk |
|
August 12, 2005, 14:44 |
Re: UDF problems
|
#15 |
Guest
Posts: n/a
|
Thanks, dirk
I have tried. And still can not solve the problem. What do you think of my code? Do you think it is OK for calculating the intersection angle between the velocity and the temperature gradient? Thank you for the help. Winnie |
|
August 12, 2005, 18:03 |
Re: UDF problems
|
#16 |
Guest
Posts: n/a
|
I just tried your UDF. It seems to work as I get non zero values for UDM 0. By the way, what is the physical sense of this intersection angle ?
|
|
August 13, 2005, 05:53 |
UDF problems
|
#17 |
Guest
Posts: n/a
|
Hi iam just starting with UDF i used unsteady BC for velocity inlet that mentioned in manual i stored the file at C:\ when asking program to cpompile the file he cant read first line #include "udf.h" the qustion should i have cpp compiler to do calaculation and if not what to do. Best regards
|
|
August 13, 2005, 06:33 |
Re: UDF problems
|
#18 |
Guest
Posts: n/a
|
dear all when i run on of the manual example i have the following at line 1 that is include udf.h should i have c++ or what to do. thanks
cpp -IC:\FLUENT.INC\fluent6.0/src -IC:\FLUENT.INC\fluent6.0/cortex/src -IC:\FLUENT.INC\fluent6.0/client/src -IC:\FLUENT.INC\fluent6.0/multiport/src -I. -DUDFCONFIG_H="<udfconfig.h>" unsteadyError: unsteady: line 1: parse error. |
|
August 14, 2005, 07:29 |
Re: UDF problems
|
#19 |
Guest
Posts: n/a
|
I am trying to do the optomization to enhance the convective heat transfer. And lower this angle, the better the heat transfer rate.
I still can't get the code work in my case, can you please tell me the detailed procedure you did? And does it have any relationship with the mesh? my mesh is irregular. Thank you. dirk. Winnie |
|
August 16, 2005, 08:47 |
Re: UDF problems
|
#20 |
Guest
Posts: n/a
|
I took your file, hooked it as interpreted UDF, enabled the storage of the gradients, set the UDF as an adjust function, set the number of UDM to 1 and iterated. Maybe you should define it as an execute-on-demand, so it doesn't have to be executed after every iteration.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dynamic Mesh UDF | Qureshi | FLUENT | 7 | March 23, 2017 08:37 |
parse error while interpreting udf | Kristin | Fluent UDF and Scheme Programming | 3 | March 15, 2012 07:43 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 23:14 |
problems with UDF to set contact angle | poiuy219 | Main CFD Forum | 0 | April 30, 2009 11:43 |
I need UDF help. | S.Whitney | FLUENT | 0 | October 15, 2007 12:29 |