|
[Sponsors] |
April 12, 2021, 04:09 |
Related to UDF
|
#1 |
Member
Heer
Join Date: Oct 2020
Posts: 45
Rep Power: 6 |
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! |
|
April 12, 2021, 05:09 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
right before line: Qfinal = Q;
you need to add global summation macro to make code works in parallel Code:
Q = PRF_GRSUM1(Q); Code:
Q = Q + (Ar*V);
__________________
best regards ****************************** press LIKE if this message was helpful |
|
April 12, 2021, 09:16 |
|
#3 |
Member
Yasser Selima
Join Date: Mar 2009
Location: Canada
Posts: 51
Rep Power: 19 |
Code:
q += a[0] * v Last edited by Yasser; April 12, 2021 at 09:19. Reason: correcting |
|
April 12, 2021, 11:32 |
|
#4 |
Member
Heer
Join Date: Oct 2020
Posts: 45
Rep Power: 6 |
@Yasser, while inculcating this change, should I not calculate the magnitude of the area vector?
|
|
April 12, 2021, 11:38 |
|
#5 |
Member
Yasser Selima
Join Date: Mar 2009
Location: Canada
Posts: 51
Rep Power: 19 |
Hello,
If you are considering F_U, you should be multiplying this time the area in the x-direction only! |
|
April 12, 2021, 11:39 |
|
#6 |
Member
Heer
Join Date: Oct 2020
Posts: 45
Rep Power: 6 |
Thanks, Yasser for your input, I will check it.
|
|
April 12, 2021, 11:40 |
|
#7 |
Member
Heer
Join Date: Oct 2020
Posts: 45
Rep Power: 6 |
Thank you Alexander for your input, I will check if it works.
|
|
April 13, 2021, 06:51 |
|
#8 | |
Member
Heer
Join Date: Oct 2020
Posts: 45
Rep Power: 6 |
Quote:
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! |
||
April 13, 2021, 12:30 |
|
#9 |
Member
Heer
Join Date: Oct 2020
Posts: 45
Rep Power: 6 |
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! |
|
April 17, 2021, 12:26 |
|
#10 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Code:
Q = Ar*V; Code:
Q += Ar*V;
__________________
"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". |
|
April 19, 2021, 03:23 |
|
#11 |
Member
Heer
Join Date: Oct 2020
Posts: 45
Rep Power: 6 |
||
Tags |
average outlet pressure, udf |
|
|
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 |