CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF boundary (https://www.cfd-online.com/Forums/fluent-udf/215642-udf-boundary.html)

Lxy2018 March 11, 2019 23:14

UDF boundary
 
#include "udf.h"
#include<math.h>

DEFINE_PROFILE(inlet_z_velocity_A, t, i)
{
real x[ND_ND];
real a;
real y;
face_t f;
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
a=x[0];
y=x[1];

if ((-4.2 <= a) && (a < -3.945))
F_PROFILE(f, t, i) = -0.088*pow(y, 5) - 0.0737*pow(y, 4) + 0.1308*pow(y, 3) + 0.0682*pow(y, 2) - 0.0665*y + 0.3545;

if ((-3.945 <= a) && (a < -3.675))
F_PROFILE(f, t, i) = 0.1012*pow(y, 6) + 0.0131*pow(y, 5) - 0.2807*pow(y, 4) - 0.0547*pow(y, 3) + 0.1929*pow(y, 2) + 0.0411*y + 0.3549;

if ((-3.675 <= a) && (a < -3.405))
F_PROFILE(f, t, i) = 0.046*pow(y, 6) + 0.0045*pow(y, 5) - 0.1283*pow(y, 4) + 0.0002*pow(y, 3) + 0.1014*pow(y, 2) - 0.0034*y + 0.3668;

if ((-3.405 <= a) && (a < -3.135))
F_PROFILE(f, t, i) = 0.0752*pow(y, 6) + 0.0194*pow(y, 5) - 0.2078*pow(y, 4) - 0.0361*pow(y, 3) + 0.1624*pow(y, 2) + 0.0196*y + 0.3454;

if ((-3.135 <= a) && (a < -2.865))
F_PROFILE(f, t, i) = -0.6608*pow(y, 6) - 0.0257*pow(y, 5) + 1.4898*pow(y, 4) + 0.0128*pow(y, 3) - 0.9274*pow(y, 2) + 0.012*y + 0.5025;

if ((-2.865 <= a) && (a < -2.595))
F_PROFILE(f, t, i) = 0.164*pow(y, 6) + 0.0698*pow(y, 5) - 0.3511*pow(y, 4) - 0.087*pow(y, 3) + 0.2244*pow(y, 2) + 0.0301*y + 0.3417;

if ((-2.595 <= a) && (a < -2.325))
F_PROFILE(f, t, i) = -0.0257*pow(y, 5) - 0.0798*pow(y, 4) + 0.022*pow(y, 3) + 0.0863*pow(y, 2) - 0.008*y + 0.3762;

if ((-2.325 <= a) && (a < -2.055))
F_PROFILE(f, t, i) = 0.05*pow(y, 6) - 0.0019*pow(y, 5) - 0.1895*pow(y, 4) + 0.0122*pow(y, 3) + 0.1427*pow(y, 2) - 0.0089*y + 0.3693;

if ((-2.055 <= a) && (a <= -1.8))
F_PROFILE(f, t, i) = 0.1494*pow(y, 6) - 0.0899*pow(y, 5) - 0.3818*pow(y, 4) + 0.2512*pow(y, 3) + 0.2011*pow(y, 2) - 0.1668*y + 0.4045;
}
end_f_loop(f,t)
}

Lxy2018 March 11, 2019 23:23

Hello!
Please help me!
Thanks!

I wrote a UDF to describe the velocity of a air supply diffusion belonging to “velocity-inlet “. And the UDF could be compiled successfully. However, when the iteration reached 500 steps, continuity residual curve kept raising. Then the TUI noted that computational diergence.

The above is my UDF.
Thanks!

zyfantastic March 12, 2019 01:32

May you try this format for if else ladder in your UDF?
if (testExpression1)
{
// statement(s)
}
else if(testExpression2)
{
// statement(s)
}
else if (testExpression 3)
{
// statement(s)
}
.
.
else
{
// statement(s)
}

Lxy2018 March 12, 2019 03:49

Thanks for your reply!
I will try it!thanks!


All times are GMT -4. The time now is 13:44.