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

Hotfix: Output node numbers in nodal_reaction_forces #26

Merged
merged 3 commits into from
May 11, 2021
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
1 change: 0 additions & 1 deletion ansys/mapdl/reader/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ def save_as_archive(filename, grid, mtype_start=1, etype_start=1,
>>> pymapdl_reader.save_as_archive('archive.cdb', grid)

"""

if isinstance(grid, pv.PolyData):
grid = grid.cast_to_unstructured_grid()

Expand Down
29 changes: 0 additions & 29 deletions ansys/mapdl/reader/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,35 +110,6 @@ def read_record(self, pointer, return_bufsize=False):
record = c_read_record(self.filename, pointer, return_bufsize)
return record

# def read_record(self, pointer, return_bufsize=False):
# """Reads a record at a given position.

# Because ANSYS 19.0+ uses compression by default, you must use
# this method rather than ``np.fromfile``.

# Parameters
# ----------
# pointer : int
# ANSYS file position (n words from start of file). A word
# is four bytes.

# return_bufsize : bool, optional
# Returns the number of words read (includes header and
# footer). Useful for determining the new position in the
# file after reading a record.

# Returns
# -------
# record : np.ndarray
# The record read as a ``n x 1`` numpy array.

# bufsize : float, optional
# When ``return_bufsize`` is enabled, returns the number of
# words read.

# """
# return c_read_record(self.filename, pointer, return_bufsize)


def read_binary(filename, **kwargs):
"""Reads ANSYS-written binary files:
Expand Down
45 changes: 42 additions & 3 deletions ansys/mapdl/reader/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,44 @@ def solution_info(self, rnum):
header : dict
Double precision solution header data.

Examples
--------
Extract the solution info from a sample example result file.

>>> from ansys.mapdl.reader import examples
>>> rst = examples.download_pontoon()
>>> rst.solution_info(0)
{'cgcent': [],
'fatjack': [],
'timfrq': 44.85185724963714,
'lfacto': 1.0,
'lfactn': 1.0,
'cptime': 3586.4873046875,
'tref': 71.6,
'tunif': 71.6,
'tbulk': 293.0,
'volbase': 0.0,
'tstep': 0.0,
'__unused': 0.0,
'accel_x': 0.0,
'accel_y': 0.0,
'accel_z': 0.0,
'omega_v_x': 0.0,
'omega_v_y': 0.0,
'omega_v_z': 0.0,
'omega_a_x': 0.0,
'omega_a_y': 0.0,
'omega_a_z': 0.0,
'omegacg_v_x': 0.0,
'omegacg_v_y': 0.0,
'omegacg_v_z': 0.0,
'omegacg_a_x': 0.0,
'omegacg_a_y': 0.0,
'omegacg_a_z': 0.0,
'dval1': 0.0,
'pCnvVal': 0.0}


Notes
-----
The keys of the solution header are described below:
Expand Down Expand Up @@ -1478,7 +1516,7 @@ def solution_info(self, rnum):
# convert to cumulative index
rnum = self.parse_step_substep(rnum)

# skip pointers table
# skip solution data header
ptr = self._resultheader['rpointers'][rnum]
_, sz = self.read_record(ptr, True)

Expand Down Expand Up @@ -3243,7 +3281,7 @@ def nodal_reaction_forces(self, rnum, sort=True):
Returns
-------
rforces : np.ndarray
Reaction Forces
Nodal reaction forces.

nnum : np.ndarray
Node numbers corresponding to the reaction forces. Does
Expand Down Expand Up @@ -3314,7 +3352,8 @@ def nodal_reaction_forces(self, rnum, sort=True):
dof = dof[sidx]
rforces = rforces[sidx]

return rforces, index, dof
nnum = self._mesh.nnum[index]
return rforces, nnum, dof

def plot_element_result(self, rnum, result_type, item_index,
in_element_coord_sys=False, **kwargs):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_binary_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
except:
_HAS_ANSYS = False

if os.environ.get('SKIP_ANSYS', '').upper() == 'TRUE':
_HAS_ANSYS = False


HAS_FFMPEG = True
try:
import imageio_ffmpeg
Expand Down
9 changes: 6 additions & 3 deletions tests/test_dist_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@
from ansys.mapdl.reader._rst_keys import element_index_table_info

try:
from ansys.mapdl.core import _HAS_ANSYS
from ansys.mapdl.core.mapdl_grpc import MapdlGrpc
# from ansys.mapdl.core.mapdl_corba import MapdlCorba
MapdlCorba = None
from ansys.mapdl.core.mapdl_console import MapdlConsole
from ansys.mapdl.core import _HAS_ANSYS as HAS_ANSYS
except:
HAS_ANSYS = False
_HAS_ANSYS = False

if os.environ.get('SKIP_ANSYS', '').upper() == 'TRUE':
_HAS_ANSYS = False


test_path = os.path.dirname(os.path.abspath(__file__))
testfiles_path = os.path.join(test_path, 'testfiles')


skip_no_ansys = pytest.mark.skipif(not HAS_ANSYS, reason="Requires ANSYS installed")
skip_no_ansys = pytest.mark.skipif(not _HAS_ANSYS, reason="Requires ANSYS installed")


@pytest.fixture()
Expand Down