USER DEFINED FUNCTIONS, CUSTOM FIELD FUNCTIONS and
MACROS MANUAL
This will be possible by using user defined fonctions
to define boundary conditions and a custom field fonction to define
initializing conditions.
Few indications will be given to help the user to define
a macro with Fluent.
This is the most difficult thing to do with Fluent
because you have to write few lines of a C++ program and to import this
program in Fluent.
But , follow exactly these indications and you will be
granted.
1. The C++ program
At first, you have to open a text editor which you
can find in Unix.
Create a new document and write these few lines:
c.
begin_f_loop ( f,thread)
{ } end_f_loop
(f,thread)
This is a fonction that will be applicated at all the
faces f of the cell zone thread.
d.
F_CENTROID is a fonction that returns the coordonates
(in the vector x) of the center of the face f (which
belongs to the cell zone thread).
e.
F_PROFILE is the valor of the main fonction. You put
here the expression of the temperature gradient. x[0] is the variable x
in meter. Here, the expression of the temperature gradient is T=250*x +300.
But, you can modify this expression.
When you have writen this program, you save it as, for
example, gradient_temp.c
2. Importation and compilation in Fluent
At first, you have to copy the file "udf.h", that
you will find on the server, in your own directory.
Second, you go, under Fluent, in the menu as described
on the following picture:
Define>User-Defined>Fonctions>Interpreted...
When you click on interpreted..., a new window appears:
You put the name of your C++ file in the Source File Name field. (Here, gradtemp.c) and you click on Compile.
If the compilation has succeeded, you have created a user defined fonction. You have now to determinate the cell zone you want to applicate this fonction.
Go in the menu Define>Boundary Conditions:
Select a domain where you want to apply the temperature gradient, for example, wall-2 . Then, click on the set... bouton, a new window appears:
Replace the valor of the menu constant by your
user defined fonction
gradient_temp.
You have defined a temperature gradient on the wall-0
as boundary condition.
You can do the same thing on the wall-01.
3. Results
You can see the result of your fonction after solving
few iterations and display some graphs.
To do this, you will have to define a custom field
fonction. Don't worry, it is easier than creating a user defined fonction.
1. Creation of the custom field fonction
At first, you have to run Fluent and to go in the
menu Define>Custom Field Fonctions.
A new window appears where you can create a new fonction.
You put the expression of the temperature gradient by selecting the boutons on the left of the windows (For example, "1","2","3"... or "+","-"...or"log","ABS"...).
For the variables like X-velocity, Y-coordinate, temperature..., select them on the right of the windows in the menu Field Fonction and click on Select.
The expression is writen on the top left of the window.
When you are satisfied of the expression, give a name
at your fonction in the New Function Name.field. So, click on Define
and Close.
2. Use of the fonction
You have defined a new fonction and you can apply
this as initial condition on the interior of the domain.
To do this, go in the menu Solve>Initialize>Patch...,
A new window appear;
Choose the option Use Field Fonction, Select on the
left the variable Temperature.
Select on the middle your field fonction gradient_temperature
and
Select on the right the zones to patch fluid-5.
When everything is selected as shown upstairs, click
on Patch and Close.
You have initialize the domain with a temperature gradient.
3. Results
You can see the temperature field obtained in the
menu Display.
You can create a lot of types of macros, but, they
are useful when you have to do repetitive actions.
For example, we are going to learn how display the evolution
of an unsteady calcul at each time step.
1. Create a macro
At first, you have to go in the menu Solve>Monitors>Command...
Then, a new menu appears:
Choose a name for the macro in the field Name,
for example, macro-1. Click on the bouton OK and begin to
define your macro by doing exactly what you will do narurally.
For example, go in the menu Display>Contour
Choose the variable you want to display, for example,
temperature.
Select OK to display a new window with the graph
of temperature.
So, click in the window named Monitor Commands
on the bouton End Macro.
You have created a new macro named macro-1 which display
the temperature field.
2. Use a macro
Stay in the window named Monitor Commands and choose
a name in the first field Name for your command, for example,
Affictemp.
Then, in the field Command, write the name of your
macro , here, macro-1.
Then select the bouton On , the case is coched.
Now, you go in the field When to choose Time
iteration (applicable for an unsteady calcul)