
[Sponsors] 
February 16, 2007, 03:06 
DEFINE_ADJUST Problem

#1 
Guest
Posts: n/a

I encountered a problem when I try to run a DEFINE_ADJUST function. This function is used to store the first gradient of velocities in UDS so that, in the next function, I can used these values to calculate the second gradient of velocities. My code is simple as the following.
DEFINE_ADJUST(adjust_grad2,domain) { Thread *t; cell_t c; domain = Get_Domain(domain_ID); /* Fill UDS with the variable */ thread_loop_c (t,domain) { begin_c_loop (c,t) { C_UDSI(c,t,0) = C_DUDX(c,t); C_UDSI(c,t,1) = C_DVDY(c,t); C_UDSI(c,t,2) = C_DWDZ(c,t); } end_c_loop (c,t) } } I successfully compile and load the library. But,when I try to run it via iteration, the following error occurs. The bad thing is that it does not specify what error should be fixed. Could anyone provide any help on this? Thanks. Error: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. Error Object: () 

February 16, 2007, 07:26 
Re: DEFINE_ADJUST Problem

#2 
Guest
Posts: n/a

I think (not 100% sure) u surely need to use udmi to store the variables. so that u can use them at a later stage. the problem is due to the fact that, solver contuosly removes gradients at each iteration or timestep to free up memory. make sure u have allocated memory to store ur UDS in first place. the help file mentions a lot about memory when using UDS.


February 16, 2007, 16:56 
Re: DEFINE_ADJUST Problem

#3 
Guest
Posts: n/a

remove the line domain=Get_Domain(domain_ID). The domain is already available to your function (via define_adjust argument).


February 19, 2007, 05:36 
Re: DEFINE_ADJUST Problem

#4 
Guest
Posts: n/a

How to make sure that I have allocated memory for UDS? Is it by utilizing Reserve_User_Scalar_Vars? By the way, does somebody know actually what the main difference between user defined scalar (UDS) and user defined memory?


February 19, 2007, 10:51 
Re: DEFINE_ADJUST Problem

#5 
Guest
Posts: n/a

when you use an user defined scalar actually you solve an equation like equation 11.2.1 in the UDF user manual. a user define memory is a variable where you store some intermediate values needed further in your calculations.
You get the segmentation fault error because when you launch FLUENT and read your data and case file, there is no gradient available so you will get the error. What you can do is either make 1 or 2 iterations without hooking your functions, then hook your functions, or use the following statement in your DEFINE_ADJUST function Alloc_Storage_Vars(domain, SV_U_G,SV_NULL) then at the end of your function: Free_Storage_Vars(domain,SV_U_G,SV_NULL) The problem with these two instructions is that they just allocate memory but actually not computing the gradient for the first one or two iterations (You can check this by putting a Message macro). Hope this help you. 

February 21, 2007, 00:12 
Re: DEFINE_ADJUST Problem

#6 
Guest
Posts: n/a

It works now. Thanks. However, I have another question.
I would like to have the second gradient of velocity so that I make use UDS as follows. thread_loop_c (t,domain) { begin_c_loop (c,t) { C_UDSI(c,t,0) = C_U_G(c,t)[0]; C_UDSI(c,t,1) = C_V_G(c,t)[1]; C_UDSI(c,t,2) = C_W_G(c,t)[2]; } end_c_loop (c,t) } } double grad2_u = NV_MAG(C_UDSI_G(c,t,0)); double grad2_v = NV_MAG(C_UDSI_G(c,t,1)); double grad2_w = NV_MAG(C_UDSI_G(c,t,2)); But, I am not sure what C_UDSI_G returns. It indeed a gradient; but, in which direction? What I need is d2u/dx2, d2v/dy2, and d2w/dz2. Could please provide advice on this? 

February 21, 2007, 02:37 
Re: DEFINE_ADJUST Problem

#7 
Guest
Posts: n/a

