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

How to give names to udf memory?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 7, 2015, 02:13
Question How to give names to udf memory?
  #1
New Member
 
Join Date: Apr 2015
Posts: 12
Rep Power: 11
sphoenix09 is on a distinguished road
In the contour plots C_UDMI(c,t,1) shows contours of user defined memory 1.
But I need this macro should display contours of velocity, temperature volume fraction etc.. How to give name to this macro?

Any help would be appreciated
sphoenix09 is offline   Reply With Quote

Old   May 7, 2015, 02:54
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Use the "Set_User_Memory_Name" function with the following format (read the section in the user's guide on User-Defined Memory for details).

Code:
void Set_User_Memory_Name(int i,char *name);
`e` is offline   Reply With Quote

Old   May 7, 2015, 07:49
Unhappy
  #3
New Member
 
Join Date: Apr 2015
Posts: 12
Rep Power: 11
sphoenix09 is on a distinguished road
Thank you.
Can you help me to solve this?

Code:
#include "udf.h"
#include "sg_udms.h"
#include "math.h"
#include "mem.h"
#include "sg.h"
"
DEFINE_ADJUST(temp, d)
{
	#if PARALLEL
	Domain *d; 	
	
	real tavg = 0.;
	real tmax = 0.;
	real tmin = 0.;
	real temp,volume,vol_tot;
	
	void Set_User_Memory_Name(int i,char *temp_ratio); 
	
	Thread *t;
	cell_t c;
	
	
	d = Get_Domain(1); 
	thread_loop_c(t,d)
	{
	
		begin_c_loop(c,t)
		{
			volume = C_VOLUME(c,t); 
			temp = C_T(c,t); 
			if (temp < tmin || tmin == 0.) tmin = temp;
			if (temp > tmax || tmax == 0.) tmax = temp;
			vol_tot += volume;
			tavg += temp*volume;
		}
		end_c_loop(c,t)
		tavg /= vol_tot;
		
		printf("\n Tmin = %g Tmax = %g Tavg = %g\n",tmin,tmax,tavg);

		begin_c_loop(c,t)
		{
			temp = C_T(c,t);
			C_UDMI(c,t,0) = (temp-tmin)/(tmax-tmin);
			C_UDMI(c,t,temp_ratio)= C_UDMI(c,t,0);
		}
		end_c_loop(c,t)
	}
	
	#endif
}
sphoenix09 is offline   Reply With Quote

Old   May 7, 2015, 08:55
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
That's not how you call functions in C. The format I posted above was of the function declaration. Try the following code to call the function:

Code:
Set_User_Memory_Name(0, "temp_ratio");
Also, what are you trying to achieve with this line of code? The variable "temp_ratio" is not declared or initialised as an integer which is what the C_UDMI macro is expecting.

Code:
C_UDMI(c,t,temp_ratio)= C_UDMI(c,t,0);
`e` is offline   Reply With Quote

Old   May 8, 2015, 02:37
Default
  #5
New Member
 
Join Date: Apr 2015
Posts: 12
Rep Power: 11
sphoenix09 is on a distinguished road
I replaced but didn't work.. Can you modify?

Code:
#include "udf.h"
#include "sg_udms.h"
#include "math.h"
#include "mem.h"
#include "sg.h"
"
DEFINE_ADJUST(temp, d)
{
	#if PARALLEL
	Domain *d; 	
	
	real tavg = 0.;
	real tmax = 0.;
	real tmin = 0.;
	real temp,volume,vol_tot;
	
	void Set_User_Memory_Name(int i,char *temp_ratio); 
	
	Thread *t;
	cell_t c;
	
	
	d = Get_Domain(1); 
	thread_loop_c(t,d)
	{
	
		begin_c_loop(c,t)
		{
			volume = C_VOLUME(c,t); 
			temp = C_T(c,t); 
			if (temp < tmin || tmin == 0.) tmin = temp;
			if (temp > tmax || tmax == 0.) tmax = temp;
			vol_tot += volume;
			tavg += temp*volume;
		}
		end_c_loop(c,t)
		tavg /= vol_tot;
		
		printf("\n Tmin = %g Tmax = %g Tavg = %g\n",tmin,tmax,tavg);

		begin_c_loop(c,t)
		{
			temp = C_T(c,t);
			C_UDMI(c,t,0) = (temp-tmin)/(tmax-tmin);
                        Set_User_Memory_Name(0, "temp_ratio");
			
		}
		end_c_loop(c,t)
	}
	
	#endif
}
sphoenix09 is offline   Reply With Quote

Old   May 8, 2015, 03:23
Default
  #6
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
You still have the following line in your code...

Code:
void Set_User_Memory_Name(int i,char *temp_ratio);
`e` is offline   Reply With Quote

Old   May 8, 2015, 04:53
Question
  #7
New Member
 
Join Date: Apr 2015
Posts: 12
Rep Power: 11
sphoenix09 is on a distinguished road
Code:
void Set_User_Memory_Name(int i,char *temp_ratio);
Thank you. So Only this line should be removed from the code, isn't it? Is rest all Ok?
sphoenix09 is offline   Reply With Quote

Old   May 8, 2015, 06:48
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Does the code do what you want it to do?
If so, it is ok.
pakk is offline   Reply With Quote

Old   May 8, 2015, 07:01
Question
  #9
New Member
 
Join Date: Apr 2015
Posts: 12
Rep Power: 11
sphoenix09 is on a distinguished road
Thank you

Yes. This is the only code.. Here I need to change inlet conditions, temperature values etc..
Code:
#include "udf.h"
#include "sg_udms.h"
#include "math.h"
#include "mem.h"
#include "sg.h"
"
DEFINE_ADJUST(temp, d)
{
	#if PARALLEL
	Domain *d; 	
	
	real tavg = 0.;
	real tmax = 0.;
	real tmin = 0.;
	real temp,volume,vol_tot;
	
	Thread *t;
	cell_t c;
	
	
	d = Get_Domain(1); 
	thread_loop_c(t,d)
	{
	
		begin_c_loop(c,t)
		{
			volume = C_VOLUME(c,t); 
			temp = C_T(c,t); 
			if (temp < tmin || tmin == 0.) tmin = temp;
			if (temp > tmax || tmax == 0.) tmax = temp;
			vol_tot += volume;
			tavg += temp*volume;
		}
		end_c_loop(c,t)
		tavg /= vol_tot;
		
		printf("\n Tmin = %g Tmax = %g Tavg = %g\n",tmin,tmax,tavg);

		begin_c_loop(c,t)
		{
			temp = C_T(c,t);
			C_UDMI(c,t,0) = (temp-tmin)/(tmax-tmin);
                        Set_User_Memory_Name(0, "temp_ratio");
			
		}
		end_c_loop(c,t)
	}
	
	#endif
}
Is it ok now? No need to declare function as mentioned in the Manual?
sphoenix09 is offline   Reply With Quote

Old   May 8, 2015, 08:13
Default
  #10
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by sphoenix09 View Post
Thank you

Yes. This is the only code.. Here I need to change inlet conditions, temperature values etc..
Code:
#include "udf.h"
#include "sg_udms.h"
#include "math.h"
#include "mem.h"
#include "sg.h"
"
DEFINE_ADJUST(temp, d)
{
	#if PARALLEL
	Domain *d; 	
	
	real tavg = 0.;
	real tmax = 0.;
	real tmin = 0.;
	real temp,volume,vol_tot;
	
	Thread *t;
	cell_t c;
	
	
	d = Get_Domain(1); 
	thread_loop_c(t,d)
	{
	
		begin_c_loop(c,t)
		{
			volume = C_VOLUME(c,t); 
			temp = C_T(c,t); 
			if (temp < tmin || tmin == 0.) tmin = temp;
			if (temp > tmax || tmax == 0.) tmax = temp;
			vol_tot += volume;
			tavg += temp*volume;
		}
		end_c_loop(c,t)
		tavg /= vol_tot;
		
		printf("\n Tmin = %g Tmax = %g Tavg = %g\n",tmin,tmax,tavg);

		begin_c_loop(c,t)
		{
			temp = C_T(c,t);
			C_UDMI(c,t,0) = (temp-tmin)/(tmax-tmin);
                        Set_User_Memory_Name(0, "temp_ratio");
			
		}
		end_c_loop(c,t)
	}
	
	#endif
}
Is it ok now? No need to declare function as mentioned in the Manual?
What do you mean with "ok"?

Do you want to know if it compiles? Try it.
Do you want to know if it does what you want it to do? I don't know, because I don't know what you want it to do.

And what do you mean with "declare function as mentioned in the Manual"? Which part of the manual are you referring to?

I only have one remark. One thing your code does, is set the name "temp_ratio" to UDM0 many times, where one time is enough. You don't have to put that in the loop, so you can make your code more efficient by putting that line somewhere else.
pakk is offline   Reply With Quote

Old   May 10, 2015, 09:13
Default
  #11
New Member
 
Join Date: Apr 2015
Posts: 12
Rep Power: 11
sphoenix09 is on a distinguished road
Thank you. I just needed the name of that udm-0 in the contour menu. I got it thank you very much.
sphoenix09 is offline   Reply With Quote

Old   May 10, 2015, 09:50
Default
  #12
New Member
 
Join Date: Apr 2015
Posts: 12
Rep Power: 11
sphoenix09 is on a distinguished road
I have one more doubt. Can this udm be read in CFX post?
sphoenix09 is offline   Reply With Quote

Old   May 10, 2015, 18:46
Default
  #13
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
UDM values can be visualised in CFD-Post. Ensure you have saved these values via File > Data File Quantities...
`e` is offline   Reply With Quote

Old   May 11, 2015, 00:59
Smile
  #14
New Member
 
Join Date: Apr 2015
Posts: 12
Rep Power: 11
sphoenix09 is on a distinguished road
Quote:
Originally Posted by `e` View Post
UDM values can be visualised in CFD-Post. Ensure you have saved these values via File > Data File Quantities...
Thank you... I visualized in CFD-Post..
sphoenix09 is offline   Reply With Quote

Old   May 11, 2015, 07:01
Default
  #15
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
Hi,
Have you read this udm in techplot?
shivakumar is offline   Reply With Quote

Reply


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 3d model to give heat flux profile around the wall surface n7310889 Fluent UDF and Scheme Programming 3 May 8, 2018 07:45
Dynamic Mesh UDF Qureshi FLUENT 7 March 23, 2017 08:37
Run-time memory allocation error akalopsis CFX 0 November 17, 2014 18:17
Lenovo C30 memory configuration and discussions with Lenovo matthewe Hardware 3 October 17, 2013 11:23
Identifying cell in parallel UDF upeksa Fluent UDF and Scheme Programming 0 July 24, 2013 12:27


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