|
[Sponsors] |
March 29, 2015, 16:44 |
UDF temperature gradient
|
#1 |
New Member
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11 |
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++. |
|
March 29, 2015, 17:45 |
|
#2 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Fluent already has a macro for the temperature gradient: C_T_G(c,t). Read the UDF manual for details.
|
|
March 29, 2015, 18:07 |
|
#3 |
New Member
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11 |
||
March 29, 2015, 18:21 |
|
#4 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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).
|
|
March 29, 2015, 19:03 |
|
#5 | |
New Member
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11 |
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) } } |
||
March 29, 2015, 19:25 |
|
#6 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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?
|
|
March 29, 2015, 19:38 |
|
#7 |
New Member
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11 |
||
March 29, 2015, 19:51 |
|
#8 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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.
|
|
March 31, 2015, 06:27 |
|
#9 | |
New Member
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11 |
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) } } |
||
March 31, 2015, 07:04 |
|
#10 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
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? |
|
March 31, 2015, 07:27 |
|
#11 | |
New Member
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11 |
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 |
||
March 31, 2015, 08:12 |
|
#12 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
I'll be specific, remove the following line of code:
Code:
domain = Get_Domain(domain_ID); |
|
March 31, 2015, 08:25 |
|
#13 |
New Member
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11 |
I removed line of code and define memory 1 but still fatal error.
|
|
March 31, 2015, 08:33 |
|
#14 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
||
March 31, 2015, 08:36 |
|
#15 |
New Member
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11 |
||
March 31, 2015, 08:39 |
|
#16 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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. |
|
March 31, 2015, 08:53 |
|
#17 | |
New Member
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11 |
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) } } |
||
March 31, 2015, 09:04 |
|
#18 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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. |
||
March 31, 2015, 10:16 |
|
#19 | |
New Member
Andrej
Join Date: Mar 2015
Posts: 18
Rep Power: 11 |
Quote:
|
||
March 31, 2015, 10:24 |
|
#20 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Temperature gradient using wall-functions | chantre | OpenFOAM | 2 | July 19, 2021 08:56 |
whats the cause of error? | immortality | OpenFOAM Running, Solving & CFD | 13 | March 24, 2021 08:15 |
UDF for time-mean temperature gradient | nenazarian | Fluent UDF and Scheme Programming | 1 | November 12, 2012 04:30 |
UDF slip and temperature jump from IFRT | abir | Fluent UDF and Scheme Programming | 1 | July 30, 2012 06:44 |
UDF velocity and temperature | Raj | FLUENT | 3 | February 1, 2009 19:29 |