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

store and access a single value in UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 21, 2019, 08:19
Default store and access a single value in UDF
  #1
Member
 
South Yorkshire
Join Date: May 2018
Posts: 33
Rep Power: 8
asking is on a distinguished road
Hi,

I wrote a UDF that determines the position and velocity of a body subjected to lift and drag forces. These variables are updated each time step and depend on their previous v(t-1) and current values v(t).

The UDF works as intended when I am running it on fluent. The problem starts when I am trying to restart the simulation after X time steps (i.e. run the simulation for X time step, save the last result, close fluent, load the last saved time step, run the simulation). The velocity value is not saved and goes back to zero when the simulation is restarted.

How can I store these values at the last saved time step so I can use them when I restart the simulation?

Thanks,
asking is offline   Reply With Quote

Old   June 23, 2019, 23:05
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
write to file, or use UDMI

best regards
AlexanderZ is offline   Reply With Quote

Old   June 24, 2019, 07:45
Default
  #3
Member
 
South Yorkshire
Join Date: May 2018
Posts: 33
Rep Power: 8
asking is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
write to file, or use UDMI

best regards
Thank you Alexander.

At the beginning I didnt want to use UDMI since I found it that saving a constant value on each cell of the body was quite inefficient but at the end I just did it and it works as intended. In any case... for completeness, this is my implementation.

Code:
if (load_ini_UDMI_time < ctime)
{
/*Load UDMI*/
#if !RP_HOST
Thread *t,*t0_cell;
Domain *d = Get_Domain(1);
cell_t c0;
face_t f;
t = Lookup_Thread(d,zoneID);

begin_f_loop(f,t)
{
if (PRINCIPAL_FACE_P(f,t))
{
	c0 = F_C0(f,t);
	t0_cell = THREAD_T0(t);
	
	vxRK = C_UDMI(c0,t0_cell,3);
	vyRK = C_UDMI(c0,t0_cell,4);
	vx = C_UDMI(c0,t0_cell,5);
	vy = C_UDMI(c0,t0_cell,6);
	ax = C_UDMI(c0,t0_cell,7);
	ay = C_UDMI(c0,t0_cell,8);
	}
}
end_f_loop(f,t)
#endif

node_to_host_real_6(vxRK,vyRK,vx,vy,ax,ay);
load_ini_UDMI_time = ctime + 10000;
}
This code will be only executed at the first time-step and it will load the saved constants.

Regards
asking 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
How to solve UDF compilation problems in Fluent. pakk Fluent UDF and Scheme Programming 16 September 10, 2018 03:48
store and access the value in UDM serene6390 Fluent UDF and Scheme Programming 8 April 16, 2018 02:21
udf problem jane Fluent UDF and Scheme Programming 37 February 20, 2018 05:17
UDF to Access Wall Normal Concentration Gradient Daniel Tanner Fluent UDF and Scheme Programming 4 February 18, 2015 15:35
Help on UDF: access to wall shear stress Zhihua Li FLUENT 2 May 26, 2004 12:55


All times are GMT -4. The time now is 17:39.