|
[Sponsors] |
UDF to define heat flux along a wall troubleshooting |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 13, 2022, 04:53 |
UDF to define heat flux along a wall troubleshooting
|
#1 |
New Member
Hamish
Join Date: Dec 2020
Location: Australia
Posts: 8
Rep Power: 5 |
I am trying to apply a wall heat-flux calculated in one simulation, onto a wall in a new simulation. The data is too complicated to fit an expression to, so I decided to try to use a UDF to apply the data extracted from fluent. So I created two array's one holding the x-position, the other the heat flux at that point. Then just used a simple interpolation function.
The UDF compiles, however, when I run the simulation the heat flux is 0 on the wall. Are there any obvious errors I've made? Code:
#include <udf.h> #include <stdio.h> #include <stdlib.h> #include <string.h> DEFINE_PROFILE(heat_flux,thread,i) { real x[ND_ND]; face_t f; real datasize = 662; real pos[662] = { 0.0946808 , 0.0947025 , 0.094724 , 0.0947465 , 0.0947696 , ... }; real flux[662] = { -21979800 , -28369700 , -10914000 , -6822270 , -5042960, ... }; begin_f_loop(f,thread) { F_CENTROID (x,f,thread); for(int j = 0; j< datasize ; j++) { if(x[0] == pos[j]){ F_PROFILE(f,thread,i) = flux[j]; } if(x[0]>pos[j] && x[0]<pos[j+1]){ F_PROFILE(f,thread,i) = flux[j] + ((pos[j]-pos[j+1])*((flux[j+1]-flux[j])/(pos[j+1]-pos[j]))); } else{ F_PROFILE(f,thread,i) = 0; } } end_f_loop(f,thread); } } |
|
April 14, 2022, 00:15 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
next time compile code to get the error log
Code:
#include <udf.h> DEFINE_PROFILE(heat_flux,thread,i) { real x[ND_ND]; face_t f; int j,datasize = 5; real pos[5] = { 0.0946808 , 0.0947025 , 0.094724 , 0.0947465 , 0.0947696 }; real flux[5] = { -21979800 , -28369700 , -10914000 , -6822270 , -5042960 }; begin_f_loop(f,thread) { F_CENTROID (x,f,thread); for(j = 0; j< datasize ; j++) { if(x[0] == pos[j]){ F_PROFILE(f,thread,i) = flux[j]; } if(x[0]>pos[j] && x[0]<pos[j+1]){ F_PROFILE(f,thread,i) = flux[j] + ((pos[j]-pos[j+1])*((flux[j+1]-flux[j])/(pos[j+1]-pos[j]))); } else{ F_PROFILE(f,thread,i) = 0; } } end_f_loop(f,thread); } }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
April 14, 2022, 08:33 |
|
#3 | |
New Member
Hamish
Join Date: Dec 2020
Location: Australia
Posts: 8
Rep Power: 5 |
Quote:
|
||
April 14, 2022, 23:10 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
when I compiled your code log file showed me few errors.
of course array should be 662 length in your case
__________________
best regards ****************************** press LIKE if this message was helpful |
|
Tags |
fluent, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Heat Flux versus Wall Heat Flux: inlet - outlet energy, different values | jmenendez | CFX | 1 | February 14, 2021 17:55 |
Radiation in semi-transparent media with surface-to-surface model? | mpeppels | CFX | 11 | August 22, 2019 08:30 |
Question about heat transfer coefficient setting for CFX | Anna Tian | CFX | 1 | June 16, 2013 07:28 |
how to impose experimental dat as boundary conditi | Rogerio Fernandes Brito | FLUENT | 14 | November 25, 2008 06:47 |
UDF FOR UNSTEADY TIME STEP | mayur | FLUENT | 3 | August 9, 2006 11:19 |