-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Operators for DPF 241 on master #1131
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -11,13 +11,18 @@ | |||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
class elements_volume(Operator): | ||||||||||||||||||
"""Compute the volume of each element of a mesh using default shape | ||||||||||||||||||
functions. | ||||||||||||||||||
"""Compute the measure of the Elements (volume for 3D elements, surface | ||||||||||||||||||
for 2D elements or length for 1D elements) using default shape | ||||||||||||||||||
functions, except for polyhedrons. | ||||||||||||||||||
|
||||||||||||||||||
Parameters | ||||||||||||||||||
---------- | ||||||||||||||||||
mesh : MeshedRegion | ||||||||||||||||||
mesh_scoping : Scoping | ||||||||||||||||||
If not provided, the measure of all elements | ||||||||||||||||||
for the mesh is computed. if | ||||||||||||||||||
provided, the scoping needs to have | ||||||||||||||||||
"elemental" location. | ||||||||||||||||||
Comment on lines
+22
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
Examples | ||||||||||||||||||
|
@@ -54,8 +59,9 @@ def __init__(self, mesh=None, mesh_scoping=None, config=None, server=None): | |||||||||||||||||
|
||||||||||||||||||
@staticmethod | ||||||||||||||||||
def _spec(): | ||||||||||||||||||
description = """Compute the volume of each element of a mesh using default shape | ||||||||||||||||||
functions.""" | ||||||||||||||||||
description = """Compute the measure of the Elements (volume for 3D elements, surface | ||||||||||||||||||
for 2D elements or length for 1D elements) using default | ||||||||||||||||||
shape functions, except for polyhedrons.""" | ||||||||||||||||||
spec = Specification( | ||||||||||||||||||
description=description, | ||||||||||||||||||
map_input_pin_spec={ | ||||||||||||||||||
|
@@ -69,7 +75,10 @@ def _spec(): | |||||||||||||||||
name="mesh_scoping", | ||||||||||||||||||
type_names=["scoping"], | ||||||||||||||||||
optional=False, | ||||||||||||||||||
document="""""", | ||||||||||||||||||
document="""If not provided, the measure of all elements | ||||||||||||||||||
for the mesh is computed. if | ||||||||||||||||||
provided, the scoping needs to have | ||||||||||||||||||
"elemental" location.""", | ||||||||||||||||||
), | ||||||||||||||||||
}, | ||||||||||||||||||
map_output_pin_spec={ | ||||||||||||||||||
|
@@ -163,6 +172,11 @@ def mesh(self): | |||||||||||||||||
def mesh_scoping(self): | ||||||||||||||||||
"""Allows to connect mesh_scoping input to the operator. | ||||||||||||||||||
|
||||||||||||||||||
If not provided, the measure of all elements | ||||||||||||||||||
for the mesh is computed. if | ||||||||||||||||||
provided, the scoping needs to have | ||||||||||||||||||
"elemental" location. | ||||||||||||||||||
|
||||||||||||||||||
Parameters | ||||||||||||||||||
---------- | ||||||||||||||||||
my_mesh_scoping : Scoping | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
""" | ||
faces_area | ||
========== | ||
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 faces_area(Operator): | ||
"""Compute the measure of the Faces (surface for 2D faces of a 3D model | ||
or length for 1D faces of a 2D model) using default shape | ||
functions, except for polygons. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MichaelNale @rafacanton same here, what happens in the case of polygons? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above, it employs pure geometry |
||
|
||
Parameters | ||
---------- | ||
mesh : MeshedRegion | ||
mesh_scoping : Scoping | ||
If not provided, the measure of all faces in | ||
the mesh is computed. if provided, | ||
the scoping needs to have "faces" | ||
location. | ||
Comment on lines
+22
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MichaelNale @rafacanton same here, is it "the measure of all faces in the mesh" or "the measure of each face in the mesh"? |
||
|
||
|
||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
|
||
>>> # Instantiate operator | ||
>>> op = dpf.operators.geo.faces_area() | ||
|
||
>>> # Make input connections | ||
>>> my_mesh = dpf.MeshedRegion() | ||
>>> op.inputs.mesh.connect(my_mesh) | ||
>>> my_mesh_scoping = dpf.Scoping() | ||
>>> op.inputs.mesh_scoping.connect(my_mesh_scoping) | ||
|
||
>>> # Instantiate operator and connect inputs in one line | ||
>>> op = dpf.operators.geo.faces_area( | ||
... mesh=my_mesh, | ||
... mesh_scoping=my_mesh_scoping, | ||
... ) | ||
|
||
>>> # Get output data | ||
>>> result_field = op.outputs.field() | ||
""" | ||
|
||
def __init__(self, mesh=None, mesh_scoping=None, config=None, server=None): | ||
super().__init__(name="face::area", config=config, server=server) | ||
self._inputs = InputsFacesArea(self) | ||
self._outputs = OutputsFacesArea(self) | ||
if mesh is not None: | ||
self.inputs.mesh.connect(mesh) | ||
if mesh_scoping is not None: | ||
self.inputs.mesh_scoping.connect(mesh_scoping) | ||
|
||
@staticmethod | ||
def _spec(): | ||
description = """Compute the measure of the Faces (surface for 2D faces of a 3D model | ||
or length for 1D faces of a 2D model) using default shape | ||
functions, except for polygons.""" | ||
spec = Specification( | ||
description=description, | ||
map_input_pin_spec={ | ||
0: PinSpecification( | ||
name="mesh", | ||
type_names=["abstract_meshed_region"], | ||
optional=False, | ||
document="""""", | ||
), | ||
1: PinSpecification( | ||
name="mesh_scoping", | ||
type_names=["scoping"], | ||
optional=False, | ||
document="""If not provided, the measure of all faces in | ||
the mesh is computed. if provided, | ||
the scoping needs to have "faces" | ||
location.""", | ||
), | ||
}, | ||
map_output_pin_spec={ | ||
0: PinSpecification( | ||
name="field", | ||
type_names=["field"], | ||
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="face::area", server=server) | ||
|
||
@property | ||
def inputs(self): | ||
"""Enables to connect inputs to the operator | ||
|
||
Returns | ||
-------- | ||
inputs : InputsFacesArea | ||
""" | ||
return super().inputs | ||
|
||
@property | ||
def outputs(self): | ||
"""Enables to get outputs of the operator by evaluating it | ||
|
||
Returns | ||
-------- | ||
outputs : OutputsFacesArea | ||
""" | ||
return super().outputs | ||
|
||
|
||
class InputsFacesArea(_Inputs): | ||
"""Intermediate class used to connect user inputs to | ||
faces_area operator. | ||
|
||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.geo.faces_area() | ||
>>> my_mesh = dpf.MeshedRegion() | ||
>>> op.inputs.mesh.connect(my_mesh) | ||
>>> my_mesh_scoping = dpf.Scoping() | ||
>>> op.inputs.mesh_scoping.connect(my_mesh_scoping) | ||
""" | ||
|
||
def __init__(self, op: Operator): | ||
super().__init__(faces_area._spec().inputs, op) | ||
self._mesh = Input(faces_area._spec().input_pin(0), 0, op, -1) | ||
self._inputs.append(self._mesh) | ||
self._mesh_scoping = Input(faces_area._spec().input_pin(1), 1, op, -1) | ||
self._inputs.append(self._mesh_scoping) | ||
|
||
@property | ||
def mesh(self): | ||
"""Allows to connect mesh input to the operator. | ||
|
||
Parameters | ||
---------- | ||
my_mesh : MeshedRegion | ||
|
||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.geo.faces_area() | ||
>>> op.inputs.mesh.connect(my_mesh) | ||
>>> # or | ||
>>> op.inputs.mesh(my_mesh) | ||
""" | ||
return self._mesh | ||
|
||
@property | ||
def mesh_scoping(self): | ||
"""Allows to connect mesh_scoping input to the operator. | ||
|
||
If not provided, the measure of all faces in | ||
the mesh is computed. if provided, | ||
the scoping needs to have "faces" | ||
location. | ||
|
||
Parameters | ||
---------- | ||
my_mesh_scoping : Scoping | ||
|
||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.geo.faces_area() | ||
>>> op.inputs.mesh_scoping.connect(my_mesh_scoping) | ||
>>> # or | ||
>>> op.inputs.mesh_scoping(my_mesh_scoping) | ||
""" | ||
return self._mesh_scoping | ||
|
||
|
||
class OutputsFacesArea(_Outputs): | ||
"""Intermediate class used to get outputs from | ||
faces_area operator. | ||
|
||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.geo.faces_area() | ||
>>> # Connect inputs : op.inputs. ... | ||
>>> result_field = op.outputs.field() | ||
""" | ||
|
||
def __init__(self, op: Operator): | ||
super().__init__(faces_area._spec().outputs, op) | ||
self._field = Output(faces_area._spec().output_pin(0), 0, op) | ||
self._outputs.append(self._field) | ||
|
||
@property | ||
def field(self): | ||
"""Allows to get field output of the operator | ||
|
||
Returns | ||
---------- | ||
my_field : Field | ||
|
||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.geo.faces_area() | ||
>>> # Connect inputs : op.inputs. ... | ||
>>> result_field = op.outputs.field() | ||
""" # noqa: E501 | ||
return self._field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MichaelNale @rafacanton it does not say what happens in the case of polyhedrons
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It uses geometrical considerations to compute volume in that case, but I agree, it could be mentioned