checkpoint#

VectorReal.checkpoint(name: str | None = None) FieldExpression#

Register this expression and return a single-entry reference to it.

Combining a sub-expression with itself duplicates its operations every time (for example dot(a, a) repeats a), so heavy reuse can grow the operation stack very quickly and overflow the calculator. Checkpoint the sub-expression once, then continue from the returned reference, whose operation stack is a single NameOfExpression entry. This mirrors the calculator’s own named-expression / CopyToStack mechanism.

Parameters:
namestr, optional

Named-expression name. A unique one is generated when not provided.

Returns:
FieldExpression

A new expression of the same kind referencing the registered name.

Examples

Reuse a named sub-expression through a single entry.

>>> calc = type(
...     "Calc",
...     (),
...     {
...         "design_type": "HFSS",
...         "add_expression": staticmethod(lambda *args, **kwargs: kwargs["name"]),
...     },
... )()
>>> from ansys.aedt.core.visualization.post.field_calculator_expressions import FieldExpressions
>>> fx = FieldExpressions(calc)
>>> ref = fx.vector("E").magnitude().checkpoint("e_mag")
>>> ref.operations
["NameOfExpression('e_mag')"]