|
| 1 | +""" |
| 2 | +nodal_to_elemental_nodal |
| 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 nodal_to_elemental_nodal(Operator): |
| 15 | + """Transforms a Nodal field to an ElementalNodal field, The result is |
| 16 | + computed on a given element's scoping. |
| 17 | +
|
| 18 | + Parameters |
| 19 | + ---------- |
| 20 | + field : Field or FieldsContainer |
| 21 | + Field or fields container with only one field |
| 22 | + is expected |
| 23 | + mesh_scoping : Scoping, optional |
| 24 | + collapse_shell_layers : bool, optional |
| 25 | + If true, shell layers are averaged as well |
| 26 | + (default is false). |
| 27 | +
|
| 28 | + Returns |
| 29 | + ------- |
| 30 | + field : Field |
| 31 | +
|
| 32 | + Examples |
| 33 | + -------- |
| 34 | + >>> from ansys.dpf import core as dpf |
| 35 | +
|
| 36 | + >>> # Instantiate operator |
| 37 | + >>> op = dpf.operators.averaging.nodal_to_elemental_nodal() |
| 38 | +
|
| 39 | + >>> # Make input connections |
| 40 | + >>> my_field = dpf.Field() |
| 41 | + >>> op.inputs.field.connect(my_field) |
| 42 | + >>> my_mesh_scoping = dpf.Scoping() |
| 43 | + >>> op.inputs.mesh_scoping.connect(my_mesh_scoping) |
| 44 | + >>> my_collapse_shell_layers = bool() |
| 45 | + >>> op.inputs.collapse_shell_layers.connect(my_collapse_shell_layers) |
| 46 | +
|
| 47 | + >>> # Instantiate operator and connect inputs in one line |
| 48 | + >>> op = dpf.operators.averaging.nodal_to_elemental_nodal( |
| 49 | + ... field=my_field, |
| 50 | + ... mesh_scoping=my_mesh_scoping, |
| 51 | + ... collapse_shell_layers=my_collapse_shell_layers, |
| 52 | + ... ) |
| 53 | +
|
| 54 | + >>> # Get output data |
| 55 | + >>> result_field = op.outputs.field() |
| 56 | + """ |
| 57 | + |
| 58 | + def __init__( |
| 59 | + self, |
| 60 | + field=None, |
| 61 | + mesh_scoping=None, |
| 62 | + collapse_shell_layers=None, |
| 63 | + config=None, |
| 64 | + server=None, |
| 65 | + ): |
| 66 | + super().__init__(name="nodal_to_elemental_nodal", config=config, server=server) |
| 67 | + self._inputs = InputsNodalToElementalNodal(self) |
| 68 | + self._outputs = OutputsNodalToElementalNodal(self) |
| 69 | + if field is not None: |
| 70 | + self.inputs.field.connect(field) |
| 71 | + if mesh_scoping is not None: |
| 72 | + self.inputs.mesh_scoping.connect(mesh_scoping) |
| 73 | + if collapse_shell_layers is not None: |
| 74 | + self.inputs.collapse_shell_layers.connect(collapse_shell_layers) |
| 75 | + |
| 76 | + @staticmethod |
| 77 | + def _spec(): |
| 78 | + description = """Transforms a Nodal field to an ElementalNodal field, The result is |
| 79 | + computed on a given element's scoping.""" |
| 80 | + spec = Specification( |
| 81 | + description=description, |
| 82 | + map_input_pin_spec={ |
| 83 | + 0: PinSpecification( |
| 84 | + name="field", |
| 85 | + type_names=["field", "fields_container"], |
| 86 | + optional=False, |
| 87 | + document="""Field or fields container with only one field |
| 88 | + is expected""", |
| 89 | + ), |
| 90 | + 1: PinSpecification( |
| 91 | + name="mesh_scoping", |
| 92 | + type_names=["scoping"], |
| 93 | + optional=True, |
| 94 | + document="""""", |
| 95 | + ), |
| 96 | + 10: PinSpecification( |
| 97 | + name="collapse_shell_layers", |
| 98 | + type_names=["bool"], |
| 99 | + optional=True, |
| 100 | + document="""If true, shell layers are averaged as well |
| 101 | + (default is false).""", |
| 102 | + ), |
| 103 | + }, |
| 104 | + map_output_pin_spec={ |
| 105 | + 0: PinSpecification( |
| 106 | + name="field", |
| 107 | + type_names=["field"], |
| 108 | + optional=False, |
| 109 | + document="""""", |
| 110 | + ), |
| 111 | + }, |
| 112 | + ) |
| 113 | + return spec |
| 114 | + |
| 115 | + @staticmethod |
| 116 | + def default_config(server=None): |
| 117 | + """Returns the default config of the operator. |
| 118 | +
|
| 119 | + This config can then be changed to the user needs and be used to |
| 120 | + instantiate the operator. The Configuration allows to customize |
| 121 | + how the operation will be processed by the operator. |
| 122 | +
|
| 123 | + Parameters |
| 124 | + ---------- |
| 125 | + server : server.DPFServer, optional |
| 126 | + Server with channel connected to the remote or local instance. When |
| 127 | + ``None``, attempts to use the global server. |
| 128 | + """ |
| 129 | + return Operator.default_config(name="nodal_to_elemental_nodal", server=server) |
| 130 | + |
| 131 | + @property |
| 132 | + def inputs(self): |
| 133 | + """Enables to connect inputs to the operator |
| 134 | +
|
| 135 | + Returns |
| 136 | + -------- |
| 137 | + inputs : InputsNodalToElementalNodal |
| 138 | + """ |
| 139 | + return super().inputs |
| 140 | + |
| 141 | + @property |
| 142 | + def outputs(self): |
| 143 | + """Enables to get outputs of the operator by evaluating it |
| 144 | +
|
| 145 | + Returns |
| 146 | + -------- |
| 147 | + outputs : OutputsNodalToElementalNodal |
| 148 | + """ |
| 149 | + return super().outputs |
| 150 | + |
| 151 | + |
| 152 | +class InputsNodalToElementalNodal(_Inputs): |
| 153 | + """Intermediate class used to connect user inputs to |
| 154 | + nodal_to_elemental_nodal operator. |
| 155 | +
|
| 156 | + Examples |
| 157 | + -------- |
| 158 | + >>> from ansys.dpf import core as dpf |
| 159 | + >>> op = dpf.operators.averaging.nodal_to_elemental_nodal() |
| 160 | + >>> my_field = dpf.Field() |
| 161 | + >>> op.inputs.field.connect(my_field) |
| 162 | + >>> my_mesh_scoping = dpf.Scoping() |
| 163 | + >>> op.inputs.mesh_scoping.connect(my_mesh_scoping) |
| 164 | + >>> my_collapse_shell_layers = bool() |
| 165 | + >>> op.inputs.collapse_shell_layers.connect(my_collapse_shell_layers) |
| 166 | + """ |
| 167 | + |
| 168 | + def __init__(self, op: Operator): |
| 169 | + super().__init__(nodal_to_elemental_nodal._spec().inputs, op) |
| 170 | + self._field = Input(nodal_to_elemental_nodal._spec().input_pin(0), 0, op, -1) |
| 171 | + self._inputs.append(self._field) |
| 172 | + self._mesh_scoping = Input( |
| 173 | + nodal_to_elemental_nodal._spec().input_pin(1), 1, op, -1 |
| 174 | + ) |
| 175 | + self._inputs.append(self._mesh_scoping) |
| 176 | + self._collapse_shell_layers = Input( |
| 177 | + nodal_to_elemental_nodal._spec().input_pin(10), 10, op, -1 |
| 178 | + ) |
| 179 | + self._inputs.append(self._collapse_shell_layers) |
| 180 | + |
| 181 | + @property |
| 182 | + def field(self): |
| 183 | + """Allows to connect field input to the operator. |
| 184 | +
|
| 185 | + Field or fields container with only one field |
| 186 | + is expected |
| 187 | +
|
| 188 | + Parameters |
| 189 | + ---------- |
| 190 | + my_field : Field or FieldsContainer |
| 191 | +
|
| 192 | + Examples |
| 193 | + -------- |
| 194 | + >>> from ansys.dpf import core as dpf |
| 195 | + >>> op = dpf.operators.averaging.nodal_to_elemental_nodal() |
| 196 | + >>> op.inputs.field.connect(my_field) |
| 197 | + >>> # or |
| 198 | + >>> op.inputs.field(my_field) |
| 199 | + """ |
| 200 | + return self._field |
| 201 | + |
| 202 | + @property |
| 203 | + def mesh_scoping(self): |
| 204 | + """Allows to connect mesh_scoping input to the operator. |
| 205 | +
|
| 206 | + Parameters |
| 207 | + ---------- |
| 208 | + my_mesh_scoping : Scoping |
| 209 | +
|
| 210 | + Examples |
| 211 | + -------- |
| 212 | + >>> from ansys.dpf import core as dpf |
| 213 | + >>> op = dpf.operators.averaging.nodal_to_elemental_nodal() |
| 214 | + >>> op.inputs.mesh_scoping.connect(my_mesh_scoping) |
| 215 | + >>> # or |
| 216 | + >>> op.inputs.mesh_scoping(my_mesh_scoping) |
| 217 | + """ |
| 218 | + return self._mesh_scoping |
| 219 | + |
| 220 | + @property |
| 221 | + def collapse_shell_layers(self): |
| 222 | + """Allows to connect collapse_shell_layers input to the operator. |
| 223 | +
|
| 224 | + If true, shell layers are averaged as well |
| 225 | + (default is false). |
| 226 | +
|
| 227 | + Parameters |
| 228 | + ---------- |
| 229 | + my_collapse_shell_layers : bool |
| 230 | +
|
| 231 | + Examples |
| 232 | + -------- |
| 233 | + >>> from ansys.dpf import core as dpf |
| 234 | + >>> op = dpf.operators.averaging.nodal_to_elemental_nodal() |
| 235 | + >>> op.inputs.collapse_shell_layers.connect(my_collapse_shell_layers) |
| 236 | + >>> # or |
| 237 | + >>> op.inputs.collapse_shell_layers(my_collapse_shell_layers) |
| 238 | + """ |
| 239 | + return self._collapse_shell_layers |
| 240 | + |
| 241 | + |
| 242 | +class OutputsNodalToElementalNodal(_Outputs): |
| 243 | + """Intermediate class used to get outputs from |
| 244 | + nodal_to_elemental_nodal operator. |
| 245 | +
|
| 246 | + Examples |
| 247 | + -------- |
| 248 | + >>> from ansys.dpf import core as dpf |
| 249 | + >>> op = dpf.operators.averaging.nodal_to_elemental_nodal() |
| 250 | + >>> # Connect inputs : op.inputs. ... |
| 251 | + >>> result_field = op.outputs.field() |
| 252 | + """ |
| 253 | + |
| 254 | + def __init__(self, op: Operator): |
| 255 | + super().__init__(nodal_to_elemental_nodal._spec().outputs, op) |
| 256 | + self._field = Output(nodal_to_elemental_nodal._spec().output_pin(0), 0, op) |
| 257 | + self._outputs.append(self._field) |
| 258 | + |
| 259 | + @property |
| 260 | + def field(self): |
| 261 | + """Allows to get field output of the operator |
| 262 | +
|
| 263 | + Returns |
| 264 | + ---------- |
| 265 | + my_field : Field |
| 266 | +
|
| 267 | + Examples |
| 268 | + -------- |
| 269 | + >>> from ansys.dpf import core as dpf |
| 270 | + >>> op = dpf.operators.averaging.nodal_to_elemental_nodal() |
| 271 | + >>> # Connect inputs : op.inputs. ... |
| 272 | + >>> result_field = op.outputs.field() |
| 273 | + """ # noqa: E501 |
| 274 | + return self._field |
0 commit comments