|
[Sponsors] |
June 23, 2009, 14:02 |
UDF problem: incorrect grid motion
|
#1 |
New Member
Iain Kyle Fraser
Join Date: Jun 2009
Posts: 1
Rep Power: 0 |
Hi, I seem to be getting this error message when I'm using this UDF to govern the valve motion in my check valve arrangement. The error happens when I'm setting up dynamic mesh zone for my walls to move through my mesh.
Warning: incorrect grid motion UDF valve::libudf on zone 6 (assuming no motion) The UDF I'm using is below, any help as to figuring out how I am getting this error would be greatly appreciated. # include "udf.h" # include "dynamesh_tools.h" # ifndef intloop # define intloop(n,m)for(n=0;n<m;++n) # endif /* DEBUG: will print out debug information. NO_OF_VALVES: Number of valves NO_OF_ZONES: a large number which is larger than the max number of face zones per valve valveid[NO_OF_VALVES][NO_OF_ZONES]={{22, 23, -1}, {13, 14, -1}}: valve face zone list, in this example, invalve consists of face zone 21 and 23, exvalve consists of face zone 13 and 14. -1 is a flag and so keep it. These face zones will be used to calculate the pressure force. axis[NO_OF_VALVES][ND_ND]={{0, 0, 1}, {0, 0, -1}}: valve motion axis. It points from the max lift to min lift. And it has to be normalized. r_rp_closed[NO_OF_VALVES][ND_ND]={{-0.025, 0, 0}, {0.025, 0, 0.005}}: The reference point coordinates when valves are closed. A reference point, used to keep track of valve motion, is a point in the valve. The loation in the valve is immaterial and you can conveniently choose the location. lift_min[NO_OF_VALVES]={0.0005, 0.0005}: minimum lift lift_max[NO_OF_VALVES]={0.01, 0.006}: maximum lift rest_conts[NO_OF_VALVES]={0.5, 0.5}: bouncing factor mass[NO_OF_VALVES]={0.02, 0.02}: valve mass stiffness[NO_OF_VALVES]={2000, 5000}: valve stiffness stretch_at_closed[NO_OF_VALVES]={0.002, 0.004}: what is the valve stretching length when the valves are closed gravity_direction: Gravitational direction. Has to be normalized. current_vel_mag[NO_OF_VALVES]: Initial velocity. Could be negative if opposite to valve axis cur_r_rp[NO_OF_VALVES][ND_ND]: Initial position */ /*************************** User Input Starts *****************************/ # define DEBUG # define NO_OF_VALVES 1 # define NO_OF_ZONES 200 static int valveid[NO_OF_VALVES][NO_OF_ZONES]={{6 -1}}; static real axis[NO_OF_VALVES][ND_ND]={{0,0,1}}; /* normalized */ static real r_rp_closed[NO_OF_VALVES][ND_ND]={{0.02475, -0.02475, 0.0135}}; static real lift_min[NO_OF_VALVES]={0}; static real lift_max[NO_OF_VALVES]={0.001975}; static real rest_conts[NO_OF_VALVES]={0}; static real mass[NO_OF_VALVES]={0.000817}; static real stiffness[NO_OF_VALVES]={0}; static real stretch_at_closed[NO_OF_VALVES]={0}; static real gravity_direction[ND_ND]={0, 0, 0}; /* normalized */ static real current_vel_mag[NO_OF_VALVES]={0}; static real cur_r_rp[NO_OF_VALVES][ND_ND]={{0.02475, -0.02475, 0.011525}}; static real previous_time[NO_OF_VALVES]={0}; /*************************** User Input Ends *******************************/ static void f_valve(int valveNo, void *dt, real *cg_vel, real *cg_omega, real time, real dtime) { #if !RP_HOST real tmp[ND_ND], dv, current_vel[ND_ND], CG[ND_ND], force[3], moment[3], stretch; real aero_force[ND_ND], aero_force_axis, spring_force, net_force, r_rp_new[NO_OF_VALVES][ND_ND]; int i; Thread * tf; Domain * domain; /************************************************** ****************/ static real cg_vel_saved[NO_OF_VALVES][ND_ND]; /************************************************** ****************/ /* Do the calculation if the new time step */ if(fabs(previous_time[valveNo]-time)>0.2*dtime) { /* reset velocities */ NV_S (cg_vel, =, 0.0); NV_S (cg_omega, =, 0.0); /* Check to see if there is data */ if (!Data_Valid_P ()) { Message0("\n\nNo data->No mesh motion!!!\n\n"); return; } /*Calculate force*/ domain = THREAD_DOMAIN (DT_THREAD ((Dynamic_Thread *)dt)); i=0; NV_S(aero_force,=,0); while(valveid[valveNo][i]>=0) { tf=Lookup_Thread(domain, valveid[valveNo][i]); NV_S (CG, =, 0.0); Compute_Force_And_Moment (domain, tf, CG, force, moment, FALSE); NV_V(aero_force,+=,force); i++; } aero_force_axis=NV_DOT(aero_force, axis[valveNo]); NV_VV(tmp,=,r_rp_closed[valveNo],-,cur_r_rp[valveNo]); stretch = (stretch_at_closed[valveNo]+NV_DOT(tmp,axis[valveNo])); spring_force=stiffness[valveNo]*stretch; net_force=spring_force+aero_force_axis+9.81*mass[valveNo]*NV_DOT(gravity_direction, axis[valveNo]); dv=net_force/mass[valveNo]*dtime; /* Calculate the C.G location and velocity if it does not hit the boundary */ NV_VS(current_vel,=,axis[valveNo],*,current_vel_mag[valveNo]); NV_VS(tmp,=,current_vel,*,dtime); NV_VV(r_rp_new[valveNo],=,cur_r_rp[valveNo],+,tmp); /* Update velocity */ current_vel_mag[valveNo]+=dv; /* debug info */ #ifdef DEBUG Message0("\n\n*********************** DEBUG INFO ***************************\n"); Message0("\nvalveNo=%3d\n", valveNo); Message0("\ncur_r_rp[%d]=(%10.3e, %10.3e, %10.3e)\n", valveNo, cur_r_rp[valveNo][0], cur_r_rp[valveNo][1], cur_r_rp[valveNo][ND_ND-1]); Message0("\naero force=(%10.3e, %10.3e, %10.3e)\n", aero_force[0], aero_force[1], aero_force[ND_ND-1]); Message0("\n(stretching at closed, stretching, force)=(%10.3e, %10.3e, %10.3e)\n", stretch_at_closed[valveNo], stretch, spring_force); Message0("\n(net_force, spring force, aero force)=(%10.3e, %10.3e, %10.3e)\n", net_force, spring_force, aero_force_axis); Message0("\nvel(cur)=%11.3e vel(next wo limit)=%11.3e ", current_vel_mag[valveNo]-dv, current_vel_mag[valveNo]); #endif /* if it hits the lift_min boundary then it stays at lift_min*/ NV_VV(tmp,=,r_rp_closed[valveNo],-,r_rp_new[valveNo]); if(NV_DOT(tmp,axis[valveNo])<(lift_min[valveNo])) { NV_V_VS(r_rp_new[valveNo],=,r_rp_closed[valveNo],-,axis[valveNo],*,lift_min[valveNo]); current_vel_mag[valveNo]=-rest_conts[valveNo]*fabs(current_vel_mag[valveNo]); } /* if it hits the lift_max boundary then it stays at lift_max*/ NV_VV(tmp,=,r_rp_closed[valveNo],-,r_rp_new[valveNo]); if(NV_DOT(tmp,axis[valveNo])>(lift_max[valveNo])) { NV_V_VS(r_rp_new[valveNo],=,r_rp_closed[valveNo],-,axis[valveNo],*,lift_max[valveNo]); current_vel_mag[valveNo]=rest_conts[valveNo]*fabs(current_vel_mag[valveNo]); } /* set valve velocity */ NV_VV(tmp,=,r_rp_new[valveNo],-,cur_r_rp[valveNo]); NV_VS(cg_vel,=,tmp,/,dtime); /* Update location and velocity */ NV_V(cur_r_rp[valveNo],=,r_rp_new[valveNo]); NV_V(cg_vel_saved[valveNo],=,cg_vel); previous_time[valveNo]=time; /* debug info */ #ifdef DEBUG Message0("vel(next w limit)=%11.3e\n", current_vel_mag[valveNo]); Message0("\nvelocity(CG)=(%10.3e, %10.3e, %10.3e)\n", cg_vel[0], cg_vel[1], cg_vel[ND_ND-1]); Message0("\nr_rp_new[%d]=(%10.3e, %10.3e, %10.3e)\n", valveNo, r_rp_new[valveNo][0], r_rp_new[valveNo][1], r_rp_new[valveNo][ND_ND-1]); Message0("\n*********************** DEBUG INFO ***************************\n\n"); #endif } else { NV_V(cg_vel,=,cg_vel_saved[valveNo]); } #endif node_to_host_real(current_vel_mag, NO_OF_VALVES); node_to_host_real(cur_r_rp[0], NO_OF_VALVES*ND_ND); node_to_host_real(previous_time, NO_OF_VALVES); } DEFINE_CG_MOTION(valve, dt, cg_vel, cg_omega, time, dtime) { f_valve(0, dt, cg_vel, cg_omega, time, dtime); node_to_host_real(cg_vel,ND_ND); node_to_host_real(cg_omega,ND_ND); } DEFINE_EXECUTE_AT_END(output_results) { #if !RP_HOST int i; FILE *fp_results; #if PARALLEL if(I_AM_NODE_ZERO_P) #endif { if(!(fp_results=fopen("results.txt","a"))) { Message0("\nCan not open file-aborting!!"); exit(0); } } #if PARALLEL if(I_AM_NODE_ZERO_P) #endif { fprintf(fp_results, "%12.4e ", CURRENT_TIME); for(i=0; i<NO_OF_VALVES; i++) { fprintf(fp_results, "%12.4e ", NV_DOT(cur_r_rp[i],axis[i])); } fprintf(fp_results, "\n"); fclose(fp_results); } #endif } static void write_data(FILE *fp) { int i, j; for(i=0; i<NO_OF_VALVES; i++) { fprintf(fp, "%e ", current_vel_mag[i]); } fprintf(fp, "\n"); for(i=0; i<NO_OF_VALVES; i++) { for(j=0; j<ND_ND; j++) { fprintf(fp, "%e ", cur_r_rp[i][j]); } fprintf(fp, "\n"); } fprintf(fp, "\n"); for(i=0; i<NO_OF_VALVES; i++) { fprintf(fp, "%e ", previous_time[i]); } } DEFINE_RW_FILE(writer, fp) { Message0("Writing UDF data to data file...\n"); #if PARALLEL #if RP_HOST write_data(fp); #endif #else write_data(fp); #endif } static void read_data(FILE * fp) { int i, j; for(i=0; i<NO_OF_VALVES; i++) { fscanf(fp, "%e", current_vel_mag+i); } for(i=0; i<NO_OF_VALVES; i++) { for(j=0; j<ND_ND; j++) { fscanf(fp, "%e", cur_r_rp[i]+j); } } for(i=0; i<NO_OF_VALVES; i++) { fscanf(fp, "%e", previous_time+i); } } DEFINE_RW_FILE(reader, fp) { Message0("Reading UDF data from data file...\n"); #if PARALLEL #if RP_HOST read_data(fp); #endif #else read_data(fp); #endif host_to_node_real(current_vel_mag, NO_OF_VALVES); host_to_node_real(cur_r_rp[0], NO_OF_VALVES*ND_ND); host_to_node_real(previous_time, NO_OF_VALVES); } Thanks a lot in advance. Last edited by Fil; June 23, 2009 at 14:26. |
|
June 23, 2009, 17:14 |
|
#2 |
New Member
Join Date: Mar 2009
Location: Turkey
Posts: 15
Rep Power: 17 |
It is not a familiar topic for me but I have a question, did you move the case&data file anywhere else than where you compiled the UDF ?
|
|
June 24, 2009, 02:39 |
|
#3 |
Super Moderator
Maxime Perelli
Join Date: Mar 2009
Location: Switzerland
Posts: 3,297
Rep Power: 41 |
you have to use this udf for completing the rigid body motion of your body
__________________
In memory of my friend Hervé: CFD engineer & freerider |
|
January 7, 2011, 18:30 |
|
#4 |
New Member
Join Date: Nov 2010
Posts: 22
Rep Power: 15 |
Hi guys
I have posted this question in many places of the forum, perhaps one of you might help me and I would really appreciate it. I need to simulate a compliant wall of say a simple pipe. I do have the elasticity and the maximum displacement also. Can you please help me whit a UDF instructions this valve program is unclear and not applicable to my case. Your help is very much appreciated Many thanks |
|
January 3, 2015, 14:14 |
|
#5 | |
New Member
Renato Venturatto Junior
Join Date: May 2014
Posts: 18
Rep Power: 12 |
Quote:
Have you solved this problem yet? I'm facing the same problem. I'd appreciate your help! |
||
December 19, 2020, 10:16 |
|
#6 |
Member
dab bence
Join Date: Mar 2013
Posts: 48
Rep Power: 13 |
I know this is a very old thread but I have diagnosed this issue, so am sharing to save other people time!
Fluent produced the warning “Warning: incorrect grid motion UDF” when I used the UDF DEFINE_CG_MOTION() in conjunction with the “user-defined” dynamic mesh zone type. For the “user-defined” type, one should use DEFINE_GRID_MOTION(), as this defines the motion individually for each node. DEFINE_CG_MOTION() should be used with Rigid Body, as there is a single motion per zone. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF Problem | ozgur | Fluent UDF and Scheme Programming | 18 | January 17, 2016 15:40 |
Moving mesh | Niklas Wikstrom (Wikstrom) | OpenFOAM Running, Solving & CFD | 122 | June 15, 2014 07:20 |
problem with UDF | Nina | FLUENT | 1 | April 30, 2008 06:09 |
Problem related with UDF for dynamic mesh | Ryan | FLUENT | 6 | April 29, 2004 10:29 |
Grid Independence problem for simple pipe geometry | chanchala | FLUENT | 13 | November 20, 2003 09:24 |