Skip to content

Commit

Permalink
correct for usage with map_flag implemented in 2021R1 (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
akaszynski authored Mar 22, 2021
1 parent 2db7c00 commit 9255e79
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
11 changes: 9 additions & 2 deletions ansys/mapdl/reader/_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
"""Version of ansys-mapdl-reader module."""
"""Version of ansys-mapdl-reader module.
On the ``master`` branch, use 'dev0' to denote a development version.
For example:
version_info = 0, 58, 'dev0'
"""

# major, minor, patch
version_info = 0, 50, 6
version_info = 0, 50, 'dev0'

# Nice string for the version
__version__ = '.'.join(map(str, version_info))
10 changes: 8 additions & 2 deletions ansys/mapdl/reader/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,16 @@ def materials(self):
def _load_section_data(self):
"""Loads the section data from the result file"""
ptr_sec = self._geometry_header['ptrSEC']
sec_table = self.read_record(ptr_sec)
sec_table, sz = self.read_record(ptr_sec, True)

# Assemble section pointers relative to ptrSEC
if self._map_flag: # required as of 2021R1
sec_pointers = self.read_record(ptr_sec + sz)
else:
sec_pointers = sec_table

self._section_data = {}
for offset in sec_table:
for offset in sec_pointers:
if offset:
table = self.read_record(ptr_sec + offset)
self._section_data[int(table[0])] = table[1:]
Expand Down
13 changes: 13 additions & 0 deletions tests/test_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
temperature_rst = os.path.join(testfiles_path, 'temp_v13.rst')
temperature_known_result = os.path.join(testfiles_path, 'temp_v13.npz')


@pytest.fixture(scope='module')
def hex_pipe_corner():
filename = os.path.join(testfiles_path, 'rst', 'cyc_stress.rst')
Expand All @@ -96,6 +97,18 @@ def volume_rst():
return pymapdl_reader.read_binary(rst_file)


def test_map_flag_section_data():
# basic 4 element SHELL181 result files
shell181_2020r2 = os.path.join(testfiles_path, 'shell181_2020R2.rst')
shell181_2021r1 = os.path.join(testfiles_path, 'shell181_2021R1.rst')

rst_2020r2 = pymapdl_reader.read_binary(shell181_2020r2)
rst_2021r1 = pymapdl_reader.read_binary(shell181_2021r1)

for key in rst_2020r2.section_data:
assert np.allclose(rst_2020r2.section_data[key],
rst_2021r1.section_data[key])

def test_overwrite(tmpdir):
tmp_path = str(tmpdir.mkdir("tmpdir"))
rst = pymapdl_reader.read_binary(copy(examples.rstfile, tmp_path))
Expand Down
Binary file added tests/testfiles/shell181_2020R2.rst
Binary file not shown.
Binary file added tests/testfiles/shell181_2021R1.rst
Binary file not shown.

0 comments on commit 9255e79

Please sign in to comment.