CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   laplacian operatorin udf (

anon_c March 6, 2010 10:26

laplacian operatorin udf
first hello to all

i would like to know if i am doning this right or wrong i want to ad an laplacian term to fluent´s momentium equation and then in the same iteration just take it away that increase the stability in some cases e.g. like turbluence etc.

rho*DV/Dt = - grad (p) + div(tau) + alpha*Laplace(U) - alpha*Laplace(U)

'''wich is offcurce an null operator on the right side'''

the udf i programmed for fluent and interpretid succsiflully is:


#include "C:\Fluent.Inc\fluent6.3.26\src\udf.h" /* Fluent-Header */
#include "C:\Fluent.Inc\fluent6.3.26\src\sg_press.h"
#include "C:\Fluent.Inc\fluent6.3.26\src\mem.h"
#include "alpha.h"


DEFINE_ADJUST(first_derivative, domain)
Thread *t;
cell_t c;

C_UDSI(c,t,u_xx) = C_DUDX(c,t);
C_UDSI(c,t,u_yy) = C_DUDY(c,t);
C_UDSI(c,t,v_xx) = C_DVDX(c,t);
C_UDSI(c,t,v_yy) = C_DVDY(c,t);

//-----------------adding alpha*laplace(U)

real Positiv_u_x;
real Positiv_force_x;

Positiv_u_x = alpha*(C_UDSI_G(c,t,u_xx)[0] + C_UDSI_G(c,t,u_yy)[1]);

Positiv_force_x = Positiv_u_x;

dS[eqn] = 0.0;
return Positiv_force_x;

real Positiv_u_y;
real Positiv_force_y;

Positiv_u_y = alpha*(C_UDSI_G(c,t,v_xx)[0] + C_UDSI_G(c,t,v_yy)[1]);

Positiv_force_y = Positiv_u_y;

dS[eqn] = 0.0;
return Positiv_force_y;

//-----------------taking alpha*laplace(U) away

real Negativ_u_x;
real Negativ_force_x;

Negativ_u_x = -1.0*(alpha*(C_UDSI_G(c,t,u_xx)[0] + C_UDSI_G(c,t,u_yy)[1]));

Negativ_force_x = Negativ_u_x;

dS[eqn] = 0.0;
return Negativ_force_x;

real Negativ_u_y;
real Negativ_force_y;

Negativ_u_y = -1.0*(alpha*(C_UDSI_G(c,t,v_xx)[0] + C_UDSI_G(c,t,v_yy)[1]));

Negativ_force_y = Negativ_u_y;

dS[eqn] = 0.0;
return Negativ_force_y;

i do as flows: just say in define scalars there is 4 uds (but no source for flux)

then in material boundary conditions (fluid set) source terms --> there i do for the x_momtium 2 sources on is adding and then take away

the same for y

then i go to solve and in control slution i just take the uds 0 to uds 4 away so they are not solved

then i start the prozess

'''' question is that right??? or am i doning some thing wrong???'''''

anon_c March 9, 2010 06:51

no ideas ? i mean it should work like this

adam14qin July 31, 2013 17:44

Since we can only take the gradient of a scalar in FLUENT, to calculate laplacian of a scalar whose value is stored in a UDS C_UDSI(c,t,0), for example two dimensional d2f/dx2+d2f/dy2, you can use one C_UDSI(c,t,1) to store df/dx (C_UDSI_G(c,t,0)[0]) and a second C_UDSI(c,t,2) to store df/dy(C_UDSI_G(c,t,0)[1]), then, take gradient of C_UDSI(c,t,1)[0] and C_UDSI(c,t,2)[1], then the laplacian = C_UDSI(c,t,1)[0]+C_UDSI(c,t,2)[1]

Hope this will help you

shashank312 August 3, 2013 15:57

Sorry but don't you think gradient can also be taken of a scalar, like VOF or temperature? And then the Laplacian of a scalar would lead to a scalar. Would you still do the same thing then?

adam14qin August 5, 2013 17:23

Sorry, that was a typo. The gradient is taken from a scalar (gradient is a vector C_UDSI_G(c,t,0)). and the laplacian of a scalar is a scalar:
laplacian = C_UDSI(c,t,1)[0]+C_UDSI(c,t,2)[1]

All times are GMT -4. The time now is 11:48.