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

Problems with interpolating UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 28, 2014, 17:28
Default Problems with interpolating UDF
  #1
New Member
 
anonymous
Join Date: Mar 2014
Posts: 5
Rep Power: 12
Topspin is on a distinguished road
I'm trying to make a UDF that interpolates between values of a continuous curve defining wall temperature to evaluate the difference the interpolation makes on the solution.

Here is the working continuous UDF:
Code:
#include "udf.h"
#define t0 0.00288

DEFINE_PROFILE(panel_wall_7_temperature, thread, i)
{
	face_t f;
	double time;
	begin_f_loop(f, thread)
	{
		time = CURRENT_TIME;
		F_PROFILE(f, thread, i) = 300.0 + 100.0 * (time / t0) - 25.0 * pow((time / t0), 3.0);
	}
	end_f_loop(f, thread)
}

And here is the non-working interpolating UDF for 100 time steps doing interpolation between every 4th point in time:
Code:
#include "udf.h"
#include <vector>

#define t0 0.00288

main()

{
	int i;	
	double Tw4i[26]; 
	double t4i[26];
	
	for (i=0;i<26;i++)
		t4i[i]=4.0*i*t0/100; /*Assemble discretized time vector*/

	for (i=0;i<26;i++)
		Tw4i[i]= 300.0 + 100.0*t4i[i]/t0 - 25.0*t4i[i]*t4i[i]*t4i[i]/t0/t0/t0; /*Discretized Wall Temperature vector to interpolate to*/

DEFINE_PROFILE(panel_wall_7_temperature_sub100, thread, i)
{
	face_t f;
	double t;
	double TL;
	double TR;
	double tL;
	double tR;

	begin_f_loop(f, thread)
	{
		t = CURRENT_TIME; /*Current timestep time that FLUENT is calculating from*/

		for (i=0;i<25;i++)
			TL=Tw4i[i]; /*Nearest Left Temperature*/
			TR=Tw4i[i+1]; /*Nearest Right Temperature*/
			tL=t4i[i]; /*Nearest Left time*/
			tR=t4i[i+1]; /*Nearest Right time*/
			
			if (t>=tL && t<=tR)
				F_PROFILE(f, thread, i) = TL + ((TR-TL)/(tR-tL))*(t-tL); /*Linear interpolation to surrounding discrete temperature values*/

	}
	end_f_loop(f, thread)
}
}

Error output in fluent:
Copied H:\Research\Fluent\100 Timesteps\Subcycling\panel-wall-7_temperature_100_Subcycling.c to libudf\src
(system "copy "C:\PROGRA~1\ANSYSI~1\v140\fluent"\fluent14.0.0\sr c\makefile_nt.udf "libudf\win64\3ddp_host\makefile" ")
1 file(s) copied.
(chdir "libudf")()
(chdir "win64\3ddp_host")()
'nmake' is not recognized as an internal or external command,
operable program or batch file.
'nmake' is not recognized as an internal or external command,
operable program or batch file.
(system "copy "C:\PROGRA~1\ANSYSI~1\v140\fluent"\fluent14.0.0\sr c\makefile_nt.udf "libudf\win64\3ddp_node\makefile" ")
1 file(s) copied.
(chdir "libudf")()
(chdir "win64\3ddp_node")()
'nmake' is not recognized as an internal or external command,
operable program or batch file.
'nmake' is not recognized as an internal or external command,
operable program or batch file.


Any idea what needs fixed for the latter? I have Visual Studio 2013 Ultimate through my school's Dreamspark program, so I don't get the 'nmake' error...

Last edited by Topspin; March 30, 2014 at 15:44.
Topspin is offline   Reply With Quote

Old   March 30, 2014, 22:23
Default
  #2
New Member
 
anonymous
Join Date: Mar 2014
Posts: 5
Rep Power: 12
Topspin is on a distinguished road
Might as well post this for anyone that stumbles upon this with the same issue:

Eliminated the 'nmake' error by launching from Net2.0 "SDK Command Prompt"

Now, it seems to compile correctly.

Here's my new code, I just edited it to get rid of the vector. It has to reassemble the temperature curve every timestep but that's fine.
Code:
#include "udf.h"


#define t0 0.00288

		
DEFINE_PROFILE(panel_wall_7_temperature_sub100, thread, i)
{
	
	face_t f;
	double TL;
	double TR;
	double tL;
	double tR;
	int j;
	double t;

	begin_f_loop(f, thread)
	{
		t = CURRENT_TIME; /*Current timestep time that FLUENT is calculating from*/

		for (j=0;j<25;j++){
			tL=4.0*j*t0/100; /*Nearest Left time*/
			tR=4.0*(j+1)*t0/100; /*Nearest Right time*/
			TL=300.0 + 100.0*tL/t0 - 25.0*tL*tL*tL/t0/t0/t0; /*Nearest Left Temperature*/
			TR=300.0 + 100.0*tR/t0 - 25.0*tR*tR*tR/t0/t0/t0; /*Nearest Right Temperature*/
			
			if (t>=tL && t<=tR)
				F_PROFILE(f, thread, i) = TL + ((TR-TL)/(tR-tL))*(t-tL);} /*Linear interpolation to surrounding discrete temperature values*/

	}
	end_f_loop(f, thread)
}
Topspin 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
Dynamic Mesh UDF Qureshi FLUENT 7 March 23, 2017 07:37
Windows Environment variables- to solve problems in compiling UDF in Fluent Modest Cat Fluent UDF and Scheme Programming 39 May 18, 2016 10:33
problems with UDF to set contact angle poiuy219 Main CFD Forum 0 April 30, 2009 10:43
DEFINE_DPM_OUTPUT macro UDF HELP Puneet FLUENT 3 November 28, 2003 10:55
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 04:01


All times are GMT -4. The time now is 09:21.