December 11, 2022 at 4:21 am
Subscriber
Here is a part of my code where i want to introduce NODE_COORD_NEST macro to create relative motion with the CG_MOTION. Please please help me .
DEFINE_GRID_MOTION(right_upper_tww,d,dt,time,dtinme)
{
Thread *t = DT_THREAD(dt);//get the thread pointer
face_t f;
Node *node_p;
int n;
FILE* fp;
real xo = 0.0; //center O of the standard circle
real yo = 0.0;
real xa = D/2; // Virtual anchor point A
real ya = 0.0;
real xp,yp; //point P on the wave wall
real NV_VEC(OA); //OA vector
OA[0] = xa - xo;
OA[1] = ya - yo;
real NV_VEC(OP); //OP vector
real costheta;
real theta;
real l;
real a;
real r;
begin_f_loop (f, t)
{
f_node_loop (f, t, n)//
{
node_p = F_NODE (f, t, n);//
if (NODE_POS_NEED_UPDATE (node_p))
{
NODE_POS_UPDATED (node_p);
Message("lamda = %.11lf \n", lamda);
Message("k = %.11lf \n", k);
xp = NODE_X(node_p);
yp = NODE_Y(node_p);
OP[0] = xp-xo;
OP[1] = yp-yo;
costheta = (OA[0]*OP[0]+OA[1]*OP[1]) / NV_MAG(OA) / NV_MAG(OP);
theta = acos(costheta); // always positive
l = theta / (2*M_PI) * (M_PI*D);
Message("theta = %.11lf \n", theta);
Message("l = %.11lf \n", l);
if (l>=0.0 && l
a = am * l / lamda;
else if (l>=lamda && l<((N-1)*lamda))
a = am;
else
a = am * (N * lamda - l) / lamda;
Message("a = %.11lf \n", a);
r = r0 + a * cos(k*(l-c_upper*time));
Message("time = %.11lf \n", time);
Message("r = %.11lf \n", r);
xp = r * cos(theta);
yp = r * sin(theta);
NODE_X(node_p) = xp+v_body[0]*dtinme;
NODE_Y(node_p) = yp+v_body[1]*dtinme;
Message("x-updated = %.11lf y-updated = %.11lf \n", NODE_X(node_p), NODE_Y(node_p));
}
}/*End Node Loop*/
}/*End Face Loop*/
end_f_loop (f, t)
}
Please Login to Report Topic
Please Login to Share Feed