Skip to content

Commit 25ed449

Browse files
committed
(Atomic) Boundary Condition Patches
1 parent e362dc9 commit 25ed449

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2203
-6267
lines changed

.github/workflows/frontier/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

33
. ./mfc.sh load -c f -m g
4-
./mfc.sh build -j 8 --gpu
4+
./mfc.sh test --dry-run -j 8 --gpu

.github/workflows/phoenix/test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if [ "$job_device" == "gpu" ]; then
55
build_opts="--gpu"
66
fi
77

8-
./mfc.sh build -j 8 $build_opts
8+
./mfc.sh test --dry-run -j 8 $build_opts
99

1010
n_test_threads=8
1111

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
- name: Build
8585
run: |
8686
if [ '${{ matrix.intel }}' == 'true' ]; then . /opt/intel/oneapi/setvars.sh; fi
87-
/bin/bash mfc.sh build -j $(nproc) --${{ matrix.debug }} --${{ matrix.mpi }}
87+
/bin/bash mfc.sh test --dry-run -j $(nproc) --${{ matrix.debug }} --${{ matrix.mpi }}
8888
8989
- name: Test
9090
run: |

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ macro(HANDLE_SOURCES target useCommon)
335335

336336
add_custom_command(
337337
OUTPUT ${f90}
338-
COMMAND ${FYPP_EXE} -m re
338+
COMMAND ${FYPP_EXE} -m re -m itertools
339339
-I "${CMAKE_BINARY_DIR}/include/${target}"
340340
-I "${${target}_DIR}/include"
341341
-I "${common_DIR}/include"

docs/documentation/case.md

+36-3
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ Details of implementation of viscosity in MFC can be found in [Coralic (2015)](r
337337
| Parameter | Type | Description |
338338
| ---: | :----: | :--- |
339339
| `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)) |
340-
| `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` |
341-
| `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` |
340+
| `bc_[x,y,z]%%vel_beg[1,2,3]`| Real | Velocity in the (x,1), (y, 2), (z,3) direction applied to `bc_[x,y,z]%%beg` |
341+
| `bc_[x,y,z]%%vel_end[1,2,3]`| Real | Velocity in the (x,1), (y, 2), (z,3) direction applied to `bc_[x,y,z]%%end` |
342342
| `model_eqns` | Integer | Multicomponent model: [1] $\Gamma/\Pi_\infty$; [2] 5-equation; [3] 6-equation; [4] 4-equation |
343343
| `alt_soundspeed` * | Logical | Alternate sound speed and $K \nabla \cdot u$ for 5-equation model |
344344
| `adv_n` | Logical | Solving directly for the number density (in the method of classes) and compute void fraction from the number density |
@@ -463,7 +463,7 @@ The value of `dt` needs to be sufficiently small to satisfy the Courant-Friedric
463463
To newly start the simulation, set `t_step_start = 0`.
464464
To restart the simulation from $k$-th time step, set `t_step_start = k`; see [Restarting Cases](running.md#restarting-cases).
465465

466-
##### Adaptive Time-Stepping
466+
##### Adaptive Time-Stepping (optional)
467467

468468
- `cfl_adap_dt` enables adaptive time stepping with a constant CFL when true
469469

@@ -480,6 +480,32 @@ To restart the simulation from $k$-th time step, set `t_step_start = k`; see [Re
480480
To newly start the simulation, set `n_start = 0`.
481481
To restart the simulation from $k$-th time step, see [Restarting Cases](running.md#restarting-cases).
482482

483+
#### Boundary Condition Patches (optional)
484+
485+
Boudary condition patches allow you to define boundary conditions with more granularity
486+
than `bc_[x,y,z]`. When using this feature, any point along the edge of the domain can
487+
be assigned its own boundary condition type. Since the boundaries of a 3D domain are
488+
2D surfaces, the concept of patches is re-introduced.
489+
490+
Boundary conditions are applied using the [Painter's algorithm](https://en.wikipedia.org/wiki/Painter%27s_algorithm)
491+
where patches with higher indices take priority, in layers. The lowest priority is given
492+
to `bc_[x,y,z]`. This feature is opt-in and enabled by assigning `num_bc_patches` to a
493+
positive value.
494+
495+
| Parameter | Type | Description |
496+
| ---: | :----: | :--- |
497+
| `num_bc_patches` | Integer | Number of boundary condition patches (default 0) |
498+
| `%%type` * | Integer | Boundary condition type (negative integer, see table [Boundary Conditions](#boundary-conditions)) |
499+
| `%%dir` * | Integer | About the [1] x; [2] y; [3] z; axis |
500+
| `%%loc` * | Integer | About the line or surface at the [-1] beginning; [+2] end; of the `%%dir` axis. |
501+
| `%%geometry` * | Integer | The geometry of the boundary condition patch. See table [Boundary Condition Patch Geometry Types](#boundary-condition-patch-geometry-types) |
502+
| `%%vel(i)` * | Real | Meaning depends on the boundary condition |
503+
| `%%centroid(i)` * | Real | Meaning depends on the patch geometry. Index $i = \text{dir}$ is always ignored |
504+
| `%%length(i)` * | Real | Meaning depends on the patch geometry. Index $i = \text{dir}$ is always ignored |
505+
| `%%radius` * | Real | Meaning depends on the patch geometry. Index $i = \text{dir}$ is always ignored |
506+
507+
*: These parameters should be prepended with `patch_bc(j)%` where $j$ is the boundary condition patch index.
508+
483509
### 7. Formatted Output
484510

485511
| Parameter | Type | Description |
@@ -862,6 +888,13 @@ This includes types exclusive to one-, two-, and three-dimensional problems.
862888
The patch type number (`#`) corresponds to the input value in `input.py` labeled `patch_icpp(j)%%geometry` where $j$ is the patch index.
863889
Each patch requires a different set of parameters, which are also listed in this table.
864890

891+
### Boundary Condition Patch Geometry Types
892+
893+
| # | Name | Dim. | Requirements |
894+
| ---: | :----: | :--- | :--- |
895+
| 1 | Cuboid | 1 & 2 | `%%centroid(1:3)` and `%%length(1:3)` |
896+
| 2 | Spheroid | 1 & 2 | `%%centroid(1:3)` and `%%radius` |
897+
865898
### Immersed Boundary Patch Types
866899

867900
| # | Name | Dim. |

examples/1D_impact/case.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
'dt' : mydt,
2626
't_step_start' : 0,
2727
't_step_stop' : int(Nt),
28-
't_step_save' : int(math.ceil(Nt/1.)),
28+
't_step_save' : 1,
2929
# ==========================================================
3030

3131
# Simulation Algorithm Parameters ==========================

examples/1D_inert_shocktube/export.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import csv
2+
import numpy as np
3+
import statistics
4+
from tqdm import tqdm
5+
6+
import mfc.viz
7+
from case import dt, sol_L as sol
8+
9+
10+
case = mfc.viz.Case(".", dt)
11+
12+
for name in tqdm(sol.species_names, desc="Loading Variables"):
13+
case.load_variable(f"Y_{name}", f"prim.{5 + sol.species_index(name)}")
14+
case.load_variable("rho", "prim.1")
15+
case.load_variable("u", "prim.2")
16+
case.load_variable("p", "prim.3")
17+
case.load_variable("T", "prim.15")
18+
19+
steps = case.get_timesteps()
20+
21+
for step in [min(steps), max(steps)]:
22+
t = step * dt
23+
24+
with open(f"mfc-{step}.csv", "w") as f:
25+
writer = csv.writer(f)
26+
keys = ['x'] + list(set(case.get_data()[0].keys()) - set(["x"]))
27+
writer.writerow(keys)
28+
for ix, x in enumerate(sorted(case.get_coords()[0])):
29+
row = [case.get_data()[step][key][ix] for key in keys]
30+
writer.writerow(row)
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import csv
2+
import numpy as np
3+
import statistics
4+
from tqdm import tqdm
5+
6+
import mfc.viz
7+
from case import dt, sol_L as sol
8+
9+
10+
case = mfc.viz.Case(".", dt)
11+
12+
for name in tqdm(sol.species_names, desc="Loading Variables"):
13+
case.load_variable(f"Y_{name}", f"prim.{5 + sol.species_index(name)}")
14+
case.load_variable("rho", "prim.1")
15+
case.load_variable("u", "prim.2")
16+
case.load_variable("p", "prim.3")
17+
case.load_variable("T", "prim.15")
18+
19+
steps = case.get_timesteps()
20+
21+
for step in [min(steps), max(steps)]:
22+
t = step * dt
23+
24+
with open(f"mfc-{step}.csv", "w") as f:
25+
writer = csv.writer(f)
26+
keys = ['x'] + list(set(case.get_data()[0].keys()) - set(["x"]))
27+
writer.writerow(keys)
28+
for ix, x in enumerate(sorted(case.get_coords()[0])):
29+
row = [case.get_data()[step][key][ix] for key in keys]
30+
writer.writerow(row)

examples/2D_advection/case.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import json
44

5+
L = 1.0
6+
57
# Configuring case dictionary
68
print(json.dumps({
79
# Logistics ================================================
@@ -10,9 +12,9 @@
1012

1113
# Computational Domain Parameters ==========================
1214
'x_domain%beg' : 0.E+00,
13-
'x_domain%end' : 1.E+00,
15+
'x_domain%end' : L,
1416
'y_domain%beg' : 0.E+00,
15-
'y_domain%end' : 1.E+00,
17+
'y_domain%end' : L,
1618
'm' : 99,
1719
'n' : 99,
1820
'p' : 0,
@@ -46,6 +48,21 @@
4648
'bc_y%end' : -3,
4749
# ==========================================================
4850

51+
'num_bc_patches' : 2,
52+
'patch_bc(1)%type' : -1,
53+
'patch_bc(1)%geometry' : 1,
54+
'patch_bc(1)%dir' : 1,
55+
'patch_bc(1)%loc' : -1,
56+
'patch_bc(1)%centroid(2)' : L/2,
57+
'patch_bc(1)%length(2)' : L/2,
58+
59+
'patch_bc(2)%type' : -1,
60+
'patch_bc(2)%geometry' : 1,
61+
'patch_bc(2)%dir' : 1,
62+
'patch_bc(2)%loc' : +1,
63+
'patch_bc(2)%centroid(2)' : L/2,
64+
'patch_bc(2)%length(2)' : L/2,
65+
4966
# Formatted Database Files Structure Parameters ============
5067
'format' : 1,
5168
'precision' : 2,
@@ -60,7 +77,7 @@
6077
'patch_icpp(1)%length_x' : 1.E+00,
6178
'patch_icpp(1)%length_y' : 1.E+00,
6279
'patch_icpp(1)%vel(1)' : 100.E+00,
63-
'patch_icpp(1)%vel(2)' : 100.E+00,
80+
'patch_icpp(1)%vel(2)' : 0.E+00,
6481
'patch_icpp(1)%pres' : 1.E+05,
6582
'patch_icpp(1)%alpha_rho(1)' : 1000.E+00,
6683
'patch_icpp(1)%alpha_rho(2)' : 1.,

examples/2D_riemann_test/case.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
'p' : 0,
2020
'dt' : 8e-05,
2121
't_step_start' : 0,
22-
't_step_stop' : 10000,
23-
't_step_save' : 100,
22+
't_step_stop' : 10000//1000,
23+
't_step_save' : 10,
2424
# ==========================================================
2525

2626
# Simulation Algorithm Parameters ==========================

examples/hypotests/case.py

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#!/usr/bin/env python3
2+
import math
3+
import json
4+
5+
# Numerical setup
6+
Nx = 201 # Number of grid points in x
7+
Ny = 201 # Number of grid points in y
8+
dx = 1./(1.*(Nx+1)) # Grid spacing in x
9+
dy = 1./(1.*(Ny+1)) # Grid spacing in y
10+
11+
Tend = 64E-06 # End time
12+
Nt = 2000 # 2000 # Number of time steps
13+
mydt = Tend/(1.*Nt) # Time step size
14+
15+
# Configuring case dictionary
16+
print(json.dumps({
17+
# Logistics ================================================
18+
'run_time_info' : 'F',
19+
# ==========================================================
20+
21+
# Computational Domain Parameters ==========================
22+
'x_domain%beg' : 0.E+00, # x start
23+
'x_domain%end' : 2.E+00, # x end
24+
'y_domain%beg' : 0.E+00, # y start
25+
'y_domain%end' : 1.E+00, # y end
26+
'm' : Nx, # Number of grid points in x direction
27+
'n' : Ny, # Number of grid points in y direction
28+
'p' : 0, # Number of grid points in z (for 3D, change this)
29+
'dt' : 1e-6, # Time step size
30+
't_step_start' : 0, # Start time
31+
't_step_stop' : Nt, # End time
32+
't_step_save' : 500, # Save frequency
33+
# ==========================================================
34+
35+
# Simulation Algorithm Parameters ==========================
36+
'num_patches' : 1, # Two patches
37+
'model_eqns' : 2, # Number of model equations
38+
'alt_soundspeed' : 'F',
39+
'num_fluids' : 2,
40+
'low_Mach' : 0,
41+
'mpp_lim' : 'F',
42+
# ' mixture_err' : 'F',
43+
'time_stepper' : 3,
44+
'weno_order' : 5,
45+
'weno_eps' : 1.E-16,
46+
'weno_Re_flux' : 'F',
47+
'weno_avg' : 'F',
48+
'mapped_weno' : 'F',
49+
'null_weights' : 'F',
50+
'mp_weno' : 'F',
51+
'riemann_solver' : 1,
52+
'wave_speeds' : 1,
53+
'avg_state' : 2,
54+
'bc_x%beg' : -3,
55+
'bc_x%end' : -3,
56+
'bc_y%beg' : -3, # Boundary conditions for y direction
57+
'bc_y%end' : -3,
58+
'num_bc_patches' : 1,
59+
'patch_bc(1)%type' : -17,
60+
'patch_bc(1)%dir' : 1,
61+
'patch_bc(1)%loc' : -1,
62+
'patch_bc(1)%geometry' : 1,
63+
'patch_bc(1)%centroid(1)' : 0,
64+
'patch_bc(1)%centroid(2)' : 0.5,
65+
'patch_bc(1)%length(2)' : 0.26,
66+
'patch_bc(1)%vel(1)' : 10,
67+
'patch_bc(1)%vel(2)' : 0,
68+
# ==========================================================
69+
70+
# Turning on IB ================================
71+
'ib' : 'T',
72+
'num_ibs' : 2,
73+
74+
# ==========================================================
75+
76+
# Formatted Database Files Structure Parameters ============
77+
'format' : 1,
78+
'precision' : 2,
79+
'prim_vars_wrt' :'T',
80+
'parallel_io' :'T',
81+
# ==========================================================
82+
83+
# Patch 1 (background flow) ===================
84+
'patch_icpp(1)%geometry' : 3, # 2D geometry
85+
'patch_icpp(1)%x_centroid' : 1.0, # x-center
86+
'patch_icpp(1)%y_centroid' : 0.5, # y-center
87+
'patch_icpp(1)%length_x' : 2.0, # x-length
88+
'patch_icpp(1)%length_y' : 1.0, # y-length
89+
'patch_icpp(1)%vel(1)' : 0.0,
90+
'patch_icpp(1)%vel(2)' : 0.0, # y-velocity '100*sin(3*x*pi)'
91+
'patch_icpp(1)%pres' : 1.E5, # Pressure
92+
'patch_icpp(1)%alpha_rho(1)' : 1000, # Density
93+
'patch_icpp(1)%alpha_rho(2)' : 0.,
94+
'patch_icpp(1)%alpha(1)' : 1,
95+
'patch_icpp(1)%alpha(2)' : 0.,
96+
'patch_icpp(1)%tau_e(1)' : 0.0,
97+
98+
99+
# ==========================================================
100+
101+
# Patch 2 (hypo material in the center) ================
102+
'patch_ib(1)%geometry' : 3, # 2D geometry
103+
# 'patch_ib(1)%hcid' : 201,
104+
'patch_ib(1)%x_centroid' : 0.5, # x-center
105+
'patch_ib(1)%y_centroid' : 0.65, # y-center
106+
'patch_ib(1)%length_x' : 1.0, # x-length
107+
'patch_ib(1)%length_y' : 0.04, # y-length
108+
'patch_ib(1)%slip' : 'T',
109+
110+
# ==========================================================
111+
112+
# Patch 3 (hypo material in the center) ================
113+
'patch_ib(2)%geometry' : 3, # 2D geometry
114+
# 'patch_ib(1)%hcid' : 201,
115+
'patch_ib(2)%x_centroid' : 0.5, # x-center
116+
'patch_ib(2)%y_centroid' : 0.35, # y-center
117+
'patch_ib(2)%length_x' : 1.0, # x-length
118+
'patch_ib(2)%length_y' : 0.04, # y-length
119+
'patch_ib(2)%slip' : 'T',
120+
121+
# Fluids Physical Parameters ===============================
122+
'fluid_pp(1)%gamma' : 1.E+00/(6.12E+00-1.E+00),
123+
'fluid_pp(1)%pi_inf' : 6.12E+00*3.43E+08/(6.12E+00 - 1.E+00),
124+
# 'fluid_pp(1)%G' : 0,
125+
'fluid_pp(2)%gamma' : 1.E+00/(1.3E+00-1.E+00),
126+
'fluid_pp(2)%pi_inf' : 1.3E+00*2.E+08/(1.3E+00 - 1.E+00),
127+
# 'fluid_pp(2)%G' : 2.7E+05/(2.E+00*(1.E+00 + 0.4E+00)),
128+
'fluid_pp(2)%G' : 1.E7,
129+
# ==========================================================
130+
}))

0 commit comments

Comments
 (0)