Skip to content

Commit 0ffd93e

Browse files
Velocity BCs in all coordinate directions, new example cases, nonpolytropic bc refactor (#279)
Co-authored-by: Ben Wilfong <[email protected]> Co-authored-by: Spencer Bryngelson <[email protected]>
1 parent 695a305 commit 0ffd93e

28 files changed

+1278
-689
lines changed

docs/documentation/case.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ Details of implementation of viscosity in MFC can be found in [Coralic (2015)](r
304304
| Parameter | Type | Description |
305305
| ---: | :----: | :--- |
306306
| `bc_[x,y,z]\%beg[end]` | Integer | Beginning [ending] boundary condition in the $[x,y,z]$-direction (negative integer, see table [Boundary Conditions](#boundary-conditions)) |
307+
| `bc_[x,y,z]\%vb[1,2,3]`| Real | Velocity in the (x,1), (y, 2), (z,3) direction applied to `bc_[x,y,z]%beg` |
308+
| `bc_[x,y,z]\%ve[1,2,3]`| Real | Velocity in the (x,1), (y, 2), (z,3) direction applied to `bc_[x,y,z]%end` |
307309
| `model_eqns` | Integer | Multicomponent model: [1] $\Gamma/\Pi_\infty$; [2] 5-equation; [3] 6-equation\\%;%[4] 4-equation |
308310
| `alt_soundspeed` * | Logical | Alternate sound speed and $K \nabla \cdot u$ for 5-equation model |
309311
| `adv_alphan` | Logical | Equations for all $N$ volume fractions (instead of $N-1$) |
@@ -323,6 +325,7 @@ Details of implementation of viscosity in MFC can be found in [Coralic (2015)](r
323325

324326
- \* Options that work only with `model_eqns` $=2$.
325327
- † Options that work only with `cyl_coord` $=$ `False`.
328+
- ‡ Options that work only with `bc_[x,y,z]%[beg,end] = -15` and/or `bc_[x,y,z]%[beg,end] = -16`
326329

327330
The table lists simulation algorithm parameters.
328331
The parameters are used to specify options in algorithms that are used to integrate the governing equations of the multi-component flow based on the initial condition.
@@ -332,6 +335,12 @@ Details of the simulation algorithms and implementation of the WENO scheme can b
332335
- `bc_[x,y,z]%[beg,end]` specifies the boundary conditions at the beginning and the end of domain boundaries in each coordinate direction by a negative integer from -1 through -12.
333336
See table [Boundary Conditions](#boundary-conditions) for details.
334337

338+
- `bc_[x,y,z]\%vb[1,2,3]` specifies the velocity in the (x,1), (y,2), (z,3) direction applied to `bc_[x,y,z]%beg` when using `bc_[x,y,z]%beg = -16`.
339+
Tangential velocities require viscosity, `weno_avg = T`, and `bc_[x,y,z]%beg = -16` to work properly. Normal velocities require `bc_[x,y,z]\%end = -15` or `\bc_[x,y,z]\%end = -16` to work properly.
340+
341+
- `bc_[x,y,z]\%ve[1,2,3]` specifies the velocity in the (x,1), (y,2), (z,3) direction applied to `bc_[x,y,z]%beg` when using `bc_[x,y,z]%end = -16`.
342+
Tangential velocities require viscosity, `weno_avg = T`, and `bc_[x,y,z]\%end = 16` to work properly. Normal velocities require `bc_[x,y,z]\%end = -15` or `\bc_[x,y,z]\%end = -16` to work properly.
343+
335344
- `model_eqns` specifies the choice of the multi-component model that is used to formulate the dynamics of the flow using integers from 1 through 3.
336345
`model_eqns` $=$ 1, 2, and 3 correspond to $\Gamma$-$\Pi_\infty$ model ([Johnsen, 2008](references.md#Johnsen08)), 5-equation model ([Allaire et al., 2002](references.md#Allaire02)), and 6-equation model ([Saurel et al., 2009](references.md#Saurel09)), respectively.
337346
The difference of the two models is assessed by ([Schmidmayer et al., 2019](references.md#Schmidmayer19)).
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Lid-Driven Cavity Problem (2D)
2+
3+
Reference: Bezgin, D. A., & Buhendwa A. B., & Adams N. A. (2022). JAX-FLUIDS: A fully-differentiable high-order computational fluid dynamics solver for compressible two-phase flows. arXiv:2203.13760
4+
5+
Reference: Ghia, U., & Ghia, K. N., & Shin, C. T. (1982). High-re solutions for incompressible flow
6+
using the Navier-Stokes equations and a multigrid method. Journal of Computational Physics, 48, 387-411
7+
8+
Video: https://youtube.com/shorts/JEP28scZrBM?feature=share
9+
10+
## Final Condition
11+
12+
![Final Condition](final_condition.png)
13+
14+
## Centerline Velocities
15+
16+
![Centerline Velocities](centerline_velocities.png)
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/env python3
2+
3+
import json
4+
eps = 1e-6
5+
# Configuring case dictionary
6+
print(json.dumps({
7+
# Logistics ================================================
8+
'run_time_info' : 'T',
9+
# ==========================================================
10+
11+
# Computational Domain Parameters ==========================
12+
'x_domain%beg' : 0.,
13+
'x_domain%end' : 1.,
14+
'y_domain%beg' : 0.,
15+
'y_domain%end' : 1.,
16+
'm' : 999,
17+
'n' : 999,
18+
'p' : 0,
19+
'dt' : 1.25E-04,
20+
't_step_start' : 0,
21+
't_step_stop' : 1600000,
22+
't_step_save' : 8000,
23+
# ==========================================================
24+
25+
# Simulation Algorithm Parameters ==========================
26+
'num_patches' : 1,
27+
'model_eqns' : 2,
28+
'alt_soundspeed' : 'F',
29+
'num_fluids' : 2,
30+
'adv_alphan' : 'T',
31+
'mpp_lim' : 'F',
32+
'mixture_err' : 'T',
33+
'time_stepper' : 3,
34+
'weno_order' : 5,
35+
'weno_eps' : 1e-16,
36+
'mapped_weno' : 'T',
37+
'weno_Re_flux' : 'T',
38+
'mp_weno' : 'T',
39+
'weno_avg' : 'T',
40+
'riemann_solver' : 2,
41+
'wave_speeds' : 1,
42+
'avg_state' : 2,
43+
'bc_x%beg' : -16,
44+
'bc_x%end' : -16,
45+
'bc_y%beg' : -16,
46+
'bc_y%end' : -16,
47+
'bc_y%ve1' : 0.5,
48+
# ==========================================================
49+
50+
# Formatted Database Files Structure Parameters ============
51+
'format' : 1,
52+
'precision' : 2,
53+
'prim_vars_wrt' :'T',
54+
'omega_wrt(3)' :'T',
55+
'fd_order' : 4,
56+
'parallel_io' :'T',
57+
# ==========================================================
58+
59+
# Patch 1: Base ============================================
60+
'patch_icpp(1)%geometry' : 3,
61+
'patch_icpp(1)%x_centroid' : 0.5,
62+
'patch_icpp(1)%y_centroid' : 0.5,
63+
'patch_icpp(1)%length_x' : 1.,
64+
'patch_icpp(1)%length_y' : 1.,
65+
'patch_icpp(1)%vel(1)' : 0,
66+
'patch_icpp(1)%vel(2)' : 0.,
67+
'patch_icpp(1)%pres' : 5,
68+
'patch_icpp(1)%alpha_rho(1)' : 0.5,
69+
'patch_icpp(1)%alpha(1)' : 0.5,
70+
'patch_icpp(1)%alpha_rho(2)' : 0.5,
71+
'patch_icpp(1)%alpha(2)' : 0.5,
72+
# ==========================================================
73+
74+
# Fluids Physical Parameters ===============================
75+
'fluid_pp(1)%gamma' : 1./(1.4-1.),
76+
'fluid_pp(1)%pi_inf' : 0.,
77+
'fluid_pp(1)%Re(1)' : 1e4,
78+
'fluid_pp(2)%gamma' : 1./(1.4-1.),
79+
'fluid_pp(2)%pi_inf' : 0.,
80+
'fluid_pp(2)%Re(1)' : 1e4,
81+
# ==========================================================
82+
}))
83+
# ==============================================================================
50.5 KB
Loading
370 KB
Loading

examples/2D_riemann_test/case.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
# ==========================================================
1111

1212
# Computational Domain Parameters ==========================
13-
'x_domain%beg' : 0.E+00,
14-
'x_domain%end' : 1.E+00,
15-
'y_domain%beg' : 0.E+00,
16-
'y_domain%end' : 1.E+00,
13+
'x_domain%beg' : 0.,
14+
'x_domain%end' : 1.,
15+
'y_domain%beg' : 0.,
16+
'y_domain%end' : 1.,
1717
'm' : 499,
1818
'n' : 499,
1919
'p' : 0,
@@ -80,8 +80,8 @@
8080
# ==========================================================
8181
# Patch 1: Base ============================================
8282
'patch_icpp(3)%geometry' : 3,
83-
'patch_icpp(3)%x_centroid' : 0.9E+00,
84-
'patch_icpp(3)%y_centroid' : 0.4E+00,
83+
'patch_icpp(3)%x_centroid' : 0.9,
84+
'patch_icpp(3)%y_centroid' : 0.4,
8585
'patch_icpp(3)%length_x' : 0.2,
8686
'patch_icpp(3)%length_y' : 0.8,
8787
'patch_icpp(3)%vel(1)' : 0,
@@ -92,8 +92,8 @@
9292
# ==========================================================
9393
# Patch 1: Base ============================================
9494
'patch_icpp(4)%geometry' : 3,
95-
'patch_icpp(4)%x_centroid' : 0.9E+00,
96-
'patch_icpp(4)%y_centroid' : 0.9E+00,
95+
'patch_icpp(4)%x_centroid' : 0.9,
96+
'patch_icpp(4)%y_centroid' : 0.9,
9797
'patch_icpp(4)%length_x' : 0.2,
9898
'patch_icpp(4)%length_y' : 0.2,
9999
'patch_icpp(4)%vel(1)' : 0,

src/common/m_derived_types.fpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ module m_derived_types
4141
type int_bounds_info
4242
integer :: beg
4343
integer :: end
44+
real(kind(0d0)) :: vb1
45+
real(kind(0d0)) :: vb2
46+
real(kind(0d0)) :: vb3
47+
real(kind(0d0)) :: ve1
48+
real(kind(0d0)) :: ve2
49+
real(kind(0d0)) :: ve3
4450
end type int_bounds_info
4551

4652
!> Derived type adding beginning (beg) and end bounds info as attributes

src/common/m_helper.fpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ module m_helper
2828
s_swap, &
2929
f_cross, &
3030
f_create_transform_matrix, &
31-
f_create_bbox
31+
f_create_bbox, &
32+
s_print_2D_array
3233

3334
contains
3435

@@ -131,6 +132,35 @@ contains
131132
132133
end subroutine s_comp_n_from_cons
133134
135+
subroutine s_print_2D_array(A, div)
136+
137+
real(kind(0d0)), dimension(:, :) :: A
138+
integer :: i, j
139+
integer :: m, n
140+
real :: c
141+
real, optional :: div
142+
143+
m = size(A, 1)
144+
n = size(A, 2)
145+
146+
if (present(div)) then
147+
c = div
148+
else
149+
c = 1
150+
end if
151+
152+
print *, m, n
153+
154+
do i = 1, m
155+
do j = 1, n
156+
write (*, fmt="(F12.4)", advance="no") A(i, j)/c
157+
end do
158+
write (*, fmt="(A1)") " "
159+
end do
160+
write (*, fmt="(A1)") " "
161+
162+
end subroutine
163+
134164
!> Initializes non-polydisperse bubble modeling
135165
subroutine s_initialize_nonpoly
136166
integer :: ir

src/post_process/m_checker.f90

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,81 @@ subroutine s_check_inputs()
402402
'fd_order. Exiting ...')
403403
end if
404404

405+
! Moving Boundaries Checks: x boundaries
406+
if (any((/bc_x%vb1, bc_x%vb2, bc_x%vb3/) /= 0d0)) then
407+
if (bc_x%beg == 15) then
408+
if (any((/bc_x%vb2, bc_x%vb3/) /= 0d0)) then
409+
call s_mpi_abort("Unsupported combination of bc_x%beg and"// &
410+
"bc_x%vb2 or bc_x%vb3. Exiting ...")
411+
end if
412+
elseif (bc_x%beg /= -16) then
413+
call s_mpi_abort("Unsupported combination of bc_x%beg and"// &
414+
"bc_x%vb1, bc_x%vb2, or bc_x%vb3. Exiting...")
415+
end if
416+
end if
417+
418+
if (any((/bc_x%ve1, bc_x%ve2, bc_x%ve3/) /= 0d0)) then
419+
if (bc_x%end == 15) then
420+
if (any((/bc_x%ve2, bc_x%ve3/) /= 0d0)) then
421+
call s_mpi_abort("Unsupported combination of bc_x%end and"// &
422+
"bc_x%ve2 or bc_x%ve3. Exiting ...")
423+
end if
424+
elseif (bc_x%end /= -16) then
425+
call s_mpi_abort("Unsupported combination of bc_x%end and"// &
426+
"bc_x%ve1, bc_x%ve2, or bc_x%ve3. Exiting...")
427+
end if
428+
end if
429+
430+
! Moving Boundaries Checks: y boundaries
431+
if (any((/bc_y%vb1, bc_y%vb2, bc_y%vb3/) /= 0d0)) then
432+
if (bc_y%beg == 15) then
433+
if (any((/bc_y%vb1, bc_y%vb3/) /= 0d0)) then
434+
call s_mpi_abort("Unsupported combination of bc_y%beg and"// &
435+
"bc_y%vb1 or bc_y%vb3. Exiting ...")
436+
end if
437+
elseif (bc_y%beg /= -16) then
438+
call s_mpi_abort("Unsupported combination of bc_y%beg and"// &
439+
"bc_y%vb1, bc_y%vb2, or bc_y%vb3. Exiting...")
440+
end if
441+
end if
442+
443+
if (any((/bc_y%ve1, bc_y%ve2, bc_y%ve3/) /= 0d0)) then
444+
if (bc_y%end == 15) then
445+
if (any((/bc_y%ve1, bc_y%ve3/) /= 0d0)) then
446+
call s_mpi_abort("Unsupported combination of bc_y%end and"// &
447+
"bc_y%ve1 or bc_y%ve3. Exiting ...")
448+
end if
449+
elseif (bc_y%end /= -16) then
450+
call s_mpi_abort("Unsupported combination of bc_y%end and"// &
451+
"bc_y%ve1, bc_y%ve2, or bc_y%ve3. Exiting...")
452+
end if
453+
end if
454+
455+
! Moving Boundaries Checks: z boundaries
456+
if (any((/bc_z%vb1, bc_z%vb2, bc_z%vb3/) /= 0d0)) then
457+
if (bc_z%beg == 15) then
458+
if (any((/bc_x%vb1, bc_x%vb2/) /= 0d0)) then
459+
call s_mpi_abort("Unsupported combination of bc_z%beg and"// &
460+
"bc_x%vb1 or bc_x%vb1. Exiting ...")
461+
end if
462+
elseif (bc_z%beg /= -16) then
463+
call s_mpi_abort("Unsupported combination of bc_z%beg and"// &
464+
"bc_z%vb1, bc_z%vb2, or bc_z%vb3. Exiting...")
465+
end if
466+
end if
467+
468+
if (any((/bc_z%ve1, bc_z%ve2, bc_z%ve3/) /= 0d0)) then
469+
if (bc_z%end == 15) then
470+
if (any((/bc_x%ve1, bc_x%ve2/) /= 0d0)) then
471+
call s_mpi_abort("Unsupported combination of bc_z%end and"// &
472+
"bc_z%ve2 or bc_z%ve3. Exiting ...")
473+
end if
474+
elseif (bc_z%end /= -16) then
475+
call s_mpi_abort("Unsupported combination of bc_z%end and"// &
476+
"bc_z%ve1, bc_z%ve2, or bc_z%ve3. Exiting...")
477+
end if
478+
end if
479+
405480
end subroutine s_check_inputs
406481

407482
end module m_checker

src/post_process/m_global_parameters.fpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,13 @@ contains
279279
bc_y%beg = dflt_int; bc_y%end = dflt_int
280280
bc_z%beg = dflt_int; bc_z%end = dflt_int
281281

282+
#:for DIM in ['x', 'y', 'z']
283+
#:for DIR in [1, 2, 3]
284+
bc_${DIM}$%vb${DIR}$ = 0d0
285+
bc_${DIM}$%ve${DIR}$ = 0d0
286+
#:endfor
287+
#:endfor
288+
282289
! Fluids physical parameters
283290
do i = 1, num_fluids_max
284291
fluid_pp(i)%gamma = dflt_real

0 commit comments

Comments
 (0)