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

udf doesn't show in the drop down list of boundry condition after function hooks

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 13, 2020, 17:19
Unhappy udf doesn't show in the drop down list of boundry condition after function hooks
  #1
New Member
 
Join Date: Oct 2020
Posts: 7
Rep Power: 5
BarmanT is on a distinguished road
hello everyone, I am new to fluent UDF, I have followed the manual and everything went smooth up until "function hooks" - did as instructed in the manual but the functions didn't hook.

please need help ASAP!
BarmanT is offline   Reply With Quote

Old   October 14, 2020, 05:34
Post
  #2
New Member
 
Join Date: Oct 2020
Posts: 7
Rep Power: 5
BarmanT is on a distinguished road
can someone look at my UDF and point on the mistake, because the file compiles but functions won't hook.


Quote:
#include "udf.h"
#include "flow.h"


DEFINE_ADJUST(inlet_mass_flow,d)
{
int count_m=1;
Thread *t;
face_t f;
thread_loop_f(t,d){
if(N_TIME<=10)
{
if(count_m<=6)
{
begin_f_loop(f,t)
{

F_FLUX(f,t)=(200/3600);
}
end_f_loop(f,t)
}

if(count_m>6 && count_m<=10)
{
begin_f_loop(f,t)
{

F_FLUX(f,t)=0;
}
end_f_loop(f,t)

if(count_m==10)
{count_m=1;}
}
}
else if(N_TIME>10)
{

if(count_m<=6)
{
begin_f_loop(f,t)
{

F_FLUX(f,t)=(50/3600);
}
end_f_loop(f,t)
}

if(count_m>6 && count_m<=10)
{
begin_f_loop(f,t)
{

F_FLUX(f,t)=0;
}
end_f_loop(f,t)

if(count_m==10)
{count_m=1;}
}
}
}
}

DEFINE_ADJUST(inlet_temperature,d)
{
int count_t=1;
Thread *t;
face_t f;
thread_loop_f(t,d){
if(N_TIME<=10)
{
if(count_t<=6)
{
begin_f_loop(f,t)
{

F_T(f,t)=50;
}
end_f_loop(f,t)
}

if(count_t>6 && count_t<=10)
{
begin_f_loop(f,t)
{

F_T(f,t)=50;
}
end_f_loop(f,t)

if(count_t==10)
{count_t=1;}
}
}
else if(N_TIME>10)
{

if(count_t<=6)
{
begin_f_loop(f,t)
{

F_T(f,t)=30;
}
end_f_loop(f,t)
}

if(count_t>6 && count_t<=10)
{
begin_f_loop(f,t)
{

F_T(f,t)=30;
}
end_f_loop(f,t)

if(count_t==10)
{count_t=1;}
}
}
}
}
BarmanT is offline   Reply With Quote

Old   October 14, 2020, 05:39
Default
  #3
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 you are clicking LOAD button, the list of available function from UDF is written into console output

if you don't have your function, most likely, you didn't compile UDF successfully

what the name of function which you expect to have? which macro in UDF do you use?
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   October 14, 2020, 08:20
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
You have a subtle bug in your problem:

Code:
F_FLUX(f,t)=(200/3600);
This will default to integer division, which will make the flux zero. You want to make them floats:

Code:
F_FLUX(f,t)=(200.0/3600);
Likewise in other places where you divide.

This is not causing the compilation error, to find out what causes the compilation error you should read whatever shows up on your screen directly after you click "build".
pakk is offline   Reply With Quote

Old   October 14, 2020, 09:54
Post
  #5
New Member
 
Join Date: Oct 2020
Posts: 7
Rep Power: 5
BarmanT is on a distinguished road
this is what I get in the TUI after build and load:

Quote:
# Generating udf_names.c because of makefile udf_n1.obj
udf_names.c
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj udf_n1.obj
Microsoft (R) Incremental Linker Version 14.20.27508.1
Copyright (C) Microsoft Corporation. All rights reserved.

Creating library libudf.lib and object libudf.exp

Done.

LiadArbel-PC: Opening library "G:\avi_folder work\work\NoamSahar_SCE\noam_files\dp0\FLU-2\Fluent\libudf44"...Done.

LiadArbel-PC: Opening library "G:\avi_folder work\work\NoamSahar_SCE\noam_files\dp0\FLU-2\Fluent\libudf44"...
inlet_mass_flow
inlet_temperature
Done.
BarmanT is offline   Reply With Quote

Old   October 14, 2020, 09:57
Default
  #6
New Member
 
Join Date: Oct 2020
Posts: 7
Rep Power: 5
BarmanT is on a distinguished road
this is what it looks like in the function hooks -

available adjust function[0/0]/// selected adjust function[0/2]
________________________/// inlrt_mass_flow::libudf44
________________________/// inlrt_temperature::libudf44
BarmanT is offline   Reply With Quote

Old   October 14, 2020, 13:40
Post
  #7
