You are on page 1of 10

A.

Additional codes

A. Additional codes
The code to create the mesh in Chapter 5:
1 f u n c t i o n f o i l g m s h ( a r c h i , a l f a , y p l u s , e t e r , Re ,M, T0 , N, bump)
2 %f o i l g m s h ( a r c h i , a l f a , y p l u s , e t e r , Re ,M, T0 , N, bump)
3 %
4 %f o i l g m s h w i l l c r e a t e a GEO f i l e with a l l n e c e s s a r y i n s t r u c t i o n s t o mesh an
a i r f o i l geometry o n l y with hexahedra i n Gmsh , d e p a r t u r i n g from a s e t o f p o i n t s
d e f i n i n g t h e a i r f o i l s e c t i o n c o n t o u r . So f a r t h i s code can o n l y d e a l with
monoelement a i r f o i l s and 2D s i m u l a t i o n s f o r f i n i t e volume CFD c o d e s .
5 %The on−s c r e e n o ut pu t d i s p l a y s a summary o f t h e i n p u t , some s t a t i s t i c s o f t h e mesh
t o be c r e a t e d and u s e f u l i n f o r m a t i o n f o r d e f i n i t i o n o f t h e c a s e i n CFD
s o f t w a r e s , s p e c i a l l y Code Saturne .
6 %
7 %− a r c h i : s t r i n g which d e f i n e s t h e c o m p l e t e name o f t h e a i r f o i l c o o r d i n a t e s f i l e .
The c o o r d i n a t e s must be g i v e n i n XFoil f o r m a t s t a r t i n g from t h e t r a i l i n g edge
and c i r c l i n g c o u n t e r c l o c k w i s e . The c o o r d i n a t e s don ’ t need t o be
a d i m e n s i o n a l i z e d , but t h e program won ’ t do i t e i t h e r , a s t h e a i r f o i l chord
w i l l be e s t i m a t e d a u t o m a t i c a l l y from i t . The a u t h o r c o n s i d e r ’ s t h i s i s u s e f u l
t o compare f u r t h e r r e s u l t s with e x p e r i m e n t a l data . The c o o r d i n a t e s can be
o f f −c e n t e r e d by s m a l l amounts .
8 %The f i l e must be l o c a t e d i n t h e a c t i v e d i r e c t o r y . The o ut pu t f i l e w i l l have t h e
same name with t h e s t r i n g ’ . geo ’ appended . I f you wish t o i n c l u d e t e x t i n your
c o o r d i n a t e s f i l e , p l e a s e add a p e r c e n t a g e s i g n on t h e f i r s t column , o t h e r w i s e
an e r r o r w i l l o c c u r .
9 %
10 %− a l f a : d e s i r e d a n g l e o f a t t a c k i n d e g r e e s . The mesh g e n e r a t e d w i l l be s o i n wind
a x i s system , where wind v e l o c i t y c o i n c i d e s i n s e n s e and d i r e c t i o n with t h e
p o s i t i v e X a x i s , s o when d e f i n i n g i n l e t speed , Y and Z components s h o u l d be
z e r o . Also , t h e s e c t i o n p l a n e c o i n c i d e s with t h e mesh XY p l a n e .
11 %
12 %− y p l u s : d e s i r e d y+ v a l u e around t h e a i r f o i l . S p a c i n g between s u s e c q u e n t c e l l s
normal t o t h e a i r f o i l s u r f a c e i s done with an a u t h o m a t i c a l l y d e f i n e d g e o m e t r i c
progression .
13 %
14 %− e t e r : s t r i n g d e f i n i n g m a t e r i a l medium where a i r f o i l i s submerged . Only t h r e e
p o s i b i l i t i e s a r e a l l o w e d , ’ a ’ f o r normal a i r , ’ h ’ f o r d i s t i l l e d water and ’ n ’
for nitrogen .
15 %
16 %− Re : Reynolds number based on a i r f o i l chord and f r e e s t r e a m s p e e d . The r e f e r e n c e
chord and t h a t o f t h e a i r f o i l i n t h e c o o r d i n a t e s f i l e must c o i n c i d e .
17 %
18 %− M: i f t h e medium i s a i r o r n i t r o g e n , i t i s t h e Mach number . I f t h e medium i s
water , i t i s t h e f r e e s t r e a m s p e e d magnitude i n m/ s . Although t h e a p p l i e d
f o r m u l a s h o l d f o r t r a n s o n i c and s u p e r s o n i c f l o w s , t h e r e s u l t i n g mesh might not
be s u i t a b l e f o r t h o s e c a s e s . C o m p r e s s i b l e f u l l y s u b s o n i c f l o w s s h o u l d not be a
problem .
19 %

Jordi Casacuberta Puig 184


OPENFOAM GUIDE FOR BEGINNERS

