ansys / pydpf-core

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

Extraction of Pressure surfaces (Surf154) with pyDPF #1510

Open Louise-Ramos opened 3 months ago

Louise-Ramos commented 3 months ago

Description of the feature

Hello,

is there a feature that extracts the pressure surfaces from a model ? It seems that I can get le pressure named selection with metadata.meshed_region..available_named_selections (as an '__LV_223__SELECTION' for instance), but when I acces the elements IDs and try to find each element in the mesh, they do not exist.

I see in the ds.dat file that the selection corresponds to a Surf154 (quad8) defined from pressure loading, but through pyDPF I can not find such elements.

Thanks in advance. Louise Ramos

Steps for implementing the feature

No response

Useful links and references

No response

PProfizi commented 3 months ago

Hello @Louise-Ramos, To clarify, do you want to extract the pressure field on a given named selection?

If the named selection is returned by MeshedRegion.available_named_selections, then it should be available. Can you try using MeshedRegion.named_selection("__LV_223__SELECTION") to get the scoping for the named selection, and then see if it is empty. In any case I do not think you will see any mention of Surf154 in DPF, but what you can do is look for 154 in the data returned when asking for MeshedRegion.property_field("apdl_element_type").

Louise-Ramos commented 3 months ago

Hello @PProfizi,

I want to extract the elements used for the pressure loading, or the scoping used to the pressure. The named selection is returned and is filled with 200 elements, but when I do extract the IDs from the selection, I can't find them in my meshed_region. In other words, I use a code such as the following to my test:

rst = Model('file.rst')
metadata = rst.metadata;
ansys_mesh = metadata.meshed_region;

print(ansys_mesh.available_named_selections) **Used to identify the '__LV_223__SELECTION' elemental selection **
print(metadata.named_selection(('_LV_227__SELECTION')).location, metadata.named_selection(('__LV_223__SELECTION')).size) ** returns  :' Elemental 248'
selection_Ids = metadata.named_selection('__LV_223__SELECTION').ids

for idel in selection_Ids :
      print(idel)
     Mesh_Element_Conn = ansys_mesh.elements.element_by_id(idel).connectivity ** Getting the connectivity of the points from the element with ID = idel **

I have the following error message:

Traceback (most recent call last): File "C:\Users\s628156\AppData\Roaming\JetBrains\PyCharmCE2022.3\scratches\scratch.py", line 24, in print(idel , ansys_mesh.elements.element_by_id(idel).connectivity) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\s628156\PycharmProjects\pythonProject\venv\Lib\site-packages\ansys\dpf\core\elements.py", line 283, in element_by_id return self.__get_element(elementid=id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\s628156\PycharmProjects\pythonProject\venv\Lib\site-packages\ansys\dpf\core\elements.py", line 445, in __get_element num_nodes = self._mesh._api.meshed_region_get_num_nodes_of_element( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\s628156\PycharmProjects\pythonProject\venv\Lib\site-packages\ansys\dpf\gate\generated\meshed_region_capi.py", line 226, in meshed_region_get_num_nodes_of_element raise errors.DPFServerException(sError.value) ansys.dpf.gate.errors.DPFServerException: element not found

I checked the elements in my mesh, and there are only these two: [187 281]. Still, the selection does not seems to be defined by the mesh elements.

Is that a bug ?

Thanks in advance,