get_values#

ENS_PART_AUX_GEOM.get_values(variables: List[Any], ids: List[int] | None = None, use_nan: int = 0, activate: int = 0) dict#

This method returns nodal or element values for specified variables on the part.

Args:
variables:

A list of variable references. A mixture of ENS_VAR objects, variable names (string) or variable ids (integers).

ids:

This keyword can be used to restrict the output to a specific collection of element or node ids. If you restrict to a given list of ids and ids are not present then an empty dictionary will be returned. It is not possible to specify separate lists for both node and element ids, so the caller must separate these into two calls. Select your part in the part list and query the part. The resulting dialog will tell you if you have ids and the ranges of the node and/or element ids. This feature can also be used to “batch” the operation.

use_nan:

EnSight uses a specific value for the ‘Undefined’ value (ensight.Undefined), use_nan is set to 1, the API will return NumPy NaN values wherever this value would be returned.

activate:

By default, if a variable specified in variables is not active, this method will throw an exception. If 1 is specified, any inactive variables will be activated as needed.

Returns:

The returned value is a dictionary. The keys to the dictionary are the objects passed in variables and the values are NumPy Float arrays. For constants the value is a one dimensional array with a single value. For other scalar variables, the value will be a 1D array of values (complex values are returned as NumPy complex types). For vector, tensor and Coordinate variables, a 2D array is returned. The first dimension is the element or node count and the second dimension will be 3, 9 or 3 respectively Note: Tensor variables will always be expanded to 9 values when returned. If any nodal variables are returned, an additional key “NODAL_IDS” will be present and will contain a NumPy array of integers that are the EnSight node IDs for any returned node value. Similarly, if any element variables are returned, “ELEMENT_IDS” will be present. Note if the part does not have element or nodal ids then a list of [-1,-1,-1,….] will be returned. If the variable is a case constant, the value is returned. If the variable is a part constant, the value for this part is returned.

Example:
s = LocalLauncher().start()
s.load_data(f"{s.cei_home}/ensight{s.cei_suffix}/data/guard_rail/crash.case")
p = s.ensight.objs.core.PARTS['guardrail'][0]
v = s.ensight.objs.core.VARIABLES[('Coordinates', 'plastic')]
p.get_values(v, activate=1)
# returned dictionary includes all the nodal Coordinates and plastic values
# as well as the node IDs.  Note: the ENS_VAR 'Coordinates' is object id 1034.
{ensight.objs.wrap_id(1034): array([[ 0.0000e+00, -8.1700e+00,  3.7600e+02],
   [ 0.0000e+00, -4.8670e+01,  3.9850e+02],
   [ 0.0000e+00, -8.9170e+01,  4.2100e+02],
   ...,
   [ 1.1335e+04, -8.1700e+00,  6.9000e+02],
   [ 1.1430e+04, -4.8670e+01,  6.6750e+02],
   [ 1.1430e+04, -8.1700e+00,  6.9000e+02]], dtype=float32),
   'NODE_IDS': array([   1,    2,    3, ..., 1818, 1819, 1820]),
   ensight.objs.wrap_id(1022): array([2.3110e-03, 1.2812e-03, 3.5511e-04, ..., 8.2598e-06, 8.2598e-06,
   1.6520e-05], dtype=float32)}