Sei sulla pagina 1di 2

Example 55

EXAMPLE 55
HOW TO USE USER DEFINED FUNCTIONS

DESCRIPTION

The objective of this example is to illustrate how interpreted UDF’s can be used within
Polyflow for boundary condition. User Defined Functions which are documented in Chap.
23 of the Polyflow User’s Manual, and must be written using the CLIPS interpreter.

We base our example on the fourth Polyflow example, i.e. Planar die swell flow of a
Newtonian liquid.

As in example 4, the flow geometry, the fluid model and the boundary conditions are the
same as in example 4. Simply, one focus on the use of the UDF in order to impose the normal
velocity component along the inlet section. One impose a fully developed velocity profile
corresponding to the flow rate equal to 1 :
Vn = −1.5 * (1 - x 2 )

KEYWORDS

UDF for boundary condition.

FILENAMES

swell.msh, swell_udf.dat, swell.udf, swell_udf.res, swell_udf.flum, swell_udf.flur

POLYDATA SESSION

- Read a mesh file : swell.msh


- Read an old data file : swell.dat
- F.E.M. Task 1
- planar die swell flow
- Flow boundary conditions

June 2003 55.1 Version 3.10.0


Example 55

BS1 : Normal and tangential velocity imposed (vn,vs)


vn : User Defined Function see note 1
Udf name : inlet_vn
nb of fields : 1
field X1 : X-coordinates
vs : 0
- File name syntax : Prefix : swell_udf
- Save and Exit :
- Polyflow data file : swell_udf.dat

Note 1

This procedure requires that you program an external CLIPS function named inlet_vn in
a separate file that we name swell_udf.clp (the name is arbitrary). Our function is the
following:

; This is a Polynomial function with 1 arg.


;
(deffunction inlet_vn (?x)
(bind ?R (* -1.5 (- 1.0 (* ?x ?x))))
(printout t crlf "Velocity profile : x = " ?x
" Vn = ", ?R crlf)
?R
)
The line starting by "(printout t crlf " is a printing statement in order to check the
imposed velocity profile.

RUNNING POLYFLOW

In the case UDF’s are being used, Polyflow needs to be informed of the file that contains the
CLIPS code. For this, use the –f option on the command line.

polyflow –f swell.udf < swell_udf.dat

The solution is the same as example 4. As you can see in the listing file, the UDF for boundary
condition is call only once time for each node of the inlet section. This is why the CPU time is
not affected by the UDF for boundary condition.

June 2003 55.2 Version 3.10.0