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

Profiles(Text file) into UDF_DEFINE SOURCE

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 25, 2018, 02:47
Default Profiles(Text file) into UDF_DEFINE SOURCE
  #1
New Member
 
Join Date: Jun 2012
Posts: 9
Rep Power: 14
kamu123 is on a distinguished road
Hello, i am panic in applying the profiles in to UDF_DEFINE SOURCE

I want to define source with "eg" depending on location x, y.

I have a text file with the information of "eg" as a series of data with x,y coordinates.

I failed to make a function like eg= f(x,y).

So I want to read directly the profile on the fluent. (profiles -> fluent)
Reading the profiles from the fluent was successful

But, desparately, i can not get any sense
applying "eg" profiles (uploaded in fluent) to UDF code


If you know some hint, please help me TT


"eg" profiles example

((eg 5 point)
(x
0.2
0.35
0.7
0.9
0.91)
(y
0.00147406
0.00147546
0.0014834
0.00148353
0.00139519)
(eg
0.8269
0.81492
0.88675
0.75573
0.83069)


UDF code shown below

=====================================
DEFINE_SOURCE(xmom_src,c,t,dS,eqn)
{
double src,x[ND_ND],source,base1,base2;

C_CENTROID(x,c,t);

{

src = C_MU_L(c,t)*eg/pk;
source = -src*C_U(c,t);
dS[eqn] = -src;
break;
}
return source;
}
kamu123 is offline   Reply With Quote

Old   April 25, 2018, 03:35
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
If your scheme variable is just one number, you can read it in a UDF as:
Code:
RP_Get_Real("variable-name")
Here, you have a list of numbers, so this will not automatically work, but maybe this brings you a step closer to a solution.
pakk is offline   Reply With Quote

Old   April 25, 2018, 04:04
Default
  #3
New Member
 
Join Date: Jun 2012
Posts: 9
Rep Power: 14
kamu123 is on a distinguished road
Thank you for your kind reply!!!

I am searching with your hint.

If you have any more information, please reply me for help. Thank you!!
kamu123 is offline   Reply With Quote

Old   April 25, 2018, 06:16
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
you may define your table in udf and use interpolation to get heat source according to coordinate

this code may help you
Code:
#include "udf.h"
#include <stdlib.h>
#include <stdio.h>

#define N 10

float Temp[N] =
{
	300	301	302	303	304	305	306	307	308	309
}

float Heat[N] =
{
	100	201	302	403	504	605	706	807	908	1009
}

DEFINE_EXECUTE_ON_LOADING(report_version, libname)
{
	Set_User_Memory_Name(0,"My heatsource [W/m3]");
}

DEFINE_SOURCE(UDF_heat_source, c, t, dS, eqn)
{
	return C_UDMI(c,t,0);
}

DEFINE_ADJUST(adjust_heat_source, d)
{
	Thread *t;
	cell_t  c;
	real source,T;
	real j, Tpre, Tcur, Hpre, Hcur, A, B, M;
	
	thread_loop_c(t,d)	// loop over all cells in model
	{
		begin_c_loop(c,t)
		{
			M=N-1;
			T = C_T(c,t);
			if(T<Temp[0])
			{
				source = 0;
			}
			for(j=1;j<=M;j++)
			{
				if(T>=Temp[j-1] && T<Temp[j])
				{
					Tpre = Temp[j-1];
					Tcur = Temp[j];
					Hpre = Heat[j-1];
					Hcur = Heat[j];
					A = (Hcur - Hpre)/(Tcur - Tpre);
					B = Hcur - (Tcur * A);
					source = (A*T)+B;
					C_UDMI(c,t,0) = source;
				}
			}
		}
		end_c_loop (c,t)
	}
best regards
AlexanderZ is offline   Reply With Quote

Old   April 25, 2018, 06:39
Default
  #5
New Member
 
Join Date: Jun 2012
Posts: 9
Rep Power: 14
kamu123 is on a distinguished road
Dear AlexanderZ

Thank you very much
i got the key information about interpolation from your reply

However, my data are actually about 120 data
and each "eg" depends on both x and y coordinates.
Even if i tried to get some fitting function with MATLAB, i failed.

So i want to apply whole 120 data points with profiles to fluent directly.

Is there any method connecting the profiles in UDF??

Thank you TTTT
kamu123 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
[swak4Foam] swak4foam for OpenFOAM 4.0 mnikku OpenFOAM Community Contributions 80 May 17, 2022 09:06
OpenFoam "Permission denied" and "command not found" problems. iyidaniel@yahoo.co.uk OpenFOAM Running, Solving & CFD 11 January 2, 2018 07:47
[Other] How to use finite area method in official OpenFOAM 2.2.0? Detian Liu OpenFOAM Meshing & Mesh Conversion 4 November 3, 2015 04:04
Problem compiling a custom Lagrangian library brbbhatti OpenFOAM Programming & Development 2 July 7, 2014 12:32
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 12:44


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