Skip to content

Commit

Permalink
update operators (#1026)
Browse files Browse the repository at this point in the history
Co-authored-by: rlagha <[email protected]>
  • Loading branch information
github-actions[bot] and rlagha authored Jul 12, 2023
1 parent bc651fa commit e37485e
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 39 deletions.
4 changes: 2 additions & 2 deletions docs/source/_static/dpf_operators.html

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/ansys/dpf/core/operators/metadata/mesh_info_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def _spec():
type_names=["generic_data_container"],
optional=False,
document="""""",
name_derived_class=["mesh_info"],
),
},
)
Expand Down Expand Up @@ -260,7 +261,7 @@ def mesh_info(self):
Returns
----------
my_mesh_info : GenericDataContainer
my_mesh_info : mesh_info
Examples
--------
Expand Down
50 changes: 50 additions & 0 deletions src/ansys/dpf/core/operators/scoping/transpose.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class transpose(Operator):
the elements/faces which have all
their nodes in the scoping are
included
requested_location : str, optional
Output scoping location for meshes with
nodes, faces and elements. by
default, elemental and faces scopings
transpose to nodal, and nodal
scopings transpose to elemental.
Examples
Expand All @@ -45,12 +51,15 @@ class transpose(Operator):
>>> op.inputs.meshed_region.connect(my_meshed_region)
>>> my_inclusive = int()
>>> op.inputs.inclusive.connect(my_inclusive)
>>> my_requested_location = str()
>>> op.inputs.requested_location.connect(my_requested_location)
>>> # Instantiate operator and connect inputs in one line
>>> op = dpf.operators.scoping.transpose(
... mesh_scoping=my_mesh_scoping,
... meshed_region=my_meshed_region,
... inclusive=my_inclusive,
... requested_location=my_requested_location,
... )
>>> # Get output data
Expand All @@ -62,6 +71,7 @@ def __init__(
mesh_scoping=None,
meshed_region=None,
inclusive=None,
requested_location=None,
config=None,
server=None,
):
Expand All @@ -74,6 +84,8 @@ def __init__(
self.inputs.meshed_region.connect(meshed_region)
if inclusive is not None:
self.inputs.inclusive.connect(inclusive)
if requested_location is not None:
self.inputs.requested_location.connect(requested_location)

@staticmethod
def _spec():
Expand Down Expand Up @@ -107,6 +119,16 @@ def _spec():
their nodes in the scoping are
included""",
),
9: PinSpecification(
name="requested_location",
type_names=["string"],
optional=True,
document="""Output scoping location for meshes with
nodes, faces and elements. by
default, elemental and faces scopings
transpose to nodal, and nodal
scopings transpose to elemental.""",
),
},
map_output_pin_spec={
0: PinSpecification(
Expand Down Expand Up @@ -171,6 +193,8 @@ class InputsTranspose(_Inputs):
>>> op.inputs.meshed_region.connect(my_meshed_region)
>>> my_inclusive = int()
>>> op.inputs.inclusive.connect(my_inclusive)
>>> my_requested_location = str()
>>> op.inputs.requested_location.connect(my_requested_location)
"""

def __init__(self, op: Operator):
Expand All @@ -181,6 +205,8 @@ def __init__(self, op: Operator):
self._inputs.append(self._meshed_region)
self._inclusive = Input(transpose._spec().input_pin(2), 2, op, -1)
self._inputs.append(self._inclusive)
self._requested_location = Input(transpose._spec().input_pin(9), 9, op, -1)
self._inputs.append(self._requested_location)

@property
def mesh_scoping(self):
Expand Down Expand Up @@ -246,6 +272,30 @@ def inclusive(self):
"""
return self._inclusive

@property
def requested_location(self):
"""Allows to connect requested_location input to the operator.
Output scoping location for meshes with
nodes, faces and elements. by
default, elemental and faces scopings
transpose to nodal, and nodal
scopings transpose to elemental.
Parameters
----------
my_requested_location : str
Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.scoping.transpose()
>>> op.inputs.requested_location.connect(my_requested_location)
>>> # or
>>> op.inputs.requested_location(my_requested_location)
"""
return self._requested_location


class OutputsTranspose(_Outputs):
"""Intermediate class used to get outputs from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ class hdf5dpf_generate_result_file(Operator):
mesh_provider_out : MeshedRegion, optional
Defines the meshedregion that is exported and
provided by meshprovider.
time_freq_support_out : TimeFreqSupport, optional
Defines the timefreqsupport that is exported
and provided by
timefreqsupportprovider.
ansys_unit_system_id : int, optional
Defines the unitsystem the results are
exported with.
Examples
Expand All @@ -35,19 +42,32 @@ class hdf5dpf_generate_result_file(Operator):
>>> op.inputs.filename.connect(my_filename)
>>> my_mesh_provider_out = dpf.MeshedRegion()
>>> op.inputs.mesh_provider_out.connect(my_mesh_provider_out)
>>> my_time_freq_support_out = dpf.TimeFreqSupport()
>>> op.inputs.time_freq_support_out.connect(my_time_freq_support_out)
>>> my_ansys_unit_system_id = int()
>>> op.inputs.ansys_unit_system_id.connect(my_ansys_unit_system_id)
>>> # Instantiate operator and connect inputs in one line
>>> op = dpf.operators.serialization.hdf5dpf_generate_result_file(
... filename=my_filename,
... mesh_provider_out=my_mesh_provider_out,
... time_freq_support_out=my_time_freq_support_out,
... ansys_unit_system_id=my_ansys_unit_system_id,
... )
>>> # Get output data
>>> result_time_freq_support_out = op.outputs.time_freq_support_out()
>>> result_ansys_unit_system_id = op.outputs.ansys_unit_system_id()
>>> result_data_sources = op.outputs.data_sources()
"""

def __init__(self, filename=None, mesh_provider_out=None, config=None, server=None):
def __init__(
self,
filename=None,
mesh_provider_out=None,
time_freq_support_out=None,
ansys_unit_system_id=None,
config=None,
server=None,
):
super().__init__(
name="hdf5::h5dpf::make_result_file", config=config, server=server
)
Expand All @@ -57,6 +77,10 @@ def __init__(self, filename=None, mesh_provider_out=None, config=None, server=No
self.inputs.filename.connect(filename)
if mesh_provider_out is not None:
self.inputs.mesh_provider_out.connect(mesh_provider_out)
if time_freq_support_out is not None:
self.inputs.time_freq_support_out.connect(time_freq_support_out)
if ansys_unit_system_id is not None:
self.inputs.ansys_unit_system_id.connect(ansys_unit_system_id)

@staticmethod
def _spec():
Expand All @@ -78,8 +102,6 @@ def _spec():
document="""Defines the meshedregion that is exported and
provided by meshprovider.""",
),
},
map_output_pin_spec={
2: PinSpecification(
name="time_freq_support_out",
type_names=["time_freq_support"],
Expand All @@ -96,6 +118,15 @@ def _spec():
exported with.""",
),
},
map_output_pin_spec={
0: PinSpecification(
name="data_sources",
type_names=["data_sources"],
optional=False,
document="""Data_sources filed with the h5 generated file
path.""",
),
},
)
return spec

