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/)
-   -   Need help regarding 6DOF udf with face loop (https://www.cfd-online.com/Forums/fluent-udf/237532-need-help-regarding-6dof-udf-face-loop.html)

burhanibrar July 28, 2021 04:48

Quote:

Originally Posted by obscureed (Post 809099)
Hi Burhan,
Well done resolving the issues. Just to help people who visit this thread in future, please could you post a working version of your code? Thanks.
Ed

Sure!

/************************************************** *****
SDOF property compiled UDF with external forces/moments
************************************************** *****/
#include "udf.h"

static real acc = 4.631;
static real mass = 5;
static real velocity, vel, area_tot, area[3];




DEFINE_SDOF_PROPERTIES(acce, prop, dt, time, dtime)
{


prop[SDOF_MASS] =5;
prop[SDOF_IXX] = 8.333e-4;
prop[SDOF_IYY] = 4.1667e-3;
prop[SDOF_IZZ] = 5.2e-5;
prop[SDOF_ZERO_TRANS_X] = False;/* boolean, allow translation in x-direction */
prop[SDOF_ZERO_TRANS_Y] = True; /* boolean, suppress translation in y-direction */
prop[SDOF_ZERO_TRANS_Z] = True; /* boolean, suppress translation in z-direction */
prop[SDOF_ZERO_ROT_X] = True; /* boolean, suppress rotation around x-axis */
prop[SDOF_ZERO_ROT_Y] = True; /* boolean, suppress rotation around y-axis */
prop[SDOF_ZERO_ROT_Z] = False; /* boolean, allow rotation around z-axis */


{
#if !RP_HOST

Thread *t;
face_t f;

Domain *domain;
int nid;
domain = THREAD_DOMAIN (DT_THREAD (dt));
nid = THREAD_ID (DT_THREAD (dt));
t = Lookup_Thread (domain, nid);

velocity=0.0;
area_tot=0;

#endif

/*t = DT_THREAD(dt);*/
/*NV_S(A, =,0.0);*/


#if !RP_HOST
begin_f_loop(f, t)
if (PRINCIPAL_FACE_P(f, t))
{
F_AREA(area,f,t);
area_tot += NV_MAG(area);
velocity += F_U(f, t)*NV_MAG(area);
}
end_f_loop(f, t)



/*area_tot=PRF_GRSUM1(noface);
velocity=PRF_GRSUM1(velocity);*/
#if RP_NODE
area_tot = PRF_GRSUM1(area_tot);
velocity = PRF_GRSUM1(velocity);
/*vel = velocity/area_tot;*/

/*Message0("\nV1 %f Area Total %f /n",vel, area_tot);*/
#endif /*RP_NODE*/

#endif /*!RP_HOST*/
/* Pass the node's total area and Velocity to the Host for averaging */
node_to_host_real_2(area_tot,velocity);

#if !RP_NODE
vel = velocity/area_tot;
Message("Total Area: %f (m2)\n",area_tot);
Message("Averaged Velocity of the Guide Rail %f (N)\n",vel);

#endif /* !RP_NODE */


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