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

Fix max element types #32

Merged
merged 2 commits into from
Jun 2, 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
6 changes: 3 additions & 3 deletions ansys/mapdl/reader/cython/_binary_reader.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ cdef class AnsysFile:
del self._file
del self._file_out

def read_element_data(self, int64_t [::1] ele_ind_table, int table_index, int ptr_off):
cdef int64_t ind
cdef int ptr
def read_element_data(self, int64_t [::1] ele_ind_table, int table_index,
int64_t ptr_off):
cdef int64_t ind, ptr
cdef int prec_flag, type_flag, size, bufsize
cdef void* c_ptr
cdef np.ndarray record
Expand Down
4 changes: 2 additions & 2 deletions ansys/mapdl/reader/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def _parse_vtk(self, allowable_types=None, force_linear=False,
etype_map[allowable_types] = ETYPE_MAP[allowable_types]

# ANSYS element type to VTK map
type_ref = np.empty(2 << 15, np.int32) # 65536
type_ref[self._ekey[:, 0]] = etype_map[self._ekey[:, 1]]
type_ref = np.empty(2 << 16, np.int32) # 131072
type_ref[self._ekey[:, 0]] = etype_map[self._ekey[:, 1]]

# special treatment for MESH200
if allowable_types is None or 200 in allowable_types:
Expand Down
29 changes: 21 additions & 8 deletions ansys/mapdl/reader/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -1339,11 +1339,11 @@ def _load_element_table(self):
e_type_table, sz = self.read_record(ptrety, True)

# store information for each element type
nodelm = np.empty(10000, np.int32) # n nodes for this element type
nodfor = np.empty(10000, np.int32) # n nodes per element having nodal forces
nodstr = np.empty(10000, np.int32) # n nodes per element having nodal stresses
nodelm = {} # n nodes for this element type
nodfor = {} # n nodes per element having nodal forces
nodstr = {} # n nodes per element having nodal stresses
ekey = []
keyopts = np.zeros((10000, 11), np.int16)
keyopts = {} # key options

# Assemble element record pointers relative to ptrETY
if self._map_flag:
Expand Down Expand Up @@ -1382,13 +1382,26 @@ def _load_element_table(self):
#
# Only valid for SHELL181 or SHELL281 elements.
if einfo[1] == 181 or einfo[1] == 281:
if keyopts[etype_ref, 7] == 0:
if keyopts[etype_ref][7] == 0:
nodstr[etype_ref] *= 2

def dict_to_arr(index_dict):
"""Convert an index dictionary to an array

For example:
{1: 20, 2: 30} --> [UNDEF, 20, 30]

"""
arr = np.empty(max(index_dict.keys()) + 1, np.int32)
for key, value in index_dict.items():
arr[key] = value
return arr

# rest of pymapdl-reader expects the following as arrays.
# store element table data
return {'nodelm': nodelm,
'nodfor': nodfor,
'nodstr': nodstr,
return {'nodelm': dict_to_arr(nodelm),
'nodfor': dict_to_arr(nodfor),
'nodstr': dict_to_arr(nodstr),
'keyopts': keyopts,
'ekey': np.array(ekey)}

Expand Down