CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   DEFINE_GRID_MOTION udf Problem (https://www.cfd-online.com/Forums/fluent/250106-define_grid_motion-udf-problem.html)

charade_4eft May 28, 2023 01:07

DEFINE_GRID_MOTION udf Problem
 
Hello Everyone,

I am working from past few weeks to understand the udf but I have reached dead end.

I am working on 2d Pipe (Rectangular in shape) which has inlet, outlet, upper wall and lower wall. I want to induce sinusoidal wave in both walls using udf. I have assigned udf to lower wall and works fine but issue is with upper wall. While simulating upper wall, I am facing ERROR: dynamic-mesh failed: negative mesh volume detected.

udf code is mentioned below:

#include"udf.h"

#define D 0.01
#define l 0.3
#define freq 1

DEFINE_GRID_MOTION(sinewave, domain, dt, time, dtime)
{
face_t f;
Thread *tf = DT_THREAD(dt);
int n;
Node *v;
real x;
real y;
SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));

begin_f_loop(f, tf)
{
f_node_loop(f, tf, n)
{
v = F_NODE(f, tf, n);
if (NODE_POS_NEED_UPDATE(v))
{
NODE_POS_UPDATED(v);
x = NODE_X(v);
y = D/8.0*sin(x*M_PI/l*2)*sin(2*M_PI*freq*CURRENT_TIME);

NODE_Y(v) = y;

}
}
Update_Face_Metrics(f, tf);
}
end_f_loop(f,tf)
}

Do you have any clue how I can fix the issue
Looking forward to your answers.

Thanks!

mperrin May 28, 2023 06:08

Hello charade_4eft,

I worked on exactly same project : double moving wall of a rectangular geometry so i can answer you :
'negative volume cell' is an error that occurs when the displacment send by your UDF is greater than mesh cell on the axis you moving.

Depending on the method used for your dynamic mesh (smoothing, layering or remeshing), i think you need to slow your timestep or reduce your mesh.

From what i understand of your UDF, you try to change the position of your node. Why do you do it this way ?

Regards,
Mickael

charade_4eft May 28, 2023 11:17

Hey Mickael,

The udf work perfectly fine with lower wall which lies on x-axis. I am facing negative mesh volume error when udf is assigned to upperwall which is 10 mm above the x-axis.

Btw I am beginner in udf... if you can give clue or suggest me another way.

Kind Regards.

mperrin June 5, 2023 12:42

Hi,



Can you tell me more about your case ? Why did you choose to modify nodes positions instead of let fluent remesh itself ?


Just in case :
y = D/8.0*sin(x*M_PI/l*2)*sin(2*M_PI*freq*CURRENT_TIME);
In this line you use D/8 to define the new node position. Did you properly change D to (D+h), h being the distance between lower and upper wall ? If not, you will define lower and upper wall on the same node position, which could explain the negative cell error.


Regards

charade_4eft June 11, 2023 11:24

Hi Mickael,

In my case, I am trying to induce sinusoidal motion in both walls to generate fluid flow.

y = D/8.0*sin(x*M_PI/l*2)*sin(2*M_PI*freq*CURRENT_TIME);

In above equation D/8 controls the amplitude of wave.

mperrin June 12, 2023 04:32

Hi,

As i said, your udf change the nodes' position of the thread you assigned.
Since you have 2 wall, you need 2 different equations.

Exemple : at first timestep, both of the wall will get a movement of dy = 1mm. I don't know your geometry so i imagine the lower wall has y = 0 mm and upper wall got y = 10mm, so the difference is h = 10 mm.
Your equation give new position to the nodes. If you assigned the same udf to both the wall, the new y of lower and upper wall will be 1mm.
you need an equation that calculate : dy for the lower wall and dy + dh for upper wall.

It can look like this :

#include"udf.h"

#define D 0.01
#define l 0.3
#define freq 1
#define h 0.010 /* dy between lower and upper wall */

DEFINE_GRID_MOTION(sinewave_lower, domain, dt, time, dtime)
{
face_t f;
Thread *tf = DT_THREAD(dt);
int n;
Node *v;
real x;
real y;
SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));

begin_f_loop(f, tf)
{
f_node_loop(f, tf, n)
{
v = F_NODE(f, tf, n);
if (NODE_POS_NEED_UPDATE(v))
{
NODE_POS_UPDATED(v);
x = NODE_X(v);
y = D/8.0*sin(x*M_PI/l*2)*sin(2*M_PI*freq*CURRENT_TIME);

NODE_Y(v) = y;

}
}
Update_Face_Metrics(f, tf);
}
end_f_loop(f,tf)
}

/* -------------------------------------------------------------------- */

DEFINE_GRID_MOTION(sinewave_upper, domain, dt, time, dtime)
{
face_t f;
Thread *tf = DT_THREAD(dt);
int n;
Node *v;
real x;
real y;
SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));

begin_f_loop(f, tf)
{
f_node_loop(f, tf, n)
{
v = F_NODE(f, tf, n);
if (NODE_POS_NEED_UPDATE(v))
{
NODE_POS_UPDATED(v);
x = NODE_X(v);
y = h + D/8.0*sin(x*M_PI/l*2)*sin(2*M_PI*freq*CURRENT_TIME);

NODE_Y(v) = y;

}
}
Update_Face_Metrics(f, tf);
}
end_f_loop(f,tf)
}

If you use only 1 UDF as i understood, this should be helpful. In other case, please tell me more about your case.

Regards

charade_4eft June 22, 2023 23:49

Hi Mickael,

I hope you are doing well. By adding height of wall in the equation, the negative mesh volume issue has been resolved.

Kind Regards.


All times are GMT -4. The time now is 05:37.