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

User Defined Memory

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By sreekargomatam

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 9, 2012, 10:19
Default User Defined Memory
  #1
New Member
 
Gomatam Sreekar
Join Date: Jul 2011
Posts: 12
Rep Power: 15
sreekargomatam is on a distinguished road
I use a nonlinear k-e model and the Reynolds Stress is stored in the User defined memory. Is it possible to clear that user defined memory after a set number of iterations while running the case??
sreekargomatam is offline   Reply With Quote

Old   January 14, 2012, 17:31
Default
  #2
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
Sure. Is it a transient case or a steady-state case? The define_adjust macro will run once per iteration, and thus you'd need to simply hook your reset macro (with appropriate logic) into define_adjust.

I haven't tried the code below, but it should give you an idea of what to do.
Code:
#include "udf.h"
int IterCounter=1;

DEFINE_ADJUST(adjust_fcn,d)
{
	Thread *t;
	cell_t c;
	/*reset if iterations > 2000 */
	if(IterCounter>2000)
	{
		IterCounter=0;
		thread_loop_c(t,d)
		{
			if (FLUID_THREAD_P(t))
			{
			begin_c_loop_all(c,t)
				{		
					for (i = 0; i < n_udm; i++)
					{
						/*This loops over all UDM locations and resets them to 0.*/
						/* Implement your own values or logic here*/
						C_UDMI(c, t, i) = 0.0; 
					}
				}
			end_c_loop_all(c,t)
			}
		}
	}
	IterCounter=IterCounter+1;
}
ComputerGuy
ComputerGuy is offline   Reply With Quote

Old   January 17, 2012, 03:46
Default
  #3
New Member
 
Gomatam Sreekar
Join Date: Jul 2011
Posts: 12
Rep Power: 15
sreekargomatam is on a distinguished road
Thanks for the code. It's a transient code. Will it make any difference if it's a steady case? If so, how?
marausna likes this.
sreekargomatam is offline   Reply With Quote

Old   January 17, 2012, 10:10
Default
  #4
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
I asked because doing something based on iterations in a transient code doesn't make a lot of sense (while they're correlated with flow time, it's not a fixed relationship, and you'd be resetting at random intervals). By iterations, do you mean time step?

ComputerGuy

Quote:
Originally Posted by sreekargomatam View Post
Thanks for the code. It's a transient code. Will it make any difference if it's a steady case? If so, how?
ComputerGuy is offline   Reply With Quote

Old   January 17, 2012, 10:13
Default
  #5
New Member
 
Gomatam Sreekar
Join Date: Jul 2011
Posts: 12
Rep Power: 15
sreekargomatam is on a distinguished road
Yes. By iterations I mean the time steps. Is it possible to delete that data at the completion of a case. If I'm running the case for 100seconds, is there someway to delete the user defined memory after 100s from the data file?
sreekargomatam is offline   Reply With Quote

Old   January 17, 2012, 10:19
Default
  #6
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
Yes. The simple fix to the code below should clear the UDM after 100 seconds. It's a define on demand to prevent running every iteration for flow times beyond 100s
Code:
#include "udf.h"


DEFINE_ON_DEMAND(eraseudm)
{
	Thread *t;
        Domain *d;
	cell_t c;
        real current_time;
        current_time = CURRENT_TIME;
        d = Get_Domain(1);
	if(current_time>100)
	{
		IterCounter=0;
		thread_loop_c(t,d)
		{
			if (FLUID_THREAD_P(t))
			{
			begin_c_loop_all(c,t)
				{		
					for (i = 0; i < n_udm; i++)
					{
						/*This loops over all UDM locations and resets them to 0.*/
						/* Implement your own values or logic here*/
						C_UDMI(c, t, i) = 0.0; 
					}
				}
			end_c_loop_all(c,t)
			}
		}
	}

}

ComputerGuy


Quote:
Originally Posted by sreekargomatam View Post
Yes. By iterations I mean the time steps. Is it possible to delete that data at the completion of a case. If I'm running the case for 100seconds, is there someway to delete the user defined memory after 100s from the data file?
ComputerGuy is offline   Reply With Quote

Old   May 18, 2012, 18:18
Default
  #7
New Member
 
moon
Join Date: Feb 2012
Posts: 26
Rep Power: 14
moun139 is on a distinguished road
this is my udf to calculate gradient of temperature dt/dy,it write me error fluent reveice .....()

what's wrong ?


#include "udf.h"

DEFINE_ON_DEMAND(store_grad)
{
Domain* d;
Thread *t;
cell_t c;

d=Get_Domain(1);
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_UDMI(c,t,0)=C_T_G(c,t)[1];
}
end_c_loop(c,t)
}
}
thx
moun139 is offline   Reply With Quote

Old   May 19, 2012, 05:56
Default
  #8
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Quote:
Originally Posted by moun139 View Post
this is my udf to calculate gradient of temperature dt/dy,it write me error fluent reveice .....()

what's wrong ?


#include "udf.h"

DEFINE_ON_DEMAND(store_grad)
{
Domain* d;
Thread *t;
cell_t c;

d=Get_Domain(1);
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_UDMI(c,t,0)=C_T_G(c,t)[1];
}
end_c_loop(c,t)
}
}
thx
Hi,

Did you patch the UDM before use?
__________________
Amir
Amir is offline   Reply With Quote

Reply

Tags
k-e model, udf, user defined memory


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
Trouble setting user scalar and user memory names tstorm FLUENT 6 November 23, 2022 04:58
How can I allocate user defined memory? MASOUD Fluent UDF and Scheme Programming 1 November 20, 2014 03:12
user defined sourcen term xck1986 CFX 1 July 8, 2010 09:35
user defined turbulence model manuutin STAR-CD 5 October 14, 2009 06:29
Gradient of a User defined Variable Ramadas CFX 2 August 21, 2007 10:19


All times are GMT -4. The time now is 11:46.