Skip to content

Commit 2c68be4

Browse files
committed
Merge branch 'main' into release/0.51
2 parents d3a0ada + 0647b94 commit 2c68be4

File tree

16 files changed

+211
-83
lines changed

16 files changed

+211
-83
lines changed

.github/workflows/testing-and-deployment.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444

4545
- name: Install XVFB
4646
run: |
47+
sudo apt update
4748
sudo apt-get install libgl1-mesa-glx xvfb
4849
pip install pyvista
4950
xvfb-run python -c "import pyvista; print(pyvista.Report())"
@@ -142,10 +143,18 @@ jobs:
142143
pip install twine
143144
twine check dist/*
144145
145-
- name: Install
146+
- name: Install on Linux
147+
if: ${{ runner.os == 'Linux' }}
148+
run: |
149+
pip install wheel
150+
pip install dist/*
151+
pip list
152+
153+
- name: Install on Windows Powershell
154+
if: ${{ runner.os == 'Windows' }}
146155
run: |
147156
pip install wheel
148-
pip install --find-links=dist ${{ env.PACKAGE_NAME }}
157+
pip install (get-item .\dist\*.whl)
149158
pip list
150159
151160
- name: Get PyVista tools
@@ -167,6 +176,7 @@ jobs:
167176
- name: Install XVFB on Linux
168177
if: ${{ runner.os == 'Linux' }}
169178
run: |
179+
sudo apt update
170180
sudo apt-get install libgl1-mesa-glx xvfb
171181
xvfb-run python -c "import pyvista; print(pyvista.Report())"
172182

ansys/mapdl/reader/_mp_keys.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
"""Contains material property indices
22
33
Obtained from:
4-
/usr/ansys_inc/v202/ansys/customize/include/mpcom.inc
4+
/usr/ansys_inc/v212/ansys/customize/include/mpcom.inc
55
6+
c ---- MP command labels --------
7+
c EX = 1, EY = 2, EZ = 3, NUXY= 4, NUYZ= 5, NUXZ= 6, GXY = 7, GYZ = 8,
8+
c GXZ = 9, ALPX=10, ALPY=11, ALPZ=12, DENS=13, MU =14, DAMP=15, KXX =16,
9+
c KYY =17, KZZ =18, RSVX=19, RSVY=20, RSVZ=21, C =22, HF =23, VISC=24,
10+
c EMIS=25, ENTH=26, LSST=27, PRXY=28, PRYZ=29, PRXZ=30, MURX=31, MURY=32,
11+
c MURZ=33, PERX=34, PERY=35, PERZ=36, MGXX=37, MGYY=38, MGZZ=39, EGXX=40,
12+
c EGYY=41, EGZZ=42, SBKX=43, SBKY=44, SBKZ=45, SONC=46, DMPS=47, ELIM=48,
13+
c USR1=49, USR2=50, USR3=51, USR4=52, FLUI=53, ORTH=54, CABL=55, RIGI=56,
14+
c HGLS=57, BVIS=58, QRAT=59, REFT=60, CTEX=61, CTEY=62, CTEZ=63, THSX=64,
15+
c THSY=65, THSZ=66, DMPR=67, LSSM=68, BETD=69, ALPD=70, RH =71, DXX =72,
16+
c DYY =73, DZZ =74, BETX=75, BETY=76, BETZ=77, CSAT=78, CREF=79, CVH =80
617
718
These indices are used when reading in results using ptrMAT from a
819
binary result file.

ansys/mapdl/reader/archive.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -605,19 +605,14 @@ def write_cmblock(filename, items, comp_name, comp_type,
605605
----------
606606
filename : str or file handle
607607
File to write CMBLOCK component to.
608-
609608
items : list or np.ndarray
610609
Element or node numbers to write.
611-
612610
comp_name : str
613611
Name of the component
614-
615612
comp_type : str
616613
Component type to write. Should be either 'ELEMENT' or 'NODE'.
617-
618614
digit_width : int, optional
619615
Default 10
620-
621616
mode : str, optional
622617
Write mode. Default ``'w'``.
623618
"""
@@ -650,20 +645,24 @@ def write_cmblock(filename, items, comp_name, comp_type,
650645
# writing each line.
651646
# nearest multiple of 8
652647
up_to = len(cmblock_items) % 8
653-
np.savetxt(fid, cmblock_items[:-up_to].reshape(-1, 8), digit_formatter*8)
648+
if up_to: # deal with the zero case
649+
np.savetxt(fid, cmblock_items[:-up_to].reshape(-1, 8), digit_formatter*8)
650+
651+
# write the final line
652+
chunk = cmblock_items[-up_to:]
653+
print(''.join([digit_formatter] * len(chunk)) % tuple(chunk), file=fid)
654+
else:
655+
np.savetxt(fid, cmblock_items.reshape(-1, 8), digit_formatter*8)
654656

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

660659
if opened_file:
661660
fid.close()
662661

663662

664663
def _write_eblock(filename, elem_id, etype, mtype, rcon, elem_nnodes,
665-
cells, offset, celltypes, typenum,
666-
nodenum, mode='a'):
664+
cells, offset, celltypes, typenum,
665+
nodenum, mode='a'):
667666
"""Write EBLOCK to disk"""
668667
# perform type checking here
669668
if elem_id.dtype != np.int32:

ansys/mapdl/reader/common.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ def read_table(f, dtype='i', nread=None, skip=False, get_nread=True, cython=Fals
198198

199199
if get_nread:
200200
n = np.fromfile(f, 'i', 1)
201-
print(n)
202201
if not n:
203202
raise Exception('end of file')
204203

ansys/mapdl/reader/cython/_binary_reader.pyx

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,16 @@ cdef class AnsysFile:
227227
# self._file = new ifstream(c_filename, binary)
228228
self._file = open_fstream(c_filename)
229229

230-
# def _read(self, int size):
231-
# cdef char raw[10000]
232-
# self._file_a.read(raw, size)
233-
# return raw[:size]
230+
def _read(self, int size):
231+
mx_sz = 10000
232+
if size > mx_sz:
233+
raise RuntimeError(f"Maximum read size is {mx_sz}")
234+
cdef char raw[10000]
235+
self._file.read(raw, size)
236+
return raw[:size]
234237

235-
# def _seekg(self, int index):
236-
# self._file_a.seekg(index)
238+
def _seekg(self, int index):
239+
self._file.seekg(index)
237240

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

247250
if return_bufsize:
248251
return ndarray, bufsize
249-
else:
250-
return ndarray
252+
return ndarray
251253

252254
def close(self):
253255
"""Close the file"""
254256
del self._file
255-
del self._file_out
256257

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

16401641

1641-
cdef inline int cell_lookup(uint8 celltype) nogil:
1642-
if celltype == VTK_HEXAHEDRON or celltype == VTK_QUADRATIC_HEXAHEDRON:
1643-
return 8
1644-
elif celltype == VTK_TETRA or celltype == VTK_QUADRATIC_TETRA:
1645-
return 4
1646-
elif celltype == VTK_PYRAMID or celltype == VTK_QUADRATIC_PYRAMID:
1647-
return 5
1648-
elif celltype == VTK_WEDGE or celltype == VTK_QUADRATIC_WEDGE:
1649-
return 6
1650-
1651-
16521642
def cells_with_all_nodes(index_type [::1] offset, index_type [::1] cells,
1653-
uint8 [::1] celltypes, uint8 [::1] point_mask):
1643+
uint8 [::1] point_mask):
16541644
"""
16551645
Updates mask of cells containing all points in the point indices
16561646
or mask.
16571647
"""
1658-
cdef int ncells = celltypes.size
1659-
cdef uint8 celltype
1660-
cdef int ncell_points, i, j
1661-
cdef index_type cell_offset
1648+
cdef int ncells = offset.size - 1
1649+
cdef int i, j
1650+
cdef index_type cell_offset, next_cell_offset
16621651
cdef uint8 [::1] cell_mask = np.ones(ncells, np.uint8)
16631652

16641653
with nogil:
16651654
for i in range(ncells):
1666-
celltype = celltypes[i]
1667-
ncell_points = cell_lookup(celltype)
16681655
cell_offset = offset[i] + 1
1669-
for j in range(cell_offset, cell_offset + ncell_points):
1656+
next_cell_offset = offset[i+1] + 1
1657+
for j in range(cell_offset, next_cell_offset):
16701658
if point_mask[cells[j]] != 1:
16711659
cell_mask[i] = 0
16721660

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

16751663

16761664
def cells_with_any_nodes(index_type [::1] offset, index_type [::1] cells,
1677-
uint8 [::1] celltypes, uint8 [::1] point_mask):
1665+
uint8 [::1] point_mask):
16781666
"""
16791667
Updates mask of cells containing at least one point in the point
16801668
indices or mask.
16811669
"""
1682-
cdef int ncells = celltypes.size
1683-
cdef uint8 celltype
1684-
cdef int ncell_points
1685-
cdef index_type cell_offset
1670+
cdef int ncells = offset.size - 1
1671+
cdef index_type cell_offset, next_cell_offset
16861672
cdef int i, j
16871673

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

16901676
with nogil:
16911677
for i in range(ncells):
1692-
celltype = celltypes[i]
1693-
ncell_points = cell_lookup(celltype)
16941678
cell_offset = offset[i] + 1
1695-
for j in range(cell_offset, cell_offset + ncell_points):
1679+
next_cell_offset = offset[i+1] + 1
1680+
for j in range(cell_offset, next_cell_offset):
16961681
if point_mask[cells[j]] == 1:
16971682
cell_mask[i] = 1
16981683
break

ansys/mapdl/reader/cython/binary_reader.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,6 @@ void* read_record_fid(fstream* file, int64_t loc, int* prec_flag, int* type_flag
552552
// always read record
553553
char *raw = new char[4*bufsize];
554554
file->read(raw, 4*bufsize);
555-
556555
*out_bufsize = bufsize + 3; // include header and footer
557556

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

637635
// read the header
638636
// seek to data location if supplied with a pointer

ansys/mapdl/reader/elements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@
235235

236236
_etype_map = [0, 2, # LINK1
237237
3, # PLANE2
238-
3, # BEAM3
238+
2, # BEAM3
239239
2, # BEAM4
240240
4, # SOLID5
241241
0, # UNUSED6

0 commit comments

Comments
 (0)