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

Osi udf

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 24, 2021, 13:13
Default Osi udf
  #1
Senior Member
 
Ali reza
Join Date: Mar 2014
Posts: 110
Rep Power: 12
1988 is on a distinguished road
Hi

I found this UDF online (I am not very familiar with UDF coding) and I used it to calculate OSI. I am using ANSYS-Fluent 2021.
I used 5 memories for the UDM and run the simulation. All the values out of these UDMs are zero. Any suggestions?
Code:
/******************************************************
	Oscillatory shear index
******************************************************/

#include "udf.h"
#include "math.h"
#include "storage.h"
#include "sg_udms.h"

#define domain_ID 1
#define zone_ID 1


/* Initialize the UDM value to zero in complete domain */
DEFINE_INIT(meminit,domain)
{
	Thread *c_thread;
	cell_t c;

	thread_loop_c(c_thread,domain)
	{
		begin_c_loop(c, c_thread)
		{
			C_UDMI(c,c_thread,0)= 0;
			C_UDMI(c,c_thread,1)= 0;
			C_UDMI(c,c_thread,2)= 0;
			C_UDMI(c,c_thread,3)= 0;
			C_UDMI(c,c_thread,4)= 0;
		}
		end_c_loop(c, c_thread)
	}
}

/* Calculate wall shear stress and store them in UDM */
DEFINE_EXECUTE_AT_END(OSI)
{
	Domain *domain;
	real area;
	face_t f;
	real A[ND_ND];
	cell_t c, c0;
	Thread *t,*t0, *c_thread;
	real wallshear [ND_ND];

	domain = Get_Domain(domain_ID);
	t = Lookup_Thread(domain,zone_ID);

	begin_f_loop(f, t)
	{
		F_AREA(A,f,t);
		area = NV_MAG(A);
		NV_V(wallshear,=,F_STORAGE_R_N3V(f,t, SV_WALL_SHEAR));
		c0 = F_C0(f,t);
		t0 = THREAD_T0(t);
		C_UDMI(c0,t0,0) = NV_MAG(wallshear)/area;
		C_UDMI(c0,t0,1) = -wallshear[0]/area;
		C_UDMI(c0,t0,2) = -wallshear[1]/area;
		C_UDMI(c0,t0,3) = -wallshear[2]/area;
		C_UDMI(c0,t0,4) = (1.-sqrt(C_UDMI(c0,t0,1)*C_UDMI(c0,t0,1) + C_UDMI(c0,t0,2)*C_UDMI(c0,t0,2) + C_UDMI(c0,t0,3)*C_UDMI(c0,t0,3))/C_UDMI(c0,t0,0))/2;
	}
	end_f_loop(f,t)
}
1988 is offline   Reply With Quote

Old   June 24, 2021, 14:12
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Maybe you did not hook the execute_at_end?
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   June 24, 2021, 16:36
Default
  #3
Senior Member
 
Ali reza
Join Date: Mar 2014
Posts: 110
Rep Power: 12
1988 is on a distinguished road
Thank you for the response. Is it a line or something that I am missing in the code or you mean running the CFD and having the UDF compiled? I compiled it with no error and ran the CFD simulation with no problem.
1988 is offline   Reply With Quote

