|
[Sponsors] |
July 20, 2018, 13:04 |
DEFINE_EXECUTE_AT_END with DEFINE_CG_MOTION
|
#1 |
Member
South Yorkshire
Join Date: May 2018
Posts: 33
Rep Power: 8 |
Hi all,
I wrote an UDF using the DEFINE_CG_MOTION macro. The problem I have is that it executes at every iteration and I only need it to execute at the end of every time step. I found the macro DEFINE_EXECUTE_AT_END which does what I want to but I can't make it work with the other macro. I tried: DEFINE_EXECUTE_AT_END(exec_end) { DEFINE_CG_MOTION(...) { script } } but didn't work. I tried to follow the example of this document (http://willem.engen.nl/uni/fluent/do...ips-Tricks.pdf page 42) but in my script I use a lot of information from DEFINE_CG_MOTION which I cant apply if they are separated as the example: DEFINE_EXECUTE_AT_END(exec_end) { script } DEFINE_CG_MOTION(...) { script } thanks! |
|
July 20, 2018, 13:09 |
|
#2 |
Member
South Yorkshire
Join Date: May 2018
Posts: 33
Rep Power: 8 |
Forgot to add the script I am trying to implement:
Code:
#include "udf.h" static real v_prev = 0.0; DEFINE_CG_MOTION(osc, dt, vel, omega, time, dtime) { Thread *t; Domain *d = Get_Domain(1); real x_cg[3], force[3], moment[3]; real accl, dv; real mass = 0.022; real wn = 3.0; real k = mass*wn*wn; real c = 2*mass*wn*0.0; /*no damping*/ int i; NV_S(vel, =, 0.0); NV_S(omega, =, 0.0); t = DT_THREAD(dt); for (i=0;i<3;i++) x_cg[i]=DT_CG(dt)[i]; Compute_Force_And_Moment(d, t, x_cg, force, moment, TRUE); force[1] += -k*x_cg[1] - c*vel[1]; accl = -force[1]/mass; dv = accl*dtime; v_prev+=dv; vel[1] = v_prev; printf("Computed force: %g \n", force[1]; printf("Velocity: %g \n", vel[1]); } DEFINE_CG_MOTION(osc_inert, dt, vel, omega, time, dtime) { vel[0] = 0.0; vel[1] = v_prev; } |
|
July 25, 2018, 02:52 |
|
#3 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
What are you trying to model? Why would you only want to apply the motion to the very last iteration of a time step? The forces acting on the surfaces are coupled with the flow field. Consider a uniform and constant velocity inlet boundary condition with a speed of 1 m/s, if you solve the transport equations with the inlet speed at 0 m/s for all iterations except the final iteration then you would have (at least) convergence issues.
|
|
March 27, 2019, 09:32 |
|
#4 |
New Member
Ouyang
Join Date: Jun 2018
Posts: 6
Rep Power: 8 |
Hi, South Yorkshire! I have just asked you in your post:
Runge-kutta fails after some iterations whether you have tried the EXECUTE_AT_END with CG_MOTION strategy, and now I find your this post. Just as you did, I wanted to simulate the VIV of the single-dof cylinder. And I also tried the udf you mentioned (Page 42 of http://willem.engen.nl/uni/fluent/do...ips-Tricks.pdf). But the generated displacement grew more and more large unrealistically. I hope you have solved this problem and I will greatly appreciate you for your suggestion. Thank you very much! |
|
April 4, 2019, 03:45 |
|
#5 |
New Member
Gang Qian
Join Date: Jan 2019
Posts: 2
Rep Power: 0 |
Did you solve this problem? My problem is also the displacement getting bigger and bigger.
|
|
April 4, 2019, 06:47 |
|
#6 | |
Member
South Yorkshire
Join Date: May 2018
Posts: 33
Rep Power: 8 |
Quote:
Runge-kutta fails after some iterations check it out. Regards, |
||
|
|