CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF to define heat flux along a wall troubleshooting

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 13, 2022, 03:53
Default UDF to define heat flux along a wall troubleshooting
  #1
New Member
 
Hamish
Join Date: Dec 2020
Location: Australia
Posts: 8
Rep Power: 5
ham551 is on a distinguished road
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);
}
}
ham551 is offline   Reply With Quote

Old   April 13, 2022, 23:15
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
AlexanderZ is offline   Reply With Quote

Old   April 14, 2022, 07:33
Default
  #3
New Member
 
Hamish
Join Date: Dec 2020
Location: Australia
Posts: 8
Rep Power: 5
ham551 is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
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);
}
}
I don't understand what changes you made? The arrays are of length 662, I just shortened it for the purpose of posting here...
ham551 is offline   Reply With Quote

Old   April 14, 2022, 22:10
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
AlexanderZ is offline   Reply With Quote

Reply

Tags
fluent, udf


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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 16:55
Radiation in semi-transparent media with surface-to-surface model? mpeppels CFX 11 August 22, 2019 07:30
Question about heat transfer coefficient setting for CFX Anna Tian CFX 1 June 16, 2013 06:28
how to impose experimental dat as boundary conditi Rogerio Fernandes Brito FLUENT 14 November 25, 2008 05:47
UDF FOR UNSTEADY TIME STEP mayur FLUENT 3 August 9, 2006 10:19


All times are GMT -4. The time now is 20:54.