|
[Sponsors] |
September 15, 2017, 00:48 |
UDS problem
|
#1 |
Member
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 9 |
Hi everyone. I am writing a udf for three-phase-flow.After I hooked it to my model,it initialised well but can't calculate.Below are my udf.
#include"udf.h" #include"unsteady.h" DEFINE_ADJUST(store_gradient,d) { real unit_normal; Thread *big_thread,*mixture_thread,*small_thread; cell_t cell; int current_iter,domainid,threadid1,threadid2; current_iter=(nres==0)?(0)(int)count2[nres-1]); domainid=8; threadid1=1; threadid2=2; mixture_thread=Lookup_Thread(d,domainid); big_thread=THREAD_SUB_THREAD(mixture_thread,thread id1); small_thread=THREAD_SUB_THREAD(mixture_thread,thre adid2); if((current_iter==0)&&(CURRENT_TIME==0)) { begin_c_loop(cell,big_thread) { C_UDMI(cell,big_thread,0)=0; C_UDMI(cell,big_thread,1)=0; C_UDMI(cell,big_thread,2)=0; C_UDMI(cell,big_thread,3)=0; C_UDMI(cell,big_thread,4)=0; } end_c_loop(cell,big_thread) begin_c_loop(cell,small_thread) { C_UDMI(cell,small_thread,5)=0; C_UDMI(cell,small_thread,6)=0; C_UDMI(cell,small_thread,7)=0; C_UDMI(cell,small_thread,8)=0; C_UDMI(cell,small_thread,9)=0; } end_c_loop(cell,small_thread) } if (!Data_Valid_P()) return; begin_c_loop(cell,big_thread) { C_UDSI(cell,big_thread,0)=0; C_UDSI(cell,big_thread,1)=0; C_UDSI(cell,big_thread,2)=0; } end_c_loop(cell,big_thread) Message("helloworld"); return; } real integrand(real scale,real density,real diameter,real tension,real dissipation) { real answer; answer=exp(-12*diameter*diameter*tension/(density*2.047*pow(scale,11.0/3.0)*pow(dissipation,2.0/3.0)))/pow(scale,4.0); return answer; } real integrand1(real scale,real density,real diameter,real tension,real dissipation) { real answer; answer=exp(-12*diameter*diameter*tension/(density*2.047*pow(scale,11.0/3.0)*pow(dissipation,2.0/3.0)))/pow(scale,11.0/3.0); return answer; } DEFINE_PROPERTY(diameter,c,t) { real diameter1,surface_tension,density_of_continuous,vi scosity,voidreturn; Thread *mixture_thread,*big_thread; int threadid; threadid=1; density_of_continuous=998.2; surface_tension=0.0719404; viscosity=0.001003; mixture_thread=THREAD_SUPER_THREAD(t); big_thread=THREAD_SUB_THREAD(mixture_thread,thread id); voidreturn=1; if(C_VOF(c,t)==0) diameter1=0.0008; else { diameter1=1.78*pow(sqrt(surface_tension/((density_of_continuous-(C_R(c,big_thread)*C_VOF(c,big_thread)+C_R(c,t)*C_ VOF(c,t))/(C_VOF(c,big_thread)+C_VOF(c,t)))*9.81)),0.889)*po w(viscosity/density_of_continuous,0.0836)/pow(C_D(c,mixture_thread)*C_VOF(c,t)/(C_VOF(c,big_thread)+C_VOF(c,t)),0.0279); } return (diameter1); } Attachment is what I did in user defined scalar dialog box. All my three scalars have the same setting. |
|
September 15, 2017, 00:50 |
|
#2 |
Member
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 9 |
My udf seems strange because it's too long and all parts excluded in this webpage have been set between /* and */ so they won't execute.
|
|
September 15, 2017, 00:54 |
|
#3 |
Member
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 9 |
I am sure the problem is on UDS because when I set 42nd,43rd and 44th line between /* and */, it works well.
Those lines are C_UDSI(cell,big_thread,0)=0; C_UDSI(cell,big_thread,1)=0; C_UDSI(cell,big_thread,2)=0; |
|
September 15, 2017, 01:00 |
|
#4 |
Member
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 9 |
I will appreciate any of your help
|
|
September 15, 2017, 03:07 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Hello,
you are using multi-phase flow, do I not know how to start such cases properly. However, you are using begin_c_loop(cell,big_thread) and begin_c_loop(cell,small_thread) to set/calculate variables for specific regions. But what values do these variable have at other regions? I did not test it, but what if UDS values should be defined everywhere? In that case you need loop over all threads to initialize UDS values, but then you may modify values of UDS variables in specified regions. I hope my idea is clear. Best regards, Zorin Alexander |
|
September 15, 2017, 03:12 |
|
#6 |
Member
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 9 |
Dear Zorin
Thank you for your help first. UDS is only used to calculate the second order gradient of void fraction of each secondary phase in my UDF. Do you have any suggestions? |
|
September 15, 2017, 03:22 |
|
#7 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Try to use loop over all threads for UDS for initialization
Code:
cell_t cell; Thread *thread; thread_loop_c (thread,domain) { begin_c_loop (cell,thread) { C_UDSI(cell,thread,0)=0.0; end_c_loop (cell,thread) } } |
|
September 15, 2017, 03:25 |
|
#8 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
or you may try to use big_thread directly, however, I have never tried it before:
Code:
thread_loop_c (big_thread,domain) { begin_c_loop (cell,big_thread) { C_UDSI(cell,big_thread,0)=0.0; end_c_loop (cell,big_thread) } } |
|
September 15, 2017, 03:32 |
|
#9 |
Member
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 9 |
I'm sorry maybe I gave you too little information.
Actually, I want to get the second order gradient of void fraction for each secondary phase, but I don't know how to do. This way is found from some predecessors' threads here in this forum. Since I don't know its detail, I may have made some mistakes on using UDS as well as on setting something in GUI. Do you know some effective ways to get second order gradient? Thank you very much |
|
September 15, 2017, 03:33 |
|
#10 |
Member
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 9 |
Oh! your reply is so quick, I should read it first
|
|
September 15, 2017, 03:52 |
|
#11 |
Member
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 9 |
looping over all threads in subdomain works! But I am still confused. Why do I have to loop over all threads in subdomain?
|
|
September 15, 2017, 04:30 |
|
#12 | |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Quote:
may be the reason is that fluent tries to calculate scalar everywhere, so without initialization it gives error Best regards |
||
September 15, 2017, 04:36 |
|
#13 |
Member
Chi Zhang
Join Date: Aug 2017
Posts: 32
Rep Power: 9 |
Thank you.Fluent is a mysterious software
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDS problem with wall boundary condition | Alex F. | FLUENT | 15 | September 21, 2015 10:28 |
a stupid UDS problem | bgu | Fluent UDF and Scheme Programming | 0 | August 18, 2013 07:52 |
Velocity profiles problem behind the elbow (3D problem) | kabat73 | FLUENT | 8 | May 9, 2010 05:26 |
natural convection problem for a CHT problem | Se-Hee | CFX | 2 | June 10, 2007 07:29 |
Adiabatic and Rotating wall (Convection problem) | ParodDav | CFX | 5 | April 29, 2007 20:13 |