20 %− T0 : i f t h e medium i s a i r o r n i t r o g e n , i t i s t h e s t a g n a t i o n t e m p e r a t u r e i n
K e l v i n d e g r e e s . I f t h e medium i s water , i t i s t h e non−s t a g n a t e d f l o w
temperature in C e l s i u s degrees .
21 %
22 %− N: f o u r i n t e g e r s v e c t o r whre N( 1 ) i s t h e number o f hexahedra a l o n g t h e a i r f o i l
chord , t h e r e f o r e t h e whole c o n t o u r o f t h e a i r f o i l w i l l be d i s c r e t i z e d i n
2∗N( 1 ) e l e m e n t s . N( 2 ) i s t h e number o f e l e m e n t s normal t o t h e chord and i n s i d e
a s e m i e l l i p s e c l o s e l y e n c l o s i n g t h e a i r f o i l ( a v a l u e between 25 and 100 s h o u l d
s u f f i c e f o r most a p p l i c a t i o n s ) . N( 3 ) i s t h e number o f e l e m e n t s i n t o which t h e
h o r i z o n t a l l e a d i n g edge−i n l e t and t r a i l i n g edge−o u t l e t gaps w i l l be
d i s c r e t i z e d . N( 4 ) i s s i m i l a r t o N( 3 ) but a p p l i e d t o t h e v e r t i c a l gaps between
t h e a i r f o i l and t h e top / bottom w a l l s d e f i n i n g t h e box .
23 %
24 %− bump : a v a l u e which d e f i n e s t h e mesh c o n c e n t r a t i o n d e g r e e around t h e l e a d i n g
and t r a i l i n g edge . I f bump=1 t h e c e l l l e n g h t s w i l l be u n i f o r m a l o n g t h e
a i r f o i l c o n t o u r , i f bump>1 t h e e l e m e n t s w i l l be c o n c e n t r a t e d around t h e
midchord . I f 0<bump<1 t h e e l e m e n t s w i l l c o n c e n t r a t e around t h e e d g e s , and
don ’ t be s u r p r i s e d i f you need v e r y low v a l u e s l i k e 0 . 1 o r l e s s t o a c h i e v e a
noticeable concentration .
25 %
26 %To mesh , s i m p l y open i n Gmsh t h e g e n e r a t e d GEO f i l e , go t o Mesh with t h e menu o r
by p r e s s i n g ’m ’ and c l i c k on ” 3D” . Save t h e mesh a s a MED f i l e f o r u s e with
C o d e S a t u r n e ( remember t o a p p l y ’ c h e c k c e l l o r i e n t a t i o n ’ i n t h e GUI o r
p r e p r o c e s s o r ) . The g e n e r a t e d g r o u p s a r e ” i n l e t ” , ” o u t l e t ” , ” a i r f o i l ” ,
” symmetry ” and ” w a l l s ” .
27 %The on−s c r e e n o ut pu t t e x t p r o v i d e s i n f o r m a t i o n t o d e f i n e a l l n e c e s s a r y v a r i a b l e s
i n CS ’ s GUI . The h y d r a u l i c d i a m e t e r v a l u e i s j u s t a dummy number s u i t a b l e t o
i n i t i a l i z e p r o p e r l y t h e t u r b u l e n c e model f o r e x t e r n a l f l o w s .
28 %
29 %Send some f e e d b a c k i f you wish t o c e s a r v e c c h i o @ g m x . com ( I a l s o a c c e p t F e r r a r i s
and P o r s c h e s ) . I hope you f i n d t h i s s o f t w a r e u s e f u l .
30 %
31 %Cesar A. V e c c h i o Toloy
32 %
33 %D i s c l a i m e r : I am g i v i n g you t h i s s o f t w a r e a s i s f u l l y f o r f r e e . I w i l l not be
r e s p o n s i b l e f o r any harm o f any k i n d t h i s code and t h e u s e s you g i v e t o i t may
c a u s e . You a r e u s i n g t h i s code under your own r e s p o n s a b i l i t y and r i s k .
34
35 more o f f
36
37 N = N+1; %number o f nodes on upper and l o w e r s u r f a c e
38 a l f a = − a l f a ∗ p i / 1 8 0 ; %c o n v e r s i o n t o r a d i a n s and Gmsh r e f e r e n c e s
39 i n i c = l o a d ( a r c h i ) ; %l o a d i n g c o o r d i n a t e s f i l e . . .
40 [m v o i d ] = s i z e ( i n i c ) ;
41 i n i c ( 1 , 2 ) =( i n i c ( 1 , 2 )+i n i c (m, 2 ) ) / 2 ; %t h e t r a i l i n g edge i s c l o s e d . S o r r y f o r t h e
inconvenience .
42 p e r c o r=i n i c ( 1 :m− 1 , : ) ; %t h e ( now ) e x t r a t r a i l i n g edge p o i n t i s removed .
43 m=m−1; d i s p (m)
44 z0 = 0 ;
45 [ maxx posmaxx ] = max( p e r c o r ( : , 1 ) ) ;
46 [ minx posminx ] = min ( p e r c o r ( : , 1 ) ) ;
47 c u e r d a = maxx−minx ; %computation o f a i r f o i l chord
48 [ maxy posmaxy ] = max( p e r c o r ( : , 2 ) ) ;
49 [ miny posminy ] = min ( p e r c o r ( : , 2 ) ) ;
50
51 f i d = f o p e n ( s t r c a t ( a r c h i , ’ . geo ’ ) , ’w ’ ) ; %o p e n i n g t h e out pu t f i l e
52

Jordi Casacuberta Puig 185


A. Additional codes

