1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 OUTRAM PARK contributors
// Derived from OpenFOAM (www.openfoam.com / openfoam.org)
// Copyright (C) 2017-2026 OpenFOAM Foundation
// Upstream project: OpenFOAM-dev (OpenFOAM Foundation), vendored read-only at
// crates/outram-foam-turbulence-lib/upstream_source/OpenFOAM
// (README.org dated 14th July 2026; etc/bashrc WM_PROJECT_VERSION=dev).
// Upstream source: src/OpenFOAM/primitives/functions/Function1/ — the `table`
// entry of `Foam::Function1<scalar>`, as used by
// `porosityModels::solidification` (`D`) and `fv::VoFSolidificationMelting`
// (`alphaSolidT`).
// Upstream licence: GPL-3.0-or-later.
//
// This file is part of OUTRAM PARK. See `src/lib.rs` for the full licence
// notice.
//! A tabulated function of temperature — the `Function1` `table` entry the
//! solidification models take their coefficients from.
//!
//! # What belongs here, and what does not
//!
//! Only the table lookup: ascending temperature knots, linear interpolation
//! between them, clamping outside them. It carries no unit and no physical
//! meaning of its own — the model that owns one says what its values are.
//!
//! This is *not* a general port of `Foam::Function1`. Upstream's `Function1`
//! also covers constants, polynomials, sine waves, CSV files and coded
//! expressions, dispatched at runtime; none of that is here, and adding it
//! would belong in its own module rather than this one.
use crateinterpolate_xy;
use Arc;
/// A monotone-in-temperature lookup table with linear interpolation and
/// end-clamping.
///
/// Upstream's `Function1<scalar>` `table` entry. Two knots are the usual case
/// for a phase-change coefficient — one value below the freezing point, another
/// above it — which makes the function ramp linearly across the interval
/// between them instead of stepping discontinuously.
///
/// # Units
///
/// `temperatures` are kelvin \[K\]. **`values` have whatever unit the owning
/// model gives them** — a rate \[1/s\] for
/// [`SolidificationPorosity`](super::SolidificationPorosity)'s drag `D(T)`, a
/// dimensionless fraction \[-\] for
/// [`VofSolidificationMelting`](super::VofSolidificationMelting)'s
/// `alphaSolid(T)`. The table itself does not know and does not check.
///
/// # Valid ranges
///
/// `temperatures` must be **strictly ascending**; `values` need not be monotone
/// in either direction (the drag table descends, and a fraction table may do
/// either). A query outside the tabulated range returns the nearest end value
/// rather than extrapolating, which is `Function1`'s `table` behaviour and is
/// what lets a two-knot table act as a smoothed step.