pyopensn.math.ScalarMaterialFunction
- class pyopensn.math.ScalarMaterialFunction
Scalar material function.
Functions that accept a material ID and a value as input and return a scalar.
Wrapper of
opensn::ScalarMaterialFunction
.Examples
>>> # Create from a Python function >>> def foo(val, id): ... return val * id >>> f = ScalarMaterialFunction(foo) >>> >>> # Create from lambda >>> g = ScalarMaterialFunction(lambda x, i : 2*x) >>> >>> # Evaluate >>> f(1.0, 1) 1.0 >>> g(1.0, 1) 2.0
- __call__(self: pyopensn.math.ScalarMaterialFunction, val: float, mat_id: int) float
Evaluate the associated function.
- Parameters:
val (float) – The scalar value (for example, a field function value).
mat_id (int) – The material ID of the cell.
- __init__(self: pyopensn.math.ScalarMaterialFunction, func: Callable[[float, int], float]) None
Construct a scalar material function from associated Python function or lambda.
- Parameters:
func (Callable[[float, int], float]) – Referenced scalar material function.