|
| 1 | +""" |
| 2 | +from_data_model_to_dpf |
| 3 | +====================== |
| 4 | +Autogenerated DPF operator classes. |
| 5 | +""" |
| 6 | + |
| 7 | +from warnings import warn |
| 8 | +from ansys.dpf.core.dpf_operator import Operator |
| 9 | +from ansys.dpf.core.inputs import Input, _Inputs |
| 10 | +from ansys.dpf.core.outputs import Output, _Outputs |
| 11 | +from ansys.dpf.core.operators.specification import PinSpecification, Specification |
| 12 | + |
| 13 | + |
| 14 | +class from_data_model_to_dpf(Operator): |
| 15 | + """Translate a data model MeshAssembly or MeshPart into a DPF |
| 16 | + MeshesContainer. |
| 17 | +
|
| 18 | + Parameters |
| 19 | + ---------- |
| 20 | + mesh : GenericDataContainer |
| 21 | + Meshassembly or meshpart |
| 22 | +
|
| 23 | +
|
| 24 | + Examples |
| 25 | + -------- |
| 26 | + >>> from ansys.dpf import core as dpf |
| 27 | +
|
| 28 | + >>> # Instantiate operator |
| 29 | + >>> op = dpf.operators.mesh.from_data_model_to_dpf() |
| 30 | +
|
| 31 | + >>> # Make input connections |
| 32 | + >>> my_mesh = dpf.GenericDataContainer() |
| 33 | + >>> op.inputs.mesh.connect(my_mesh) |
| 34 | +
|
| 35 | + >>> # Instantiate operator and connect inputs in one line |
| 36 | + >>> op = dpf.operators.mesh.from_data_model_to_dpf( |
| 37 | + ... mesh=my_mesh, |
| 38 | + ... ) |
| 39 | +
|
| 40 | + >>> # Get output data |
| 41 | + >>> result_meshes_op = op.outputs.meshes_op() |
| 42 | + """ |
| 43 | + |
| 44 | + def __init__(self, mesh=None, config=None, server=None): |
| 45 | + super().__init__( |
| 46 | + name="mesh::from_data_model_to_dpf", config=config, server=server |
| 47 | + ) |
| 48 | + self._inputs = InputsFromDataModelToDpf(self) |
| 49 | + self._outputs = OutputsFromDataModelToDpf(self) |
| 50 | + if mesh is not None: |
| 51 | + self.inputs.mesh.connect(mesh) |
| 52 | + |
| 53 | + @staticmethod |
| 54 | + def _spec(): |
| 55 | + description = """Translate a data model MeshAssembly or MeshPart into a DPF |
| 56 | + MeshesContainer.""" |
| 57 | + spec = Specification( |
| 58 | + description=description, |
| 59 | + map_input_pin_spec={ |
| 60 | + 0: PinSpecification( |
| 61 | + name="mesh", |
| 62 | + type_names=["generic_data_container"], |
| 63 | + optional=False, |
| 64 | + document="""Meshassembly or meshpart""", |
| 65 | + name_derived_class=["mesh_assembly"], |
| 66 | + ), |
| 67 | + }, |
| 68 | + map_output_pin_spec={ |
| 69 | + 0: PinSpecification( |
| 70 | + name="meshes_op", |
| 71 | + type_names=["meshes_container"], |
| 72 | + optional=False, |
| 73 | + document="""""", |
| 74 | + ), |
| 75 | + }, |
| 76 | + ) |
| 77 | + return spec |
| 78 | + |
| 79 | + @staticmethod |
| 80 | + def default_config(server=None): |
| 81 | + """Returns the default config of the operator. |
| 82 | +
|
| 83 | + This config can then be changed to the user needs and be used to |
| 84 | + instantiate the operator. The Configuration allows to customize |
| 85 | + how the operation will be processed by the operator. |
| 86 | +
|
| 87 | + Parameters |
| 88 | + ---------- |
| 89 | + server : server.DPFServer, optional |
| 90 | + Server with channel connected to the remote or local instance. When |
| 91 | + ``None``, attempts to use the global server. |
| 92 | + """ |
| 93 | + return Operator.default_config( |
| 94 | + name="mesh::from_data_model_to_dpf", server=server |
| 95 | + ) |
| 96 | + |
| 97 | + @property |
| 98 | + def inputs(self): |
| 99 | + """Enables to connect inputs to the operator |
| 100 | +
|
| 101 | + Returns |
| 102 | + -------- |
| 103 | + inputs : InputsFromDataModelToDpf |
| 104 | + """ |
| 105 | + return super().inputs |
| 106 | + |
| 107 | + @property |
| 108 | + def outputs(self): |
| 109 | + """Enables to get outputs of the operator by evaluating it |
| 110 | +
|
| 111 | + Returns |
| 112 | + -------- |
| 113 | + outputs : OutputsFromDataModelToDpf |
| 114 | + """ |
| 115 | + return super().outputs |
| 116 | + |
| 117 | + |
| 118 | +class InputsFromDataModelToDpf(_Inputs): |
| 119 | + """Intermediate class used to connect user inputs to |
| 120 | + from_data_model_to_dpf operator. |
| 121 | +
|
| 122 | + Examples |
| 123 | + -------- |
| 124 | + >>> from ansys.dpf import core as dpf |
| 125 | + >>> op = dpf.operators.mesh.from_data_model_to_dpf() |
| 126 | + >>> my_mesh = dpf.GenericDataContainer() |
| 127 | + >>> op.inputs.mesh.connect(my_mesh) |
| 128 | + """ |
| 129 | + |
| 130 | + def __init__(self, op: Operator): |
| 131 | + super().__init__(from_data_model_to_dpf._spec().inputs, op) |
| 132 | + self._mesh = Input(from_data_model_to_dpf._spec().input_pin(0), 0, op, -1) |
| 133 | + self._inputs.append(self._mesh) |
| 134 | + |
| 135 | + @property |
| 136 | + def mesh(self): |
| 137 | + """Allows to connect mesh input to the operator. |
| 138 | +
|
| 139 | + Meshassembly or meshpart |
| 140 | +
|
| 141 | + Parameters |
| 142 | + ---------- |
| 143 | + my_mesh : GenericDataContainer |
| 144 | +
|
| 145 | + Examples |
| 146 | + -------- |
| 147 | + >>> from ansys.dpf import core as dpf |
| 148 | + >>> op = dpf.operators.mesh.from_data_model_to_dpf() |
| 149 | + >>> op.inputs.mesh.connect(my_mesh) |
| 150 | + >>> # or |
| 151 | + >>> op.inputs.mesh(my_mesh) |
| 152 | + """ |
| 153 | + return self._mesh |
| 154 | + |
| 155 | + |
| 156 | +class OutputsFromDataModelToDpf(_Outputs): |
| 157 | + """Intermediate class used to get outputs from |
| 158 | + from_data_model_to_dpf operator. |
| 159 | +
|
| 160 | + Examples |
| 161 | + -------- |
| 162 | + >>> from ansys.dpf import core as dpf |
| 163 | + >>> op = dpf.operators.mesh.from_data_model_to_dpf() |
| 164 | + >>> # Connect inputs : op.inputs. ... |
| 165 | + >>> result_meshes_op = op.outputs.meshes_op() |
| 166 | + """ |
| 167 | + |
| 168 | + def __init__(self, op: Operator): |
| 169 | + super().__init__(from_data_model_to_dpf._spec().outputs, op) |
| 170 | + self._meshes_op = Output(from_data_model_to_dpf._spec().output_pin(0), 0, op) |
| 171 | + self._outputs.append(self._meshes_op) |
| 172 | + |
| 173 | + @property |
| 174 | + def meshes_op(self): |
| 175 | + """Allows to get meshes_op output of the operator |
| 176 | +
|
| 177 | + Returns |
| 178 | + ---------- |
| 179 | + my_meshes_op : MeshesContainer |
| 180 | +
|
| 181 | + Examples |
| 182 | + -------- |
| 183 | + >>> from ansys.dpf import core as dpf |
| 184 | + >>> op = dpf.operators.mesh.from_data_model_to_dpf() |
| 185 | + >>> # Connect inputs : op.inputs. ... |
| 186 | + >>> result_meshes_op = op.outputs.meshes_op() |
| 187 | + """ # noqa: E501 |
| 188 | + return self._meshes_op |
0 commit comments