Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions doc/source/_static/dpf_operators.html

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions src/ansys/dpf/core/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from ansys import dpf
from ansys.dpf.core import dimensionality, errors, meshed_region, scoping, time_freq_support
from ansys.dpf.core.available_result import Homogeneity
from ansys.dpf.core.check_version import server_meet_version_and_raise
from ansys.dpf.core.common import (
_get_size_of_list,
locations,
Expand All @@ -50,6 +51,7 @@
from ansys.dpf.gate.errors import DPFServerException

if TYPE_CHECKING: # pragma: nocover
from ansys.dpf.core.data_tree import DataTree
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.meshed_region import MeshedRegion
from ansys.dpf.core.results import Result
Expand Down Expand Up @@ -804,6 +806,27 @@
def meshed_region(self, value: MeshedRegion):
self._set_support(support=value, support_type="MESHED_REGION")

@property
def header(self) -> DataTree:
"""Field Header, which stores metadata of the Field.

Returns
-------
:class:`ansys.dpf.core.data_tree.DataTree`

"""
server_meet_version_and_raise(

Check warning on line 818 in src/ansys/dpf/core/field.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/field.py#L818

Added line #L818 was not covered by tests
required_version="11.0",
server=self._server,
msg="Getting a Field Header requires DPF 11.0 (2026 R1) or above.",
)
from ansys.dpf.core import dpf_operator

Check warning on line 823 in src/ansys/dpf/core/field.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/field.py#L823

Added line #L823 was not covered by tests

op = dpf_operator.Operator("field::get_attribute", server=self._server)
op.connect(0, self)
op.connect(1, "header")
return op.get_output(0, types.data_tree)

Check warning on line 828 in src/ansys/dpf/core/field.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/field.py#L825-L828

Added lines #L825 - L828 were not covered by tests

def __add__(self, field_b):
"""Add two fields.

Expand Down
2 changes: 2 additions & 0 deletions src/ansys/dpf/core/operators/utility/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .change_location import change_location
from .change_shell_layers import change_shell_layers
from .compute_time_scoping import compute_time_scoping
from .customtypefield_get_attribute import customtypefield_get_attribute
from .default_value import default_value
from .delegate_to_operator import delegate_to_operator
from .ds_get_attribute import ds_get_attribute
Expand Down Expand Up @@ -64,6 +65,7 @@
from .overlap_fields import overlap_fields
from .producer_consumer_for_each import producer_consumer_for_each
from .property_field import property_field
from .propertyfield_get_attribute import propertyfield_get_attribute
from .python_generator import python_generator
from .remote_operator_instantiate import remote_operator_instantiate
from .remote_workflow_instantiate import remote_workflow_instantiate
Expand Down
252 changes: 252 additions & 0 deletions src/ansys/dpf/core/operators/utility/customtypefield_get_attribute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
"""
customtypefield_get_attribute

Autogenerated DPF operator classes.
"""

from __future__ import annotations

from warnings import warn
from ansys.dpf.core.dpf_operator import Operator
from ansys.dpf.core.inputs import Input, _Inputs
from ansys.dpf.core.outputs import Output, _Outputs
from ansys.dpf.core.outputs import _modify_output_spec_with_one_type
from ansys.dpf.core.operators.specification import PinSpecification, Specification
from ansys.dpf.core.config import Config
from ansys.dpf.core.server_types import AnyServerType


class customtypefield_get_attribute(Operator):
r"""A CustomTypeField in pin 0 and a property name (string) in pin 1 are
expected in input.


Parameters
----------
custom_type_field: CustomTypeField
property_name: str
Accepted inputs are: 'time_freq_support', 'scoping' and 'header'.

Returns
-------
property: TimeFreqSupport or Scoping or DataTree
Property value.

Examples
--------
>>> from ansys.dpf import core as dpf

>>> # Instantiate operator
>>> op = dpf.operators.utility.customtypefield_get_attribute()

>>> # Make input connections
>>> my_custom_type_field = dpf.CustomTypeField()
>>> op.inputs.custom_type_field.connect(my_custom_type_field)
>>> my_property_name = str()
>>> op.inputs.property_name.connect(my_property_name)

>>> # Instantiate operator and connect inputs in one line
>>> op = dpf.operators.utility.customtypefield_get_attribute(
... custom_type_field=my_custom_type_field,
... property_name=my_property_name,
... )

>>> # Get output data
>>> result_property = op.outputs.property()
"""

def __init__(
self, custom_type_field=None, property_name=None, config=None, server=None
):
super().__init__(
name="customtypefield::get_attribute", config=config, server=server
)
self._inputs = InputsCustomtypefieldGetAttribute(self)
self._outputs = OutputsCustomtypefieldGetAttribute(self)
if custom_type_field is not None:
self.inputs.custom_type_field.connect(custom_type_field)
if property_name is not None:
self.inputs.property_name.connect(property_name)

@staticmethod
def _spec() -> Specification:
description = r"""A CustomTypeField in pin 0 and a property name (string) in pin 1 are
expected in input.
"""
spec = Specification(
description=description,
map_input_pin_spec={
0: PinSpecification(
name="custom_type_field",
type_names=["custom_type_field"],
optional=False,
document=r"""""",
),
1: PinSpecification(
name="property_name",
type_names=["string"],
optional=False,
document=r"""Accepted inputs are: 'time_freq_support', 'scoping' and 'header'.""",
),
},
map_output_pin_spec={
0: PinSpecification(
name="property",
type_names=["time_freq_support", "scoping", "abstract_data_tree"],
optional=False,
document=r"""Property value.""",
),
},
)
return spec

@staticmethod
def default_config(server: AnyServerType = None) -> Config:
"""Returns the default config of the operator.

This config can then be changed to the user needs and be used to
instantiate the operator. The Configuration allows to customize
how the operation will be processed by the operator.

Parameters
----------
server:
Server with channel connected to the remote or local instance. When
``None``, attempts to use the global server.

Returns
-------
config:
A new Config instance equivalent to the default config for this operator.
"""
return Operator.default_config(
name="customtypefield::get_attribute", server=server
)

@property
def inputs(self) -> InputsCustomtypefieldGetAttribute:
"""Enables to connect inputs to the operator

Returns
--------
inputs:
An instance of InputsCustomtypefieldGetAttribute.
"""
return super().inputs

@property
def outputs(self) -> OutputsCustomtypefieldGetAttribute:
"""Enables to get outputs of the operator by evaluating it

Returns
--------
outputs:
An instance of OutputsCustomtypefieldGetAttribute.
"""
return super().outputs


class InputsCustomtypefieldGetAttribute(_Inputs):
"""Intermediate class used to connect user inputs to
customtypefield_get_attribute operator.

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.utility.customtypefield_get_attribute()
>>> my_custom_type_field = dpf.CustomTypeField()
>>> op.inputs.custom_type_field.connect(my_custom_type_field)
>>> my_property_name = str()
>>> op.inputs.property_name.connect(my_property_name)
"""

def __init__(self, op: Operator):
super().__init__(customtypefield_get_attribute._spec().inputs, op)
self._custom_type_field = Input(
customtypefield_get_attribute._spec().input_pin(0), 0, op, -1
)
self._inputs.append(self._custom_type_field)
self._property_name = Input(
customtypefield_get_attribute._spec().input_pin(1), 1, op, -1
)
self._inputs.append(self._property_name)

@property
def custom_type_field(self) -> Input:
r"""Allows to connect custom_type_field input to the operator.

Returns
-------
input:
An Input instance for this pin.

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.utility.customtypefield_get_attribute()
>>> op.inputs.custom_type_field.connect(my_custom_type_field)
>>> # or
>>> op.inputs.custom_type_field(my_custom_type_field)
"""
return self._custom_type_field

@property
def property_name(self) -> Input:
r"""Allows to connect property_name input to the operator.

Accepted inputs are: 'time_freq_support', 'scoping' and 'header'.

Returns
-------
input:
An Input instance for this pin.

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.utility.customtypefield_get_attribute()
>>> op.inputs.property_name.connect(my_property_name)
>>> # or
>>> op.inputs.property_name(my_property_name)
"""
return self._property_name


class OutputsCustomtypefieldGetAttribute(_Outputs):
"""Intermediate class used to get outputs from
customtypefield_get_attribute operator.

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.utility.customtypefield_get_attribute()
>>> # Connect inputs : op.inputs. ...
>>> result_property = op.outputs.property()
"""

def __init__(self, op: Operator):
super().__init__(customtypefield_get_attribute._spec().outputs, op)
self.property_as_time_freq_support = Output(
_modify_output_spec_with_one_type(
customtypefield_get_attribute._spec().output_pin(0), "time_freq_support"
),
0,
op,
)
self._outputs.append(self.property_as_time_freq_support)
self.property_as_scoping = Output(
_modify_output_spec_with_one_type(
customtypefield_get_attribute._spec().output_pin(0), "scoping"
),
0,
op,
)
self._outputs.append(self.property_as_scoping)
self.property_as_data_tree = Output(
_modify_output_spec_with_one_type(
customtypefield_get_attribute._spec().output_pin(0), "data_tree"
),
0,
op,
)
self._outputs.append(self.property_as_data_tree)
18 changes: 13 additions & 5 deletions src/ansys/dpf/core/operators/utility/field_get_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class field_get_attribute(Operator):
----------
field: Field
property_name: str
Accepted inputs are: 'time_freq_support' and 'scoping'.
Accepted inputs are: 'time_freq_support', 'scoping' and 'header'.

Returns
-------
property: TimeFreqSupport or Scoping
property: TimeFreqSupport or Scoping or DataTree
Property value.

Examples
Expand Down Expand Up @@ -82,13 +82,13 @@ def _spec() -> Specification:
name="property_name",
type_names=["string"],
optional=False,
document=r"""Accepted inputs are: 'time_freq_support' and 'scoping'.""",
document=r"""Accepted inputs are: 'time_freq_support', 'scoping' and 'header'.""",
),
},
map_output_pin_spec={
0: PinSpecification(
name="property",
type_names=["time_freq_support", "scoping"],
type_names=["time_freq_support", "scoping", "abstract_data_tree"],
optional=False,
document=r"""Property value.""",
),
Expand Down Expand Up @@ -184,7 +184,7 @@ def field(self) -> Input:
def property_name(self) -> Input:
r"""Allows to connect property_name input to the operator.

Accepted inputs are: 'time_freq_support' and 'scoping'.
Accepted inputs are: 'time_freq_support', 'scoping' and 'header'.

Returns
-------
Expand Down Expand Up @@ -232,3 +232,11 @@ def __init__(self, op: Operator):
op,
)
self._outputs.append(self.property_as_scoping)
self.property_as_data_tree = Output(
_modify_output_spec_with_one_type(
field_get_attribute._spec().output_pin(0), "data_tree"
),
0,
op,
)
self._outputs.append(self.property_as_data_tree)
Loading
Loading