ansys / pydpf-core

Data Processing Framework - Python Core
http://dpf.docs.pyansys.com/
MIT License
70 stars 25 forks source link

Enhance ``Result.on_named_selection()`` #723

Open GuillemBarroso opened 1 year ago

GuillemBarroso commented 1 year ago

Description of the feature

The Result.on_named_selection() method, see docs could have an additional argument requested_location, similar to the scoping.on_named_selection(), see docs.

This would fix the behavior I am having: I am requesting the displacements on a named selection and I end up with a displacement field that has elemental location. See code below.

from ansys.dpf import core as dpf
from ansys.dpf.core import examples
model = dpf.Model(examples.download_all_kinds_of_complexity())
disp_selection_fc = model.results.displacement.on_named_selection(named_selection="_CM82").eval()
print(disp_selection_fc[0].location)

Again, this could be fix by adding an extra argument as:

disp_selection_fc = model.results.displacement.on_named_selection(named_selection="_CM82", requested_location="nodal").eval()

Steps for implementing the feature

N/A

Useful links and references

N/A

GuillemBarroso commented 1 year ago

I have found a workaround by doing

from ansys.dpf import core as dpf
from ansys.dpf.core import operators as ops
from ansys.dpf.core import examples
model = dpf.Model(examples.download_all_kinds_of_complexity())
scoping_op = ops.scoping.on_named_selection()
scoping_op.inputs.requested_location.connect("nodal")
scoping_op.inputs.named_selection_name.connect("_CM82")
scoping_op.inputs.data_sources.connect(
    dpf.DataSources(examples.download_all_kinds_of_complexity())
)
mesh_scoping = scoping_op.outputs.mesh_scoping()
disp_selection_fc = model.results.displacement.on_mesh_scoping(mesh_scoping).eval()
print(disp_selection_fc[0].location)

Still, I think it would be nice to add the extra argument requested_location in on_named_selection as initially described in this issue so we don't have to explicitly use the scoping operator.