Old   June 25, 2021, 01:34
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
After compiling the UDF, you have to tell Fluent to use it. This is called hooking. Look in the manual, it is explained below every example of a UDF.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   June 25, 2021, 01:57
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
compile UDF
load compiled library (in console you will see the list of available functions, you've loaded)
in interface:
user defined-> function hooks ->
initialization -> choose you function -> ok
execute at end -> choose you function -> ok
->ok
1988 and aerosuraj1 like this.
__________________
best regards


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

Old   August 23, 2022, 01:45
Default Compilation warning
  #6
New Member
 
Md Asif Equbal
Join Date: Aug 2022
Location: India
Posts: 15
Rep Power: 4
mep20108@tezu.ac.in is on a distinguished road
After compilation of UDF, one warning is generated on console screen.

'unsigned long' [-Wint-to-void-pointer-cast]
return ( (void * POINTER_32) (unsigned long) (UNLONG_PTR) P);

I want to know where is the problem. If anyone help it must be appreciated.
Thanks in advance.
mep20108@tezu.ac.in is offline   Reply With Quote

Old   August 23, 2022, 04:07
Default
  #7
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
in case you need help you should provide the whole information:
full log output
warnings usually don't lead to problems with running the code
__________________
best regards


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

Old   August 24, 2022, 14:53
Default
  #8
New Member
 
Md Asif Equbal
Join Date: Aug 2022
Location: India
Posts: 15
Rep Power: 4
mep20108@tezu.ac.in is on a distinguished road
Dear AlexanderZ,
After compilation and hooking the UDF when I start the simulation the fluent exits without showing any error. Try so many times but not succeeded. I am using Ansys 2022R1. Can anyone help what is the actual problem. Here is the screenshot of the Fluent.
Attached Images
File Type: png udf.PNG (52.5 KB, 35 views)

Last edited by mep20108@tezu.ac.in; August 25, 2022 at 23:39.
mep20108@tezu.ac.in is offline   Reply With Quote

Old   October 24, 2022, 01:41
Default
  #9
New Member
 
shima mohammadi
Join Date: Oct 2022
Posts: 14
Rep Power: 4
sara9310 is on a distinguished road
Quote:
Originally Posted by mep20108@tezu.ac.in View Post
Dear AlexanderZ,
After compilation and hooking the UDF when I start the simulation the fluent exits without showing any error. Try so many times but not succeeded. I am using Ansys 2022R1. Can anyone help what is the actual problem. Here is the screenshot of the Fluent.
Did you find the solution to the problem? I have similar problem.
sara9310 is offline   Reply With Quote

Old   October 24, 2022, 07:01
Default
  #10
New Member
 
Md Asif Equbal
Join Date: Aug 2022
Location: India
Posts: 15
Rep Power: 4
mep20108@tezu.ac.in is on a distinguished road
Dear shima,
First you set user defined memory (UDM).
In this case it is 5. Make sure you have also changed zone Id as per your boundary where you want apply OSI.
After that you can go for hooking.
I did in similar way it solved my problem.
Hope it works for you too.
mep20108@tezu.ac.in is offline   Reply With Quote

Old   October 24, 2022, 08:38
Default
  #11
New Member
 
shima mohammadi
Join Date: Oct 2022
Posts: 14
Rep Power: 4
sara9310 is on a distinguished road
Quote:
Originally Posted by mep20108@tezu.ac.in View Post
Dear shima,
First you set user defined memory (UDM).
In this case it is 5. Make sure you have also changed zone Id as per your boundary where you want apply OSI.
After that you can go for hooking.
I did in similar way it solved my problem.
Hope it works for you too.
Thank you!
I set the number of memories
But Where is the "Zone id" in fluent?
And exactly what should i do?

Last edited by sara9310; October 24, 2022 at 16:10.
sara9310 is offline   Reply With Quote

Old   October 31, 2022, 02:46
Default
  #12
New Member
 
Suraj Shembekar
Join Date: Feb 2021
Location: India
Posts: 18
Rep Power: 5
aerosuraj1 is on a distinguished road
zone id for each component, you can see it in the boundary condition
aerosuraj1 is offline   Reply With Quote

Old   October 31, 2022, 03:50
Default
  #13
New Member
 
shima mohammadi
Join Date: Oct 2022
Posts: 14
Rep Power: 4
sara9310 is on a distinguished road
Quote:
Originally Posted by aerosuraj1 View Post
zone id for each component, you can see it in the boundary condition
How can i enter "zone id" in osi code?
sara9310 is offline   Reply With Quote

Old   November 1, 2022, 05:44
Default
  #14
New Member
 
Suraj Shembekar
Join Date: Feb 2021
Location: India
Posts: 18
Rep Power: 5
aerosuraj1 is on a distinguished road
Quote:
Originally Posted by sara9310 View Post
How can i enter "zone id" in osi code?
you need to edit the UDF file.
you can use a platform like ''visual studio'' or ''geany''
aerosuraj1 is offline   Reply With Quote

Old   November 1, 2022, 12:34
Default
  #15
New Member
 
shima mohammadi
Join Date: Oct 2022
Posts: 14
Rep Power: 4
sara9310 is on a distinguished road
Quote:
Originally Posted by aerosuraj1 View Post
you need to edit the UDF file.
you can use a platform like ''visual studio'' or ''geany''
Thank you
I wrote
real zone_ID = 21;
But when i complie udf; 2 error is showing:
1) missing ';' before constant
2) 'real' : illegal use of this type as an expression

