-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRANS.usr
240 lines (201 loc) · 6.86 KB
/
RANS.usr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
c-----------------------------------------------------------------------
c nek5000 user-file template
c
c user specified routines:
c - uservp : variable properties
c - userf : local acceleration term for fluid
c - userq : local source term for scalars
c - userbc : boundary conditions
c - useric : initial conditions
c - userchk : general purpose routine for checking errors etc.
c - userqtl : thermal divergence for lowMach number flows
c - usrdat : modify element vertices
c - usrdat2 : modify mesh coordinates
c - usrdat3 : general purpose routine for initialization
c
c-----------------------------------------------------------------------
include "experimental/rans_komg.f"
include "/home/dshaver/NEKSOURCE/usrcode/limits.f"
include "/home/dshaver/NEKSOURCE/usrcode/utilities.f"
include "/home/dshaver/NEKSOURCE/usrcode/blunt_profile.f"
c-----------------------------------------------------------------------
subroutine uservp(ix,iy,iz,eg) ! set variable properties
implicit none
include 'SIZE'
include 'TOTAL'
include 'NEKUSE'
integer ix,iy,iz,e,eg
real rans_mut,rans_mutsk,rans_mutso,rans_turbPrandtl
real mu_t,Pr_t
e = gllel(eg)
Pr_t=rans_turbPrandtl()
mu_t=rans_mut(ix,iy,iz,e)
if(ifield.eq.1) then
t(ix,iy,iz,e,4)=mu_t/cpfld(ifield,1) !store eddy viscosity for post processing
udiff = cpfld(ifield,1)+mu_t
utrans = cpfld(ifield,2)
elseif(ifield.eq.2) then
udiff = cpfld(ifield,1)+mu_t*cpfld(ifield,2)/(Pr_t*cpfld(1,2))
utrans = cpfld(ifield,2)
elseif(ifield.eq.3) then !use rho and mu from field 1
udiff = cpfld(1,1)+rans_mutsk(ix,iy,iz,e)
utrans = cpfld(1,2)
elseif(ifield.eq.4) then !use rho and mu from field 1
udiff = cpfld(1,1)+rans_mutso(ix,iy,iz,e)
utrans = cpfld(1,2)
endif
return
end
c-----------------------------------------------------------------------
subroutine userf(ix,iy,iz,eg) ! set acceleration term
implicit none
include 'SIZE'
include 'TOTAL'
include 'NEKUSE'
c
c Note: this is an acceleration term, NOT a force!
c Thus, ffx will subsequently be multiplied by rho(x,t).
c
integer ix,iy,iz,e,eg
c e = gllel(eg)
ffx = 0.0
ffy = 0.0
ffz = 0.0
return
end
c-----------------------------------------------------------------------
subroutine userq(ix,iy,iz,eg) ! set source term
implicit none
include 'SIZE'
include 'TOTAL'
include 'NEKUSE'
integer ix,iy,iz,e,eg
real rans_kSrc,rans_omgSrc
real rans_kDiag,rans_omgDiag
e = gllel(eg)
if(ifield.eq.3) then
qvol = rans_kSrc(ix,iy,iz,e)
avol = rans_kDiag(ix,iy,iz,e)
elseif(ifield.eq.4) then
qvol = rans_omgSrc(ix,iy,iz,e)
avol = rans_omgDiag(ix,iy,iz,e)
else
qvol = 0.0
endif
return
end
c-----------------------------------------------------------------------
subroutine userbc(ix,iy,iz,iside,eg) ! set up boundary conditions
implicit none
include 'SIZE'
include 'TOTAL'
include 'NEKUSE'
c
c NOTE ::: This subroutine MAY NOT be called by every process
c
integer ix,iy,iz,iside,e,eg
C U, TKE, and Omg are all zero on the wall
ux = 0.0
uy = 0.0
uz = 0.0
temp = 0.0
return
end
c-----------------------------------------------------------------------
subroutine useric(ix,iy,iz,eg) ! set up initial conditions
implicit none
include 'SIZE'
include 'TOTAL'
include 'NEKUSE'
integer ix,iy,iz,e,eg
e = gllel(eg)
ux = 1.0
uy = 0.0
uz = 0.0
temp = 0.0
if(ifield.eq.3) temp = 0.01
if(ifield.eq.4) temp = 0.2
return
end
c-----------------------------------------------------------------------
subroutine userchk()
implicit none
include 'SIZE'
include 'TOTAL'
return
end
c-----------------------------------------------------------------------
subroutine userqtl ! Set thermal divergence
call userqtl_scig
return
end
c-----------------------------------------------------------------------
subroutine usrdat() ! This routine to modify element vertices
implicit none
include 'SIZE'
include 'TOTAL'
C enforce constant average velocity
param(54) = -1
param(55) = 1.0
c suppress runtime statistics
param(120) = nsteps
return
end
c-----------------------------------------------------------------------
subroutine usrdat2() ! This routine to modify mesh coordinates
implicit none
include 'SIZE'
include 'TOTAL'
real wd
common /walldist/ wd(lx1,ly1,lz1,lelv)
integer n,iel,ifc,id_face
real xmin,xmax,ymin,ymax,scaley,scalex
real glmin,glmax
integer ifld_k,ifld_t,m_id,w_id
real coeffs(30) !array for passing custom coeffs to RANS model
logical ifcoeffs !flag to use custom or default coeffs
n=nx1*ny1*nz1*nelv
C set BCs for velocity and temperature for 3rd party mesh
C tke and omega/tau are handled by rans_init
C do this BEFORE calling rans_init
c do iel=1,nelv
c do ifc=1,2*ndim
c id_face = boundaryID(ifc,iel)
c if (id_face.eq.1) then ! dirichlet (inlet) BCs
c cbc(ifc,iel,1) = 'v '
c cbc(ifc,iel,2) = 't '
c elseif (id_face.eq.2) then ! Wall / heat flux BCs
c cbc(ifc,iel,1) = 'W '
c cbc(ifc,iel,2) = 'f '
c elseif (id_face.eq.3) then ! Outlet BCs
c cbc(ifc,iel,1) = 'O '
c cbc(ifc,iel,2) = 'I '
c endif
c enddo
c enddo
C Setup RANS model, this MUST be done in usrdat2
ifld_k = 3 !field number for tke, t(1,1,1,1,ifld_k-1)
ifld_t = 4 !field number for omega/tau, t(1,1,1,1,ifld_t-1)
ifcoeffs = .false. !set to true to pass custom coefficients
C Available models:
c m_id = 0 !regularized standard k-omega
c m_id = 1 !regularized low-Re k-omega
c m_id = 2 !regularized standard k-omega SST
c m_id = 3 !non-regularized standard k-omega (NOT SUPPORTED)
m_id = 4 !standard k-tau
c m_id = 5 !low-Re k-tau
C Wall distance function:
c w_id = 0 ! user specified
c w_id = 1 ! cheap_dist (path to wall, may work better for periodic boundaries)
w_id = 2 ! distf (coordinate difference, provides smoother function)
call rans_init(ifld_k,ifld_t,ifcoeffs,coeffs,w_id,wd,m_id)
return
end
c-----------------------------------------------------------------------
subroutine usrdat3()
implicit none
include 'SIZE'
include 'TOTAL'
return
end
C-----------------------------------------------------------------------