53 %w r i t i n g t h e p o i n t s which d e f i n e t h e a i r f o i l
54 f o r i = 1 :m
55 f p r i n t f ( f i d , ’ P o i n t(% i ) =
{%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ , i , p e r c o r ( i , 1 ) , p e r c o r ( i , 2 ) , z0 , c u e r d a / 1 0 0 ) ;
56 end
57
58 %w r i t i n g t h e p o i n t s which d e f i n e t h e e n c l o s i n g s e m i e l l i p s e
59 f p r i n t f ( f i d , ’ P o i n t(% i ) = {%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ ,
m+1 ,minx−c u e r d a / 2 0 , 0 , z0 , c u e r d a / 2 5 ) ;
60 f p r i n t f ( f i d , ’ P o i n t(% i ) = {%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ ,
m+2 ,maxx , maxy+c u e r d a / 4 , z0 , c u e r d a / 2 5 ) ;
61 f p r i n t f ( f i d , ’ P o i n t(% i ) = {%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ ,
m+3 ,maxx , miny−c u e r d a / 4 , z0 , c u e r d a / 2 5 ) ;
62
63 f p r i n t f ( f i d , ’ S p l i n e ( 1 ) = { ’ ) ; %d e f i n i n g an i n t e r p o l a t i n g s p l i n e f o r t h e upper
surface
64 f o r i = posminx :m
65 f p r i n t f ( f i d , ’%i , ’ , i ) ;
66 end
67 %The f o l l o w i n g and a l l t h e l i n e s where you s e e ’ T r a n s f i n i t e ’ i s a way o f
i n d i c a t i n g t o Gmsh t h a t a s t r u c t u r e d mesh w i l l be made .
68 f p r i n t f ( f i d , ’%i } ; T r a n s f i n i t e L i n e {1} = %i Using Bump %f ; \ n ’ , 1 ,N( 1 ) ,bump) ;
69 f p r i n t f ( f i d , ’ S p l i n e ( 2 ) = { ’ ) ; %l o w e r s u r f a c e i n t e r p o l a t i n g s p l i n e
70 f o r i = 1 : posminx −1
71 f p r i n t f ( f i d , ’%i , ’ , i ) ;
72 end
73 f p r i n t f ( f i d , ’%i } ; T r a n s f i n i t e L i n e {2} = %i Using Bump %f ; \ n ’ , posminx ,N( 1 ) ,bump) ;
74
75 %D e f i n i n g t h e l i n e s o f our e n c l o s i n g s e m i e l l i p s e
76 f p r i n t f ( f i d , ’ E l l i p s e ( 3 ) = {%i ,% i ,% i ,% i } ; T r a n s f i n i t e L i n e {3} = %i Using
P r o g r e s s i o n 1 ; \ n ’ , m+1 ,1 , posminx ,m+2 ,N( 1 ) ) ;
77 f p r i n t f ( f i d , ’ E l l i p s e ( 4 ) = {%i ,% i ,% i ,% i } ; T r a n s f i n i t e L i n e {4} = %i Using
P r o g r e s s i o n 1 ; \ n ’ , m+1 ,1 , posminx ,m+3 ,N( 1 ) ) ;
78 %C a l c u l a t i n g minimum c e l l d i s t a n c e from w a l l and g e o m e t r i c p r o g r e s s i o n with
subfunctions
79 Ymin = ypar ( y p l u s , cuerda , Re ,M, T0 , e t e r ) ; Prog5 =
m i n d i s t ( Ymin , norm ( p e r c o r ( posmaxx , : ) −[maxx , maxy+c u e r d a / 4 ] ) ,N( 2 ) ) ;
80 f p r i n t f ( f i d , ’ L i n e ( 5 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {5} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , 1 ,m+2 ,N( 2 ) , Prog5 ) ;
81 Prog6 = m i n d i s t ( Ymin , norm ( p e r c o r ( posmaxx , : ) −[maxx , miny−c u e r d a / 4 ] ) ,N( 2 ) ) ;
82 f p r i n t f ( f i d , ’ L i n e ( 6 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {6} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , 1 ,m+3 ,N( 2 ) , Prog6 ) ;
83 Prog7 = m i n d i s t ( Ymin , norm ( p e r c o r ( posminx , : ) −[minx−c u e r d a / 2 0 , 0 ] ) ,N( 2 ) ) ;
84 f p r i n t f ( f i d , ’ L i n e ( 7 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {7} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , posminx ,m+1 ,N( 2 ) , Prog7 ) ;
85
86 %2D s u r f a c e s a r e c r e a t e d from t h e a v a i l a b l e l i e n s s o f a r
87 f p r i n t f ( fid , ’ L i n e Loop ( 1 ) = { −2 ,5 , −3 , −7};\n ’ ) ;
88 f p r i n t f ( fid , ’ Ruled S u r f a c e ( 1 ) = { 1 } ; \ n ’ ) ;
89 f p r i n t f ( fid , ’ T r a n s f i n i t e S u r f a c e ( 1 ) = {%i ,% i ,% i ,% i } ; \ n ’ , 1 , posminx ,m+1 ,m+2) ;
90 f p r i n t f ( fid , ’ L i n e Loop ( 2 ) = {1 ,6 , −4 , −7};\ n ’ ) ;
91 f p r i n t f ( fid , ’ Ruled S u r f a c e ( 2 ) = { 2 } ; \ n ’ ) ;
92 f p r i n t f ( fid , ’ T r a n s f i n i t e S u r f a c e ( 2 ) = {%i ,% i ,% i ,% i } ; \ n ’ , 1 , posminx ,m+1 ,m+3) ;
93
94 %Let ’ s t e l l Gmsh t o r o t a t e t h e a i r f o i l +s e m i e l i p s e our d e s i r e d a n g l e o f a t t a c k
95 f p r i n t f ( f i d , ’ Rotate { { 0 , 0 , 1 } , { % . 1 0 g , 0 , 0 } , % . 1 0 g } { S u r f a c e { 1 , 2 } ; } \ n ’ ,
minx+c u e r d a / 2 , a l f a ) ;

Jordi Casacuberta Puig 186


OPENFOAM GUIDE FOR BEGINNERS

96
97 %Now some p o i n t s t o d e f i n e t h e f l o w f i e l d b o u n d a r i e s . N o t i c e t h e r e s u l t i n g box w i l l
be 15∗ chord l o n g and 8∗ chord h i g h .
98 f p r i n t f ( f i d , ’ P o i n t(% i ) = {%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ ,
m+4 ,maxx−(1− c o s ( a l f a ) ) ∗ c u e r d a /2− s i n ( a l f a ) ∗ ( c u e r d a /4+maxy ) , 4 ∗ cuerda , z0 , c u e r d a ) ;
99 f p r i n t f ( f i d , ’ P o i n t(% i ) = {%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ ,
m+5 ,minx−2∗ cuerda , 4 ∗ cuerda , z0 , c u e r d a ) ;
100 f p r i n t f ( f i d , ’ P o i n t(% i ) = {%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ ,
m+6 ,minx−4∗ cuerda , 4 ∗ cuerda , z0 , c u e r d a ) ;
101 f p r i n t f ( f i d , ’ P o i n t(% i ) = {%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ ,
m+7 ,minx−4∗ cuerda , 0 − 0 . 5 5 ∗ c u e r d a ∗ s i n ( a l f a ) , z0 , c u e r d a ) ;
102 f p r i n t f ( f i d , ’ P o i n t(% i ) = {%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ ,
m+8 ,minx−4∗ cuerda , −4∗ cuerda , z0 , c u e r d a ) ;
103 f p r i n t f ( f i d , ’ P o i n t(% i ) = {%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ ,
m+9 ,minx−2∗ cuerda , −4∗ cuerda , z0 , c u e r d a ) ;
104 f p r i n t f ( f i d , ’ P o i n t(% i ) = {%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ ,
m+10 ,maxx−(1− c o s ( a l f a ) ) ∗ c u e r d a /2− s i n ( a l f a ) ∗(− c u e r d a /4+miny ) , −4∗ cuerda , z0 , c u e r d a ) ;
105 f p r i n t f ( f i d , ’ P o i n t(% i ) = {%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ ,
m+11 ,maxx+10∗ cuerda , −4∗ cuerda , z0 , c u e r d a ) ;
106 f p r i n t f ( f i d , ’ P o i n t(% i ) = {%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ ,
m+12 ,maxx+10∗ cuerda , p e r c o r ( posmaxx , 2 )+c o s ( a l f a ) ∗ ( miny−c u e r d a / 4 )+c u e r d a /2∗ s i n ( a l f a ) , z0 , c u e r d a ) ;
107 f p r i n t f ( f i d , ’ P o i n t(% i ) = {%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ ,
m+13 ,maxx+10∗ cuerda , s i n ( a l f a ) ∗ c u e r d a / 2 , z0 , c u e r d a ) ;
108 f p r i n t f ( f i d , ’ P o i n t(% i ) = {%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ ,
m+14 ,maxx+10∗ cuerda , p e r c o r ( posmaxx , 2 )+c o s ( a l f a ) ∗ ( maxy+c u e r d a / 4 )+c u e r d a /2∗ s i n ( a l f a ) , z0 , c u e r d a ) ;
109 f p r i n t f ( f i d , ’ P o i n t(% i ) = {%.10 g , % . 1 0 g , % . 1 0 g , % . 1 0 g } ; \ n ’ ,
m+15 ,maxx+10∗ cuerda , 4 ∗ cuerda , z0 , c u e r d a ) ;
110
111 %Now we j o i n t h e p r e v i o u s p o i n t s with some l i n e s
112 Prog =
m i n d i s t ( Ymin∗ Prog7 ˆ (N( 2 ) −1) , abs ( 3 . 9 5 ∗ c u e r d a +(1− c o s ( a l f a ) ) ∗ 0 . 5 5 ∗ c u e r d a ) ,N( 3 ) ) ;
113 f p r i n t f ( f i d , ’ L i n e ( 8 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {8} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , m+1 ,m+7 ,N( 3 ) , Prog ) ;
114
115 Prog = m i n d i s t ( c u e r d a /N( 1 ) , abs ( 1 0 ∗ c u e r d a+(1+ c o s ( a l f a ) ) ∗ 0 . 5 ∗ c u e r d a ) ,N( 3 ) ) ;
116 f p r i n t f ( f i d , ’ L i n e ( 9 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {9} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , 1 ,m+13 ,N( 3 ) , Prog ) ;
117
118 L = 4∗ cuerda −( p e r c o r ( posmaxx , 2 )+c u e r d a / 4 ) ∗ c o s ( a l f a )−c u e r d a /2∗ s i n ( a l f a ) ;
119 Prog = m i n d i s t ( Ymin∗ Prog5 ˆ (N( 2 ) −1) , L ,N( 4 ) ) ;
120 f p r i n t f ( f i d , ’ L i n e ( 1 0 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {10} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , m+2 ,m+4 ,N( 4 ) , Prog ) ;
121
122 L =
norm ( [ minx−c u e r d a ∗ 2 , c u e r d a ∗ 4 ] − [ ( minx−c u e r d a / 2 0 )−(1− c o s ( a l f a ) ) ∗ 0 . 5 5 ∗ cuerda , p e r c o r ( posminx , 2 )−s i n ( a
123 Prog = m i n d i s t ( Ymin∗ Prog7 ˆ (N( 2 ) −1) , L ,N( 4 ) ) ;
124 f p r i n t f ( f i d , ’ L i n e ( 1 1 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {11} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , m+1 ,m+5 ,N( 4 ) , Prog ) ;
125
126 L = 4∗ c u e r d a +(miny−c u e r d a / 4 ) ∗ c o s ( a l f a )+c u e r d a /2∗ s i n ( a l f a ) ;
127 Prog = m i n d i s t ( Ymin∗ Prog6 ˆ (N( 2 ) −1) , L ,N( 4 ) ) ;
128 f p r i n t f ( f i d , ’ L i n e ( 1 2 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {12} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , m+3 ,m+10 ,N( 4 ) , Prog ) ;
129
130 L =
norm ( [ minx−c u e r d a ∗2 , − c u e r d a ∗ 4 ] − [ ( minx−c u e r d a / 2 0 )−(1− c o s ( a l f a ) ) ∗ 0 . 5 5 ∗ cuerda , p e r c o r ( posminx , 2 )−s i n (
131 Prog = m i n d i s t ( Ymin∗ Prog7 ˆ (N( 2 ) −1) , L ,N( 4 ) ) ;

Jordi Casacuberta Puig 187


A. Additional codes

132 f p r i n t f ( f i d , ’ L i n e ( 1 3 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {13} = %i Using P r o g r e s s i o n


%.10 g ; \ n ’ , m+1 ,m+9 ,N( 4 ) , Prog ) ;
133
134 Prog =
m i n d i s t ( c u e r d a /N( 1 ) , abs ( 1 0 ∗ c u e r d a +(1− c o s ( a l f a ) ) ∗ 0 . 5 ∗ c u e r d a+s i n ( a l f a ) ∗ ( maxy+c u e r d a / 4 ) ) ,N( 3 ) ) ;
135 f p r i n t f ( f i d , ’ L i n e ( 1 4 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {14} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , m+2 ,m+14 ,N( 3 ) , Prog ) ;
136
137 Prog =
m i n d i s t ( c u e r d a /N( 1 ) , abs ( 1 0 ∗ c u e r d a +(1− c o s ( a l f a ) ) ∗ 0 . 5 ∗ c u e r d a+s i n ( a l f a ) ∗ ( miny−c u e r d a / 4 ) ) ,N( 3 ) ) ;
138 f p r i n t f ( f i d , ’ L i n e ( 1 5 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {15} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , m+3 ,m+12 ,N( 3 ) , Prog ) ;
139
140 f p r i n t f ( f i d , ’ L i n e ( 1 6 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {16} = %i Using P r o g r e s s i o n
1 . 0 0 ; \ n ’ , m+4 ,m+5 ,N( 1 ) ) ;
141
142 f p r i n t f ( f i d , ’ L i n e ( 1 7 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {17} = %i Using P r o g r e s s i o n
1 . 0 0 ; \ n ’ , m+10 ,m+9 ,N( 1 ) ) ;
143
144 Prog =
m i n d i s t ( ( 3 ∗ cuerda−c u e r d a /2∗ c o s ( a l f a )−s i n ( a l f a ) ∗ ( maxy+c u e r d a / 4 ) ) /N( 1 ) , 2 ∗ cuerda ,N( 3 ) ) ;
145 f p r i n t f ( f i d , ’ L i n e ( 1 8 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {18} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , m+5 ,m+6 ,N( 3 ) , Prog ) ;
146
147 Prog =
m i n d i s t ( ( 3 ∗ cuerda−c u e r d a /2∗ c o s ( a l f a )−s i n ( a l f a ) ∗ ( miny−c u e r d a / 4 ) ) /N( 1 ) , 2 ∗ cuerda ,N( 3 ) ) ;
148 f p r i n t f ( f i d , ’ L i n e ( 1 9 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {19} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , m+9 ,m+8 ,N( 3 ) , Prog ) ;
149
150 Prog = m i n d i s t ( c u e r d a /N( 1 ) , 4 ∗ c u e r d a+c u e r d a ∗ 0 . 5 5 ∗ s i n ( a l f a ) ,N( 4 ) ) ;
151 f p r i n t f ( f i d , ’ L i n e ( 2 0 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {20} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , m+7 ,m+6 ,N( 4 ) , Prog ) ;
152
153 Prog = m i n d i s t ( c u e r d a /N( 1 ) , 4 ∗ cuerda−c u e r d a ∗ 0 . 5 5 ∗ s i n ( a l f a ) ,N( 4 ) ) ;
154 f p r i n t f ( f i d , ’ L i n e ( 2 1 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {21} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , m+7 ,m+8 ,N( 4 ) , Prog ) ;
155
156 Prog =
m i n d i s t ( ( 3 ∗ cuerda−c u e r d a /2∗ c o s ( a l f a )−s i n ( a l f a ) ∗ ( maxy+c u e r d a / 4 ) ) /N( 1 ) , abs ( 1 0 ∗ c u e r d a +(1− c o s ( a l f a ) ) ∗
157 f p r i n t f ( f i d , ’ L i n e ( 2 2 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {22} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , m+4 ,m+15 ,N( 3 ) , Prog ) ;
158
159 Prog =
m i n d i s t ( ( 3 ∗ cuerda−c u e r d a /2∗ c o s ( a l f a )−s i n ( a l f a ) ∗ ( miny−c u e r d a / 4 ) ) /N( 1 ) , abs ( 1 0 ∗ c u e r d a +(1− c o s ( a l f a ) ) ∗
160 f p r i n t f ( f i d , ’ L i n e ( 2 3 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {23} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , m+10 ,m+11 ,N( 3 ) , Prog ) ;
161
162 L = 4∗ c u e r d a +(miny−c u e r d a / 4 ) ∗ c o s ( a l f a )+c u e r d a /2∗ s i n ( a l f a ) ;
163 Prog = m i n d i s t ( Ymin∗ Prog6 ˆ (N( 2 ) −1) , L ,N( 4 ) ) ;
164 f p r i n t f ( f i d , ’ L i n e ( 2 4 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {24} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , m+12 ,m+11 ,N( 4 ) , Prog ) ;
165
166 Prog = m i n d i s t ( Ymin , abs ( miny−c u e r d a / 4 ) ∗ c o s ( a l f a ) ,N( 2 ) ) ;
167 f p r i n t f ( f i d , ’ L i n e ( 2 5 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {25} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , m+13 ,m+12 ,N( 2 ) , Prog ) ;
168
169 Prog = m i n d i s t ( Ymin , abs ( maxy+c u e r d a / 4 ) ∗ c o s ( a l f a ) ,N( 2 ) ) ;

Jordi Casacuberta Puig 188


OPENFOAM GUIDE FOR BEGINNERS

170 f p r i n t f ( f i d , ’ L i n e ( 2 6 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {26} = %i Using P r o g r e s s i o n


%.10 g ; \ n ’ , m+13 ,m+14 ,N( 2 ) , Prog ) ;
171
172 L = 4∗ cuerda −(maxy+c u e r d a / 4 ) ∗ c o s ( a l f a )−c u e r d a /2∗ s i n ( a l f a ) ;
173 Prog = m i n d i s t ( Ymin∗ Prog5 ˆ (N( 2 ) −1) , L ,N( 4 ) ) ;
174 f p r i n t f ( f i d , ’ L i n e ( 2 7 ) = {%i ,% i } ; T r a n s f i n i t e L i n e {27} = %i Using P r o g r e s s i o n
%.10 g ; \ n ’ , m+14 ,m+15 ,N( 4 ) , Prog ) ;
175
176 %2D s u r f a c e s a r e d e f i n e d from t h e p r e v i o u s l i n e s .
177 f p r i n t f ( fid , ’ L i n e Loop ( 3 ) = { 3 , 1 0 , 1 6 , − 1 1 } ; \ n ’ ) ;
178 f p r i n t f ( fid , ’ Ruled S u r f a c e ( 3 ) = { 3 } ; \ n ’ ) ;
179 f p r i n t f ( fid , ’ T r a n s f i n i t e S u r f a c e ( 3 ) = {%i ,% i ,% i ,% i } ; \ n ’ , m+1 ,m+2 ,m+4 ,m+5) ;
180
181 f p r i n t f ( fid , ’ L i n e Loop ( 4 ) = { 4 , 1 2 , 1 7 , − 1 3 } ; \ n ’ ) ;
182 f p r i n t f ( fid , ’ Ruled S u r f a c e ( 4 ) = { 4 } ; \ n ’ ) ;
183 f p r i n t f ( fid , ’ T r a n s f i n i t e S u r f a c e ( 4 ) = {%i ,% i ,% i ,% i } ; \ n ’ , m+1 ,m+3 ,m+10 ,m+9) ;
184
185 f p r i n t f ( fid , ’ L i n e Loop ( 5 ) = { −18 , −11 ,8 ,20};\ n ’ ) ;
186 f p r i n t f ( fid , ’ Ruled S u r f a c e ( 5 ) = { 5 } ; \ n ’ ) ;
187 f p r i n t f ( fid , ’ T r a n s f i n i t e S u r f a c e ( 5 ) = {%i ,% i ,% i ,% i } ; \ n ’ , m+1 ,m+5 ,m+6 ,m+7) ;
188
189 f p r i n t f ( fid , ’ L i n e Loop ( 6 ) = { −19 , −13 ,8 ,21};\ n ’ ) ;
190 f p r i n t f ( fid , ’ Ruled S u r f a c e ( 6 ) = { 6 } ; \ n ’ ) ;
191 f p r i n t f ( fid , ’ T r a n s f i n i t e S u r f a c e ( 6 ) = {%i ,% i ,% i ,% i } ; \ n ’ , m+1 ,m+7 ,m+8 ,m+9) ;
192
193 f p r i n t f ( fid , ’ L i n e Loop ( 7 ) = {5 ,14 , −26 , −9};\ n ’ ) ;
194 f p r i n t f ( fid , ’ Ruled S u r f a c e ( 7 ) = { 7 } ; \ n ’ ) ;
195 f p r i n t f ( fid , ’ T r a n s f i n i t e S u r f a c e ( 7 ) = {%i ,% i ,% i ,% i } ; \ n ’ , m+2 ,m+14 ,m+13 ,1) ;
196
197 f p r i n t f ( fid , ’ L i n e Loop ( 8 ) = {6 ,15 , −25 , −9};\ n ’ ) ;
198 f p r i n t f ( fid , ’ Ruled S u r f a c e ( 8 ) = { 8 } ; \ n ’ ) ;
199 f p r i n t f ( fid , ’ T r a n s f i n i t e S u r f a c e ( 8 ) = {%i ,% i ,% i ,% i } ; \ n ’ , m+3 ,m+12 ,m+13 ,1) ;
200
201 f p r i n t f ( fid , ’ L i n e Loop ( 9 ) = {14 ,27 , −22 , −10};\ n ’ ) ;
202 f p r i n t f ( fid , ’ Ruled S u r f a c e ( 9 ) = { 9 } ; \ n ’ ) ;
203 f p r i n t f ( fid , ’ T r a n s f i n i t e S u r f a c e ( 9 ) = {%i ,% i ,% i ,% i } ; \ n ’ , m+2 ,m+14 ,m+15 ,m+4) ;
204
205 f p r i n t f ( fid , ’ L i n e Loop ( 1 0 ) = {15 ,24 , −23 , −12};\ n ’ ) ;
206 f p r i n t f ( fid , ’ Ruled S u r f a c e ( 1 0 ) = { 1 0 } ; \ n ’ ) ;
207 f p r i n t f ( fid , ’ T r a n s f i n i t e S u r f a c e ( 1 0 ) = {%i ,% i ,% i ,% i } ; \ n ’ , m+3 ,m+10 ,m+11 ,m+12) ;
208
209 f p r i n t f ( f i d , ’ Recombine S u r f a c e { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 1 0 } = 0 ; \ n ’ ) ; %This i s important ,
i t t e l l s Gmsh t o attemp t o j o i n t h e d e f a u l t t r i a n g l e s i n t o q u a d r a n g l e s
( 2 t r i a n g l e s =1q u a d r a n g l e )
210
211 %The n e x t l i n e s e x t r u d e a s m a l l h e i g h t t h e 2D s u r f a c e t o have a one−c e l l −depth
volume , n e c e s s a r y f o r f i n i t e volume c o d e s . I t i s not n e c e s s a r y f o r f i n i t e
e l e m e n t s , but who u s e s them ? :D
212 f p r i n t f ( f i d , ’ j 1 [ ] = Extrude { 0 , 0 , % . 1 0 g } { S u r f a c e { 1 } ; L a y e r s { 1 } ; Recombine ; } ; \ n ’ ,
cuerda /10) ;
213 f p r i n t f ( f i d , ’ j 2 [ ] = Extrude { 0 , 0 , % . 1 0 g } { S u r f a c e { 2 } ; L a y e r s { 1 } ; Recombine ; } ; \ n ’ ,
cuerda /10) ;
214 f p r i n t f ( f i d , ’ j 3 [ ] = Extrude { 0 , 0 , % . 1 0 g } { S u r f a c e { 3 } ; L a y e r s { 1 } ; Recombine ; } ; \ n ’ ,
cuerda /10) ;
215 f p r i n t f ( f i d , ’ j 4 [ ] = Extrude { 0 , 0 , % . 1 0 g } { S u r f a c e { 4 } ; L a y e r s { 1 } ; Recombine ; } ; \ n ’ ,
cuerda /10) ;

Jordi Casacuberta Puig 189


A. Additional codes

216 f p r i n t f ( f i d , ’ j 5 [ ] = Extrude { 0 , 0 , % . 1 0 g } { S u r f a c e { 5 } ; L a y e r s { 1 } ; Recombine ; } ; \ n ’ ,


cuerda /10) ;
217 f p r i n t f ( f i d , ’ j 6 [ ] = Extrude { 0 , 0 , % . 1 0 g } { S u r f a c e { 6 } ; L a y e r s { 1 } ; Recombine ; } ; \ n ’ ,
cuerda /10) ;
218 f p r i n t f ( f i d , ’ j 7 [ ] = Extrude { 0 , 0 , % . 1 0 g } { S u r f a c e { 7 } ; L a y e r s { 1 } ; Recombine ; } ; \ n ’ ,
cuerda /10) ;
219 f p r i n t f ( f i d , ’ j 8 [ ] = Extrude { 0 , 0 , % . 1 0 g } { S u r f a c e { 8 } ; L a y e r s { 1 } ; Recombine ; } ; \ n ’ ,
cuerda /10) ;
220 f p r i n t f ( f i d , ’ j 9 [ ] = Extrude { 0 , 0 , % . 1 0 g } { S u r f a c e { 9 } ; L a y e r s { 1 } ; Recombine ; } ; \ n ’ ,
cuerda /10) ;
221 f p r i n t f ( f i d , ’ j 1 0 [ ] = Extrude { 0 , 0 , % . 1 0 g } { S u r f a c e { 1 0 } ; L a y e r s { 1 } ; Recombine ; } ; \ n ’ ,
cuerda /10) ;
222
223 %Grouping t h e f a c e s and t h e volumes . . .
224 f p r i n t f ( fid , ’ Physical Surface (” i n l e t ”) = { j5 [ 5 ] , j6 [ 5 ] } ; \ n ’ ) ;
225 f p r i n t f ( fid , ’ Physical Surface (” o u t l e t ”) = { j7 [ 4 ] , j8 [ 4 ] , j9 [ 3 ] , j10 [ 3 ] } ; \ n ’ ) ;
226 f p r i n t f ( fid , ’ Physical Surface (” a i r f o i l ”) = { j1 [ 2 ] , j2 [ 2 ] } ; \ n ’ ) ;
227 f p r i n t f ( fid , ’ Physical Surface (” w a l l s ”) =
{ j3 [ 4 ] , j4 [ 4 ] , j5 [ 2 ] , j6 [ 2 ] , j9 [ 4 ] , j10 [ 4 ] } ; \ n ’ ) ;
228 f p r i n t f ( f i d , ’ P h y s i c a l S u r f a c e ( ” symmetry ” ) =
{1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 , j1 [ 0 ] , j2 [ 0 ] , j3 [ 0 ] , j4 [ 0 ] , j5 [ 0 ] , j6 [ 0 ] , j7 [ 0 ] , j8 [ 0 ] , j9 [ 0 ] , j10 [ 0 ] } ; \ n ’ ) ;
229
230 f p r i n t f ( f i d , ’ P h y s i c a l Volume ( ” Volumen ” ) =
{ j1 [ 1 ] , j2 [ 1 ] , j3 [ 1 ] , j4 [ 1 ] , j5 [ 1 ] , j6 [ 1 ] , j7 [ 1 ] , j8 [ 1 ] , j9 [ 1 ] , j10 [ 1 ] } ; \ n ’ ) ;
231
232 fclose ( fid ) ;
233
234 N = N−1;
235 %I n c a s e you wonder , t h e i n f o i s j u s t below :
236 p r i n t f ( ’ The mesh i s made o f %i l i n e a r hexahedra . \ n ’ ,
2 ∗ (N( 1 ) ∗ (N( 2 )+N( 4 ) )+N( 4 ) ∗2∗N( 3 )+N( 2 ) ∗N( 3 ) ) )
237 printf
( ’ \n− − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − \n\n ’ )
238
239 end
240
241
242
243 %%%%%%%%%%−−−−%%%%%%%%%%−−−−%%%%%%%%%%−−−−%%%%%%%%%%−−−−%%%%%%%%%%−−−−%%%%%%%%%%
244
245
246
247 f u n c t i o n Prog = m i n d i s t ( Ymin , L ,N)
248
249 %For a l i n e o f l e n g t h L t o be d i s c r e t i z e d i n N e l e m e n t s , o f which t h e s h o r t e s t i s
a t t h e b e g g i n i n g and has a l e n g t h Ymin , we compute t h e Prog such t h a t
L=Ymin∗sum ( Prog ˆn , from n=0 t o n=N) . Ymin can be but i s not l i m i t e d t o t h e
Ymin d e f i n e d i n t h e n e x t f u n c t i o n .
250
251 e = 1;
252 Prog = 1 . 0 0 1 ;
253
254 while e > 0.001
255
256 P r o g t = Prog +
( ( Prog ˆ4−2∗ Progˆ3+Prog ˆ 2 ) ∗L+(Progˆ3−Progˆ2+Prog ˆN∗ ( Prog−Prog ˆ 2 ) ) ∗Ymin ) / ( ( Prog −1)∗ Prog ˆN∗Ymin∗N+
257 e = abs ( ( P r o g t −Prog ) / Prog ) ;

Jordi Casacuberta Puig 190


OPENFOAM GUIDE FOR BEGINNERS

258 Prog = P r o g t ;
259
260 end
261
262 i f Prog < 1
263
264 Prog = 1 ;
265
266 end
267
268 end
269
270
271
272 %%%%%%%%%%−−−−%%%%%%%%%%−−−−%%%%%%%%%%−−−−%%%%%%%%%%−−−−%%%%%%%%%%−−−−%%%%%%%%%%
273
274
275
276 f u n c t i o n Ymin = ypar ( y p l u s , cuerda , Re ,M, T0 , e t e r )
277
278 %This f u n c t i o n computes t h e minimum c e l l d i s t a n c e from a w a l l , a c c o r d i n g t o
equations f o r turbulent flow over a f l a t p l a t e at zero i n c i d e n c e . I t a l s o
computes some bonus data t o d e f i n e s i m u l a t i o n p a r a m e t e r s .
279
280 switch eter
281
282 case ’a ’
283 T = T0/ ( 1 + 0 . 2 ∗Mˆ 2 ) ;
284 V = M∗ s q r t ( 1 . 4 ∗ 2 8 7 . 0 7 4 ∗T) ;
285 muT = 1 . 4 5 8 e −6∗Tˆ 1 . 5 / ( 1 1 0 . 4 +T) ;
286 rho = Re∗muT/ (V∗ c u e r d a ) ;
287 P = rho ∗ 2 8 7 . 0 7 4 ∗T ;
288 P0 = P∗ ( T0/T) ˆ ( 1 . 4 / 0 . 4 ) ;
289 printf
( ’ \n− − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − \n\
290 p r i n t f ( ’ Medium : a i r \nRe = %g \ nChord = %f [m] \ n D e n s i t y = %g [ Kg/mˆ 3 ] \ nDynamic
v i s c o s i t y = %g [ Kg/ ( ms ) ] \ n F r e e s t r e a m s p e e d = %f [m/ s ] \ n F r e e s t r e a m Mach =
%f \ n S t a t i c p r e s s u r e ( a b s o l u t e ) = %f [ Pa ] \ n S t a g n a t i o n p r e s s u r e = %f
[ Pa ] \ nTemperature = %f [K] \ n S t a g n a t i o n t e m e p r a t u r e = %f [K] \ nY+ = %f \n\n ’ ,
Re , cuerda , rho , muT, V,M, P , P0 , T, T0 , y p l u s )
291
292 case ’n ’
293 T = T0/ ( 1 + 0 . 2 ∗Mˆ 2 ) ;
294 V = M∗ s q r t ( 1 . 4 ∗ 2 9 7 ∗T) ;
295 muT = 1 . 7 8 1 e −5∗(111+300.55) /(111+T) ∗ (T/ 3 0 0 . 5 5 ) ˆ 1 . 5 ;
296 rho = Re∗muT/ (V∗ c u e r d a ) ;
297 P = rho ∗297∗T ;
298 P0 = P∗ ( T0/T) ˆ ( 1 . 4 / 0 . 4 ) ;
299 printf
( ’ \n− − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − \n\
300 p r i n t f ( ’ Medium : n i t r o g e n \nRe = %g \ nChord = %f [m] \ n D e n s i t y = %g
[ Kg/mˆ 3 ] \ nDynamic v i s c o s i t y = %g [ Kg/ ( ms ) ] \ n F r e e s t r e a m s p e e d = %f
[m/ s ] \ n F r e e s t r e a m Mach = %f \ n S t a t i c p r e s s u r e ( a b s o l u t e ) = %f
[ Pa ] \ n S t a g n a t i o n p r e s s u r e = %f [ Pa ] \ nTemperature = %f [K] \ n S t a g n a t i o n
t e m p e r a t u r e = %f [K] \ nY+ = %f \n\n ’ , Re , cuerda , rho , muT, V,M, P , P0 , T, T0 , y p l u s )
301
302 case ’h ’

Jordi Casacuberta Puig 191


A. Additional codes

303 V = M;
304 rho = 1000∗(1 −(T0+ 2 8 8 . 9 4 1 4 ) / ( 5 0 8 9 2 9 . 2 ∗ ( T0+ 6 8 . 1 2 9 6 3 ) ) ∗ ( T0− 3 . 9 8 6 3 ) ˆ 2 ) ;
305 muT = rho ∗V∗ c u e r d a /Re ;
306 printf
( ’ \n− − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − \n\
307 p r i n t f ( ’ Medium : water \nRe = %g \ nChord = %f [m] \ n D e n s i t y = %g
[ Kg/mˆ 3 ] \ nDynamic v i s c o s i t y = %g [ Kg/ ( ms ) ] \ n F r e e s t r e a m s p e e d = %f
[m/ s ] \ nTemperature = %f [K] \ nY+ = %f \n\n ’ , Re , cuerda , rho , muT, V, y p l u s )
308
309 end
310
311 Cf = 0 . 0 2 ;
312
313 w h i l e i <10
314
315 f u n c i o n = 4 . 1 5 ∗ s q r t ( Cf ) ∗ l o g 1 0 ( Re∗ Cf ) +1.7∗ s q r t ( Cf ) − 1 . 0 ;
316 d e r f u n c = ( 4 . 1 5 ∗ l o g 1 0 ( exp ( 1 . 0 ) ) + 0 . 5 ∗ 4 . 1 5 ∗ l o g 1 0 ( Re∗ Cf ) + 1 . 7 / 2 . 0 ) / s q r t ( Cf ) ;
317 fsd = funcion / derfunc ;
318
319 i f abs ( f s d / Cf ) <= exp ( − 5 . 0 )
320 break
321 end
322
323 Cfo = Cf−f s d ;
324
325 i f Cfo <= 0 . 0
326 Cf = 0 . 5 ∗ Cf ;
327 else
328 Cf = Cfo ;
329 end
330
331 i=i +1;
332
333 end
334
335 %Cfo = ( 1 . / ( 4 . 1 5 ∗ l o g 1 0 ( Re∗ Cf ) +1.7) ) ˆ 2 ;
336 %tau = 0 . 5 ∗ rho ∗V∗V∗ Cf
337 %aus = s q r t ( tau / rho )
338
339 Ymin = y p l u s ∗muT/ (V∗ s q r t ( Cf / 2 ) ) ;
340
341 p r i n t f ( ’ To o b t a i n CFL(max) <= 20 a c r o s s t h e whole f l o w f i e l d , a t i m e s t e p dt <=
%.10 g s i s recomended f o r t r a n s i e n t s i m u l a t i o n s . \ n\n ’ , 20∗Ymin/V)
342 p r i n t f ( ’ The f o l l o w i n g v a l u e s a r e recomended t o i n i t i a l i z e e x t e r n a l f l o w f i e l d
v a r i a b l e s : \ nK = %g [mˆ2/ s ˆ 2 ] \ n E p s i l o n = %g [mˆ2/ s ˆ 3 ] \ nOmega = %g
[ 1 / s ] \ nTurbulent i n t e n s i t y = 6 . 6 6 6 7 e−7 [%%]\ n H y d r a u l i c d i a m e t e r = %f [m] \ n\n ’ ,
1 e −6∗Vˆ 2 , 4 . 5 e −7∗Vˆ3/ cuerda , 0 . 4 5 ∗V/ cuerda , 0 . 0 0 5 2 1 6 4 ∗ c u e r d a )
343
344 end

Jordi Casacuberta Puig 192


OPENFOAM GUIDE FOR BEGINNERS

Bibliography
[1] OpenFOAM, the open source CFD toolbox User Guide. OpenFOAM, 2013.

[2] B Mutlu Sumer and Jorgen Fredsoe. Hydrodynamics around cylindrical struc-
tures. World Scientific, 2006.

Jordi Casacuberta Puig 193

You might also like