C_UDSI_G returns a vector which components are the x, y and z directions, so:
d2u/dx2 is C_UDSI_G(c,t,0)[0], d2v/dy2 is C_UDSI_G(c,t,1)[1] and d2w/dx2 is C_UDSI_G(c,t,2)[2] 

February 21, 2007, 11:58 
Re: DEFINE_ADJUST Problem

#8 
Guest
Posts: n/a

Thank you. Now my udf works perfectly fine.


December 23, 2009, 04:34 

#9 
New Member
emma
Join Date: Dec 2009
Posts: 4
Rep Power: 9 
I compute fourth order derivative with UDS through Gauss's divergence theorem.
We can obtain second order derivative of Φ through integrating Laplacian of Φ at cell c0. For computing fourth order derivative, the idea is that using Gauss's divergence theorem again and let the second order derivative to be the UDS. I directly use c_face_loop to present second order derivative first. c_face_loop(c,t,n) { F_AREA(A,C_FACE(c,t,n), C_FACE_THREAD(c,t,n)); At = NV_MAG(A); Aterm = At/C_VOLUME(c,t); NV_DS(Grad2, +=, C_UDSI_G(c,t,GRAD_1)[0], C_UDSI_G(c,t,GRAD_1)[1], C_UDSI_G(c,t,GRAD_1)[2],*,Aterm); } For computing fourth order derivative, I use magnitude of second order gradient to define a UDS. C_UDSI(c,t,GRAD_1) =NV_MAG(Grad2) The fourth gradient is then be, c_face_loop(c,t,n) { F_AREA(A,C_FACE(c,t,n), C_FACE_THREAD(c,t,n)); At = NV_MAG(A); Aterm = At/C_VOLUME(c,t); NV_DS(Grad4, +=, C_UDSI_G(c,t,GRAD_1)[0], C_UDSI_G(c,t,GRAD_1)[1], C_UDSI_G(c,t,GRAD_1)[2],*,Aterm); } I was wondering if this is correct to slove it. i was confusing that seconder order gradient is a vector here, and not like the original Φ, which is a scalar. how to solve this problem? Could anybody provide any helps? Thanks Last edited by Emma66; December 24, 2009 at 10:35. 

December 24, 2009, 10:37 

#10 
New Member
emma
Join Date: Dec 2009
Posts: 4
Rep Power: 9 
Has anyone done the similar or been familar with this problem?


December 28, 2009, 23:07 

#11 
New Member
emma
Join Date: Dec 2009
Posts: 4
Rep Power: 9 
Dear Davis Yohanes Arifin,
How do you set boundary conditions for uds1, uds2, uds3 because they are only set for your final need. I now meet a quite similar questions. I have to introduce three uds to compute my source term in another uds equation. However, I have no idea whether should I set the same source term to these three uds with the one I need to comput? Please give me some suggestion. Many thanks. 

June 16, 2014, 04:08 

#12 
New Member
Join Date: Jun 2014
Posts: 16
Rep Power: 4 
Hi,Davis. I meet a similar problem. I need to obtain the second derivation of temperature in DEFINE_SOURCE. Here is the code:
DEFINE_ADJUST(my_adjust,d) { Thread *t; cell_t c; if (! Data_Valid_P()) return; thread_loop_c(t,d) { begin_c_loop(c,t) { C_UDSI(c,t,1)=C_T_G(c,t)[0]; C_UDSI(c,t,2)=C_T_G(c,t)[1]; C_UDSI(c,t,3)=C_T_G(c,t)[2]; } end_c_loop(c,t) } } DEFINE_SOURCE(uds_source, c, t, dS, eqn) { real source; source=0.000143472*(C_UDSI_G(c,t,1)[0]+C_UDSI_G(c,t,2)[1]+C_UDSI_G(c,t,3)[2]); dS[eqn]=0; return source; } I've tried solve/set/expert temporary solver memory [yes], and iterated some steps before hooking DEFINE_ADJUST. After I hook DEFINE_ADJUST, it can calculate without any problems. But once I include the source term, I meet the error access_violation. Can you give me some suggestion? Thank you in advance. 

