Skip to content

Commit 7912215

Browse files
committed
(Atomic) Boundary Condition Patches
1 parent d1b8028 commit 7912215

40 files changed

+2189
-6484
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

+40-3
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ Details of implementation of viscosity in MFC can be found in [Coralic (2015)](r
349349
| Parameter | Type | Description |
350350
| ---: | :----: | :--- |
351351
| `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)) |
352-
| `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` |
353-
| `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` |
352+
| `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` |
353+
| `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` |
354354
| `model_eqns` | Integer | Multicomponent model: [1] $\Gamma/\Pi_\infty$; [2] 5-equation; [3] 6-equation; [4] 4-equation |
355355
| `alt_soundspeed` * | Logical | Alternate sound speed and $K \nabla \cdot u$ for 5-equation model |
356356
| `adv_n` | Logical | Solving directly for the number density (in the method of classes) and compute void fraction from the number density |
@@ -475,7 +475,7 @@ The value of `dt` needs to be sufficiently small to satisfy the Courant-Friedric
475475
To newly start the simulation, set `t_step_start = 0`.
476476
To restart the simulation from $k$-th time step, set `t_step_start = k`; see [Restarting Cases](running.md#restarting-cases).
477477

478-
##### Adaptive Time-Stepping
478+
##### Adaptive Time-Stepping (optional)
479479

480480
- `cfl_adap_dt` enables adaptive time stepping with a constant CFL when true
481481

@@ -492,6 +492,36 @@ To restart the simulation from $k$-th time step, set `t_step_start = k`; see [Re
492492
To newly start the simulation, set `n_start = 0`.
493493
To restart the simulation from $k$-th time step, see [Restarting Cases](running.md#restarting-cases).
494494

495+
##### Boundary Condition Patches (optional and experimental)
496+
497+
> [!WARNING]
498+
> This feature is currently experimental and may not produce physicall correct
499+
> results when certain other features are turned on.
500+
501+
Boundary condition patches allow you to define boundary conditions with more granularity
502+
than `bc_[x,y,z]`. When using this feature, any point along the edge of the domain can
503+
be assigned its own boundary condition type. Since the boundaries of a 3D domain are
504+
2D surfaces, the concept of patches is re-introduced.
505+
506+
Boundary conditions are applied using the [Painter's algorithm](https://en.wikipedia.org/wiki/Painter%27s_algorithm)
507+
where patches with higher indices take priority, in layers. The lowest priority is given
508+
to `bc_[x,y,z]`. This feature is opt-in and enabled by assigning `num_bc_patches` to a
509+
positive value.
510+
511+
| Parameter | Type | Description |
512+
| ---: | :----: | :--- |
513+
| `num_bc_patches` | Integer | Number of boundary condition patches (default 0) |
514+
| `%%type` * | Integer | Boundary condition type (negative integer, see table [Boundary Conditions](#boundary-conditions)) |
515+
| `%%dir` * | Integer | About the [1] x; [2] y; [3] z; axis |
516+
| `%%loc` * | Integer | About the line or surface at the [-1] beginning; [+2] end; of the `%%dir` axis. |
517+
| `%%geometry` * | Integer | The geometry of the boundary condition patch. See table [Boundary Condition Patch Geometry Types](#boundary-condition-patch-geometry-types) |
518+
| `%%vel(i)` * | Real | Meaning depends on the boundary condition |
519+
| `%%centroid(i)` * | Real | Meaning depends on the patch geometry. Index $i = \text{dir}$ is always ignored |
520+
| `%%length(i)` * | Real | Meaning depends on the patch geometry. Index $i = \text{dir}$ is always ignored |
521+
| `%%radius` * | Real | Meaning depends on the patch geometry. Index $i = \text{dir}$ is always ignored |
522+
523+
*: These parameters should be prepended with `patch_bc(j)%` where $j$ is the boundary condition patch index.
524+
495525
### 7. Formatted Output
496526

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

907+
### Boundary Condition Patch Geometry Types
908+
909+
| # | Name | Dim. | Requirements |
910+
| ---: | :----: | :--- | :--- |
911+
| 1 | Cuboid | 1 & 2 | `%%centroid(1:3)` and `%%length(1:3)` |
912+
| 2 | Spheroid | 1 & 2 | `%%centroid(1:3)` and `%%radius` |
913+
877914
### Immersed Boundary Patch Types
878915

879916
| # | Name | Dim. |

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/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)