Force on moving body
Hi,
I want to calculate the resulting force on a body moving in a fluid with predefined speed, but I am new to the work with UDF's. As far as I understood with the SDOF Macro the Motion resulting out of a Force can be simulated, but the Macro is of void type, so there is no output. The CG_MOTION Macro however defines a Motion, so this is more what I want. Is there a possibility to generate a output(for example by using the DEFINE_OUTPUT_PARAMETER Macro) of the total force acting in the body, like the Force the SDOF Macro uses to calculate the Motion? The force resulting out of the pressure(integration over the faces) and the fictious force (F=m*(dv/dt)) are no problem to calculate, but how can the "dynamic" force, resultant of the friction of the fluid on the body be calculated in UDF, like SDOF (at least I think) does? Is it maybe possible to export the force from the SDOF makro? Thank you very much in advance for any sugestion! |
Motion UDF
The UDF part for the motion should look like this:
Code:
#include "udf.h" |
Which force components do you wish to include: pressure, wall shear? Have a read of this thread because they have code for calculating the force as a sum of pressure and wall shear.
|
Thank you very much, did not find this thread before... :rolleyes:
So the UDF schould look like this, right? Code:
#include "udf.h" is there any way to get a double output? Thanks in advance! |
If DEFINE_OUTPUT_PARAMETER doesn't suit your requirements, you could either print the force to the screen with Message() or save to a text file.
When are you calling this force summation, you may need to parallelise this code if running Fluent in parallel. |
First, I see a couple minor syntax issues:
C is case sensitive. I see both 'hub' and 'freq' in several places, which need to be 'HUB' and 'FREQ'. Check your variable declarations. C requires all variable declarations at the top, before any non-declaration code. 'f_tot' is being declared where it appears at the end, not at the top. (i.e. you should have 'real f_tot;' at the top and 'f_tot = forces...;' near the end. I'm really not sure what's going on with the return type. It looks like that code, as written, doesn't return an int, but a pointer to an int. If you remove the '(int *)' and instead just have 'return f_tot;' it should return a real (which is a float when running fluent in single precision and a double when running in double precision). I'm not exactly sure how the vector operations play with arrays, since your 'forces' array isn't exactly the kind of vector you'd usually use for 'NV_*' operations. Instead of 'real forces*;' and later 'NV_S(forces, =, 0.0);' it might be more robust to just have 'real forces[3]={0};' |
All times are GMT -4. The time now is 20:32. |