0
How to write a udf in openfoam

Hi

I am trying to give user defined inlet in openfoam

i do have udf defined for fluent

here is the code

#include "udf.h"//file that contains definitions for define functions and fluent operations
#define PI 3.141592654

DEFINE_PROFILE(inlet_velocity,th,i)
{
face_t f;
begin_f_loop(f,th)
double t = (CURRENT_TIME*2-floor(CURRENT_TIME*2))/2; //t is the local time within each period

{
if(t <= 0.218)
F_PROFILE(f,th,i) = 0.5*sin(4*PI*(t+0.0160236));
else
F_PROFILE(f,th,i) = 0.1;
}
end_f_loop(f,th);
}

how can i convert and use it in openfoam


OpenFOAM 26-07-21, 3:25 p.m. prth_bndl
1

Hi,

You can find an example of a user-defined velocity at a boundary in the video below.

https://youtu.be/_jjYmW8sBNA

The function defined there is a spatially varying one. Since yours is a temporal variation, you can refer to section 5.2.3.4, in the link below, to get an idea on how to define a function in OpenFOAM.

https://cfd.direct/openfoam/user-guide/v6-boundaries/

Regards,
Ashley

26-07-21, 3:42 p.m. ashleymelvin


Log-in to answer to this question.