Expand Down Expand Up @@ -150,6 +181,10 @@ class InputsHdf5DpfGenerateResultFile(_Inputs):
>>> op.inputs.filename.connect(my_filename)
>>> my_mesh_provider_out = dpf.MeshedRegion()
>>> op.inputs.mesh_provider_out.connect(my_mesh_provider_out)
>>> my_time_freq_support_out = dpf.TimeFreqSupport()
>>> op.inputs.time_freq_support_out.connect(my_time_freq_support_out)
>>> my_ansys_unit_system_id = int()
>>> op.inputs.ansys_unit_system_id.connect(my_ansys_unit_system_id)
"""

def __init__(self, op: Operator):
Expand All @@ -162,6 +197,14 @@ def __init__(self, op: Operator):
hdf5dpf_generate_result_file._spec().input_pin(1), 1, op, -1
)
self._inputs.append(self._mesh_provider_out)
self._time_freq_support_out = Input(
hdf5dpf_generate_result_file._spec().input_pin(2), 2, op, -1
)
self._inputs.append(self._time_freq_support_out)
self._ansys_unit_system_id = Input(
hdf5dpf_generate_result_file._spec().input_pin(3), 3, op, -1
)
self._inputs.append(self._ansys_unit_system_id)

@property
def filename(self):
Expand Down Expand Up @@ -205,6 +248,49 @@ def mesh_provider_out(self):
"""
return self._mesh_provider_out

