|
| 1 | +""" |
| 2 | +faces_area |
| 3 | +========== |
| 4 | +Autogenerated DPF operator classes. |
| 5 | +""" |
| 6 | +from warnings import warn |
| 7 | +from ansys.dpf.core.dpf_operator import Operator |
| 8 | +from ansys.dpf.core.inputs import Input, _Inputs |
| 9 | +from ansys.dpf.core.outputs import Output, _Outputs |
| 10 | +from ansys.dpf.core.operators.specification import PinSpecification, Specification |
| 11 | + |
| 12 | + |
| 13 | +class faces_area(Operator): |
| 14 | + """Compute the measure of the Faces (surface for 2D faces of a 3D model |
| 15 | + or length for 1D faces of a 2D model) using default shape |
| 16 | + functions, except for polygons. |
| 17 | +
|
| 18 | + Parameters |
| 19 | + ---------- |
| 20 | + mesh : MeshedRegion |
| 21 | + mesh_scoping : Scoping |
| 22 | + If not provided, the measure of all faces in |
| 23 | + the mesh is computed. if provided, |
| 24 | + the scoping needs to have "faces" |
| 25 | + location. |
| 26 | +
|
| 27 | +
|
| 28 | + Examples |
| 29 | + -------- |
| 30 | + >>> from ansys.dpf import core as dpf |
| 31 | +
|
| 32 | + >>> # Instantiate operator |
| 33 | + >>> op = dpf.operators.geo.faces_area() |
| 34 | +
|
| 35 | + >>> # Make input connections |
| 36 | + >>> my_mesh = dpf.MeshedRegion() |
| 37 | + >>> op.inputs.mesh.connect(my_mesh) |
| 38 | + >>> my_mesh_scoping = dpf.Scoping() |
| 39 | + >>> op.inputs.mesh_scoping.connect(my_mesh_scoping) |
| 40 | +
|
| 41 | + >>> # Instantiate operator and connect inputs in one line |
| 42 | + >>> op = dpf.operators.geo.faces_area( |
| 43 | + ... mesh=my_mesh, |
| 44 | + ... mesh_scoping=my_mesh_scoping, |
| 45 | + ... ) |
| 46 | +
|
| 47 | + >>> # Get output data |
| 48 | + >>> result_field = op.outputs.field() |
| 49 | + """ |
| 50 | + |
| 51 | + def __init__(self, mesh=None, mesh_scoping=None, config=None, server=None): |
| 52 | + super().__init__(name="face::area", config=config, server=server) |
| 53 | + self._inputs = InputsFacesArea(self) |
| 54 | + self._outputs = OutputsFacesArea(self) |
| 55 | + if mesh is not None: |
| 56 | + self.inputs.mesh.connect(mesh) |
| 57 | + if mesh_scoping is not None: |
| 58 | + self.inputs.mesh_scoping.connect(mesh_scoping) |
| 59 | + |
| 60 | + @staticmethod |
| 61 | + def _spec(): |
| 62 | + description = """Compute the measure of the Faces (surface for 2D faces of a 3D model |
| 63 | + or length for 1D faces of a 2D model) using default shape |
| 64 | + functions, except for polygons.""" |
| 65 | + spec = Specification( |
| 66 | + description=description, |
| 67 | + map_input_pin_spec={ |
| 68 | + 0: PinSpecification( |
| 69 | + name="mesh", |
| 70 | + type_names=["abstract_meshed_region"], |
| 71 | + optional=False, |
| 72 | + document="""""", |
| 73 | + ), |
| 74 | + 1: PinSpecification( |
| 75 | + name="mesh_scoping", |
| 76 | + type_names=["scoping"], |
| 77 | + optional=False, |
| 78 | + document="""If not provided, the measure of all faces in |
| 79 | + the mesh is computed. if provided, |
| 80 | + the scoping needs to have "faces" |
| 81 | + location.""", |
| 82 | + ), |
| 83 | + }, |
| 84 | + map_output_pin_spec={ |
| 85 | + 0: PinSpecification( |
| 86 | + name="field", |
| 87 | + type_names=["field"], |
| 88 | + optional=False, |
| 89 | + document="""""", |
| 90 | + ), |
| 91 | + }, |
| 92 | + ) |
| 93 | + return spec |
| 94 | + |
| 95 | + @staticmethod |
| 96 | + def default_config(server=None): |
| 97 | + """Returns the default config of the operator. |
| 98 | +
|
| 99 | + This config can then be changed to the user needs and be used to |
| 100 | + instantiate the operator. The Configuration allows to customize |
| 101 | + how the operation will be processed by the operator. |
| 102 | +
|
| 103 | + Parameters |
| 104 | + ---------- |
| 105 | + server : server.DPFServer, optional |
| 106 | + Server with channel connected to the remote or local instance. When |
| 107 | + ``None``, attempts to use the global server. |
| 108 | + """ |
| 109 | + return Operator.default_config(name="face::area", server=server) |
| 110 | + |
| 111 | + @property |
| 112 | + def inputs(self): |
| 113 | + """Enables to connect inputs to the operator |
| 114 | +
|
| 115 | + Returns |
| 116 | + -------- |
| 117 | + inputs : InputsFacesArea |
| 118 | + """ |
| 119 | + return super().inputs |
| 120 | + |
| 121 | + @property |
| 122 | + def outputs(self): |
| 123 | + """Enables to get outputs of the operator by evaluating it |
| 124 | +
|
| 125 | + Returns |
| 126 | + -------- |
| 127 | + outputs : OutputsFacesArea |
| 128 | + """ |
| 129 | + return super().outputs |
| 130 | + |
| 131 | + |
| 132 | +class InputsFacesArea(_Inputs): |
| 133 | + """Intermediate class used to connect user inputs to |
| 134 | + faces_area operator. |
| 135 | +
|
| 136 | + Examples |
| 137 | + -------- |
| 138 | + >>> from ansys.dpf import core as dpf |
| 139 | + >>> op = dpf.operators.geo.faces_area() |
| 140 | + >>> my_mesh = dpf.MeshedRegion() |
| 141 | + >>> op.inputs.mesh.connect(my_mesh) |
| 142 | + >>> my_mesh_scoping = dpf.Scoping() |
| 143 | + >>> op.inputs.mesh_scoping.connect(my_mesh_scoping) |
| 144 | + """ |
| 145 | + |
| 146 | + def __init__(self, op: Operator): |
| 147 | + super().__init__(faces_area._spec().inputs, op) |
| 148 | + self._mesh = Input(faces_area._spec().input_pin(0), 0, op, -1) |
| 149 | + self._inputs.append(self._mesh) |
| 150 | + self._mesh_scoping = Input(faces_area._spec().input_pin(1), 1, op, -1) |
| 151 | + self._inputs.append(self._mesh_scoping) |
| 152 | + |
| 153 | + @property |
| 154 | + def mesh(self): |
| 155 | + """Allows to connect mesh input to the operator. |
| 156 | +
|
| 157 | + Parameters |
| 158 | + ---------- |
| 159 | + my_mesh : MeshedRegion |
| 160 | +
|
| 161 | + Examples |
| 162 | + -------- |
| 163 | + >>> from ansys.dpf import core as dpf |
| 164 | + >>> op = dpf.operators.geo.faces_area() |
| 165 | + >>> op.inputs.mesh.connect(my_mesh) |
| 166 | + >>> # or |
| 167 | + >>> op.inputs.mesh(my_mesh) |
| 168 | + """ |
| 169 | + return self._mesh |
| 170 | + |
| 171 | + @property |
| 172 | + def mesh_scoping(self): |
| 173 | + """Allows to connect mesh_scoping input to the operator. |
| 174 | +
|
| 175 | + If not provided, the measure of all faces in |
| 176 | + the mesh is computed. if provided, |
| 177 | + the scoping needs to have "faces" |
| 178 | + location. |
| 179 | +
|
| 180 | + Parameters |
| 181 | + ---------- |
| 182 | + my_mesh_scoping : Scoping |
| 183 | +
|
| 184 | + Examples |
| 185 | + -------- |
| 186 | + >>> from ansys.dpf import core as dpf |
| 187 | + >>> op = dpf.operators.geo.faces_area() |
| 188 | + >>> op.inputs.mesh_scoping.connect(my_mesh_scoping) |
| 189 | + >>> # or |
| 190 | + >>> op.inputs.mesh_scoping(my_mesh_scoping) |
| 191 | + """ |
| 192 | + return self._mesh_scoping |
| 193 | + |
| 194 | + |
| 195 | +class OutputsFacesArea(_Outputs): |
| 196 | + """Intermediate class used to get outputs from |
| 197 | + faces_area operator. |
| 198 | +
|
| 199 | + Examples |
| 200 | + -------- |
| 201 | + >>> from ansys.dpf import core as dpf |
| 202 | + >>> op = dpf.operators.geo.faces_area() |
| 203 | + >>> # Connect inputs : op.inputs. ... |
| 204 | + >>> result_field = op.outputs.field() |
| 205 | + """ |
| 206 | + |
| 207 | + def __init__(self, op: Operator): |
| 208 | + super().__init__(faces_area._spec().outputs, op) |
| 209 | + self._field = Output(faces_area._spec().output_pin(0), 0, op) |
| 210 | + self._outputs.append(self._field) |
| 211 | + |
| 212 | + @property |
| 213 | + def field(self): |
| 214 | + """Allows to get field output of the operator |
| 215 | +
|
| 216 | + Returns |
| 217 | + ---------- |
| 218 | + my_field : Field |
| 219 | +
|
| 220 | + Examples |
| 221 | + -------- |
| 222 | + >>> from ansys.dpf import core as dpf |
| 223 | + >>> op = dpf.operators.geo.faces_area() |
| 224 | + >>> # Connect inputs : op.inputs. ... |
| 225 | + >>> result_field = op.outputs.field() |
| 226 | + """ # noqa: E501 |
| 227 | + return self._field |
0 commit comments