September 20, 2015, 13:22 

#13 
Member
Join Date: Nov 2014
Posts: 42
Rep Power: 4 
Hi every body
I wanted to return derivative of UDS as wall boundary value, but I faced with "fatal signal" while initializing (both Hybrid and standard) that I found this because of boundary condition UDS. this is part of my udf for B.C of UDS( volume fraction of nanoparticle in my case) DEFINE_PROFILE(alpha_bc1,thread,position) { Thread *t; cell_t c; . . . begin_f_loop(f,thread) { C_UDSI_G(c,t,0)[0]=(D_T/D_B)*C_T_G(c,t)[0]; F_PROFILE(f,thread,position)=C_UDSI_G(c,t,0)[0]; } end_f_loop(f,t) } I would appreciate if anyone can help me about my mistakes. 

September 20, 2015, 14:04 

#14 
Member
Join Date: Nov 2014
Posts: 42
Rep Power: 4 
Furthermore, I used Define_Adjust to calculate laplacian, maybe this is my fault?
can I use UDS as scalar variable and then I used it in source function? I will turn off all Uds except one that I wanted to solve. is it true? thread_loop_c(t,d) { begin_c_loop(c,t) { C_UDSI(c,t,1)=D_T*C_T_G(c,t)[0]; C_UDSI(c,t,2)=D_T*C_T_G(c,t)[1]; C_UDSI(c,t,3)=D_T*C_T_G(c,t)[2]; Laplacian=Laplacian+C_UDSI_G(c,t,1)[0]+C_UDSI_G(c,t,2)[1]+C_UDSI_G(c,t,3)[2]; C_UDSI(c,t,5)=dD_T*C_T_G(c,t)[0]; C_UDSI(c,t,6)=dD_T*C_T_G(c,t)[1]; C_UDSI(c,t,7)=dD_T*C_T_G(c,t)[2]; d_Laplacian=d_Laplacian+C_UDSI_G(c,t,4)[0]+C_UDSI_G(c,t,5)[1]+C_UDSI_G(c,t,6)[2]; C_UDSI(c,t,9)=D_D*C_T_G(c,t)[0]; C_UDSI(c,t,10)=D_D*C_T_G(c,t)[1]; C_UDSI(c,t,11)=D_D*C_T_G(c,t)[2]; LL=LL+C_UDSI_G(c,t,9)[0]+C_UDSI_G(c,t,10)[1]+C_UDSI_G(c,t,11)[2]; C_UDSI(c,t,13)=dD_D*C_T_G(c,t)[0]; C_UDSI(c,t,14)=dD_D*C_T_G(c,t)[1]; C_UDSI(c,t,15)=dD_D*C_T_G(c,t)[2]; dLL=dLL+C_UDSI_G(c,t,13)[0]+C_UDSI_G(c,t,14)[1]+C_UDSI_G(c,t,15)[2]; } end_c_loop(c,t) } C_UDSI(c,t,4)=Laplacian; C_UDSI(c,t,8)=d_Laplacian; C_UDSI(c,t,12)=LL; C_UDSI(c,t,16)=dLL; } 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
UDF compiling problem  Wouter  Fluent UDF and Scheme Programming  6  June 6, 2012 04:43 
Gambit  meshing over airfoil wrapping (?) problem  JFDC  FLUENT  1  July 11, 2011 05:59 
natural convection problem for a CHT problem  SeHee  CFX  2  June 10, 2007 06:29 
Adiabatic and Rotating wall (Convection problem)  ParodDav  CFX  5  April 29, 2007 19:13 
Is this problem well posed?  Thomas P. Abraham  Main CFD Forum  5  September 8, 1999 14:52 