Professional Documents
Culture Documents
Coupled motion의 구현
Outline
Introduction
What is a User Defined Function?
A UDF is a routine (programmed by the user) written in C which can be
dynamically linked with the solver.
Standard C functions
s Trigonometric, exponential, control blocks, do-loops, file i/o, etc.
Pre-Defined Macros
s Allows access to field variable, material property, and cell geometry
data.
Why build UDF‟s?
Standard interface cannot be programmed to anticipate all needs.
Customization of boundary conditions, source terms, reaction rates,
material properties, etc.
Adjust functions (once per iteration)
Execute on Demand functions
Solution Initialization
User-
Initialize Begin Loop defined Solver? Solve U-Momentum Source terms
ADJUST
Solve Mass,
Source terms Solve V-Momentum Momentum,
Solve Mass Source terms
User Defined Energy,
& Momentum
INITIALIZE Species
Solve W-Momentum
Repeat
Solve Mass Continuity;
Update Velocity
UDF Basics
UDF‟s assigns values (e.g., boundary data,
source terms) to individual cells and cell
faces
in fluid and boundary zones
In a UDF, zones are referred to as threads
A looping macro is used to access individual
cells belonging to a thread.
For example, a face-loop macro visits 563
faces on face zone 3 (named inlet).
s Position of each face is available to
calculate and assign spatially varying
properties
Thread and variable references are
automatically passed to the UDF when
assigned to a boundary zone in the GUI.
Values returned to the solver by UDFs must
be in SI units.
u( y)
y0
Add the UDF source code to the Source Add the UDF source code to the Source
File Name list. Files list.
Click Interpret. Click Build to create UDF library.
The assembly language code will Click Load to load the library.
display in the FLUENT console. You can also unload a library if needed.
Define User-Defined Functions Manage…
Macros
Macros are functions defined by FLUENT.
DEFINE_ macros allows definitions of UDF functionality.
Variable access macros allow access to field variables and cell
information.
Utility macros provide looping capabilities, thread identification, vector
and numerous other functions.
Macros are defined in header files.
The udf.h header file must be included in your source code.
#include “udf.h”
The header files must be accessible in your path.
Typically stored in Fluent.Inc/src/ directory.
A list of often used macros is provided in the UDF User‟s Guide.
Help More Documentation…
DEFINE Macros
Any UDF you write must begin with a DEFINE_ macro:
18 „general purpose‟ macros and 13 DPM and multiphase related macros
(not listed):
DEFINE_ADJUST(name,domain); general purpose UDF called every iteration
DEFINE_INIT(name,domain); UDF used to initialize field variables
DEFINE_ON_DEMAND(name); defines an „execute-on-demand‟ function
DEFINE_RW_FILE(name,fp); customize reads/writes to case/data files
DEFINE_PROFILE(name,thread,index); defines boundary profiles
DEFINE_SOURCE(name,cell,thread,dS,index); defines source terms
DEFINE_HEAT_FLUX(name,face,thread,c0,t0,cid,cir); defines heat flux
DEFINE_PROPERTY(name,cell,thread); defines material properties
DEFINE_DIFFUSIVITY(name,cell,thread,index); defines UDS and species diffusivities
DEFINE_UDS_FLUX(name,face,thread,index); defines UDS flux terms
DEFINE_UDS_UNSTEADY(name,cell,thread,index,apu,su); defines UDS transient terms
DEFINE_SR_RATE(name,face,thread,r,mw,yi,rr); defines surface reaction rates
DEFINE_VR_RATE(name,cell,thread,r,mw,yi,rr,rr_t); defines vol. reaction rates
DEFINE_SCAT_PHASE_FUNC(name,cell,face); defines scattering phase function for DOM
DEFINE_DELTAT(name,domain); defines variable time step size for unsteady problems
DEFINE_TURBULENT_VISCOSITY(name,cell,thread); defines procedure for calculating turbulent viscosity
DEFINE_TURB_PREMIX_SOURCE(name,cell,thread,turbflamespeed,source); defines turb. flame speed
DEFINE_NOX_RATE(name,cell,thread,nox); defines NOx production and destruction rates
DEFINE_CG_MOTION : Introduction
In the previous lecture, we used the 6DOF UDF to couple the motion of
objects to the flow solution;
We saw that the heart of the 6DOF UDF is the DEFINE_CG_MOTION macro;
The macro simply governs how far the object will move/rotate during each time step
(it is called every time step);
The object moves as a rigid body: all nodes and boundaries/walls associated with it
move as one, without any relative motion (deformation);
The translational and rotational motions of the rigid body are specified with respect to
the CG (Center of Gravity) of the body;
The macro works for both prescribed and coupled motions.
#include "udf.h“
DEFINE_CG_MOTION(pod_prescribed_UDF, dt, cg_vel, cg_omega, time, dtime)
{
cg_vel[0] = 0.0; dt = dynamic thread
if (time <= 3.0)
pointer
cg_vel[1] = - time/3.0;
else
cg_vel[1] = - 1.0;
cg_omega[0] = 0.0; Note this name
cg_omega[1] = 0.0;
cg_omega[2] = 0.3;
}
Local Remeshing
As user-specified skewness and
size limits are exceeded, local
nodes and cells are added or
deleted;
As cells are added or deleted,
connectivity changes;
Available only for tri and tet
mesh elements;
The animation also shows
smoothing (which one typically
uses together with remeshing).
Layering
Cells are added or deleted as
the zone grows and shrinks;
As cells are added or deleted,
connectivity changes;
Available for quad, hex and
wedge mesh elements.
Motion Specification
Internal node positions are automatically calculated based on user
specified boundary motion:
Prescribed mesh motion:
Position or velocity versus time, i.e., „profile‟ text file;
UDF with expression for position or velocity versus time (independent of
the flow solution).
Flow dependent motion (coupled motion):
Motion is coupled with hydrodynamic forces from the flow solution via
FLUENT‟s 6 DOF model.
Mesh Preview
Mesh motion can be previewed without calculating flow variables:
Allows user to quickly check mesh quality throughout the
simulation cycle;
Applicable to any dynamic mesh simulation;
Save your case before doing the preview, else the setup will be lost!
Layering: Introduction
Layering involves the creation
and destruction of cells;
Available for quad, hex and
wedge mesh elements;
Layering is used for purely
linear motion – two examples
are:
A piston moving inside a
cylinder (see animation);
A box on a conveyor belt.
We will now look at these two
examples.
Constant
Piston at Ratio
top-most Edge “i+1”
position is an average
of edge “i”
and the
Edge “i” piston shape
Layering: Other
Examples
Fuel injector;
Flow solution on the next slide.
Fuel injector;
Flow solution
(velocity contours).
2-stroke engine;
Of course, a 4-stroke engine could be
simulated in the same way
Premixed combustion
Vibromixer;
Layering;
Flow solution on
next slide.
Vibromixer;
Layering;
Flow solution
(contours of
velocity).
Layering: Limitations
Layering is used for linear/translational motion;
Layering is only available for quad, hex, and wedge cells (but you can have other
cell types in the stationary fluid zones);
If the moving zone is bounded by a two-sided wall, then define a coupled, sliding
interface;
In 2D, the sliding interfaces must be parallel, straight lines. In 3D, they must be
sides of a prismatic cylinder (i.e., a cylinder with constant cross section);
One layer of quad cells must always remain, i.e., one cannot eliminate a dynamic
zone;
If you turn a fluid zone into a dynamic zone, you should also turn the associated
moving walls into dynamic zones – otherwise the incorrect wall boundary
conditions will be applied, and you will get unphysical velocities adjacent to the
wall.
While preparing a nonconformal (sliding) interface within Gambit, be sure that the
two fluid zones are totally disconnected. Even nodes on the interface must be
disconnected (i.e., duplicate). If one does not do this, then the typical symptom is
that the dynamic mesh fails, with nodes from the static fluid zone being dragged
along by nodes in the layering zone;
Also, be sure that the cells are of similar size on both sides of the interface;
otherwise, the dynamic mesh may fail and report negative volumes.
If you use sliding interfaces, keep the mesh density on both sides similar;
((butterfly 6 point)
(time 0 0.6 1.0 2.2 2.6 3.2)
(omega_z 0.0 1.571 1.571 -1.571 -1.571 0.0)
)
The valve first rotates Omega_z (rad/s)
CCW through 90
1.571
degrees, then CW;
3.2
The maximum 0.0
0.6 Time (sec)
rotational speed is
15 RPM.
Local Remeshing:
Short Example 5/12
Here is an application of the previous
set-up: a compressor with spring-
loaded intake and exhaust valves;
Flow solution on the next slide:
Local Remeshing:
Short Example 5/12
Compressor with spring-loaded
intake and exhaust valves;
Flow solution.
Airplane
wing‟s
control
surface
(aileron);
Flow
solution on
next slide:
Airplane
wing‟s
control
surface
(aileron):
2D flow
solution.
Airplane
wing‟s
control
surface
(aileron):
3D.
If the motion of the moving object is limited, it may be a good idea to split
the fluid domain into two fluid zones: you can thereby restrict the remeshing
to just one of those two zones and reduce the computational effort.
6 DOF Solver
Motion is coupled with hydrodynamic forces from the flow solution via
FLUENT’s 6 DOF model.
A udf is needed to specify the mass and the initial inertia matrix, which can be
time dependent
#include "udf.h“
DEFINE_SDOF_PROPERTIES(stage, prop, dt, time, dtime)
{
prop[SDOF_MASS] = 800.0;
prop[SDOF_IXX] = 200.0;
prop[SDOF_IYY] = 100.0;
prop[SDOF_IZZ] = 100.0;
prop[SDOF_IZZ] = 5000.;
“wall-object”
“fluid-bl”
Rotation as well as
Translation
© 2006 ANSYS, Inc. All rights reserved. 100 ANSYS, Inc. Proprietary
Dynamic Mesh Training Notes Fluent User Services Center
UGM at Marine Industries 2007 www.fluentusers.com
© 2006 ANSYS, Inc. All rights reserved. 101 ANSYS, Inc. Proprietary
Dynamic Mesh Training Notes Fluent User Services Center
UGM at Marine Industries 2007 www.fluentusers.com
© 2006 ANSYS, Inc. All rights reserved. 102 ANSYS, Inc. Proprietary
Dynamic Mesh Training Notes Fluent User Services Center
UGM at Marine Industries 2007 www.fluentusers.com
#include "udf.h"
begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) = 5.0 + 5.0*sin(10.0*t + M_PI*1.5);
}
end_f_loop(f, thread)
}
© 2006 ANSYS, Inc. All rights reserved. 103 ANSYS, Inc. Proprietary
Dynamic Mesh Training Notes Fluent User Services Center
UGM at Marine Industries 2007 www.fluentusers.com
• Another UDF is needed to specify the mass and the initial inertia matrix,
compute forces and moment, and drive an object to move.
© 2006 ANSYS, Inc. All rights reserved. 104 ANSYS, Inc. Proprietary
Dynamic Mesh Training Notes Fluent User Services Center
UGM at Marine Industries 2007 www.fluentusers.com
“fluid_layer”
“fluid_rotate”
“moving_body”
© 2006 ANSYS, Inc. All rights reserved. 105 ANSYS, Inc. Proprietary
Dynamic Mesh Training Notes Fluent User Services Center
UGM at Marine Industries 2007 www.fluentusers.com
“top_wall_stat”
“bottom_wall_stat”
© 2006 ANSYS, Inc. All rights reserved. 106 ANSYS, Inc. Proprietary
Dynamic Mesh Training Notes Fluent User Services Center
UGM at Marine Industries 2007 www.fluentusers.com
© 2006 ANSYS, Inc. All rights reserved. 107 ANSYS, Inc. Proprietary
Dynamic Mesh Training Notes Fluent User Services Center
UGM at Marine Industries 2007 www.fluentusers.com
© 2006 ANSYS, Inc. All rights reserved. 108 ANSYS, Inc. Proprietary