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
2 changes: 1 addition & 1 deletion doc/source/_static/dpf_operators.html

Large diffs are not rendered by default.

188 changes: 188 additions & 0 deletions src/ansys/dpf/core/operators/mesh/from_data_model_to_dpf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
"""
from_data_model_to_dpf
======================
Autogenerated DPF operator classes.
"""

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.operators.specification import PinSpecification, Specification


class from_data_model_to_dpf(Operator):
"""Translate a data model MeshAssembly or MeshPart into a DPF
MeshesContainer.

Parameters
----------
mesh : GenericDataContainer
Meshassembly or meshpart


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

>>> # Instantiate operator
>>> op = dpf.operators.mesh.from_data_model_to_dpf()

>>> # Make input connections
>>> my_mesh = dpf.GenericDataContainer()
>>> op.inputs.mesh.connect(my_mesh)

>>> # Instantiate operator and connect inputs in one line
>>> op = dpf.operators.mesh.from_data_model_to_dpf(
... mesh=my_mesh,
... )

>>> # Get output data
>>> result_meshes_op = op.outputs.meshes_op()
"""

def __init__(self, mesh=None, config=None, server=None):
super().__init__(
name="mesh::from_data_model_to_dpf", config=config, server=server
)
self._inputs = InputsFromDataModelToDpf(self)
self._outputs = OutputsFromDataModelToDpf(self)
if mesh is not None:
self.inputs.mesh.connect(mesh)

@staticmethod
def _spec():
description = """Translate a data model MeshAssembly or MeshPart into a DPF
MeshesContainer."""
spec = Specification(
description=description,
map_input_pin_spec={
0: PinSpecification(
name="mesh",
type_names=["generic_data_container"],
optional=False,
document="""Meshassembly or meshpart""",
name_derived_class=["mesh_assembly"],
),
},
map_output_pin_spec={
0: PinSpecification(
name="meshes_op",
type_names=["meshes_container"],
optional=False,
document="""""",
),
},
)
return spec

@staticmethod
def default_config(server=None):
"""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.DPFServer, optional
Server with channel connected to the remote or local instance. When
``None``, attempts to use the global server.
"""
return Operator.default_config(
name="mesh::from_data_model_to_dpf", server=server
)

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

Returns
--------
inputs : InputsFromDataModelToDpf
"""
return super().inputs

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

Returns
--------
outputs : OutputsFromDataModelToDpf
"""
return super().outputs


class InputsFromDataModelToDpf(_Inputs):
"""Intermediate class used to connect user inputs to
from_data_model_to_dpf operator.

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.mesh.from_data_model_to_dpf()
>>> my_mesh = dpf.GenericDataContainer()
>>> op.inputs.mesh.connect(my_mesh)
"""

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

@property
def mesh(self):
"""Allows to connect mesh input to the operator.

Meshassembly or meshpart

Parameters
----------
my_mesh : GenericDataContainer

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.mesh.from_data_model_to_dpf()
>>> op.inputs.mesh.connect(my_mesh)
>>> # or
>>> op.inputs.mesh(my_mesh)
"""
return self._mesh


class OutputsFromDataModelToDpf(_Outputs):
"""Intermediate class used to get outputs from
from_data_model_to_dpf operator.

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.mesh.from_data_model_to_dpf()
>>> # Connect inputs : op.inputs. ...
>>> result_meshes_op = op.outputs.meshes_op()
"""

def __init__(self, op: Operator):
super().__init__(from_data_model_to_dpf._spec().outputs, op)
self._meshes_op = Output(from_data_model_to_dpf._spec().output_pin(0), 0, op)
self._outputs.append(self._meshes_op)

@property
def meshes_op(self):
"""Allows to get meshes_op output of the operator

Returns
----------
my_meshes_op : MeshesContainer

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.mesh.from_data_model_to_dpf()
>>> # Connect inputs : op.inputs. ...
>>> result_meshes_op = op.outputs.meshes_op()
""" # noqa: E501
return self._meshes_op
Loading
Loading