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

Boundary Condition ID _ location_ udf code problem

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 25, 2018, 13:37
Default Boundary Condition ID _ location_ udf code problem
  #1
New Member
 
Join Date: Jun 2012
Posts: 9
Rep Power: 14
kamu123 is on a distinguished road
Hello i have a question about setting the location with boundary condition ID

I have divided two section as A-B, B-C with boundary A,B,C.

As original code, i set the boundary A,B,C with coordinate directly.


Original Code
================================
#define A 6.
#define B A+5.
#define C B+4.


DEFINE_SOURCE(xmom_src,c,t,dS,eqn)
{
int body;
double src,x[ND_ND],loc,source;

body=0;
C_CENTROID(x,c,t);
loc=x[0];

if ((loc > A) && (loc <= B)) body = 1;
else if ((loc > B) && (loc <= C)) body = 2;

switch (body)
{
case 1:
src = 1/p;
source = -src*C_U(c,t);
dS[eqn] = -src;
break;
case 2:
src = 1/p;
source = -src*C_U(c,t);
dS[eqn] = -src;
break;
default:
source = 0.;
dS[eqn] = 0.;
}
return source;
}

=================================

Now the boundary "B" is changed as the curved face.

So i have to use the boundary condition ID.

I have checked from BC panel and the ID of B was 191.

From here, please anyone check my code.

I am confusing where should be changed

Changed code is shown below
===================================
Changed code

#define A 6.
#define C A+9.


DEFINE_SOURCE(xmom_src,c,t,dS,eqn)
{
int body;
double src,x[ND_ND],loc,source;

body=0;
C_CENTROID(x,c,t);
loc=x[0];

int ID = 191; /* Zone ID for top from Boundary Conditions task page */
Thread *B;
B = Lookup_Thread(d, ID);

if ((loc > A) && (loc <= B)) body = 1;
else if ((loc > B) && (loc <= C)) body = 2;

switch (body)
{
case 1:
src = 1/p;
source = -src*C_U(c,t);
dS[eqn] = -src;
break;
case 2:
src = 1/p;
source = -src*C_U(c,t);
dS[eqn] = -src;
break;
default:
source = 0.;
dS[eqn] = 0.;
}
return source;
}
=================================
kamu123 is offline   Reply With Quote

Old   April 25, 2018, 21:56
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
variable loc is coordinate along x axis, so you should define start/end of AB BC as x coordinate

recommendation: do not use double type in UDF, use real instead

best regards
AlexanderZ is offline   Reply With Quote

Old   April 25, 2018, 22:10
Default
  #3
New Member
 
Join Date: Jun 2012
Posts: 9
Rep Power: 14
kamu123 is on a distinguished road
hello AlexanderZ

That's what i am asking now.

start/end of AB BC was x coordinate.

But now i can not set B as x coordinate because it is curved

I just tried changing only B as domain ID

And then do i have to change the whole variable loc?
kamu123 is offline   Reply With Quote

Old   April 25, 2018, 22:18
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
curved line is 2d line, so you need bouch x and y axis to define it.
for your case loc_x =x[0]; loc_y = x[1];

looks like you need to change your if statement

best regards
AlexanderZ 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
3D Windturbine simulation in SU2 k.vimalakanthan SU2 15 October 12, 2023 06:53
Multiphase flow - incorrect velocity on inlet Mike_Tom CFX 6 September 29, 2016 02:27
Error - Solar absorber - Solar Thermal Radiation MichaelK CFX 12 September 1, 2016 06:15
Error finding variable "THERMX" sunilpatil CFX 8 April 26, 2013 08:00
Convective Heat Transfer - Heat Exchanger Mark CFX 6 November 15, 2004 16:55


All times are GMT -4. The time now is 15:49.