CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

DEFINE_EXECUTE_AT_END with DEFINE_CG_MOTION

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 20, 2018, 12:04
Default DEFINE_EXECUTE_AT_END with DEFINE_CG_MOTION
  #1
Member
 
South Yorkshire
Join Date: May 2018
Posts: 33
Rep Power: 8
asking is on a distinguished road
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!
asking is offline   Reply With Quote

Old   July 20, 2018, 12:09
Default
  #2
Member
 
South Yorkshire
Join Date: May 2018
Posts: 33
Rep Power: 8
asking is on a distinguished road
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;
}
asking is offline   Reply With Quote

Old   July 25, 2018, 01:52
Default
  #3
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
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.
`e` is offline   Reply With Quote

Old   March 27, 2019, 08:32
Default
  #4
New Member
 
Ouyang
Join Date: Jun 2018
Posts: 6
Rep Power: 8
eagle_001 is on a distinguished road
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!
eagle_001 is offline   Reply With Quote

Old   April 4, 2019, 02:45
Default
  #5
New Member
 
Gang Qian
Join Date: Jan 2019
Posts: 2
Rep Power: 0
Keith Love is on a distinguished road
Did you solve this problem? My problem is also the displacement getting bigger and bigger.
Keith Love is offline   Reply With Quote

Old   April 4, 2019, 05:47
Default
  #6
Member
 
South Yorkshire
Join Date: May 2018
Posts: 33
Rep Power: 8
asking is on a distinguished road
Quote:
Originally Posted by Keith Love View Post
Did you solve this problem? My problem is also the displacement getting bigger and bigger.
Yes, I posted an improved version of the UDF on:
Runge-kutta fails after some iterations

check it out.

Regards,
asking is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 03:24.