How can i solve these problems?!
sara9310 is offline   Reply With Quote

Old   November 2, 2022, 00:24
Default
  #16
New Member
 
Suraj Shembekar
Join Date: Feb 2021
Location: India
Posts: 18
Rep Power: 5
aerosuraj1 is on a distinguished road
Quote:
Originally Posted by sara9310 View Post
Thank you
I wrote
real zone_ID = 21;
But when i complie udf; 2 error is showing:
1) missing ';' before constant
2) 'real' : illegal use of this type as an expression

How can i solve these problems?!
can you post your UDF code here, so that the expert members take a look and suggest any changes.
aerosuraj1 is offline   Reply With Quote

Old   November 2, 2022, 01:49
Default
  #17
New Member
 
shima mohammadi
Join Date: Oct 2022
Posts: 14
Rep Power: 4
sara9310 is on a distinguished road
Quote:
Originally Posted by aerosuraj1 View Post
can you post your UDF code here, so that the expert members take a look and suggest any changes.
Thank you
I upload udf file. When I compile this udf, for two line:
real domain_ID=1;
real zone_ID=21;
These errors appear:
1) missing ';' before constant
2) 'real' : illegal use of this type as an expression
Attached Files
File Type: c osi 3.c (1.7 KB, 22 views)
sara9310 is offline   Reply With Quote

Old   November 2, 2022, 02:07
Default
  #18
New Member
 
Suraj Shembekar
Join Date: Feb 2021
Location: India
Posts: 18
Rep Power: 5
aerosuraj1 is on a distinguished road
Quote:
Originally Posted by sara9310 View Post
Thank you
I upload udf file. When I compile this udf, for two line:
real domain_ID=1;
real zone_ID=21;
These errors appear:
1) missing ';' before constant
2) 'real' : illegal use of this type as an expression
Dear Shima,
delete line numbers 54 (real domain_ID = 1 and 55 (real zone_ID = ? from your UDF code and try to run it.
I am quite sure this time you will run it successfully.
All the best
aerosuraj1 is offline   Reply With Quote

Old   November 2, 2022, 03:51
Default
  #19
New Member
 
shima mohammadi
Join Date: Oct 2022
Posts: 14
Rep Power: 4
sara9310 is on a distinguished road
Quote:
Originally Posted by aerosuraj1 View Post
Dear Shima,
delete line numbers 54 (real domain_ID = 1 and 55 (real zone_ID = ? from your UDF code and try to run it.
I am quite sure this time you will run it successfully.
All the best
I complied code without these two lines and run it; when I select "osi" in contours of cfd-post, anything is showing!
Some body tell me zone id should specify in code; how can I solve this problem?

Last edited by sara9310; November 2, 2022 at 05:35.
sara9310 is offline   Reply With Quote

Old   November 2, 2022, 06:01
Default
  #20
New Member
 
Suraj Shembekar
Join Date: Feb 2021
Location: India
Posts: 18
Rep Power: 5
aerosuraj1 is on a distinguished road
Quote:
Originally Posted by sara9310 View Post
I complied code without these two lines and run it; when I select "osi" in contours of cfd-post, anything is showing!
Some body tell me zone id should specify in code; how can I solve this problem?
I am glad that you have successfully compiled and run the simulation.
Yes, the zone ID should be specified in the code for the component on which you would like to see the OSI contours in CFD post. (mostly, people use to see the OSI contours on the "wall", so the zone ID of the wall should be specified within the code).
aerosuraj1 is offline   Reply With Quote

Reply

Tags
ansys-fluent, osi, 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
udf for one dimensional linear motion based on force maccheese Fluent UDF and Scheme Programming 2 September 1, 2019 03:18
can anyone help me about the udf of dynamic contact angle in FLUENT? Albert Lee FLUENT 0 July 1, 2018 09:21
Save output of udf in another udf! JuanJoMex FLUENT 0 February 8, 2018 13:43
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


All times are GMT -4. The time now is 01:29.