CustomSpecification#

class ansys.dpf.core.operator_specification.CustomSpecification(description=None, server=None)#

Bases: Specification

Create an operator specification with its description.

Allows to create an Operator Specification with its description (what the Operator does), its inputs and outputs and some properties. Inherits from Specification (which has only getters) to implement setters.

Designed to be used in an implementation of CustomOperatorBase for the property specification.

Notes

Is only implemented for usage with type(server)= ansys.dpf.core.server_types.InProcessServer and server version higher than 4.0.

Examples

>>> from ansys.dpf.core.custom_operator import CustomOperatorBase
>>> from ansys.dpf.core import Field
>>> from ansys.dpf.core.operator_specification import CustomSpecification,     SpecificationProperties, PinSpecification
>>> class AddFloatToFieldData(CustomOperatorBase):
...     def run(self):
...         field = self.get_input(0, Field)
...         to_add = self.get_input(1, float)
...         data = field.data
...         data += to_add
...         self.set_output(0, field)
...         self.set_succeeded()
...
...     @property
...     def specification(self):
...         spec = CustomSpecification()
...         spec.description = "Add a custom value to all the data of an input Field"
...         spec.inputs = {
...             0: PinSpecification("field", [Field], "Field on which float value is added."),
...             1: PinSpecification("to_add", [float], "Data to add.") }
...         spec.outputs = {
...             0: PinSpecification("field", [Field], "Updated field.")}
...         spec.properties = SpecificationProperties("custom add to field", "math")
...         return spec
...
...     @property
...     def name(self):
...         return "custom_add_to_field"

Overview#

description

Description of the operation applied by the Operator.

inputs

Dictionary mapping the input pin numbers to their PinSpecification.

outputs

Returns a dictionary mapping the output pin numbers to their PinSpecification.

config_specification

Documents the available configuration options supported by the Operator.

properties

Return additional properties of the Operator.

Import detail#

from ansys.dpf.core.operator_specification import CustomSpecification

Property detail#

property CustomSpecification.description: str#

Description of the operation applied by the Operator.

property CustomSpecification.inputs: dict#

Dictionary mapping the input pin numbers to their PinSpecification.

Returns:

inputs

Return type:

dict[int:PinSpecification]

property CustomSpecification.outputs: dict#

Returns a dictionary mapping the output pin numbers to their PinSpecification.

Returns:

outputs

Return type:

dict[int:PinSpecification]

property CustomSpecification.config_specification: ConfigSpecification#

Documents the available configuration options supported by the Operator.

Return type:

ConfigSpecification

property CustomSpecification.properties: SpecificationProperties#

Return additional properties of the Operator.

Returns some additional properties of the Operator, like the category, the exposure, the scripting and user names and the plugin