@property
def time_freq_support_out(self):
"""Allows to connect time_freq_support_out input to the operator.
Defines the timefreqsupport that is exported
and provided by
timefreqsupportprovider.
Parameters
----------
my_time_freq_support_out : TimeFreqSupport
Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.serialization.hdf5dpf_generate_result_file()
>>> op.inputs.time_freq_support_out.connect(my_time_freq_support_out)
>>> # or
>>> op.inputs.time_freq_support_out(my_time_freq_support_out)
"""
return self._time_freq_support_out

@property
def ansys_unit_system_id(self):
"""Allows to connect ansys_unit_system_id input to the operator.
Defines the unitsystem the results are
exported with.
Parameters
----------
my_ansys_unit_system_id : int
Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.serialization.hdf5dpf_generate_result_file()
>>> op.inputs.ansys_unit_system_id.connect(my_ansys_unit_system_id)
>>> # or
>>> op.inputs.ansys_unit_system_id(my_ansys_unit_system_id)
"""
return self._ansys_unit_system_id


class OutputsHdf5DpfGenerateResultFile(_Outputs):
"""Intermediate class used to get outputs from
Expand All @@ -215,51 +301,29 @@ class OutputsHdf5DpfGenerateResultFile(_Outputs):
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.serialization.hdf5dpf_generate_result_file()
>>> # Connect inputs : op.inputs. ...
>>> result_time_freq_support_out = op.outputs.time_freq_support_out()
>>> result_ansys_unit_system_id = op.outputs.ansys_unit_system_id()
>>> result_data_sources = op.outputs.data_sources()
"""

def __init__(self, op: Operator):
super().__init__(hdf5dpf_generate_result_file._spec().outputs, op)
self._time_freq_support_out = Output(
hdf5dpf_generate_result_file._spec().output_pin(2), 2, op
self._data_sources = Output(
hdf5dpf_generate_result_file._spec().output_pin(0), 0, op
)
self._outputs.append(self._time_freq_support_out)
self._ansys_unit_system_id = Output(
hdf5dpf_generate_result_file._spec().output_pin(3), 3, op
)
self._outputs.append(self._ansys_unit_system_id)
self._outputs.append(self._data_sources)

@property
def time_freq_support_out(self):
"""Allows to get time_freq_support_out output of the operator
def data_sources(self):
"""Allows to get data_sources output of the operator
Returns
----------
my_time_freq_support_out : TimeFreqSupport
my_data_sources : DataSources
Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.serialization.hdf5dpf_generate_result_file()
>>> # Connect inputs : op.inputs. ...
>>> result_time_freq_support_out = op.outputs.time_freq_support_out()
>>> result_data_sources = op.outputs.data_sources()
""" # noqa: E501
return self._time_freq_support_out

@property
def ansys_unit_system_id(self):
"""Allows to get ansys_unit_system_id output of the operator
Returns
----------
my_ansys_unit_system_id : int
Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.serialization.hdf5dpf_generate_result_file()
>>> # Connect inputs : op.inputs. ...
>>> result_ansys_unit_system_id = op.outputs.ansys_unit_system_id()
""" # noqa: E501
return self._ansys_unit_system_id
return self._data_sources

0 comments on commit e37485e

Please sign in to comment.