pyopensn.math.ScalarSpatialMaterialFunction
- class pyopensn.math.ScalarSpatialMaterialFunction
Scalar spatial material function.
Functions that accept a material ID and a point as input and return a scalar.
Wrapper of
opensn::ScalarSpatialMaterialFunction
.Examples
>>> # Create from a Python function >>> def foo(id, xyz): ... return 0.0 >>> f = ScalarSpatialMaterialFunction(foo) >>> >>> # Create from lambda >>> g = ScalarSpatialMaterialFunction(lambda id, p : p.x + p.y + p.z) >>> >>> # Evaluate >>> f(0, Vector3()) 0.0 >>> g(0, Vector3(1.0, 2.0, 3.0)) 6.0
- __call__(self: pyopensn.math.ScalarSpatialMaterialFunction, mat_id: int, xyz: pyopensn.math.Vector3) float
Evaluate the associated function.
- Parameters:
mat_id (int) – The material ID of the cell.
xyz (pyopensn.math.Vector3) – The xyz coordinates of the point where the function is called.
- __init__(self: pyopensn.math.ScalarSpatialMaterialFunction, func: Callable[[int, pyopensn.math.Vector3], float]) None
Construct a scalar spatial material function from associated Python function or lambda.
- Parameters:
func (Callable[[int, pyopensn.math.Vector3], float]) – Referenced scalar spatial material function.