CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)

 kenan July 21, 2013 12:54

Hello all,

I have a simple 2D circle meshed with tetra elements. I want this circle to expand radially. For that purpose i have written the code below, using DEFINE_GRID_MOTION. This code gets face unit normal vectors on boundary, and tries each node to move through this unit vector of the face which it belongs to. However Fluent gives the error " Left handed faces detected! ". I dont know how to handle this problem. Any help would be kindly appreciated.

/* Expansion-Contraction through face normal unit vector */

#include "udf.h"

{
face_t f;
Node *v;
real displ;
real A[ND_ND]; /* face area normal vector */
real AMag; /* face area magnitude */
real NV_VEC(e); /* face unit normal vector */
int n;

displ=5*dtime;

begin_f_loop(f, tf)
{
AMag=NV_MAG(A);
NV_VS(e,=,A,/,AMag); /* face unit normal vector */

f_node_loop(f,tf,n)
{
v=F_NODE(f,tf,n);
if (NODE_POS_NEED_UPDATE(v))
{
NODE_POS_UPDATED(v);
NV_V_VS(NODE_COORD(v),=, NODE_COORD(v), +, e, *, displ);
}
}

 kenan July 21, 2013 16:54

Finally i have managed it, even with a 3D cylinder. I used position vector of each node, instead of face normal vector. I eliminate the z component of the position vector, in order to get uniform expansion (equal displacement for all nodes) for a 3-D cylinder (The central axis of the cylinder is z axis).

However, i still wonder how i could get a uniform expansion; if i would have, for example, an ellipsoid or a sphere.

 kure87 October 16, 2013 09:14

Hi, if it's help here is my code for normal expansion (respective fluctuation) of the surface in the Ansys Fluent. I used it for creation of the pressure waves and sound propagation excited by oscilating part.

Tested on the sphere, more complicated test will follow in next few days.

Code:

```/**********************************************************************   NormalExpansionSurface.c   UDF for specifying a transient expansion of the mesh, normal to its face  ***********************************************************************/ #include "udf.h" DEFINE_GRID_MOTION(NormalExpansion3, domain, dt, time, dtime) { Thread *tf = DT_THREAD(dt); face_t f; Node *v; real displ; real NV_VEC(axis); real A[ND_ND]; /* face area normal vector */ real AMag; /* face area magnitude */ int n; SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf)); displ=-0.002388*cos(6280*(time+0.00025)); //grid displacement begin_f_loop(f, tf) { f_node_loop(f,tf,n) { F_AREA(A,f,tf);  /*A is a vector, f face index, t thread index */ AMag=NV_MAG(A); /* Face normal vector */ A[0]=A[0]/AMag; /* X component of vector */ A[1]=A[1]/AMag; /* Y component of vector */ A[2]=A[2]/AMag; /* Z component of vector */ NV_D(axis, =, A[0], A[1], A[2]); v=F_NODE(f,tf,n); if (NODE_POS_NEED_UPDATE(v)) { NODE_POS_UPDATED(v); NV_V_VS(NODE_COORD(v), =, NODE_COORD(v), +, axis,*,displ); } } } end_f_loop(f,tf); }```

 kenan October 16, 2013 10:59

Hi kure87,

Thank you for your reply. Actually we have sought for almost-proper expansion of left ventricle of human heart. It is difficult to preserve the approximate shape of the LV after applying expansion operation.

 All times are GMT -4. The time now is 13:56.