-
Notifications
You must be signed in to change notification settings - Fork 3
/
TestCases.f90
178 lines (137 loc) · 4.65 KB
/
TestCases.f90
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
module LBM_Test_Cases
!! Contains routines for constructing predefined test cases
!
!
use iso_fortran_env, only: sp=> real32
implicit none
contains
subroutine get_case_lid_cavity(ni,nj,npts,dx,dt,tau,bcFlags,velocities)
!! Flow in square lid-driven cavity
!
integer, intent(in) :: ni !! No. of points in i direction
integer, intent(out) :: nj !! j directions
integer, intent(out) :: npts !! Always ni*nj
real(sp), intent(out) :: dx !! Grid spacing
real(sp), intent(out) :: dt !! Timestep
real(sp), intent(out) :: tau !! Viscosity parameter
integer, intent(out), allocatable :: bcFlags(:)
!! Boundary condition flags (ni x nj)
real(sp), intent(out), allocatable :: velocities(:)
!! Velocity boundary condition vectors (2 x n)
integer :: i, j
nj = ni
npts = ni*nj
allocate(bcFlags(npts))
allocate(velocities(2))
bcFlags = 0
do i=1,ni
do j=1,nj
if (i==1 .or. i==ni .or. j==1) then
bcFlags( (i-1)*nj+j ) = -1; ! No slip
end if
if (j==nj) then
bcFlags( (i-1)*nj+j ) = 1; ! Moving
end if
end do
end do
velocities = [0.5, 0.0]
dx = 0.1
dt = 1
tau = 0.6
end subroutine get_case_lid_cavity
! -----------------------------------------------------------------------------
subroutine get_case_cylinder(ni,d,AR,nj,npts,dx,dt,tau,bcFlags,velocities)
!! Separating flow around a cylinder
!
integer, intent(in) :: ni !! No. of points in i direction
real(sp), intent(in) :: d !! Diameter of cylinder
real(sp), intent(in) :: AR !! Domain aspect ratio
integer, intent(out) :: nj !! No. of points in j direction
integer, intent(out) :: npts !! Always ni*nj
real(sp), intent(out) :: dx !! Grid spacing
real(sp), intent(out) :: dt !! Timestep
real(sp), intent(out) :: tau !! Viscosity parameter
integer, intent(out), allocatable :: bcFlags(:)
!! Boundary condition flags (ni x nj)
real(sp), intent(out), allocatable :: velocities(:)
!! Velocity boundary condition vectors (2 x n)
integer :: i, j
real(sp) :: r, radius
real(sp) :: cx, cy
radius = d/2
nj = int(ni/AR)
npts = ni*nj
allocate(bcFlags(npts))
allocate(velocities(2))
cx = 40+radius
cy = (nj)/2
bcFlags = 0
do i=1,ni
do j=1,nj
if (i==1) then ! Inlet
bcFlags( (i-1)*nj+j ) = 1
end if
if (i==ni) then ! Outlet
bcFlags( (i-1)*nj+j ) = -2 ! Extrapolate
end if
if (j==1 .or. j==nj) then
bcFlags( (i-1)*nj+j ) = -1
end if
r = sqrt( (i-cx)**2 + (j-cy)**2 )
if (r < radius) then
bcFlags( (i-1)*nj+j ) = -1
end if
end do
end do
velocities = [0.15, 0.0]
dx = 1.0
dt = 0.5
tau = 0.50001
end subroutine get_case_cylinder
! -----------------------------------------------------------------------------
subroutine get_case_step(ni,AR,h,nj,npts,dx,dt,tau,bcFlags,velocities) !! Flow over a square step
!
integer, intent(in) :: ni !! No. of points in i direction
real(sp), intent(in) :: AR !! Domain aspect ratio, default 4.0
real(sp), intent(in) :: h !! Step height % of domain, default = 0.25
integer, intent(out) :: nj !! No. of points in j direction
integer, intent(out) :: npts !! Always ni*nj
real(sp), intent(out) :: dx !! Grid spacing
real(sp), intent(out) :: dt !! Timestep
real(sp), intent(out) :: tau !! Viscosity parameter
integer, intent(out), allocatable :: bcFlags(:)
!! Boundary condition flags (ni x nj)
real(sp), intent(out), allocatable :: velocities(:)
!! Velocity boundary condition vectors (2 x n)
integer :: i, j, nh
nj = int(ni/AR)
npts = ni*nj
nh = int(h*min(ni,nj))
allocate(bcFlags(npts))
allocate(velocities(2))
bcFlags = 0
do i=1,ni
do j=1,nj
if (i==1 .or. i==ni .or. j==nj) then
bcFlags( (i-1)*nj+j ) = 1; ! Moving
end if
if (j==1) then
bcFlags( (i-1)*nj+j ) = -1; ! Wall
end if
end do
end do
do i=1,ni
do j=1,nj
! No slip
if (i<(ni+nh)/2 .and. i>(ni-nh)/2 .and. j<nh) then
bcFlags( (i-1)*nj+j ) = -1 ! Wall
end if
end do
end do
velocities = [0.15, 0.0]
dx = 0.5
dt = 0.5
tau = 0.6
end subroutine get_case_step
! -----------------------------------------------------------------------------
end module LBM_Test_Cases