CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Viv 2dof (https://www.cfd-online.com/Forums/main/255526-viv-2dof.html)

Mahesh_M April 15, 2024 05:25

Viv 2dof
 
Hello Everyone,
I am trying to simulate VIV in 2dof of a circular cylinder and is using overset meshing and the dynamic mesh with the help of the UDF. The fluid is air and the time step size is 0.05s. I tried so many times but the negative cell volume error is still showing. Can anyone please help me identify and correct the mistake I have been doing? I am attaching the UDF code below:
#include "udf.h"
#include "sg_mem.h"
#include "dynamesh_tools.h"
#include "unsteady.h"
#define mass 0.1
#define md 0.00962
#define fn 0.0261
#define z 0.002
#define ZONE_ID1 7
static real v_prev1, v_prev0;
static int i;
static real Fx, Fy;
static real wn, k, c, dv;
FILE *fout, *fout1;
DEFINE_EXECUTE_AT_END(vel)
{
Thread *t;
Dynamic_Thread *dt;
Domain *d = Get_Domain(1);

real vel[3], x_cg[3], force[3], moment[3];
real time, dtime;
real X[100000];
real Y[100000];
wn = 2*M_PI*fn;
k = (mass+md)*wn*wn;
c = 2*(mass+md)*wn*z;
t = Lookup_Thread(d, ZONE_ID1);

Compute_Force_And_Moment(d, t, x_cg, force, moment, TRUE);
Fx = force[0]; /* force[0] in x direction*/
Fy = force[1];

/* compute the updating position*/
i = N_TIME; /* set i = time step number*/
X[0] = 0;
X[1] = 0;

dtime = CURRENT_TIMESTEP; // Set dtime = timestep/
time = CURRENT_TIME; // time = current time/
X[i+1] = (Fx + X[i]*((2*mass/dtime*dtime)-k)+X[i-1]*((c/2*dtime)-(mass/dtime*dtime)))*(1/((mass/dtime*dtime)+(c/2*dtime)));
X[i+1] = (Fy + Y[i]*((2*mass/dtime*dtime)-k)+Y[i-1]*((c/2*dtime)-(mass/dtime*dtime)))*(1/((mass/dtime*dtime)+(c/2*dtime)));

v_prev1 = (X[i+1] - X[i-1]) / (2*dtime); // inline velocity/
v_prev0 = (Y[i+1] - Y[i-1]) / (2*dtime); // crossflow velocity/
}
/* Update velocity using CG_MOTION Macro*/
DEFINE_CG_MOTION(cylinder, dt, vel, omega, time, dtime)
{
vel[1] = v_prev1; // update crossflow velocity/
vel[0] = v_prev0; // update inline velocity/
fout = fopen("results.txt", "a");
fprintf(fout, "%g %g %g \n", time, DT_CG(dt)[1], DT_CG(dt)[0]);
fclose(fout);
}


All times are GMT -4. The time now is 10:35.