-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm_global_parameters.f90
405 lines (298 loc) · 14.1 KB
/
m_global_parameters.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
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
!>
!! @file m_global_parameters.f90
!! @brief Contains module m_global_parameters
!> @brief This module contains all of the parameters characterizing the
!! computational domain, simulation algorithm, stiffened equation of
!! state and finally, the formatted database file(s) structure.
module m_global_parameters
! Dependencies =============================================================
#ifdef MFC_MPI
use mpi !< Message passing interface (MPI) module
#endif
use m_derived_types !< Definitions of the derived types
! ==========================================================================
implicit none
!> @name Logistics
!> @{
integer :: num_procs !< Number of processors
integer, parameter :: num_stcls_min = 5 !< Mininum # of stencils
integer, parameter :: path_len = 400 !< Maximum path length
integer, parameter :: name_len = 50 !< Maximum name length
real(kind(0d0)), parameter :: dflt_real = -1d6 !< Default real value
integer, parameter :: dflt_int = -100 !< Default integer value
real(kind(0d0)), parameter :: sgm_eps = 1d-16 !< Segmentation tolerance
character(LEN=path_len) :: case_dir !< Case folder location
!> @}
! Computational Domain Parameters ==========================================
integer :: proc_rank !< Rank of the local processor
!> @name Number of cells in the x-, y- and z-coordinate directions
!> @{
integer :: m, m_root
integer :: n
!> @}
!> @name Global number of cells in each direction
!> @{
integer :: m_glb, n_glb
!> @}
integer :: num_dims !< Number of spatial dimensions
!> @name Cell-boundary locations in the x-, y- and z-coordinate directions
!> @{
real(kind(0d0)), allocatable, dimension(:) :: x_cb, x_root_cb, y_cb
real(kind(0d0)), allocatable, dimension(:) :: coarse_x_cb, coarse_y_cb
!> @}
!> @name Cell-center locations in the x-, y- and z-coordinate directions
!> @{
real(kind(0d0)), allocatable, dimension(:) :: x_cc, x_root_cc, y_cc
!> @}
!> Cell-width distributions in the x-, y- and z-coordinate directions
!> @{
real(kind(0d0)), allocatable, dimension(:) :: dx, dy
!> @}
integer :: buff_size !<
!! Number of cells in buffer region. For the variables which feature a buffer
!! region, this region is used to store information outside the computational
!! domain based on the boundary conditions.
integer :: t_step_start !< First time-step directory
integer :: t_step_stop !< Last time-step directory
integer :: t_step_save !< Interval between consecutive time-step directory
! NOTE: The variables m_root, x_root_cb and x_root_cc contain the grid data
! of the defragmented computational domain. They are only used in 1D. For
! serial simulations, they are equal to m, x_cb and x_cc, respectively.
! ==========================================================================
!> @name Simulation Algorithm Parameters
!> @{
integer :: num_fluids !< Number of different fluids present in the flow
integer :: sys_size !< Number of unknowns in the system of equations
integer :: weno_order !< Order of accuracy for the WENO reconstruction
!> @}
!> @name Annotations of the structure, i.e. the organization, of the state vectors
!> @{
type(int_bounds_info) :: cont_idx !< Indexes of first & last continuity eqns.
type(int_bounds_info) :: mom_idx !< Indexes of first & last momentum eqns.
integer :: E_idx !< Index of energy equation
type(int_bounds_info) :: adv_idx !< Indexes of first & last advection eqns.
integer :: gamma_idx !< Index of specific heat ratio func. eqn.
integer :: pi_inf_idx !< Index of liquid stiffness func. eqn.
!> @}
!> @name Boundary conditions in the x-, y- and z-coordinate directions
!> @{
type(int_bounds_info) :: bc_x, bc_y
!> @}
logical :: parallel_io !< Format of the data files
integer, allocatable, dimension(:) :: proc_coords !<
!! Processor coordinates in MPI_CART_COMM
integer, allocatable, dimension(:) :: start_idx !<
!! Starting cell-center index of local processor in global grid
#ifdef MFC_MPI
type(mpi_io_var), public :: MPI_IO_DATA
#endif
!> @name MPI info for parallel IO with Lustre file systems
!> @{
character(LEN=name_len) :: mpiiofs
integer :: mpi_info_int
!> @}
integer, private :: ierr
! ==========================================================================
type(physical_parameters), dimension(num_fluids_max) :: fluid_pp !<
!! Database of the physical parameters of each of the fluids that is present
!! in the flow. These include the stiffened gas equation of state parameters,
!! the Reynolds numbers and the Weber numbers.
! ==========================================================================
! Formatted Database File(s) Structure Parameters ==========================
integer :: format !< Format of the database file(s)
integer :: precision !< Floating point precision of the database file(s)
!> @name Size of the ghost zone layer in the x-, y- and z-coordinate directions.
!! The definition of the ghost zone layers is only necessary when using the
!! Silo database file format in multidimensions. These zones provide VisIt
!! with the subdomain connectivity information that it requires in order to
!! produce smooth plots.
!> @{
type(int_bounds_info) :: offset_x, offset_y
!> @}
!> @name The list of all possible flow variables that may be written to a database
!! file. It includes partial densities, density, momentum, velocity, energy,
!! pressure, volume fraction(s), specific heat ratio function, specific heat
!! ratio, liquid stiffness function, liquid stiffness, primitive variables,
!! conservative variables, speed of sound, the vorticity,
!! and the numerical Schlieren function.
!> @{
logical :: prim_vars_wrt
logical :: cons_vars_wrt
logical, dimension(2) :: omega_wrt
logical :: schlieren_wrt
!> @}
real(kind(0d0)), dimension(num_fluids_max) :: schlieren_alpha !<
!! Amplitude coefficients of the numerical Schlieren function that are used
!! to adjust the intensity of numerical Schlieren renderings for individual
!! fluids. This enables waves and interfaces of varying strenghts and in all
!! of the fluids to be made simulatenously visible on a single plot.
integer :: fd_order !<
!! The order of the finite-difference (fd) approximations of the first-order
!! derivatives that need to be evaluated when vorticity and/or the numerical
!! Schlieren function are to be outputted to the formatted database file(s).
integer :: fd_number !<
!! The finite-difference number is given by MAX(1, fd_order/2). Essentially,
!! it is a measure of the half-size of the finite-difference stencil for the
!! selected order of accuracy.
! ==========================================================================
!> @name Index variables used for m_variables_conversion
!> @{
integer :: momxb, momxe
integer :: advxb, advxe
integer :: contxb, contxe
!> @}
! Mathematical and Physical Constants ======================================
real(kind(0d0)), parameter :: pi = 3.141592653589793d0
! ==========================================================================
contains
!> Assigns default values to user inputs prior to reading
!! them in. This allows for an easier consistency check of
!! these parameters once they are read from the input file.
subroutine s_assign_default_values_to_user_inputs() ! ------------------
integer :: i !< Generic loop iterator
! Logistics
case_dir = ' '
! Computational domain parameters
m = dflt_int; n = 0
m_root = dflt_int
t_step_start = dflt_int
t_step_stop = dflt_int
t_step_save = dflt_int
! Simulation algorithm parameters
num_fluids = dflt_int
weno_order = dflt_int
bc_x%beg = dflt_int
bc_x%end = dflt_int
bc_y%beg = dflt_int
bc_y%end = dflt_int
! Fluids physical parameters
do i = 1, num_fluids_max
fluid_pp(i)%gamma = dflt_real
fluid_pp(i)%pi_inf = dflt_real
end do
! Formatted database file(s) structure parameters
format = dflt_int
precision = dflt_int
parallel_io = .false.
prim_vars_wrt = .false.
cons_vars_wrt = .false.
omega_wrt = .false.
schlieren_wrt = .false.
schlieren_alpha = dflt_real
fd_order = dflt_int
end subroutine s_assign_default_values_to_user_inputs ! ----------------
!> Computation of parameters, allocation procedures, and/or
!! any other tasks needed to properly setup the module
subroutine s_initialize_global_parameters_module() ! ----------------------
integer :: i
! Setting m_root equal to m in the case of a 1D serial simulation
if (num_procs == 1 .and. n == 0) m_root = m
! Annotating structure of the state and flux vectors belonging
! to the system of equations defined by the selected number of
! spatial dimensions and the volume fraction model
cont_idx%beg = 1
cont_idx%end = num_fluids
mom_idx%beg = cont_idx%end + 1
mom_idx%end = cont_idx%end + num_dims
E_idx = mom_idx%end + 1
adv_idx%beg = E_idx + 1
adv_idx%end = E_idx + num_fluids
sys_size = adv_idx%end
momxb = mom_idx%beg
momxe = mom_idx%end
advxb = adv_idx%beg
advxe = adv_idx%end
contxb = cont_idx%beg
contxe = cont_idx%end
! ==================================================================
#ifdef MFC_MPI
allocate (MPI_IO_DATA%view(1:sys_size))
allocate (MPI_IO_DATA%var(1:sys_size))
do i = 1, sys_size
allocate (MPI_IO_DATA%var(i)%sf(0:m, 0:n))
MPI_IO_DATA%var(i)%sf => null()
end do
#endif
! Size of the ghost zone layer is non-zero only when post-processing
! the raw simulation data of a parallel multidimensional computation
! in the Silo-HDF5 format. If this is the case, one must also verify
! whether the raw simulation data is 2D or 3D. In the 2D case, size
! of the z-coordinate direction ghost zone layer must be zeroed out.
if (num_procs == 1 .or. format /= 1 .or. n == 0) then
offset_x%beg = 0
offset_x%end = 0
offset_y%beg = 0
offset_y%end = 0
end if
! Determining the finite-difference number and the buffer size. Note
! that the size of the buffer is unrelated to the order of the WENO
! scheme. Rather, it is directly dependent on maximum size of ghost
! zone layers and possibly the order of the finite difference scheme
! used for the computation of vorticity and/or numerical Schlieren
! function.
buff_size = max(offset_x%beg, offset_x%end, offset_y%beg, &
offset_y%end)
if (any(omega_wrt) .or. schlieren_wrt) then
fd_number = max(1, fd_order/2)
buff_size = buff_size + fd_number
end if
! Allocating the grid variables in the x-coordinate direction
allocate (x_cb(-1 - offset_x%beg:m + offset_x%end))
allocate (x_cc(-buff_size:m + buff_size))
allocate (dx(-buff_size:m + buff_size))
! Allocating grid variables in the y- and z-coordinate directions
if (n > 0) then
allocate (y_cb(-1 - offset_y%beg:n + offset_y%end))
allocate (y_cc(-buff_size:n + buff_size))
allocate (dy(-buff_size:n + buff_size))
! Allocating the grid variables, only used for the 1D simulations,
! and containing the defragmented computational domain grid data
else
allocate (x_root_cb(-1:m_root))
allocate (x_root_cc(0:m_root))
end if
end subroutine s_initialize_global_parameters_module ! --------------------
!> Subroutine to initialize parallel infrastructure
subroutine s_initialize_parallel_io() ! --------------------------------
num_dims = 1 + min(1, n)
allocate (proc_coords(1:num_dims))
if (parallel_io .neqv. .true.) return
#ifdef MFC_MPI
! Option for Lustre file system (Darter/Comet/Stampede)
write (mpiiofs, '(A)') '/lustre_'
mpiiofs = trim(mpiiofs)
call MPI_INFO_CREATE(mpi_info_int, ierr)
call MPI_INFO_SET(mpi_info_int, 'romio_ds_write', 'disable', ierr)
! Option for UNIX file system (Hooke/Thomson)
! WRITE(mpiiofs, '(A)') '/ufs_'
! mpiiofs = TRIM(mpiiofs)
! mpi_info_int = MPI_INFO_NULL
allocate (start_idx(1:num_dims))
#endif
end subroutine s_initialize_parallel_io ! ------------------------------
!> Deallocation procedures for the module
subroutine s_finalize_global_parameters_module() ! -------------------
integer :: i
! Deallocating the grid variables for the x-coordinate direction
deallocate (x_cb, x_cc, dx)
! Deallocating grid variables for the y- and z-coordinate directions
if (n > 0) then
deallocate (y_cb, y_cc, dy)
! Deallocating the grid variables, only used for the 1D simulations,
! and containing the defragmented computational domain grid data
else
deallocate (x_root_cb, x_root_cc)
end if
deallocate (proc_coords)
#ifdef MFC_MPI
if (parallel_io) then
deallocate (start_idx)
do i = 1, sys_size
MPI_IO_DATA%var(i)%sf => null()
end do
deallocate (MPI_IO_DATA%var)
deallocate (MPI_IO_DATA%view)
end if
#endif
end subroutine s_finalize_global_parameters_module ! -----------------
end module m_global_parameters