UDF temperature gradient
Hi guys
I would like to create UDF for computing temperature gradient (in time and space). I have 2D axysimmetric model. Some tips? I havent enough experiencies with c++. |
Fluent already has a macro for the temperature gradient: C_T_G(c,t). Read the UDF manual for details.
|
Quote:
Could you be more specific? |
Read section "3.2.3.7. Gradient (G) and Reconstruction Gradient (RG) Vector Macros" on page 221 of the ANSYS Fluent 15.0 UDF Manual (may have different page number and/or section for different versions of Fluent).
|
Quote:
#include "udf.h" DEFINE_ON_DEMAND(Temp_grad_ondemand) { Domain *d; cell_t c; Thread *t; d = Get_Domain(1); thread_loop_c(t,d) { begin_c_loop(c,t) { C_UDMI(c,t,1) = NV_MAG(C_T_G(c,t)); } end_c_loop(c,t) } } |
Your code appears correct if you want the magnitude of the temperature gradient. Have you tried compiling this UDF, and do you get expected results?
|
Quote:
thank you. Do you know how it looks with macro DEFINE_ADJUST? Thanks |
The code for determining the temperature gradient magnitude with a DEFINE_ADJUST macro would look very similar to your DEFINE_ON_DEMAND code. Again, have a read of the UDF manual and return if you have any precise questions.
|
Quote:
# include "udf.h" # define domain_ID 2 DEFINE_ADJUST(adjust_gradient, domain) { Thread *t; cell_t c; face_t f; domain = Get_Domain(domain_ID); /* Fill UDS with the variable. */ thread_loop_c (t,domain) { begin_c_loop (c,t) { C_UDMI(c,t,1) = NV_MAG(C_T_G(c,t)); } end_c_loop (c,t) } } |
What are the errors and when do they occur?
'domain' is a pointer to the domain that the adjust function is to be applied. Typically you only have one domain and use the macro Get_Domain(1) if you require the pointer for it (but it's provided with DEFINE_ADJUST). Do you have multiple domains or are you confusing domains with cell zones? |
1 Attachment(s)
Quote:
1.Star fluet 2. Sets bounday conditions 3. Interpred program 4. Set funkcions hook =>set it in adjust 5. Star calculation and then error Thx |
I'll be specific, remove the following line of code:
Code:
domain = Get_Domain(domain_ID); |
1 Attachment(s)
Quote:
|
Quote:
|
Quote:
|
I recommend that you think about how to solve the problem.
The current situation: you use a memory location that is not defined. The wanted situation: you use a memory location that is defined. How would you go from the current situation to the wanted situation? There are two strategies for that. |
Quote:
- max. time gradient 20°C/h during heating - max. time gradient 30°C/h during cooling - max. space temperature gradient 60°C/m I have found that I have to use type define_adjust and macro C_T_G. So I tried to use this after some upgrades: # include "udf.h" DEFINE_ADJUST(adjust_gradient, domain) { Thread *t; cell_t c; face_t f; /* Fill UDS with the variable. */ thread_loop_c (t,domain) { begin_c_loop (c,t) { C_UDMI(c,t,1) = NV_MAG(C_T_G(c,t)); } end_c_loop (c,t) } } |
Quote:
The current situation: you use a memory location that is not defined. The wanted situation: you use a memory location that is defined. How would you go from the current situation to the wanted situation? There are two strategies for that. This is really not a super-hard question. |
Quote:
|
Quote:
You give the impression that you don't want to understand anything, but that you just want to hear what you should do to get rid of your error. Is that what you want? In that case, you'll have to hire me, I don't do those jobs for free. |
All times are GMT -4. The time now is 07:25. |