Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/documentation/case.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ Additional details on this specification can be found in [NACA airfoil](https://

- `thermal_layer` = δ > 0 starts the gas around a `thermal_bc = 1` or `3` circle (geometry 2) or sphere (geometry 8) in the conduction solution for a wall brought to `Twall` (the initial `Twall` for `thermal_bc = 3`) a time t₀ = δ²/(4α) earlier: T = T∞ + (`Twall` − T∞)(R/r)^((d−1)/2) erfc((r − R)/δ), with pressure and composition unchanged. It is exact for a sphere and the leading-order term for a cylinder. Without it a hot wall meets ambient gas as a temperature step at t = 0, and the near-wall cells heat faster than they can expand; on coarse grids that transient can drive the state non-physical. Resolve δ with a few cells: the profile is evaluated at the cell centres, not cell-averaged, so the cell-mean density differs from it by O((h/δ)²), about 1 % at δ = 2 cells. Where layers overlap, the IB with the largest temperature change sets the cell, and periodic directions use the nearest image.

- `wall_column` = T gives each first-layer ghost of the wall a one-dimensional low-Mach conduction column along the wall normal, from the wall at `Twall` to a distance max(3h, `wall_column_len`), with the body's curvature, frozen composition and the gas temperature and pressure at its top (a Lagrange probe). The ghost's conduction temperature (see `thermal_bc = 1` above) mirrors the first gas cell's temperature, which carries at most about 2λΔT/h through the face, far below the flux of a wall layer thinner than a cell. The column advances once per step from the state of the step's first stage; its step-mean wall flux enters the gas as one equivalent conduction temperature per ghost, with the diffusion flux's own face conductivity and the steady radial weight of each gas face. A one-sided guard cuts the drain of a gas cell colder than the column averaged over its own area (zero in steady state). With `ib_heat_wrt` the body books the column's flux: the gas faces' flux plus the guard's cut. `wall_column_dt_frac` adds a time-step limit (`WCOL`) that keeps a step's column drain within that fraction of a near-wall cell's heat span. The option requires `chemistry`, `chem_params%%diffusion`, `chem_params%%transport_model = 1`, `surface_reaction = 0`, fixed bodies, no AMR, and `cfl_adap_dt` or `cfl_const_dt`. The default F leaves every result unchanged.
- `wall_column` = T gives each first-layer ghost of the wall a one-dimensional low-Mach conduction column along the wall normal, from the wall at `Twall` to a distance max(3h, `wall_column_len`), with the body's curvature, frozen composition and the gas temperature and pressure at its top (a Lagrange probe). The ghost's conduction temperature (see `thermal_bc = 1` above) mirrors the first gas cell's temperature, which carries at most about 2λΔT/h through the face, far below the flux of a wall layer thinner than a cell. The column advances once per step from the state of the step's first stage; its step-mean wall flux enters the gas as one equivalent conduction temperature per ghost, with the diffusion flux's own face conductivity and the steady radial weight of each gas face. A one-sided guard cuts the drain of a gas cell colder than the column averaged over its own area (zero in steady state). With `ib_heat_wrt` the body books the column's flux: the gas faces' flux plus the guard's cut. `wall_column_dt_frac` adds a time-step limit (`WCOL`) that keeps a step's column drain within that fraction of a near-wall cell's heat span. The option requires `chemistry`, `chem_params%%diffusion`, `chem_params%%transport_model = 1`, `surface_reaction = 0`, fixed bodies, no AMR, and `cfl_adap_dt` or `cfl_const_dt`. With `cfl_const_dt` the limit is evaluated once, at the first step, from the column's initial (semi-infinite-wall) flux estimate, and stays in the constant dt: conservative, possibly much smaller than needed. The default F leaves every result unchanged.

- `surface_reaction` enables heterogeneous surface chemistry when set to 1. Surface reactions require `chemistry = T` and cannot be combined with `inj_species > 0`.

Expand Down
2 changes: 1 addition & 1 deletion docs/documentation/validation_cyl_drag_nu.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Heat transfer, Tw/T_inf = 1.1, 20 cells/D:
| Re | Nu | Lange | err | Churchill-Bernstein | err |
| ---: | ---: | ---: | ---: | ---: | ---: |
| 20 | 2.442 | 2.409 | +1.4 % | 2.479 | -1.5 % |
| 40 | 3.243 | 3.281 | -1.1 % | 3.386 | -4.2 % |
| 40 | 3.243 | 3.281 | -1.2 % | 3.386 | -4.2 % |
| 100 | 4.962 | 5.128 | -3.2 % | 5.190 | -4.4 % |

## Assessment
Expand Down
1 change: 1 addition & 0 deletions docs/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ @article{Maw1976
volume = {38},
pages = {101--114},
year = {1976}
}

@book{ShahLondon1978,
author = {R. K. Shah and A. L. London},
Expand Down
2 changes: 1 addition & 1 deletion examples/2D_ibm_cylinder_drag_nu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Re 20 and 40 and Henderson (mean Cd 1.35) for Re 100.
| 20 | 10 | 1.982 | 1.983 | 0.721 | not run |
| 20 | 20 | 2.029 (-1.0 %) | 2.029 | 0.818 (ref 0.94) | 2.442 (Lange +1.4 %) |
| 40 | 10 | 1.500 | 1.498 | 1.932 | not run |
| 40 | 20 | 1.521 (+0.1 %) | 1.519 | 2.064 (ref 2.35) | 3.243 (Lange -1.1 %) |
| 40 | 20 | 1.521 (+0.1 %) | 1.519 | 2.064 (ref 2.35) | 3.243 (Lange -1.2 %) |
| 100 | 20 | 1.354 (+0.3 %) | 1.332 | shedding | 4.962 (Lange -3.2 %) |

Re 100 used a smaller domain ([-8 D, 16 D] x [-8 D, 8 D], 6 % blockage) and `t U / D` = 120: Cl amplitude 0.287 (references
Expand Down
4 changes: 2 additions & 2 deletions examples/2D_ibm_cylinder_drag_nu/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
python3 examples/2D_ibm_cylinder_drag_nu/check_cylinder.py <case directory> [--hot <heated run directory>]

Defaults are a CI-sized run (Re 20, 16 cells per D, a 12 D x 8 D domain, 200 fixed steps: the flow is not steady). Production-like
values for a table run: --xu 15 --xd 25 --hy 16 (blockage 3 %), --cells_per_D 20 or 40, --tstar 50 (Re 20 and 40) or 200 (Re 100),
values for a table run: --xu 15 --xd 25 --hy 16 (blockage 3 %), --cells_per_D 20 or 40, --tstar 50 (Re 20 and 40) or 120 (Re 100),
with the adaptive time step (--tstar sets it); the README lists the commands.
"""

Expand All @@ -32,7 +32,7 @@
parser.add_argument("--hy", type=float, default=4.0, help="Lateral half width [D]; the blockage is 1/(2 hy).")
parser.add_argument("--steps", type=int, default=200, help="Fixed number of steps (CI-sized run); 0 selects the adaptive step with --tstar.")
parser.add_argument("--tstar", type=float, default=50.0, help="Run length t U / D when --steps is 0.")
parser.add_argument("--cfl", type=float, default=0.4, help="CFL number of the fixed step or the adaptive step.")
parser.add_argument("--cfl", type=float, default=0.4, help="CFL number of the fixed step (the adaptive step uses cfl_target, set from Re and --cells_per_D).")
parser.add_argument("--frames", type=int, default=10, help="Saves of the adaptive run (a fixed-step run saves once, at the end).")
parser.add_argument("--stride", type=int, default=20, help="ib_force_stride: steps between force and heat rows.")
parser.add_argument("--ib_ip_interp", type=int, default=1, choices=(1, 2), help="Image-point interpolation (1: inverse distance, the default).")
Expand Down
6 changes: 5 additions & 1 deletion examples/2D_ibm_cylinder_drag_nu/check_cylinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

import numpy as np

trapezoid = getattr(np, "trapezoid", None) or np.trapz # np.trapezoid needs NumPy >= 2

# Reference values as tabulated in the papers (see the validation page for the citations)
CD_REF = {20: {"Dennis & Chang": 2.05, "Fornberg": 2.00}, 40: {"Dennis & Chang": 1.52, "Fornberg": 1.50}, 100: {"Henderson": 1.35, "Park et al.": 1.33}}
LD_REF = {20: 0.94, 40: 2.35} # Dennis & Chang
Expand Down Expand Up @@ -119,6 +121,8 @@ def fields(run, info, avg):
from mfc.viz.silo_reader import assemble_silo

steps = sorted(int(os.path.basename(f)[:-5]) for f in glob.glob(os.path.join(run, "silo_hdf5", "p0", "*.silo")) if os.path.basename(f)[:-5].isdigit())
if not steps:
raise SystemExit(f"{run}/silo_hdf5/p0 holds no *.silo saves (run with --silo and post_process)")
use = [s for s in steps if s >= (1 - avg) * steps[-1]] or steps[-1:]
cvs = []
for s in use:
Expand All @@ -143,7 +147,7 @@ def cv_drag(xs, V, info, half):
for j in range(2): # face normal
flux = rho * vel[0] * vel[j] - mu * (g[0][j] + g[j][0]) + (p + 2 / 3 * mu * div) * (j == 0)
for end, sign in ((-1, 1.0), (0, -1.0)):
total += sign * np.trapezoid(np.take(flux, end, axis=j), xb[1 - j])
total += sign * trapezoid(np.take(flux, end, axis=j), xb[1 - j])
return -total / info["q"]


Expand Down
14 changes: 12 additions & 2 deletions examples/2D_thermal_channel/check_nu.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import cantera as ct
import numpy as np

trapezoid = getattr(np, "trapezoid", None) or np.trapz # np.trapezoid needs NumPy >= 2

parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("runs", nargs="+", help="One run directory, or the hot and the cold run directory.")
parser.add_argument("--win", type=float, default=0.1, help="Averaging window, fraction of the mean_temp.dat rows (default 0.1).")
Expand Down Expand Up @@ -58,7 +60,7 @@ def nu_exact(pe_h, n=400):
psi = np.concatenate([[0.0], v[:m, i].real, [0.0]])
psi /= psi[n // 2]
uu = 6.0 * eta * (1.0 - eta)
psi_m = np.trapezoid(uu * psi, eta) / np.trapezoid(uu, eta)
psi_m = trapezoid(uu * psi, eta) / trapezoid(uu, eta)
return 2.0 * (-3.0 * psi[0] + 4.0 * psi[1] - psi[2]) / (2.0 * h) / psi_m, w[i].real


Expand All @@ -81,7 +83,15 @@ def conductivity(temp):

# wall gradient from the last save: T from the conservative state through the mechanism
last = max(glob.glob(os.path.join(d, "p_all", "p0", "*")), key=lambda s: int(os.path.basename(s)))
q = [np.fromfile(os.path.join(last, f"q_cons_vf{i}.dat"), dtype=args.dtype, offset=4, count=nx * ny).reshape(ny, nx) for i in range(1, 6 + gas.n_species)]

def read_cons(i):
# one Fortran unformatted record per file: a 4-byte marker, nx*ny values, a 4-byte marker
path = os.path.join(last, f"q_cons_vf{i}.dat")
if os.path.getsize(path) != 8 + nx * ny * np.dtype(args.dtype).itemsize:
sys.exit(f"{path}: size does not match one {nx} x {ny} record of {args.dtype} (wrong --dtype or grid?)")
return np.fromfile(path, dtype=args.dtype, offset=4, count=nx * ny).reshape(ny, nx)

q = [read_cons(i) for i in range(1, 6 + gas.n_species)]
rho, e_tot = q[0], q[3]
kin = 0.5 * (q[1] ** 2 + q[2] ** 2) / rho**2
temp = np.empty_like(rho)
Expand Down
2 changes: 2 additions & 0 deletions src/simulation/m_ibm.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -4905,6 +4905,8 @@ contains
if (allocated(wc_T)) then
@:DEALLOCATE(wc_T, wc_w, wc_g, wc_ext, wc_q, wc_cut, wc_on, wc_gp)
end if
n_wc = 0
wc_ready = .false.
call s_finalize_ib_patches()
if (collision_model > 0) call s_finalize_collisions_module()
#ifdef MFC_MPI
Expand Down
2 changes: 1 addition & 1 deletion toolchain/mfc/case_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ def check_ibm(self):
self.prohibit(moving, f"{pre} requires every immersed boundary to be fixed (moving_ibm = 0)")
self.prohibit(self.get("amr", "F") == "T", f"{pre} is not supported with amr")
self.prohibit(self.get("cfl_adap_dt", "F") != "T" and self.get("cfl_const_dt", "F") != "T", f"{pre} requires cfl_adap_dt or cfl_const_dt (the WCOL time-step limit)")
self.prohibit(not 0 < (self.get("wall_column_dt_frac", 0.1) or 0.1) <= 1, "wall_column_dt_frac must be in (0, 1]")
self.prohibit(not 0 < self.get("wall_column_dt_frac", 0.1) <= 1, "wall_column_dt_frac must be in (0, 1]")

if surface_reaction == 1:
self.prohibit(not chemistry, f"patch_ib({i})%surface_reaction = 1 requires chemistry = T")
Expand Down
7 changes: 6 additions & 1 deletion toolchain/mfc/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ def nvhpc_gpu_known_difference(uuid: str, gpu: str, fc_version: str) -> bool:
return uuid in NVHPC_GPU_KNOWN_DIFFERENCE_UUIDS and gpu != "no" and bool(match) and (int(match[1]), int(match[2])) < NVHPC_GPU_FIXED_VERSION


def gpu_fc_version(fc_version: str, probe=lambda: _compiler_version("nvfortran")) -> str:
"""`fc_version` unless it names no known compiler (a wrapper such as mpifort or ftn that hides it): then `nvfortran --version`."""
return fc_version if re.search(r"\b(nvfortran|gnu|cray|ifx|ifort|flang|clang)", fc_version, re.I) else probe()


def __filter(cases_) -> typing.Tuple[typing.List[TestCase], typing.List[TestCase]]:
cases = cases_[:]
selected_cases = []
Expand Down Expand Up @@ -380,7 +385,7 @@ def is_uuid(term):
cases.remove(case)

fc = os.environ.get("FC", "").split(maxsplit=1)
fc_version = _compiler_version(fc[0]) if fc and ARG("gpu") != "no" else ""
fc_version = gpu_fc_version(_compiler_version(fc[0]) if fc else "") if ARG("gpu") != "no" else ""
for case in cases[:]:
if nvhpc_gpu_known_difference(case.get_uuid(), ARG("gpu"), fc_version):
cons.print(f"[yellow]skipped {case.get_uuid()} ({case.trace}): known difference on NVHPC < 25.11 GPU, see #2181[/yellow]")
Expand Down
16 changes: 15 additions & 1 deletion toolchain/mfc/test/test_nvhpc_known_difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from mfc.test.test import nvhpc_gpu_known_difference
from mfc.test.test import gpu_fc_version, nvhpc_gpu_known_difference

OLD = "nvfortran 25.5-0 64-bit target on x86-64 Linux -tp haswell"

Expand All @@ -25,3 +25,17 @@
)
def test_skip_decision(uuid, gpu, version, skipped):
assert nvhpc_gpu_known_difference(uuid, gpu, version) is skipped


@pytest.mark.parametrize(
"fc_version, probed, expected",
[
(OLD, "unused", OLD),
("GNU Fortran (GCC) 13.2.0", "unused", "GNU Fortran (GCC) 13.2.0"),
("mpifort 4.1", OLD, OLD),
("", OLD, OLD),
("ftn 25.5", "", ""),
],
)
def test_wrapper_falls_back_to_nvfortran(fc_version, probed, expected):
assert gpu_fc_version(fc_version, lambda: probed) == expected
1 change: 1 addition & 0 deletions toolchain/mfc/test_case_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ def test_a_wall_column_needs_a_fixed_inert_isothermal_circle_or_sphere(self):
self.assertRejects({**col, "chem_params%transport_model": 2}, "requires chem_params%transport_model = 1")
self.assertRejects({**col, "cfl_adap_dt": "F"}, "requires cfl_adap_dt or cfl_const_dt")
self.assertRejects({**col, "wall_column_dt_frac": 2.0}, "wall_column_dt_frac must be in (0, 1]")
self.assertRejects({**col, "wall_column_dt_frac": 0.0}, "wall_column_dt_frac must be in (0, 1]")
self.assertRejects({**col, "patch_ib(1)%wall_column_len": -1.0}, "wall_column_len must be >= 0")

def test_the_energy_balance_needs_a_reacting_surface(self):
Expand Down
Loading