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

Related to UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 12, 2021, 04:09
Default Related to UDF
  #1
msd
Member
 
Heer
Join Date: Oct 2020
Posts: 45
Rep Power: 6
msd is on a distinguished road
Hello All,

I am trying to write a UDF for the pressure outlet boundary condition and the underlying condition is,
P = R*Q.
P = Mean pressure at the outlet (i.e. it remains constant at the whole face)
R = constant taken from literature
Q = flow rate
At the inlet, the pressure boundary condition is specified.

The code written goes as follows,
#include "udf.h"

#define R 12e9 /*Value taken from literature*/

#include "mem.h"
#include "metric.h"

DEFINE_PROFILE (outlet_pressure, thread, position)
{
real A[ND_ND];
face_t f;
Thread *t;
real Ar, V, Qfinal;
real Q = 0;

begin_f_loop(f, thread)
{
F_AREA(A, f, thread);
Ar = NV_MAG(A); /* Used for the computation of the magnitude of the area vector */
V = F_U(f, thread);
Q = Q + (Ar*V);
}
end_f_loop(f, thread)

Qfinal = Q;

begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) = R*Qfinal;
}
end_f_loop(f, thread)
}


Can someone please tell if there is some logical error in the code because the relation P = R*Q is not getting satisfied.

Thanks in advance!
msd is offline   Reply With Quote

Old   April 12, 2021, 05:09
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
right before line: Qfinal = Q;
you need to add global summation macro to make code works in parallel
Code:
Q = PRF_GRSUM1(Q);
also I'm not sure if you need to use full outlet area of each finite are (as you did) here:
Code:
Q = Q + (Ar*V);
check it
__________________
best regards


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

Old   April 12, 2021, 09:16
Default
  #3
Member
 
Yasser Selima
Join Date: Mar 2009
Location: Canada
Posts: 51
Rep Power: 19
Yasser is on a distinguished road
Code:
  q += a[0] * v
q += a[0] * v;

Last edited by Yasser; April 12, 2021 at 09:19. Reason: correcting
Yasser is offline   Reply With Quote

Old   April 12, 2021, 11:32
Default
  #4
msd
Member
 
Heer
Join Date: Oct 2020
Posts: 45
Rep Power: 6
msd is on a distinguished road
@Yasser, while inculcating this change, should I not calculate the magnitude of the area vector?
msd is offline   Reply With Quote

Old   April 12, 2021, 11:38
Default
  #5
Member
 
Yasser Selima
Join Date: Mar 2009
Location: Canada
Posts: 51
Rep Power: 19
Yasser is on a distinguished road
Hello,

If you are considering F_U, you should be multiplying this time the area in the x-direction only!
Yasser is offline   Reply With Quote

Old   April 12, 2021, 11:39
Default
  #6
msd
Member
 
Heer
Join Date: Oct 2020
Posts: 45
Rep Power: 6
msd is on a distinguished road
Thanks, Yasser for your input, I will check it.
msd is offline   Reply With Quote

Old   April 12, 2021, 11:40
Default
  #7
msd
Member
 
Heer
Join Date: Oct 2020
Posts: 45
Rep Power: 6
msd is on a distinguished road
Thank you Alexander for your input, I will check if it works.
msd is offline   Reply With Quote

Old   April 13, 2021, 06:51
Default
  #8
msd
Member
 
Heer
Join Date: Oct 2020
Posts: 45
Rep Power: 6
msd is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
right before line: Qfinal = Q;
you need to add global summation macro to make code works in parallel
Code:
Q = PRF_GRSUM1(Q);
also I'm not sure if you need to use full outlet area of each finite are (as you did) here:
Code:
Q = Q + (Ar*V);
check it
Dear Alexander,

I tried incorporating the change suggested by you and the modified code is as follows:
#include "udf.h"

#define R 12e9 /*Value taken from literature*/

#include "mem.h"
#include "metric.h"
#include "prf.h"

DEFINE_PROFILE (outlet_pressure, thread, position)
{
real A[ND_ND];
face_t f;
Thread *t;
real Ar, V, Qfinal;
real Q, P;

begin_f_loop(f, thread)
{
F_AREA(A, f, thread);
Ar = NV_MAG(A); /* Used for the computation of the magnitude of the area vector */
V = F_U(f, thread);
Q = Ar*V;
}
end_f_loop(f, thread)

Q = PRF_GRSUM1(Q);
Qfinal = Q;

begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) = R*Qfinal;
}
end_f_loop(f, thread)
}

But I have a couple of questions, as in will the final pressure obtained be the same all over the face or some more modification is required? Also, I don't know why my relation is still not getting satisfied.

Can you please help?

Thanks!
msd is offline   Reply With Quote

Old   April 13, 2021, 12:30
Default
  #9
msd
Member
 
Heer
Join Date: Oct 2020
Posts: 45
Rep Power: 6
msd is on a distinguished road
Dear Alexander,

I am facing one more problem, the volumetric flow rate calculated by the UDF (as I printed and checked the value), and the surface integral is coming different and it is differing by a value of order 10^(-3). But the relation is satisfied by the value of the volumetric flow rate obtained from the UDF and not from surface integral.

Can you please tell what can be the possible reason behind it?

Thanks in advance!
msd is offline   Reply With Quote

Old   April 17, 2021, 12:26
Default
  #10
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Code:
Q = Ar*V;
This is wrong, you only keep the value of the last cell.

Code:
Q += Ar*V;
msd likes this.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   April 19, 2021, 03:23
Default
  #11
msd
Member
 
Heer
Join Date: Oct 2020
Posts: 45
Rep Power: 6
msd is on a distinguished road
Quote:
Originally Posted by pakk View Post
Code:
Q = Ar*V;
This is wrong, you only keep the value of the last cell.

Code:
Q += Ar*V;
Thank you, I will try incorporating the changes.
msd is offline   Reply With Quote

Reply

Tags
average outlet pressure, 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
Want help regarding the UDF that is been written in VS code related to weber number saratunni07 CFD Freelancers 0 May 20, 2017 03:30
Problem in convergence regarding constant viscosity and UDF related Viscosity. alexskerhut FLUENT 0 May 9, 2016 09:43
UDF Compilation Error - Loading Library - COMMON Problem! Help! robtheslob Fluent UDF and Scheme Programming 8 July 24, 2015 01:53
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
DEFINE_DPM_OUTPUT macro UDF HELP Puneet FLUENT 3 November 28, 2003 11:55


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