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

Error with Velocity Profile UFD

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 2, 2019, 04:15
Default Error with Velocity Profile UFD
  #1
New Member
 
Will
Join Date: Jun 2019
Posts: 2
Rep Power: 0
will.jones1995 is on a distinguished road
Hello everyone,

I'm hoping someone will be able to help me with an error on my UFD. I should start by saying that I have no knowledge of C, so a coding error was going to happen.


The Problem

I have the geometry shown in the image below, I want an fully developed velocity profile at the inlet with an x component.



The velocity components for the flow profile are shown below:

u/ui = 2(1-r^2), v/ui = 0 and w/ui = 0


My Code

As I said previously, I've no knowledge of C and there's an error in here somewhere. I've tried a couple of different things (including Googling), but I just can't seem to get it to work, so any help would be massively appreciated.

Code:
#include "udf.r"

DEFINE_PROFILE(inlet_x_velocity, thread, position)
{
	real x[ND_ND];    /* this will hold the position vector */
	real y;
	face_t f;

	r = 0.0127; /* radius in m */

	begin_f_loop(f,t)
	{
	F_CENTROID(x,f,t);
	y = x[1];
	F_PROFILE(f,t,i) = 2 * (1 - (r * r))
	}
	end_f_loop(f,t)
}
If anyone knows how to fix this to get it to work, I will be very grateful.

Thanking you all in advance,

Will
will.jones1995 is offline   Reply With Quote

Old   July 2, 2019, 08:01
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
If you try to compile this code, it does not work. You get errors. What you should do: read those errors!


The first error that I get:
Quote:
..\..\src\temp.c(1): fatal error C1083: Cannot open include file: 'udf.r': No such file or directory
So, the compiler complains that it can not find the file "udf.r". Why does it look for that file? Because you told it to. You made a typo: it should be "udf.h", as it is in all examples in the Fluent manual.


OK, so I fixed that, and compiled again. Again errors:
Quote:
..\..\src\temp.c(9): error C2065: 'r': undeclared identifier ..\..\src\temp.c(11): error C2065: 't': undeclared identifier
..\..\src\temp.c(11): error C2223: left of '->nelements_in_layer' must point to struct/union
..\..\src\temp.c(13): error C2065: 't': undeclared identifier
..\..\src\temp.c(13): error C2223: left of '->storage' must point to struct/union
..\..\src\temp.c(15): error C2065: 't': undeclared identifier
..\..\src\temp.c(15): error C2223: left of '->storage' must point to struct/union
..\..\src\temp.c(15): error C2065: 'i': undeclared identifier
..\..\src\temp.c(15): error C2065: 'r': undeclared identifier
..\..\src\temp.c(16): error C2143: syntax error: missing ';' before '}'
Always start on the top. The first error is that 'r' is undeclared. So the solution: declare it! Tell the compiler what 'r' is. You want it to be a variable that is a floating number. Similarly, you use 't' and 'i', but you never told the compiler what they are. I don't know where you started from, but actually 't' should be the same as 'thread' in the declaration, and 'i' should be the same as 'position' in the declaration.


After fixing that, I compile again, and see one error remaining:
Quote:
..\..\src\temp.c(16): error C2143: syntax error: missing ';' before '}'
Aha, you forgot to put a semicolon after your statement.


I added the semicolon, and the compilation went perfect.


So to conclude: compile, and look at the errors. You might not understand the error, but if you don't try you'll never know.
will.jones1995 likes this.
pakk is offline   Reply With Quote

Old   July 3, 2019, 19:37
Default
  #3
New Member
 
Will
Join Date: Jun 2019
Posts: 2
Rep Power: 0
will.jones1995 is on a distinguished road
Thanks pakk, that was really helpful.
will.jones1995 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
Plot velocity profile along longitudinal axis of pipe jorgelmilan EnSight 8 July 7, 2018 15:30
[UDF] Relative coordinates in logarithmic velocity profile cfdworker Fluent UDF and Scheme Programming 25 July 13, 2017 04:44
InterFoam - Validation for velocity profile in simple channel me.ouda OpenFOAM Running, Solving & CFD 0 October 19, 2015 07:42
Logarithmic velocity profile cfdworker Fluent UDF and Scheme Programming 0 April 23, 2009 20:09
[boundary condition] logarithmic velocity profile cfdworker FLUENT 2 April 18, 2009 00:36


All times are GMT -4. The time now is 12:53.