Skip to content

Commit c7a1f05

Browse files
authored
Named values for enumerated case parameters and AST-based analytic IC codegen (#1550)
1 parent a221310 commit c7a1f05

185 files changed

Lines changed: 2961 additions & 2310 deletions

File tree

Some content is hidden

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

docs/documentation/case.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ There are multiple sets of parameters that must be specified in the python input
9898
Items 8, 9, 10, 11 and 12 are optional sets of parameters that activate the acoustic source model, ensemble-averaged bubble model, initial velocity field setup, phase change, artificial Mach number respectively.
9999
Definition of the parameters is described in the following subsections.
100100

101+
Enumerated parameters accept named values as well as integer codes: `"riemann_solver": "hllc"`
102+
is equivalent to `"riemann_solver": 2`. Defined names appear in each parameter's table entry
103+
(e.g. `1` (`hll`), `2` (`hllc`)). Existing case files can be rewritten to named syntax with
104+
`./mfc.sh validate case.py --migrate`.
105+
101106
### 1. Runtime {#sec-runtime}
102107

103108
| Parameter | Type | Description |
@@ -213,24 +218,34 @@ Some parameters, as described above, can be defined by analytical functions in t
213218

214219
where `alpha_rho` is defined with the `1 + 0.1*sin(20*x*pi)` function.
215220

216-
The expressions are interpreted as Fortran code, in the execution context and scope of the function that defines the patch.
217-
Additionally, the following variables are made available as shorthand:
221+
Expressions use **Python syntax** and are parsed at case load time.
222+
Syntax errors and unknown variable or function names are immediate, named errors — they are reported before any Fortran is compiled, with a message identifying the offending expression and listing the available names.
223+
224+
The following variables are available in IC patch expressions:
218225

219226
| Shorthand | Expands To | Shorthand | Expands To | Shorthand | Expands To |
220227
| --------- | ------------------------ | --------- | ------------------------- | --------- | ------------------------ |
221228
| `x` | `x_cc(i)` | `lx` | The patch's `length_x` | `xc` | The patch's `x_centroid` |
222229
| `y` | `y_cc(j)` | `ly` | The patch's `length_y` | `yc` | The patch's `y_centroid` |
223230
| `z` | `z_cc(k)` | `lz` | The patch's `length_z` | `zc` | The patch's `z_centroid` |
224231
| `eps` | The patch's `epsilon` | `beta` | The patch's `beta` | `radii` | The patch's `radii` |
225-
| `tau_e` | The patch's `tau_e` | `r` | The patch's `radius` | `pi` and `e` | \f$\pi\f$ and \f$e\f$ |
232+
| `tau_e` | The patch's `tau_e` | `r` | The patch's `radius` | `pi` | \f$\pi\f$ (Fortran constant from `m_constants`) |
226233

227234
where $(i,j,k)$ are the grid-indices of the current cell in each coordinate direction.
228235

236+
The allowed functions are the standard Fortran intrinsics:
237+
`sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`,
238+
`sinh`, `cosh`, `tanh`, `exp`, `log`, `log10`, `sqrt`,
239+
`abs`, `min`, `max`, `mod`, `sign`.
240+
241+
**Euler's number:** bare `e` is **not** a variable.
242+
Write `exp(1.0)` or a numeric literal instead (e.g. `2.718281828`).
243+
229244
In the example above, the following code is generated:
230245

231246
```f90
232247
if (patch_id == 2) then
233-
q_prim_vf(eqn_idx%cont%beg)%sf(i, 0, 0) = 1 + 0.1*sin(20*x_cc(i)*3.141592653589793)
248+
q_prim_vf(eqn_idx%cont%beg)%sf(i, 0, 0) = 1 + 0.1 * sin(20 * x_cc(i) * pi)
234249
end if
235250
```
236251

@@ -355,9 +370,13 @@ Additional details on this specification can be found in [NACA airfoil](https://
355370

356371
- `moving_ibm` sets the method by which movement will be applied to the immersed boundary. Using 0 will result in no movement. Using 1 will result 1-way coupling where the boundary moves at a constant rate and applied forces to the fluid based upon it's own motion. In 1-way coupling, the fluid does not apply forces back onto the IB. Using 2 will result in 2-way coupling, where the boundary pushes on the fluid and the fluid pushes back on the boundary via pressure and viscous forces. If external forces are applied, the boundary will also experience those forces.
357372

358-
- `vel(i)` is the initial linear velocity of the IB in the x, y, z direction for i=1, 2, 3. When `moving_ibm` equals 2, this velocity is just the starting speed of the object, which will then accelerate due to external forces. If `moving_ibm` equals 1, then this is constant if it is a number, or can be described analytically with an expression.
373+
- `vel(i)` is the initial linear velocity of the IB in the x, y, z direction for i=1, 2, 3. When `moving_ibm` equals 2, this velocity is just the starting speed of the object, which will then accelerate due to external forces. If `moving_ibm` equals 1, then this is constant if it is a number, or can be described analytically with an expression.
374+
375+
- `angular_vel(i)` is the initial angular velocity of the IB about the x, y, z axes for i=1, 2, 3 in radians per second. When `moving_ibm` equals 2, this rotation rate is just the starting rate of the object, which will then change due to external torques. If `moving_ibm` equals 1, then this is constant if it is a number, or can be described analytically with an expression.
359376

360-
- `angular_vel(i)` is the initial angular velocity of the IB about the x, y, z axes for i=1, 2, 3 in radians per second. When `moving_ibm` equals 2, this rotation rate is just the starting rate of the object, which will then change due to external torques. If `moving_ibm` equals 1, then this is constant if it is a number, or can be described analytically with an expression.
377+
Moving-IB analytic expressions use the same Python syntax and error-reporting as IC patch expressions (see the "Analytical Definition of Primitive Variables" section above).
378+
Available variables: `x` (`x_cc(i)`), `y` (`y_cc(j)`), `z` (`z_cc(k)`), `t` (current simulation time), and `r` (the IB patch radius).
379+
The same intrinsic functions and `pi` constant apply; bare `e` is not available.
361380

362381
- `coefficient_of_restitution` is a number from 0 (exclusive) to 1 (inclusive) describing how elastic IB collisions are. 0 is for perfectly inellastic collisions while 1 is for perfectly ellastic collisions.
363382

examples/0D_bubblecollapse_adap/case.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,25 @@
6969
"t_step_save": t_save,
7070
# Simulation Algorithm Parameters
7171
"num_patches": 1,
72-
"model_eqns": 2,
72+
"model_eqns": "5eq",
7373
"alt_soundspeed": "F",
7474
"num_fluids": 1,
7575
"mpp_lim": "F",
7676
"mixture_err": "F",
77-
"time_stepper": 3,
77+
"time_stepper": "rk3",
7878
"weno_order": 5,
7979
"weno_eps": 1.0e-16,
8080
"mapped_weno": "T",
8181
"null_weights": "F",
8282
"mp_weno": "T",
83-
"riemann_solver": 2,
84-
"wave_speeds": 1,
85-
"avg_state": 2,
83+
"riemann_solver": "hllc",
84+
"wave_speeds": "direct",
85+
"avg_state": "arithmetic",
8686
"bc_x%beg": -1,
8787
"bc_x%end": -1,
8888
# Formatted Database Files Structure Parameters
89-
"format": 1,
90-
"precision": 2,
89+
"format": "silo",
90+
"precision": "double",
9191
"prim_vars_wrt": "T",
9292
"parallel_io": "T",
9393
"fd_order": 1,
@@ -103,7 +103,7 @@
103103
"patch_icpp(1)%v0": 0.0,
104104
# Bubbles
105105
"bubbles_euler": "T",
106-
"bubble_model": 2,
106+
"bubble_model": "keller_miksis",
107107
# Nondimensional numbers
108108
"bub_pp%R0ref": R0ref / x0,
109109
"bub_pp%p0ref": p0ref / p0,

examples/1D_acoustic_dipole/case.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@
1919
"t_step_save": 1,
2020
# Simulation Algorithm Parameters
2121
"num_patches": 1,
22-
"model_eqns": 2,
22+
"model_eqns": "5eq",
2323
"alt_soundspeed": "F",
2424
"num_fluids": 1,
2525
"mpp_lim": "F",
2626
"mixture_err": "F",
27-
"time_stepper": 3,
27+
"time_stepper": "rk3",
2828
"weno_order": 5,
2929
"weno_eps": 1.0e-16,
3030
"teno": "T",
3131
"teno_CT": 1e-8,
3232
"null_weights": "F",
3333
"mp_weno": "F",
34-
"riemann_solver": 2,
35-
"wave_speeds": 1,
36-
"avg_state": 2,
34+
"riemann_solver": "hllc",
35+
"wave_speeds": "direct",
36+
"avg_state": "arithmetic",
3737
"bc_x%beg": -6,
3838
"bc_x%end": -6,
3939
# Formatted Database Files Structure Parameters
40-
"format": 1,
41-
"precision": 2,
40+
"format": "silo",
41+
"precision": "double",
4242
"prim_vars_wrt": "T",
4343
"rho_wrt": "T",
4444
"parallel_io": "T",

examples/1D_acoustic_gauss_sigmadist/case.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@
1919
"t_step_save": 1,
2020
# Simulation Algorithm Parameters
2121
"num_patches": 1,
22-
"model_eqns": 2,
22+
"model_eqns": "5eq",
2323
"alt_soundspeed": "F",
2424
"num_fluids": 1,
2525
"mpp_lim": "F",
2626
"mixture_err": "F",
27-
"time_stepper": 3,
27+
"time_stepper": "rk3",
2828
"weno_order": 5,
2929
"weno_eps": 1.0e-16,
3030
"teno": "T",
3131
"teno_CT": 1e-8,
3232
"null_weights": "F",
3333
"mp_weno": "F",
34-
"riemann_solver": 2,
35-
"wave_speeds": 1,
36-
"avg_state": 2,
34+
"riemann_solver": "hllc",
35+
"wave_speeds": "direct",
36+
"avg_state": "arithmetic",
3737
"bc_x%beg": -6,
3838
"bc_x%end": -6,
3939
# Formatted Database Files Structure Parameters
40-
"format": 1,
41-
"precision": 2,
40+
"format": "silo",
41+
"precision": "double",
4242
"prim_vars_wrt": "T",
4343
"rho_wrt": "T",
4444
"parallel_io": "T",

examples/1D_acoustic_gauss_sigmatime/case.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@
1919
"t_step_save": 1,
2020
# Simulation Algorithm Parameters
2121
"num_patches": 1,
22-
"model_eqns": 2,
22+
"model_eqns": "5eq",
2323
"alt_soundspeed": "F",
2424
"num_fluids": 1,
2525
"mpp_lim": "F",
2626
"mixture_err": "F",
27-
"time_stepper": 3,
27+
"time_stepper": "rk3",
2828
"weno_order": 5,
2929
"weno_eps": 1.0e-16,
3030
"teno": "T",
3131
"teno_CT": 1e-8,
3232
"null_weights": "F",
3333
"mp_weno": "F",
34-
"riemann_solver": 2,
35-
"wave_speeds": 1,
36-
"avg_state": 2,
34+
"riemann_solver": "hllc",
35+
"wave_speeds": "direct",
36+
"avg_state": "arithmetic",
3737
"bc_x%beg": -6,
3838
"bc_x%end": -6,
3939
# Formatted Database Files Structure Parameters
40-
"format": 1,
41-
"precision": 2,
40+
"format": "silo",
41+
"precision": "double",
4242
"prim_vars_wrt": "T",
4343
"rho_wrt": "T",
4444
"parallel_io": "T",

examples/1D_acoustic_sine_frequency/case.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@
1919
"t_step_save": 1,
2020
# Simulation Algorithm Parameters
2121
"num_patches": 1,
22-
"model_eqns": 2,
22+
"model_eqns": "5eq",
2323
"alt_soundspeed": "F",
2424
"num_fluids": 1,
2525
"mpp_lim": "F",
2626
"mixture_err": "F",
27-
"time_stepper": 3,
27+
"time_stepper": "rk3",
2828
"weno_order": 5,
2929
"weno_eps": 1.0e-16,
3030
"teno": "T",
3131
"teno_CT": 1e-8,
3232
"null_weights": "F",
3333
"mp_weno": "F",
34-
"riemann_solver": 2,
35-
"wave_speeds": 1,
36-
"avg_state": 2,
34+
"riemann_solver": "hllc",
35+
"wave_speeds": "direct",
36+
"avg_state": "arithmetic",
3737
"bc_x%beg": -6,
3838
"bc_x%end": -6,
3939
# Formatted Database Files Structure Parameters
40-
"format": 1,
41-
"precision": 2,
40+
"format": "silo",
41+
"precision": "double",
4242
"prim_vars_wrt": "T",
4343
"rho_wrt": "T",
4444
"parallel_io": "T",

examples/1D_acoustic_sine_wavelength/case.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@
1919
"t_step_save": 5,
2020
# Simulation Algorithm Parameters
2121
"num_patches": 1,
22-
"model_eqns": 2,
22+
"model_eqns": "5eq",
2323
"alt_soundspeed": "F",
2424
"num_fluids": 1,
2525
"mpp_lim": "F",
2626
"mixture_err": "F",
27-
"time_stepper": 3,
27+
"time_stepper": "rk3",
2828
"weno_order": 5,
2929
"weno_eps": 1.0e-16,
3030
"teno": "T",
3131
"teno_CT": 1e-8,
3232
"null_weights": "F",
3333
"mp_weno": "F",
34-
"riemann_solver": 2,
35-
"wave_speeds": 1,
36-
"avg_state": 2,
34+
"riemann_solver": "hllc",
35+
"wave_speeds": "direct",
36+
"avg_state": "arithmetic",
3737
"bc_x%beg": -6,
3838
"bc_x%end": -6,
3939
# Formatted Database Files Structure Parameters
40-
"format": 1,
41-
"precision": 2,
40+
"format": "silo",
41+
"precision": "double",
4242
"prim_vars_wrt": "T",
4343
"rho_wrt": "T",
4444
"parallel_io": "T",

examples/1D_advection_convergence/case.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939

4040
if args.muscl:
4141
scheme_params = {
42-
"recon_type": 2,
43-
"muscl_order": 2,
42+
"recon_type": "muscl",
43+
"muscl_order": "second_order",
4444
"muscl_lim": args.muscl_lim,
4545
}
4646
else:
4747
scheme_params = {
48-
"recon_type": 1,
48+
"recon_type": "weno",
4949
"weno_order": args.order,
5050
"weno_eps": 1.0e-16,
5151
"weno_Re_flux": "F",
@@ -69,19 +69,19 @@
6969
"t_step_stop": Nt,
7070
"t_step_save": Nt,
7171
"num_patches": 1,
72-
"model_eqns": 2,
72+
"model_eqns": "5eq",
7373
"alt_soundspeed": "F",
7474
"num_fluids": 2,
7575
"mpp_lim": "F",
7676
"mixture_err": "F",
77-
"time_stepper": 3,
78-
"riemann_solver": 2,
79-
"wave_speeds": 1,
80-
"avg_state": 2,
77+
"time_stepper": "rk3",
78+
"riemann_solver": "hllc",
79+
"wave_speeds": "direct",
80+
"avg_state": "arithmetic",
8181
"bc_x%beg": -1,
8282
"bc_x%end": -1,
83-
"format": 1,
84-
"precision": 2,
83+
"format": "silo",
84+
"precision": "double",
8585
"prim_vars_wrt": "T",
8686
"parallel_io": "F",
8787
"patch_icpp(1)%geometry": 1,

examples/1D_brio_wu/case.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@
2222
"t_step_save": 100,
2323
# Simulation Algorithm Parameters
2424
"num_patches": 2,
25-
"model_eqns": 2,
25+
"model_eqns": "5eq",
2626
"alt_soundspeed": "F",
2727
"num_fluids": 1,
2828
"mpp_lim": "F",
2929
"mixture_err": "F",
30-
"time_stepper": 3,
30+
"time_stepper": "rk3",
3131
"weno_order": 5,
3232
"mapped_weno": "T",
3333
"weno_eps": 1.0e-16,
3434
"null_weights": "F",
3535
"mp_weno": "F",
36-
"riemann_solver": 1,
37-
"wave_speeds": 1,
38-
"avg_state": 2,
36+
"riemann_solver": "hll",
37+
"wave_speeds": "direct",
38+
"avg_state": "arithmetic",
3939
"bc_x%beg": -3,
4040
"bc_x%end": -3,
4141
# Formatted Database Files Structure Parameters
42-
"format": 1,
43-
"precision": 2,
42+
"format": "silo",
43+
"precision": "double",
4444
"prim_vars_wrt": "T",
4545
"rho_wrt": "T",
4646
"parallel_io": "T",

examples/1D_brio_wu_hlld/case.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,25 @@
2323
"t_step_save": 100,
2424
# Simulation Algorithm Parameters
2525
"num_patches": 2,
26-
"model_eqns": 2,
26+
"model_eqns": "5eq",
2727
"alt_soundspeed": "F",
2828
"num_fluids": 1,
2929
"mpp_lim": "F",
3030
"mixture_err": "F",
31-
"time_stepper": 3,
31+
"time_stepper": "rk3",
3232
"weno_order": 5,
3333
"mapped_weno": "T",
3434
"weno_eps": 1.0e-16,
3535
"null_weights": "F",
3636
"mp_weno": "F",
37-
"riemann_solver": 4,
38-
"wave_speeds": 1,
39-
"avg_state": 2,
37+
"riemann_solver": "hlld",
38+
"wave_speeds": "direct",
39+
"avg_state": "arithmetic",
4040
"bc_x%beg": -3,
4141
"bc_x%end": -3,
4242
# Formatted Database Files Structure Parameters
43-
"format": 1,
44-
"precision": 2,
43+
"format": "silo",
44+
"precision": "double",
4545
"prim_vars_wrt": "T",
4646
"rho_wrt": "T",
4747
"parallel_io": "T",

0 commit comments

Comments
 (0)