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

Add element results to post module #684

Merged
merged 10 commits into from
Nov 2, 2021
57 changes: 39 additions & 18 deletions ansys/mapdl/core/_commands/post1_/element_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,36 +381,57 @@ def pretab(
lab9="",
**kwargs,
):
"""Prints the element table items.
"""Print the element table items.

APDL Command: PRETAB

Parameters
----------
lab1, lab2, lab3, . . . , lab9
Print selected items. Valid labels are (blank) or any label as
specified with the ETABLE command. Convenience labels may be used
for Lab1 to select groups of labels (10 labels maximum): GRP1 for
first 10 stored items; GRP2 for items 11 to 20; GRP3 for items 21
to 30; GRP4 for items 31 to 40; GRP5 for items 41 to 50. Enter
ETABLE,STAT command to list stored item order. If all labels are
lab1, lab2, lab3, ... , lab9
Print selected items. Valid labels are ``""`` or any
label as specified with the ETABLE command. Convenience
labels may be used for Lab1 to select groups of labels (10
labels maximum): GRP1 for first 10 stored items; GRP2 for
items 11 to 20; GRP3 for items 21 to 30; GRP4 for items 31
to 40; GRP5 for items 41 to 50. Run ``etable("stat")``
command to list stored item order. If all labels are
blank, print first 10 stored items (GRP1).

Notes
-----
Prints the items stored in the table defined with the ETABLE command.
Item values will be listed for the selected elements in the sorted
sequence [ESORT]. The FORCE command can be used to define which
component of the nodal load is to be used (static, damping, inertia,
or total).
Prints the items stored in the table defined with the
:func:`etable() <ansys.mapdl.core.Mapdl.etable>` command.
Item values will be listed for the selected elements in the
sorted sequence [ESORT]. :func:`force()
<ansys.mapdl.core.Mapdl.force>` can be used to define which
component of the nodal load is to be used (static, damping,
inertia, or total).

Examples
--------
Print out element displacement results.

>>> mapdl.etable("values", "U", "X")
STORE VALUES FROM ITEM=U COMP=X FOR ALL SELECTED ELEMENTS

Now print out the table.

>>> mapdl.pretab().splitlines()[:4]
['PRINT ELEMENT TABLE ITEMS PER ELEMENT',
' 1 0.1073961540E-005 0.1073961540E-005',
' 2 0.3156317304E-005 0.3156317304E-005',
' 3 0.5125435148E-005 0.5125435148E-005']

Note that can access the array directly from APDL:

>>> mapdl.get_array("elem", 1, "ETAB", "values")
array([1.07396154e-06, 3.15631730e-06, 5.12543515e-06, ...,
5.41204700e-06, 3.33649806e-06, 1.13836132e-06])

Portions of this command are not supported by PowerGraphics
[/GRAPHICS,POWER].
"""
command = (
f"PRETAB,{lab1},{lab2},{lab3},{lab4},{lab5},{lab6},{lab7},{lab8},{lab9}"
return self.run(
f"PRETAB,{lab1},{lab2},{lab3},{lab4},{lab5},{lab6},{lab7},{lab8},{lab9}", **kwargs
)
return self.run(command, **kwargs)

def sabs(self, key="", **kwargs):
"""Specifies absolute values for element table operations.
Expand Down
32 changes: 28 additions & 4 deletions ansys/mapdl/core/mesh_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ def nnum(self) -> np.ndarray:

@property
def nnum_all(self) -> np.ndarray:
"""Array of all node numbers.
"""Array of all node numbers, even those not selected.

Examples
--------
>>> mapdl.mesh.nnum
>>> mapdl.mesh.nnum_all
array([ 1, 2, 3, ..., 19998, 19999, 20000])
"""
self._ignore_cache_reset = True
Expand All @@ -137,10 +137,34 @@ def nnum_all(self) -> np.ndarray:

return nnum

@property
def enum_all(self) -> np.ndarray:
"""Array of all element numbers, even those not selected.

Examples
--------
>>> mapdl.mesh.enum_all
array([ 1, 2, 3, ..., 19998, 19999, 20000])
"""
self._ignore_cache_reset = True
self._mapdl.cm("__ELEM__", "ELEM", mute=True)
self._mapdl.esel("all", mute=True)

enum = self._mapdl.get_array("ELEM", item1="NLIST")
enum = enum.astype(np.int32)
if enum.size == 1:
if enum[0] == 0:
enum = np.empty(0, np.int32)

self._mapdl.cmsel("S", "__ELEM__", "ELEM", mute=True)
self._ignore_cache_reset = False

return enum

@property
@supress_logging
def n_node(self) -> int:
"""Number of currently selected nodes in MAPDL
"""Number of currently selected nodes in MAPDL.

Examples
--------
Expand All @@ -152,7 +176,7 @@ def n_node(self) -> int:
@property
@supress_logging
def n_elem(self) -> int:
"""Number of currently selected nodes in MAPDL
"""Number of currently selected elements in MAPDL.

Examples
--------
Expand Down
Loading