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/)
-   -   Multiple udf in fluent (https://www.cfd-online.com/Forums/fluent-udf/246613-multiple-udf-fluent.html)

hassnas December 13, 2022 02:23

Multiple udf in fluent
 
Hi, I am using fluent for 2D transient simulation of oscillating flexible foil. I had used both mentioned UDF below. It works fine when it was used separately. but it didnot work when cg motion udf were used for pitching and grid_motion for deformation of foil.
Question is how it can be used for pitching as well as deformation of airfoil.
UDF is attached below..

#include "udf.h"
#include "dynamesh_tools.h"
DEFINE_CG_MOTION(airfoil,dt,vel,omega,time,dtime)
{
Thread *t = DT_THREAD(dt);
face_t f;
real pi = 3.141592654;
real freq = 1;
real daft = 0;
real w = 2*pi*freq;
real a = 5*(pi/180);
/*reset velocities*/
NV_S(vel,=,0.0);
NV_S(omega,=,0.0);
if (!Data_Valid_P())
return;

#if !RP_HOST
daft = -a*w*cos(w*time);
omega[2] = daft;
#endif
}


#include "udf.h"
#include "unsteady.h"
#include "dynamesh_tools.h"
#include "math.h"

#define l 1
#define k 2
#define frequency 1
#define amplitude 0.1

DEFINE_GRID_MOTION(deformation,domain,dt,time,dtim e)
{
Thread * t = DT_THREAD(dt);
face_t f;
Node * v;
int n;
double x, y, y_ref_previous, y_ref;
SET_DEFORMING_THREAD_FLAG(THREAD_T0(t));
begin_f_loop(f,t)
{
f_node_loop(f,t,n)
{
v = F_NODE(f,t,n);
if (NODE_POS_NEED_UPDATE(v))
{
NODE_POS_UPDATED(v);
x = NODE_X(v);
y_ref_previous = -amplitude*(x/l)*(x/l)*sin(2*3.142*frequency*(PREVIOUS_TIME));
y_ref = -amplitude*(x/l)*(x/l)*sin(2*3.142*frequency*(CURRENT_TIME));
if (NODE_Y(v) > y_ref_previous)
{
NODE_Y(v) = y_ref + fabs(NODE_Y(v)-y_ref_previous);
}
else
if (NODE_Y(v) < y_ref_previous)
{
NODE_Y(v) = y_ref - fabs(NODE_Y(v)-y_ref_previous);
}
else
{
NODE_Y(v) = y_ref;
}
}
}
}
end_f_loop(f,t);
}

AlexanderZ December 13, 2022 07:41

put as a header
Code:

#include "udf.h"
#include "unsteady.h"
#include "dynamesh_tools.h"
#include "math.h"

#define l 1
#define k 2
#define frequency 1
#define amplitude 0.1

instead of
Code:

#include "udf.h"
#include "dynamesh_tools.h"

compile codee and read log to avoid these kind of questions


All times are GMT -4. The time now is 16:43.