Skip to content

Commit 0144937

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

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

+2207
-6266
lines changed

.github/workflows/frontier/build.sh

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 36 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 30 additions & 0 deletions
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)
Lines changed: 30 additions & 0 deletions
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

Lines changed: 20 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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 ==========================

0 commit comments

Comments
 (0)