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

How can I get a variable as output parameter from a UDF for post processing?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 20, 2022, 06:56
Default How can I get a variable as output parameter from a UDF for post processing?
  #1
New Member
 
mohammad
Join Date: Dec 2021
Posts: 10
Rep Power: 5
mmd96 is on a distinguished road
Hi, I want to get ''xpos'' variable in my UDF code (which has been attached) as an output parameter for plot xpos vs time in cfdpost.
Thanks.
Code:
#include "udf.h"

DEFINE_SDOF_PROPERTIES(sphere, prop, dt, time, dtime)
{
real xpos;

prop[SDOF_MASS] = 0.786;
prop[SDOF_IXX] = 0.00000786;
prop[SDOF_IYY] = 0.00000786;
prop[SDOF_IZZ] = 0.00000786;
                   
xpos = DT_CG(dt) [0];  

}
mmd96 is offline   Reply With Quote

Old   June 21, 2022, 22:46
Default
  #2
Senior Member
 
Join Date: Feb 2020
Posts: 114
Rep Power: 6
lbj007 is on a distinguished road
try to use UDM to store the variable
lbj007 is offline   Reply With Quote

Old   June 22, 2022, 07:01
Default
  #3
New Member
 
mohammad
Join Date: Dec 2021
Posts: 10
Rep Power: 5
mmd96 is on a distinguished road
Thanks for your reply. I will be grateful if tell me which macro should I use.
mmd96 is offline   Reply With Quote

Old   June 23, 2022, 02:00
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
better to write to file, as xpos is same for the whole domain at specified time moment
compile code:
Code:
#include "udf.h"

DEFINE_SDOF_PROPERTIES(sphere, prop, dt, time, dtime)
{
real xpos;

prop[SDOF_MASS] = 0.786;
prop[SDOF_IXX] = 0.00000786;
prop[SDOF_IYY] = 0.00000786;
prop[SDOF_IZZ] = 0.00000786;
                   
xpos = DT_CG(dt) [0];
  
host_to_node_real_1(xpos);

#if !RP_NODE
	if ((fp = fopen(out_xpos, "w"))==NULL)
		{
			Message("\n Warning: Unable to open %s for writing\n",out_xpos);
			exit(0);
		}
	else
		{
			fprintf(fp, "%f	%f\n",time, xpos);
			Message("\nWriting data to %s...",out_xpos);			
		}
#endif	
}
mmd96 likes this.
__________________
best regards


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

Reply

Tags
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 error_ undeclared variable panos_metal21 Fluent UDF and Scheme Programming 6 December 19, 2019 01:44
Pass variable from one udf to another Spyrost FLUENT 8 September 14, 2019 13:13
How to set as input parameter in Fluent a variable existing outside it? didimad FLUENT 1 March 3, 2015 12:10
Accessing output parameter value in scheme nnvoro Fluent UDF and Scheme Programming 1 October 11, 2014 15:53
UDF: exporting a variable between two DEFINE function Carlo FLUENT 3 August 19, 2009 13:21


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