Skip to content

Commit

Permalink
Merge branch 'main' into release/0.51
Browse files Browse the repository at this point in the history
  • Loading branch information
akaszynski committed Nov 24, 2021
2 parents d3a0ada + 0647b94 commit 2c68be4
Show file tree
Hide file tree
Showing 16 changed files with 211 additions and 83 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/testing-and-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:

- name: Install XVFB
run: |
sudo apt update
sudo apt-get install libgl1-mesa-glx xvfb
pip install pyvista
xvfb-run python -c "import pyvista; print(pyvista.Report())"
Expand Down Expand Up @@ -142,10 +143,18 @@ jobs:
pip install twine
twine check dist/*
- name: Install
- name: Install on Linux
if: ${{ runner.os == 'Linux' }}
run: |
pip install wheel
pip install dist/*
pip list
- name: Install on Windows Powershell
if: ${{ runner.os == 'Windows' }}
run: |
pip install wheel
pip install --find-links=dist ${{ env.PACKAGE_NAME }}
pip install (get-item .\dist\*.whl)
pip list
- name: Get PyVista tools
Expand All @@ -167,6 +176,7 @@ jobs:
- name: Install XVFB on Linux
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt update
sudo apt-get install libgl1-mesa-glx xvfb
xvfb-run python -c "import pyvista; print(pyvista.Report())"
Expand Down
13 changes: 12 additions & 1 deletion ansys/mapdl/reader/_mp_keys.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
"""Contains material property indices
Obtained from:
/usr/ansys_inc/v202/ansys/customize/include/mpcom.inc
/usr/ansys_inc/v212/ansys/customize/include/mpcom.inc
c ---- MP command labels --------
c EX = 1, EY = 2, EZ = 3, NUXY= 4, NUYZ= 5, NUXZ= 6, GXY = 7, GYZ = 8,
c GXZ = 9, ALPX=10, ALPY=11, ALPZ=12, DENS=13, MU =14, DAMP=15, KXX =16,
c KYY =17, KZZ =18, RSVX=19, RSVY=20, RSVZ=21, C =22, HF =23, VISC=24,
c EMIS=25, ENTH=26, LSST=27, PRXY=28, PRYZ=29, PRXZ=30, MURX=31, MURY=32,
c MURZ=33, PERX=34, PERY=35, PERZ=36, MGXX=37, MGYY=38, MGZZ=39, EGXX=40,
c EGYY=41, EGZZ=42, SBKX=43, SBKY=44, SBKZ=45, SONC=46, DMPS=47, ELIM=48,
c USR1=49, USR2=50, USR3=51, USR4=52, FLUI=53, ORTH=54, CABL=55, RIGI=56,
c HGLS=57, BVIS=58, QRAT=59, REFT=60, CTEX=61, CTEY=62, CTEZ=63, THSX=64,
c THSY=65, THSZ=66, DMPR=67, LSSM=68, BETD=69, ALPD=70, RH =71, DXX =72,
c DYY =73, DZZ =74, BETX=75, BETY=76, BETZ=77, CSAT=78, CREF=79, CVH =80
These indices are used when reading in results using ptrMAT from a
binary result file.
Expand Down
21 changes: 10 additions & 11 deletions ansys/mapdl/reader/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,19 +605,14 @@ def write_cmblock(filename, items, comp_name, comp_type,
----------
filename : str or file handle
File to write CMBLOCK component to.
items : list or np.ndarray
Element or node numbers to write.
comp_name : str
Name of the component
comp_type : str
Component type to write. Should be either 'ELEMENT' or 'NODE'.
digit_width : int, optional
Default 10
mode : str, optional
Write mode. Default ``'w'``.
"""
Expand Down Expand Up @@ -650,20 +645,24 @@ def write_cmblock(filename, items, comp_name, comp_type,
# writing each line.
# nearest multiple of 8
up_to = len(cmblock_items) % 8
np.savetxt(fid, cmblock_items[:-up_to].reshape(-1, 8), digit_formatter*8)
if up_to: # deal with the zero case
np.savetxt(fid, cmblock_items[:-up_to].reshape(-1, 8), digit_formatter*8)

# write the final line
chunk = cmblock_items[-up_to:]
print(''.join([digit_formatter] * len(chunk)) % tuple(chunk), file=fid)
else:
np.savetxt(fid, cmblock_items.reshape(-1, 8), digit_formatter*8)

# write the final line
chunk = cmblock_items[-up_to:]
print(''.join([digit_formatter] * len(chunk)) % tuple(chunk), file=fid)
print('', file=fid)

if opened_file:
fid.close()


def _write_eblock(filename, elem_id, etype, mtype, rcon, elem_nnodes,
cells, offset, celltypes, typenum,
nodenum, mode='a'):
cells, offset, celltypes, typenum,
nodenum, mode='a'):
"""Write EBLOCK to disk"""
# perform type checking here
if elem_id.dtype != np.int32:
Expand Down
1 change: 0 additions & 1 deletion ansys/mapdl/reader/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ def read_table(f, dtype='i', nread=None, skip=False, get_nread=True, cython=Fals

if get_nread:
n = np.fromfile(f, 'i', 1)
print(n)
if not n:
raise Exception('end of file')

Expand Down
57 changes: 21 additions & 36 deletions ansys/mapdl/reader/cython/_binary_reader.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,16 @@ cdef class AnsysFile:
# self._file = new ifstream(c_filename, binary)
self._file = open_fstream(c_filename)

# def _read(self, int size):
# cdef char raw[10000]
# self._file_a.read(raw, size)
# return raw[:size]
def _read(self, int size):
mx_sz = 10000
if size > mx_sz:
raise RuntimeError(f"Maximum read size is {mx_sz}")
cdef char raw[10000]
self._file.read(raw, size)
return raw[:size]

# def _seekg(self, int index):
# self._file_a.seekg(index)
def _seekg(self, int index):
self._file.seekg(index)

def read_record(self, int64_t ptr, int return_bufsize=0):
"""Read a record from the opened file"""
Expand All @@ -246,13 +249,11 @@ cdef class AnsysFile:

if return_bufsize:
return ndarray, bufsize
else:
return ndarray
return ndarray

def close(self):
"""Close the file"""
del self._file
del self._file_out

def read_element_data(self, int64_t [::1] ele_ind_table, int table_index,
int64_t ptr_off):
Expand Down Expand Up @@ -1638,61 +1639,45 @@ def affline_transform(float_or_double [:, ::1] points, float_or_double [:, ::1]
points[i, 2] = t20*x + t21*y + t22*z + t23


cdef inline int cell_lookup(uint8 celltype) nogil:
if celltype == VTK_HEXAHEDRON or celltype == VTK_QUADRATIC_HEXAHEDRON:
return 8
elif celltype == VTK_TETRA or celltype == VTK_QUADRATIC_TETRA:
return 4
elif celltype == VTK_PYRAMID or celltype == VTK_QUADRATIC_PYRAMID:
return 5
elif celltype == VTK_WEDGE or celltype == VTK_QUADRATIC_WEDGE:
return 6


def cells_with_all_nodes(index_type [::1] offset, index_type [::1] cells,
uint8 [::1] celltypes, uint8 [::1] point_mask):
uint8 [::1] point_mask):
"""
Updates mask of cells containing all points in the point indices
or mask.
"""
cdef int ncells = celltypes.size
cdef uint8 celltype
cdef int ncell_points, i, j
cdef index_type cell_offset
cdef int ncells = offset.size - 1
cdef int i, j
cdef index_type cell_offset, next_cell_offset
cdef uint8 [::1] cell_mask = np.ones(ncells, np.uint8)

with nogil:
for i in range(ncells):
celltype = celltypes[i]
ncell_points = cell_lookup(celltype)
cell_offset = offset[i] + 1
for j in range(cell_offset, cell_offset + ncell_points):
next_cell_offset = offset[i+1] + 1
for j in range(cell_offset, next_cell_offset):
if point_mask[cells[j]] != 1:
cell_mask[i] = 0

return np.asarray(cell_mask, dtype=np.bool)


def cells_with_any_nodes(index_type [::1] offset, index_type [::1] cells,
uint8 [::1] celltypes, uint8 [::1] point_mask):
uint8 [::1] point_mask):
"""
Updates mask of cells containing at least one point in the point
indices or mask.
"""
cdef int ncells = celltypes.size
cdef uint8 celltype
cdef int ncell_points
cdef index_type cell_offset
cdef int ncells = offset.size - 1
cdef index_type cell_offset, next_cell_offset
cdef int i, j

cdef uint8 [::1] cell_mask = np.zeros(ncells, np.uint8)

with nogil:
for i in range(ncells):
celltype = celltypes[i]
ncell_points = cell_lookup(celltype)
cell_offset = offset[i] + 1
for j in range(cell_offset, cell_offset + ncell_points):
next_cell_offset = offset[i+1] + 1
for j in range(cell_offset, next_cell_offset):
if point_mask[cells[j]] == 1:
cell_mask[i] = 1
break
Expand Down
2 changes: 0 additions & 2 deletions ansys/mapdl/reader/cython/binary_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,6 @@ void* read_record_fid(fstream* file, int64_t loc, int* prec_flag, int* type_flag
// always read record
char *raw = new char[4*bufsize];
file->read(raw, 4*bufsize);

*out_bufsize = bufsize + 3; // include header and footer

if (bsparse_flag){
Expand Down Expand Up @@ -632,7 +631,6 @@ fstream* open_fstream(const char* filename){
// overwrite an existing ansys record at location ptr
int overwriteRecord(fstream* fs, int ptr, double* data){
int bsparse_flag, wsparse_flag, zlib_flag, prec_flag, type_flag;
int size;

// read the header
// seek to data location if supplied with a pointer
Expand Down
2 changes: 1 addition & 1 deletion ansys/mapdl/reader/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@

_etype_map = [0, 2, # LINK1
3, # PLANE2
3, # BEAM3
2, # BEAM3
2, # BEAM4
4, # SOLID5
0, # UNUSED6
Expand Down
Loading

0 comments on commit 2c68be4

Please sign in to comment.