New Member
 
Join Date: Oct 2020
Posts: 7
Rep Power: 5
BarmanT is on a distinguished road
Is anyone familiar with this problem?
BarmanT is offline   Reply With Quote

Old   October 14, 2020, 14:04
Post
  #8
New Member
 
Join Date: Oct 2020
Posts: 7
Rep Power: 5
BarmanT is on a distinguished road
I found that DEFINE_ADJUST macro won't hook, but DEFINE_PROFILE can be compiled and load properly.

how can I adjust the code above to match DEFINE_PROFILE macro?
BarmanT is offline   Reply With Quote

Old   October 16, 2020, 03:38
Default
  #9
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Quote:
Originally Posted by BarmanT View Post
this is what it looks like in the function hooks -

available adjust function[0/0]/// selected adjust function[0/2]
________________________/// inlrt_mass_flow::libudf44
________________________/// inlrt_temperature::libudf44
this means, that adjusted functions are hooked already, both of them on the right side of menu

the reason, why your boundary conditions are not changing is that you need DEFINE_PROFILE macro to define boundary conditions.
Read Ansys Fluent Customization manual for good examples (or use forum)
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   October 18, 2020, 18:37
Post
  #10
New Member
 
Join Date: Oct 2020
Posts: 7
Rep Power: 5
BarmanT is on a distinguished road
managed to solve the problem I had here is the final code, if someone has a suggestion for refinement it will be greatly appreciated.

Quote:
#include "udf.h"

DEFINE_PROFILE(inlet_mass_flow,t,i)
{
printf("Num of Time Step %lld\n", N_TIME);
face_t f;
float res = N_TIME;
float count_m = ((int)((res/96)*100))%100;
printf("\n res %f\n", res);
printf("\n count_m %f\n", count_m);
if(N_TIME<=23040)
{
if(count_m<=25)
{
printf("Num of Time Step %lld\n", N_TIME);
printf("got in Mass_Flow 1.1_loop\n");
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=(200.0/3600);
printf("got in Mass_Flow F_PROFILE 1.1_loop count_m %f\n", count_m);
}
end_f_loop(f,t)
}
else
{
printf("Num of Time Step %lld\n", N_TIME);
printf("got in Mass_Flow secod IF 1.2_loop\n");
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=0;
printf("got in Mass_Flow F_PROFILE 1.2_loop count_m %f\n", count_m);
}
end_f_loop(f,t)
}
}
else
{
if(count_m<=25)
{
printf("Num of Time Step %lld\n", N_TIME);
printf("got in Mass_Flow IF 2_loop\n");
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=(50.0/3600);
printf("got in Mass_Flow F_PROFILE 2.1_loop count_m %f\n", count_m);
}
end_f_loop(f,t)
}
else
{
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=0;
printf("got in Mass_Flow F_PROFILE 2.2_loop count_m %f\n", count_m);
}
end_f_loop(f,t)
}
}
}


DEFINE_PROFILE(inlet_temperature,t,i)
{
face_t f;
float res_t = N_TIME;
float count_t = ((int)((res_t/96)*100))%100;
printf("\n res %f\n",res_t);
if(N_TIME<=23040)
{
if(count_t<=25)
{
printf("Num of Time Step %lld\n", N_TIME);
printf("got in temperature 1.1_loop\n");
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=50;
printf("got in temperature F_PROFILE 1.1_loop res %f\n", count_t);
}
end_f_loop(f,t)
}
else
{
printf("Num of Time Step %lld\n", N_TIME);
printf("got in temperature secod IF 1.2_loop\n");
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=25;
printf("got in temperature F_PROFILE 1.2_loop res %f\n", count_t);
}
end_f_loop(f,t)
}
}
else
{
if(count_t<=25)
{
printf("Num of Time Step %lld\n", N_TIME);
printf("got in temperature IF 2_loop\n");
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=30;
printf("got in temperature F_PROFILE 2.1_loop res %f\n", count_t);
}
end_f_loop(f,t)
}
else
{
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=25;
printf("got in temperature F_PROFILE 2.2_loop res %f\n", count_t);
}
end_f_loop(f,t)
}
}
}
BarmanT is offline   Reply With Quote

Reply

Tags
fluent - udf, function hookes, 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
[swak4Foam] installation problem with version 0.2.3 Claudio87 OpenFOAM Community Contributions 9 May 8, 2013 10:20
[swak4Foam] build problem swak4Foam OF 2.2.0 mcathela OpenFOAM Community Contributions 14 April 23, 2013 13:59
[blockMesh] non-orthogonal faces and incorrect orientation? nennbs OpenFOAM Meshing & Mesh Conversion 7 April 17, 2013 05:42
[blockMesh] error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Meshing & Mesh Conversion 2 March 14, 2012 09:56
Droplet Evaporation Christian Main CFD Forum 2 February 27, 2007 06:27


All times are GMT -4. The time now is 06:40.