Skip to content
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

Merged
merged 2 commits into from
Aug 31, 2023
Merged
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
12 changes: 6 additions & 6 deletions docs/source/_static/dpf_operators.html

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions src/ansys/dpf/core/operators/filter/filtering_max_over_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@

class filtering_max_over_time(Operator):
"""Creates a filtering workflow that will filter results based on a
threshold of Selected invariant.
threshold of a selected invariant.

Parameters
----------
invariant_fc_operator : str
Name of nvariant operator to be used to
calculate filter (e.g. eqv_fc).
Name of the invariant operator to be used to
calculate filter (avalailable:
eqv_fc, invariants_deriv_fc,
invariants_fc).
output_pin : int, optional
Output pin of the invariant operator. default
= 0.
Expand Down Expand Up @@ -83,16 +85,18 @@ def __init__(
@staticmethod
def _spec():
description = """Creates a filtering workflow that will filter results based on a
threshold of Selected invariant."""
threshold of a selected invariant."""
spec = Specification(
description=description,
map_input_pin_spec={
0: PinSpecification(
name="invariant_fc_operator",
type_names=["string"],
optional=False,
document="""Name of nvariant operator to be used to
calculate filter (e.g. eqv_fc).""",
document="""Name of the invariant operator to be used to
calculate filter (avalailable:
eqv_fc, invariants_deriv_fc,
invariants_fc).""",
),
1: PinSpecification(
name="output_pin",
Expand Down Expand Up @@ -203,8 +207,10 @@ def __init__(self, op: Operator):
def invariant_fc_operator(self):
"""Allows to connect invariant_fc_operator input to the operator.

Name of nvariant operator to be used to
calculate filter (e.g. eqv_fc).
Name of the invariant operator to be used to
calculate filter (avalailable:
eqv_fc, invariants_deriv_fc,
invariants_fc).

Parameters
----------
Expand Down
1 change: 1 addition & 0 deletions src/ansys/dpf/core/operators/geo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .elements_facets_surfaces_over_time import elements_facets_surfaces_over_time
from .elements_volume import elements_volume
from .elements_volumes_over_time import elements_volumes_over_time
from .faces_area import faces_area
from .gauss_to_node import gauss_to_node
from .integrate_over_elements import integrate_over_elements
from .normals import normals
Expand Down
24 changes: 19 additions & 5 deletions src/ansys/dpf/core/operators/geo/elements_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment on lines +14 to +16
Copy link
Contributor

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

Copy link
Contributor

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


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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MichaelNale @rafacanton

Suggested change
If not provided, the measure of all elements
for the mesh is computed. if
provided, the scoping needs to have
"elemental" location.
If not provided, the measure is computed
for each element in the mesh. If
provided, the scoping needs to have
"elemental" location.



Examples
Expand Down Expand Up @@ -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={
Expand All @@ -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={
Expand Down Expand Up @@ -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
Expand Down
227 changes: 227 additions & 0 deletions src/ansys/dpf/core/operators/geo/faces_area.py
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MichaelNale @rafacanton same here, what happens in the case of polygons?

Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

@PProfizi PProfizi Aug 31, 2023

Choose a reason for hiding this comment

The 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
2 changes: 2 additions & 0 deletions src/ansys/dpf/core/operators/logic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from .descending_sort import descending_sort
from .descending_sort_fc import descending_sort_fc
from .enrich_materials import enrich_materials
from .entity_selector import entity_selector
from .entity_selector_fc import entity_selector_fc
from .identical_fc import identical_fc
from .identical_fields import identical_fields
from .identical_meshes import identical_meshes
Expand Down
Loading