Skip to content

Commit f283006

Browse files
committed
added more logical tweaking for the grid clustering
1 parent c8881cb commit f283006

File tree

25 files changed

+77
-48
lines changed

25 files changed

+77
-48
lines changed

docs/INFO_INPUT.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Consider the following input file as example (corresponds to a turbulent plane c
55
~~~
66
512 256 144 ! itot, jtot, ktot
77
6. 3. 1. ! lx, ly, lz
8-
0. ! gr
8+
0 1. ! gtype, gr
99
.95 1.0e5 ! cfl, dtmin
1010
5640. ! visci
1111
poi ! inivel
@@ -34,14 +34,19 @@ T F F ! is_forced(1:3)
3434
~~~
3535
512 256 144 ! itot, jtot, ktot
3636
6. 3. 1. ! lx, ly, lz
37-
0. ! gr
37+
0 0. ! gtype, gr
3838
~~~
3939

4040
These lines set the computational grid.
4141

4242
`itot, jtot, ktot ` and `lx, ly, lz` are the **number of points** and **domain length** in each direction.
4343

44-
`gr` is a **grid stretching parameter** that tweaks the non-uniform grid in the third direction; zero `gr` implies no stretching. See `initgrid.f90` for more details.
44+
`gtype` and `gr` are the **grid stretching type** and **grid stretching parameter** that tweak the non-uniform grid in the third direction; zero `gr` implies no stretching. See `initgrid.f90` for more details. The following options are available for `gtype`:
45+
46+
* `0`: grid clustered towards both ends (default)
47+
* `1`: grid clustered towards the lower end
48+
* `2`: grid clustered towards the upper end
49+
* `3`: grid clustered towards the middle
4550

4651
---
4752

@@ -106,9 +111,9 @@ These lines set the simulation termination criteria and whether the simulation s
106111

107112
`stop_type` sets which criteria for terminating the simulation are to be used (more than one can be selected, and at least one of them must be `T`)
108113

109-
* `stop_type(1)`, if true (`T`), the simulation will terminate after `nstep` time steps have been simulated;
110-
* `stop_type(2)`, if true (`T`), the simulation will terminate after `time_max` physical time units have been reached;
111-
* `stop_type(3)`, if true (`T`), the simulation will terminate after `tw_max` simulation wall-clock time (in hours) has been reached;
114+
* `stop_type(1)`, if true (`T`), the simulation will terminate after `nstep` time steps have been simulated
115+
* `stop_type(2)`, if true (`T`), the simulation will terminate after `time_max` physical time units have been reached
116+
* `stop_type(3)`, if true (`T`), the simulation will terminate after `tw_max` simulation wall-clock time (in hours) has been reached
112117

113118
a checkpoint file `fld.bin` will be saved before the simulation is terminated.
114119

@@ -126,12 +131,12 @@ a checkpoint file `fld.bin` will be saved before the simulation is terminated.
126131

127132
These lines set the frequency of time step checking and output:
128133

129-
* every `icheck` time steps **the new time step size** is computed according to the new stability criterion and cfl (above);
130-
* every `iout0d` time steps **history files with global scalar variables** are appended; currently the forcing pressure gradient and time step history are reported;
131-
* every `iout1d` time steps **1d profiles** are written (e.g. velocity and its moments) to a file;
132-
* every `iout2d` time steps **2d slices of a 3d scalar field** are written to a file;
133-
* every `iout3d` time steps **3d scalar fields** are written to a file;
134-
* every `isave` time steps a **checkpoint file** is written (`fld_???????.bin`), and a symbolic link for the restart file, `fld.bin`, will point to this last save so that, by default, the last saved checkpoint file is used to restart the simulation.
134+
* every `icheck` time steps **the new time step size** is computed according to the new stability criterion and cfl (above)
135+
* every `iout0d` time steps **history files with global scalar variables** are appended; currently the forcing pressure gradient and time step history are reported
136+
* every `iout1d` time steps **1d profiles** are written (e.g. velocity and its moments) to a file
137+
* every `iout2d` time steps **2d slices of a 3d scalar field** are written to a file
138+
* every `iout3d` time steps **3d scalar fields** are written to a file
139+
* every `isave` time steps a **checkpoint file** is written (`fld_???????.bin`), and a symbolic link for the restart file, `fld.bin`, will point to this last save so that, by default, the last saved checkpoint file is used to restart the simulation
135140

136141
1d, 2d and 3d outputs can be tweaked modifying files `out?d.h90`, and re-compiling the source. See also `output.f90` for more details.
137142

@@ -152,17 +157,17 @@ These lines set the boundary conditions (BC).
152157

153158
The **type** (BC) for each field variable are set by a row of six characters, `X0 X1 Y0 Y1 Z0 Z1` where,
154159

155-
* `X0` `X1` set the type of BC the field variable for the **lower** and **upper** boundaries in `x`;
156-
* `Y0` `Y1` set the type of BC the field variable for the **lower** and **upper** boundaries in `y`;
157-
* `Z0` `Z1` set the type of BC the field variable for the **lower** and **upper** boundaries in `z`.
160+
* `X0` `X1` set the type of BC the field variable for the **lower** and **upper** boundaries in `x`
161+
* `Y0` `Y1` set the type of BC the field variable for the **lower** and **upper** boundaries in `y`
162+
* `Z0` `Z1` set the type of BC the field variable for the **lower** and **upper** boundaries in `z`
158163

159164
The four rows correspond to the three velocity components, and pressure, i.e. `u`, `v`, `w`, and `p`.
160165

161166
The following options are available:
162167

163-
* `P` periodic;
164-
* `D` Dirichlet;
165-
* `N` Neumann.
168+
* `P` periodic
169+
* `D` Dirichlet
170+
* `N` Neumann
166171

167172
The **last four rows** follow the same logic, but now for the BC **values** (dummy for a periodic direction).
168173

examples/_manuscript_lid_driven_cavity/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
128 128 128 ! itot, jtot, ktot
22
1. 1. 1. ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
1000. ! visci
66
zer ! inivel

examples/_manuscript_taylor_green_vortex/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
512 512 512 ! itot, jtot, ktot
22
6.2831853071795 6.283185307179586 6.283185307179586 ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
1600. ! visci
66
tgv ! inivel

examples/_manuscript_turbulent_channel/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
512 256 144 ! itot, jtot, ktot
22
6. 3. 1. ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
5640. ! visci
66
poi ! inivel

examples/_manuscript_turbulent_duct/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
512 128 128 ! itot, jtot, ktot
22
10. 1. 1. ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
4410. ! visci
66
poi ! inivel

examples/closed_box/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
64 64 64 ! itot, jtot, ktot
22
1. 1. 1. ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
1000. ! visci
66
zer ! inivel

examples/couette/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
64 64 64 ! itot, jtot, ktot
22
1. 1.5 1. ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
1000. ! visci
66
cou ! inivel

examples/developing_channel/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
64 64 64 ! itot, jtot, ktot
22
1. 1.5 1. ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
1000. ! visci
66
zer ! inivel

examples/developing_duct/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
64 64 64 ! itot, jtot, ktot
22
1. 1.5 1. ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
1000. ! visci
66
zer ! inivel

examples/half_channel/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
64 64 64 ! itot, jtot, ktot
22
1. 1.5 1. ! lx, ly, lz
3-
0. ! gr
3+
1 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
1000. ! visci
66
hcl ! inivel

examples/lid_driven_cavity/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
64 64 64 ! itot, jtot, ktot
22
1. 1. 1. ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
1000. ! visci
66
zer ! inivel

examples/periodic_channel/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
64 64 64 ! itot, jtot, ktot
22
3. 1.5 1. ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
1000. ! visci
66
log ! inivel

examples/periodic_duct/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
64 64 64 ! itot, jtot, ktot
22
3. 1.5 1. ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
1000. ! visci
66
log ! inivel

examples/taylor_green_vortex_2d/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
32 32 4 ! itot, jtot, ktot
22
6.2831853071795 6.283185307179586 0.125 ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype, gr
44
.95 0.1 ! cfl, dtmin
55
100. ! visci
66
tgw ! inivel

examples/temporal_boundary_layer/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
128 128 256 ! itot, jtot, ktot
22
40. 20. 72. ! lx, ly, lz
3-
4. ! gr
3+
1 4. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
500. ! visci
66
tbl ! inivel

examples/triperiodic/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
64 64 64 ! itot, jtot, ktot
22
1. 1. 1. ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
1000. ! visci
66
zer ! inivel

examples/turbulent_channel_constant_pressure_gradient/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
512 256 144 ! itot, jtot, ktot
22
12. 6. 2. ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
180. ! visci
66
pdc ! inivel

examples/turbulent_channel_convective_reference_frame/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
512 256 144 ! itot, jtot, ktot
22
6. 3. 1. ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
5640. ! visci
66
iop ! inivel

examples/turbulent_half_channel_constant_pressure_gradient/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
512 256 72 ! itot, jtot, ktot
22
12. 6. 1. ! lx, ly, lz
3-
0. ! gr
3+
1 0. ! gtype, gr
44
.95 1.e5 ! cfl, dtmin
55
180. ! visci
66
hdc ! inivel

src/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
64 64 64 ! itot, jtot, ktot
22
3. 1.5 1. ! lx, ly, lz
3-
1. ! gr
3+
0 1. ! gtype, gr
44
.95 1.0e5 ! cfl, dtmin
55
1000. ! visci
66
poi ! inivel

src/initgrid.f90

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,30 @@ module mod_initgrid
1111
private
1212
public initgrid
1313
contains
14-
subroutine initgrid(inivel,n,gr,lz,dzc,dzf,zc,zf)
14+
subroutine initgrid(gtype,n,gr,lz,dzc,dzf,zc,zf)
1515
!
1616
! initializes the non-uniform grid along z
1717
!
1818
implicit none
19-
character(len=3), intent(in) :: inivel
20-
integer , intent(in ) :: n
19+
integer, parameter :: CLUSTER_TWO_END = 0, &
20+
CLUSTER_ONE_END = 1, &
21+
CLUSTER_ONE_END_R = 2, &
22+
CLUSTER_MIDDLE = 3
23+
integer , intent(in ) :: gtype,n
2124
real(rp), intent(in ) :: gr,lz
2225
real(rp), intent(out), dimension(0:n+1) :: dzc,dzf,zc,zf
2326
real(rp) :: z0
2427
integer :: k
2528
procedure (), pointer :: gridpoint => null()
26-
select case(inivel)
27-
case('zer','log','poi','cou','iop','pdc')
29+
select case(gtype)
30+
case(CLUSTER_TWO_END)
2831
gridpoint => gridpoint_cluster_two_end
29-
case('hcl','hcp','hdc','tbl')
32+
case(CLUSTER_ONE_END)
3033
gridpoint => gridpoint_cluster_one_end
34+
case(CLUSTER_ONE_END_R)
35+
gridpoint => gridpoint_cluster_one_end_r
36+
case(CLUSTER_MIDDLE)
37+
gridpoint => gridpoint_cluster_middle
3138
case default
3239
gridpoint => gridpoint_cluster_two_end
3340
end select
@@ -102,6 +109,20 @@ subroutine gridpoint_cluster_one_end(alpha,z0,z)
102109
z = z0
103110
end if
104111
end subroutine gridpoint_cluster_one_end
112+
subroutine gridpoint_cluster_one_end_r(alpha,r0,r)
113+
!
114+
! clustered at the upper side
115+
!
116+
implicit none
117+
real(rp), intent(in ) :: alpha,r0
118+
real(rp), intent(out) :: r
119+
if(alpha /= 0._rp) then
120+
r = 1._rp-1.0_rp*(1._rp+tanh((1._rp-r0-1.0_rp)*alpha)/tanh(alpha/1._rp))
121+
!r = 1._rp-1.0_rp*(1._rp+erf( (1._rp-r0-1.0_rp)*alpha)/erf( alpha/1._rp))
122+
else
123+
r = r0
124+
end if
125+
end subroutine gridpoint_cluster_one_end_r
105126
subroutine gridpoint_cluster_middle(alpha,z0,z)
106127
!
107128
! clustered in the middle

src/main.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ program cans
5555
cfl,dtmin, &
5656
inivel, &
5757
dims, &
58-
gr, &
58+
gtype,gr, &
5959
is_forced,velf,bforce, &
6060
ng,l,dl,dli, &
6161
read_input
@@ -209,7 +209,7 @@ program cans
209209
if(myid == 0) print*, '*** Beginning of simulation ***'
210210
if(myid == 0) print*, '*******************************'
211211
if(myid == 0) print*, ''
212-
call initgrid(inivel,ng(3),gr,lz,dzc_g,dzf_g,zc_g,zf_g)
212+
call initgrid(gtype,ng(3),gr,lz,dzc_g,dzf_g,zc_g,zf_g)
213213
if(myid == 0) then
214214
inquire(iolength=rlen) 1._rp
215215
open(99,file=trim(datadir)//'grid.bin',access='direct',recl=4*ng(3)*rlen)

src/param.f90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ module mod_param
2828
! variables to be determined from the input file 'dns.in'
2929
!
3030
integer , protected :: itot,jtot,ktot
31-
real(rp), protected :: lx,ly,lz,dx,dy,dz,dxi,dyi,dzi,gr
31+
real(rp), protected :: lx,ly,lz,dx,dy,dz,dxi,dyi,dzi
32+
integer , protected :: gtype
33+
real(rp), protected :: gr
3234
real(rp), protected :: cfl,dtmin
3335
real(rp), protected :: visci
3436
!
@@ -81,7 +83,7 @@ subroutine read_input(myid)
8183
if( ierr == 0 ) then
8284
read(iunit,*,iostat=ierr) itot,jtot,ktot
8385
read(iunit,*,iostat=ierr) lx,ly,lz
84-
read(iunit,*,iostat=ierr) gr
86+
read(iunit,*,iostat=ierr) gtype,gr
8587
read(iunit,*,iostat=ierr) cfl,dtmin
8688
read(iunit,*,iostat=ierr) visci
8789
read(iunit,*,iostat=ierr) inivel

src/solver.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ subroutine solver(n,ng,arrplan,normfft,lambdaxy,a,b,c,bc,c_or_f,p)
5656
call fft(arrplan(1,2),py) ! fwd transform in y
5757
!
5858
call transpose_y_to_z(py,pz)
59+
!
5960
q = 0
6061
if(c_or_f(3) == 'f'.and.bc(1,3) == 'D') q = 1
6162
if(bc(0,3)//bc(1,3) == 'PP') then

tests/lid_driven_cavity/dns.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
2 64 64 ! itot, jtot, ktot
22
0.03125 1. 1. ! lx, ly, lz
3-
0. ! gr
3+
0 0. ! gtype,gr
44
.95 1.e5 ! cfl
55
1000. ! visci
66
zer ! inivel

0 commit comments

Comments
 (0)