pyopensn.math.VectorSpatialFunction

class pyopensn.math.VectorSpatialFunction

Vector spatial function.

Functions that accept a point and a number of groups as input and return a vector (per group).

Wrapper of opensn::VectorSpatialFunction.

Examples

>>> # Create from a Python function
>>> def foo(point, n_groups):
...     return [point.x * point.y] * n_groups
>>> f = VectorSpatialFunction(foo)
>>>
>>> # Create from lambda
>>> g = VectorSpatialFunction(lambda p, n : [p.x + p.y + p.z] * n)
>>>
>>> # Evaluate
>>> f(Vector3(1.0, 2.0, 3.0), 2)
[2.0, 2.0]
>>> g(Vector3(1.0, 2.0, 3.0), 3)
[6.0, 6.0, 6.0]
__call__(self: pyopensn.math.VectorSpatialFunction, xyz: pyopensn.math.Vector3, num_groups: int) list[float]

Evaluate the associated function.

Parameters:
  • xyz (pyopensn.math.Vector3) – The xyz coordinates of the point where the function is called.

  • num_groups (int) – The number of groups.

__init__(self: pyopensn.math.VectorSpatialFunction, func: Callable[[pyopensn.math.Vector3, int], list[float]]) None

Construct a vector spatial function from associated Python function or lambda.

Parameters:

func (Callable[[pyopensn.math.Vector3, int], List[float]]) – Referenced vector spatial function.