UDF for undulating Fish

  • Last Post 12 March 2019
kfouladi posted this 07 September 2018


We are trying to model a fish swimming with undulating motion. Does anyone has a UDF example that we can start with? Thanks.


Order By: Standard | Newest | Votes
Kremella posted this 07 September 2018

Hello Kamran,

Please elaborate on how you are attempting to model this problem. What is the purpose of this UDF? Perhaps, we may be able to point you to some resources which can help you get started?

Thank you.

Best Regards,


jmccasli posted this 07 September 2018

Hi Kamran,


I do not have a UDF to share, but there are some useful examples in the literature for similar studies involving Fluent. See this one for example, in which the use a DEFINE_GRID_MOTION macro to account for the undulation of the fish:



That may be a good place to start.




kfouladi posted this 07 September 2018

Hi Kremella and Jeremy,

Thank you for your quick replies. What I need to do is put the fish in wavy motion. Therefore, I need a UDF so I can put the fish through some lateral or vertical displacement as a function of time. I am not sure what the UDF should look like or more specifically, what parameters it should pass to Fluent. I will provide a picture for more clarity.


(I posted this earlier but somehow that post is gone now).

kfouladi posted this 07 September 2018

Here is a picture

Attached Files

rwoolhou posted this 10 September 2018

Thanks. As Jeremy says you'll need the DEFINE_GRID_MOTION macro to define change in shape of the object. There's an example in the UDF manual, and as an ASC you should be able to access the Customer Portal for additional resources: I'd suggest looking at the UDF and Moving Mesh materials. 

kfouladi posted this 12 September 2018

Thank you all. I will look into DEFINE_GRID_MOTION macro and see if I can make any progress. 



CatherineIl posted this 01 March 2019


I would like to ask you if you can post the code here because I am doing something similar for my dissertation but using an airfoil and a wing. I would really appreciate that as I have already wasted a lot of time trying to find a solution and I have never used udf before. 

Thank you in advance. 

kfouladi posted this 12 March 2019

I modified a UDF file so I can put a flat plate in flapping motion. Here is the file. I wonder if this helps you.



/* WingDM.c                                  */

/* UDF for specifying a time-varying omega    */

/*                                            */

/* Simulates +/- angFlip deg flapping with a  */

/* cycle of FN Hz.                            */

/*                                            */



#include "udf.h"

#define FN 34.4

#define angFlip 30

#define omegpi 2.0*M_PI*FN

#define omegMx angFlip*M_PI*omegpi/180.0


DEFINE_CG_MOTION(dm, dt, cg_vel, cg_omega, time, dtime)


  real omega, tm;


  tm = time - 0.5*dtime; 


  omega = omegMx*cos(omegpi*tm); /* rotational speed about axis*/ 


  cg_vel[0] = 0.0;

  cg_vel[1] = 0.0;

  cg_vel[2] = 0.0;


  cg_omega[0] = 0.0;

  cg_omega[1] = 0.0;

  cg_omega[2] = omega;