Program Structure

Availability and Requirements

The file   is downloadable from the website By unpacking the folder   "NaSt2D-2.0"   is generated with the subdirectories   "Program", "Par", "Tools"   and   "Grafik". The folder   "Program"   contains all source and header files of the program NaSt2D-2.0, in detail:

File Function Task

main.c   controls the program execution
datadef.h   contains the program overall definitions

boundary.c + boundary.h SETBCOND set the general boundary conditions
  SETSPECBCOND set problem-specific boundary conditions

flag.c + cars.c + valves.c + drachen.c + flag.h INIT_FLAG defined obstacle cells

init.c + init.h READ_PARAMETER read in the par-file parameters
  INIT_UVP set start values
  SCHREIBE_ERG_bin binary writing for continued computation
  LESE_ERG_bin binary reading at continued computation

uvp.c + uvp.h COMP_TEMP calculates the dimensionless temperature T*
  COMP_FG calculates the F*- and G*-values in laminar and turbulent case
  COMP_RHS calculates the right-hand-side of Poisson equation for dimensionless pressure p*
  ADAP_UV calculates the new dimensionless velocities u* and v*
  POISSON solves the Poisson equation for pressure p* by SOR-method
  COMP_delt calculates the new dimensionless time step value δt*

turbulence.c + turbulence.h COMP_NUT calculates the dimensionless turbulent viscosity νturb*
  COMP_KAEP calculates the dimensionless k*- and ε*- values

surface.c + surface.h SET_PART set problem-dependent initial particles at free boundary value problems
  MARK_CELLS marked cells, in which particles located, and determined cells on free boundaries
  SET_UVP_SURFACE calculates the values on free boundaries

visual.c + visual.h OUTPUTVEC writes δxW*, δyW*, u*, v*, p*, T*, νturb*, k*, ε*, ζ*, ψ*, H* and FLAG in the out-file
  COMPPSIZETA calculates the dimensionless stream function ψ* and the dimensionless vorticity ζ*
  COMP_HEAT calculates the dimensionless heat function H*
  ADVANCE_PARTICLES moved particles forward
  ADVANCE_AT_BOUND calculates the particle position at obstacle cells
  INJECT_PARTICLES injected particles for streaklines
  WRITE_PARTICLES writes the actual particle positions as ASCII-file
  WRITE_PARTICLES_bin writes the actual particle positions binary
  PARTICLE_TRACING writes particle positions of pathlines in the tra-file
  STREAKLINES writes particle positions of streaklines in the str-file

Makefile_L + Makefile_W compile + link makefiles for the LINUX- and WINDOWS- environment

zeit.gnu script file visualized the temporal course of computation with GNUPLOT

The C-files may be compiled with   gcc   and taken for execution. The necessary software for LINUX-environment is costless available from   GNU Compiler Collection   on the website ; for WINDOWS-environment on The GCC-package contains also the compiler   g77   for   FORTRAN77 - programs and the Makefile - tool. The graphic program   GNUPLOT   is downloadable costless from the website .

In folder   "Par"   are stored all input files of up to now in NaSt2D-2.0 implemented problems, in detail:

Problem par-file brief Description

flow round autoA.par flow round a car type A, vintage car   link
  autoB.par flow round a car type B, Porsche 911   link
  autoC.par flow round a car type C, Audi A4 ragtop   link
  autoD.par flow round a car type D, bionic car   link
  autoE.par flow round a car type E, racing car   link
  backstep.par flow over a step   link
  balken.par Kármán vortex street after an inclined timber   link
  kreis.par Kármán vortex street after a circle, semicircle et al.   link
  drachen.par Kármán vortex street after a kite   link
  tragschrauber.par Kármán vortex street after a gyrocopter   link

flow through dcavity.par cavity flow   link
  duese.par nozzle flow   link
  ventilD.par gate valve flow   link
  ventilE.par angle valve flow   link
  ventilK.par Koswa-type valve flow   link
  ventilL.par Leser-valve flow   link
  ventilP.par Patent-Freifluss-type valve flow   link
  ventilR.par Rhei-type valve flow   link

free boundary values damm.par broken dam   Dam
  spritzguss.par injection molding of plastics   Injection
  tropfen1.par single drop falling   Drop1
  tropfen2.par two drops falling   Drop2
  wafa.par back struck wave   Wave

energy transport convection.par natural convection   link
  fluidtrap.par captive fluid   link
  rayleigh.par Rayleigh-Bénard flow   link

The folder   "Tools"   contains   C- resp. FORTRAN77 - files, which are useful at the implementation of new problems with complicated geometry or at preparation of computed results for visualization with the graphic programs   GNUPLOT   and   DISLIN, in detail:

Function File Task

  flagg.c + flagg.f calculate straight lines from sequenced point couples
implementation kontur.c + kontur.f scale polynomials from fig-files

visualization datgen.c + datgen.f generate input files for GNUPLOT and DISLIN
  delete.c + delete.f delete repeately occuring data points
  marker.c + marker.f mark the data especially for splitting into 3 data sequences
  neighbor.c + neighbor.f arrange data corresponding their adjacency
  revers.c + revers.f write out input data in reverse order
  split.c + split.f split data optional in 2 or 8 data sequences

calculation drag.c + drag.f calculate the drag coefficient CW of flow round bodies

Fig -files can generated and edited in a LINUX-environment with the vector graphics program   XFIG, which downloadable costless from the website . For WINDOWS-environment one should purchase the shareware program   WINFIG   from .

In folder   "Grafik"   are stored   kon-files. These contain outline data of all implemented problems with complicated geometry, e.g. polynomials, which describe outlines of a car. They can displayed with the program GNUPLOT; a GNUPLOT operate program is here exemplarily specified. More manifold in its illustration facilities is the graphic program   DISLIN, which is downloadable costless from the website   for LINUX- and WINDOWS- environment. In combination with GNUPLOT one can generate relatively unproblematic the necessary input files for DISLIN using the   C- resp. FORTRAN77 - programs in folder   "Tools". Control programs for display with DISLIN are given exemplarily in folder   "Grafik". There are in detail:

Function File Task

outline polynomial autoA.kon car outline type A, vintage car
  autoB.kon car outline type B, Porsche 911
  autoC.kon car outline type C, Audi A4 ragtop
  autoD.kon car outline type D, bionic car
  autoE.kon car outline type E, racing car
  ventilD.kon gate valve outline
  ventilE.kon angle valve outline
  ventilK.kon Koswa-type valve outline
  ventilL.kon Leser-valve outline
  ventilP.kon Patent-Freifluss-type valve outline
  ventilR.kon Rhei-type valve outline
  drachen.kon kite

GNUPLOT control program iso.gnu displays polynomials with GNUPLOT

DISLIN control programs Vektor.c + Vektor.for generate a vector plot of velocity w(u,v) with DISLIN
  IsoFarb.c + IsoFarb.for isolines + color-coded area of data matrix ψ, p etc.
  autoBdatInc.c + autoBdatInc.for autoB outline data (Porsche 911) for DISLIN
  autoBplotInc.c + autoBplotInc.for display the autoB outline data (Porsche 911) with DISLIN
  Streak.c + Streak.for generate streakline plots with DISLIN
  Trace.c + Trace.for generate traceline plots with DISLIN
  Profil.c + Profil.for generate profile plots with DISLIN
  e3Ddruck.c + e3Ddruck.for generate a 3D-surface with DISLIN

Structure and Adjustments

The main algorithm in program   main.c   has follow structure:

  1. Set the parameters for turbulence models; presently are set the values given in [1]:   Cμ = 0,09 , Cε = 0,07 , C1 = 0,126 and C2 = 1,92 .

  2. Read in the start values at continued computations, if called a file name in the par-file.

  3. Setting the start values and defining of obstacle cells in case the computation is not continued, cp. point 2.

  4. Setting of particles for streaklines and/or pathlines, if given accordant file names in the par-file.

  5. Setting of particles for free boundary value problems, if accessed a such problem in the par-file.

  6. Setting of boundary conditions in case the computation is not continued, cp. point 2.

  7. Computation of dimensionless turbulent viscosity νturb* and k*- and ε*- values, if accessed a turbulence model in the par-file.

  8. Executing the   time loop   from t_anf* equal zero up to t_end*.

  9. Computation of dimensionless stream function ψ*, vorticity ζ*, heat function H*, and writing of results in the out-file, if called a file name for this vector file in the par-file.

  10. Deallocation of memory and program end.

The time loop end is given in par-file, either with t_end* equal zero or greater zero. In the first case the computation will be ended by achievement of   stationary flow conditions, i.e. if the absolute value of velocity gradient in a predetermined area point falls below the value 10-4. In the second case the computation will be ended by achievement of the user-defined   end time, whereas the value t_end* = 29.3 is a control parameter and can not used therefor. The called time values are dimensionless and denoted here with *. The dimension-afflicted time is   t = t*· L / c   with characteristic length L and inlet velocity c.

Initially of each computation it happens more or less big fluctuations of velocity gradient, therefore one can predefine a   minimum run time value   for the time loop with a value for tks in main.c. Also the area point for destination of the velocity gradient is arbitrary; in normal case are ikx = imax/2 and jky = jmax/2 applicable values. Is the arbitrary area point yet located in an obstacle cell or on another fluid mechanics inapplicable place, so can be found an applicable area point with follow algorithm in main.c:

if(U[ikx][jky] == 0.) {
printf("ikx,iky rearrange, so that the gradient not zero, see time loop in main.c\n");
/* return(0); here deactivate and follow search algorithm activate */
//           return(0);
/* With activation of the follow term find the applicable values for ikx,iky */
if(U[i][j]!=0.) printf("ikx,jky choose: i %d j %d U %1.5g V %1.5g\n",i,j,U[i][j],V[i][j]);

Processing the   time loop   includes:

  1. Calculation of new time step value δt*. In case of δt* < 10-8 is displayed a warning on desktop. The computation does not converge furthermore, i.e. the input data should be changed.

  2. At free boundary value problems the cells are marked, in which particles located, the cells at free boundaries are assessed, and the velocities on free boundaries are computed.

  3. Calculation of temperature T*, of F*- and G*-values for laminar and turbulent flow, as well as the right-hand-side of Poisson's equation.

  4. Display of remaining life time, number of SOR-iterations, as well as velocity gradient in the selected area point on desktop. Simultaneously are written on the file zeit.dat time t*, velocity u*, pressure p* and velocity gradient ∂u*/∂t* in the selected area point. During the computation one can display with GNUPLOT, i.e. with the files zeit.gnu and zeit.dat, the gradient course, thus the calculation can be traced.

  5. Calculation of new velocities u* and v*.

  6. Calculation of new general and new problem-specific boundary conditions.

  7. In case of turbulence νturb* and k*- and ε*- values are new calculated.

  8. At free boundary value problems the values on free boundaries are new calculated.

  9. Whether with del_vec, del_trace and del-streak specified in the par-file, intermediate data are written on out-file and on file for continued computation, likewise particle positions in the str-file and/or the tra-file.

The algorithm of function   OUTPUTVEC   in program   visual.c   controls writing out of results and should be adapted before each computation, so that a nonessential data output can be avoided by deactivation, respectively dimension-afflicted data will directly written out by transformation. All program computations underlie dimensionless variables, therefore the output variables are at first dimensionless. Would like writing out dimension-afflicted values, then should be included for the output parameters follow transformations with the reference parameters   L , c , p , ρ , λ , cp∞ , η :

Parameter dimensionless dimension-afflicted

horizontal coordinate X = x* x = x*· L
vertical coordinate Y = y* y = y*· L
time t = t* t = t*· L / c

velocity in x-direction U = u* u = u*· c
velocity in y-direction V = v* v = v*· c
pressure P = p* p = p + p*· ρ· c2
temperature TEMP = T* T = T + T*· ΔT
turbulent viscosity NUT = νturb* νturb = νturb*· L· c
turbulent kinetic energy KA = k* k = k*· c2
rate of dissipation EP = ε* ε = ε*· c3/ L
vorticity ZETA = ζ* ζ = ζ*· c / L
stream function PSI = ψ* ψ = ψ*· L· c
heat function HEAT = H* H = H*· λ· ΔT     with     T = 0 °C     and     ΔT = Thot - Tcold

Problem-specific Adjustments

In program   boundary.c   follow problem-specific boundary conditions are defined and may be changed there, in detail:

Problem Definition

backstep inlet flow region
dcavity upper velocity
spritzguss inlet flow region
wafa inlet flow region
convection wall temperatures
fluidtrap wall temperatures
rayleigh wall temperatures

In program   flag.c   problem-specific obstacle cells are defined and may be changed there. Simple geometries as steps, circles, rectangles, sinusoidal nozzles etc. are outlined with few analytical functions. Complicated geometries as valves and cars need as outline a number of polynomials. The data field FLAG(x,y) with 0 or 16 in the grid points is defined as result, whereby obstacles and non-obstacles are denoted. The simple geometries may be changed in flag.c by changing of few parameters. At the problem "kreis" it is possible, as well at the complicated geometries, FLAG-distribution write out in the out-file par-file controlled for check and correction. In detail it are about follow problems:

Problem Definition of Geometry

backstep HEIGHT and length of step
balken lower and upper BORDER of inclined timber
kreis possible are circle, semi-circle, semicircle-triangle-profile , streamlined shape
duese sinusoidal nozzle outline
spritzguss circle
wafa HEIGHT and length of step
fluidtrap boundary walls

In program   init.c   are defined the problem-specific initial conditions for the problems "backstep" and "duese", i.e. geometry-dependent initial values for velocity and turbulence will set. Finally are specified in program   surface.c   parameters for the free boundary value problems "damm", "tropfen1" and "tropfen2", i.e. number of particle tracings, geometry of drops and of catchment tank as well as initial velocities of drops.

Preamble   |   Table of Contents