Skip to content

Commit a3d61b0

Browse files
committed
fixed RLBLOCK bug
1 parent deb8722 commit a3d61b0

File tree

3 files changed

+76
-27
lines changed

3 files changed

+76
-27
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ pyansys/Interface.py
2424

2525
# Testing
2626
Testing/
27-

pyansys/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# major, minor, patch
2-
version_info = 0, 18, 0
2+
version_info = 0, 18, 1
33

44
# Nice string for the version
55
__version__ = '.'.join(map(str, version_info))

pyansys/archive_reader.py

Lines changed: 75 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"""
1919
import warnings
2020
import numpy as np
21+
import logging
2122

2223
# Attempt to load VTK dependent modules
2324
try:
@@ -43,23 +44,25 @@
4344

4445

4546
class ReadArchive(object):
46-
""" FEM object """
47+
"""
48+
Initialize cdb object by reading raw cdb from file
4749
48-
def __init__(self, filename='', use_cython=True, raw=None):
49-
"""
50-
Initialize cdb object by reading raw cdb from file
50+
Parameters
51+
----------
52+
filename : string
53+
Filename of block formatted cdb file
5154
52-
INPUTS:
53-
filename (string):
54-
filename of block formatted cdb file
55-
56-
use_cython (bool optional):
57-
boolean flag to use cython reader defaults to True
55+
use_cython : bool, optional:
56+
Boolean flag to use cython reader defaults to True
5857
59-
raw (dictonary optional):
60-
dictionary of raw data
61-
62-
"""
58+
raw : dictonary, optional
59+
Dictionary of raw data. Used to initialize the cdb object without a
60+
file.
61+
62+
"""
63+
64+
def __init__(self, filename='', use_cython=True, raw=None):
65+
""" Initializes a cdb object """
6366

6467
if raw and not filename:
6568
# Load raw data exterinally
@@ -80,16 +83,15 @@ def ParseVTK(self, use_cython=True, force_linear=False):
8083
Parses raw data from cdb file to VTK format. Creates unstructured grid
8184
as self.uGrid
8285
83-
Paramters
84-
---------
86+
Parameters
87+
----------
8588
use_cython : bool, optional
8689
Select between cython parser vs. python. Default True.
8790
8891
force_linear : bool, optional
8992
This parser creates quadradic elements if available. Set this to
9093
True to always create linear elements. Defaults to False.
9194
92-
9395
Returns
9496
-------
9597
uGrid : vtk.vtkUnstructuredGrid
@@ -183,8 +185,39 @@ def ParseVTK(self, use_cython=True, force_linear=False):
183185
return uGrid
184186

185187

186-
def ParseFEM(self, use_cython=True, raw=None):
187-
""" Parses raw data from cdb file to VTK format """
188+
def ParseFEM(self, use_cython=True):
189+
"""
190+
Parses raw data from cdb file to VTK format. Creates unstructured grid
191+
as self.uGrid. Returns additional arrays to be used in downstream FEM
192+
analysis.
193+
194+
195+
Parameters
196+
----------
197+
use_cython : bool, optional
198+
Select between cython parser and slower python parser.
199+
Default True. Enable for debugging purposes.
200+
201+
202+
Returns
203+
-------
204+
data : dictionary
205+
Dictionary containing arrays useful for interacting with the FEM
206+
without the use of the unstructured grid.
207+
208+
uGrid : vtk.vtkUnstructuredGrid
209+
VTK unstructured grid from archive file.
210+
211+
cellarr : np.int32 numpy.ndarray
212+
Each row of this array contains the points used to construct a
213+
cell. -1 indicates that it is an unused point.
214+
215+
ncellpts : np.int32 numpy.ndarray
216+
Number of points per cell. Indexing corresponds to row numbers in
217+
cellarr.
218+
219+
"""
220+
188221
if not vtk_loaded:
189222
raise Exception('Unable to load VTK module. Cannot parse raw cdb data')
190223
return
@@ -228,7 +261,17 @@ def AddThickness(self):
228261
"""
229262
Adds 'thickness' point scalars to uGrid
230263
231-
Assumes that thickness is stored as SURF154 elements
264+
Assumes that thickness is stored as SURF154 elements in the 7th entry
265+
of the RLBLOCK for each item.
266+
267+
Parameters
268+
----------
269+
None
270+
271+
272+
Returns
273+
-------
274+
None
232275
233276
"""
234277
nnum = self.uGrid.GetPointScalars('ANSYSnodenum')
@@ -277,6 +320,7 @@ def SaveAsVTK(self, filename, binary=True):
277320
278321
Run ParseFEM before running this to generate the vtk object
279322
323+
280324
Parameters
281325
----------
282326
filename : str
@@ -285,7 +329,8 @@ def SaveAsVTK(self, filename, binary=True):
285329
while *.vtu will select the PVTK XML writer
286330
binary : bool, optional
287331
Writes as a binary file by default. Set to False to write ASCII
288-
332+
333+
289334
Returns
290335
-------
291336
None
@@ -346,10 +391,15 @@ def ExtractThickness(raw):
346391

347392
idx = idx[idx != -1]
348393

349-
# Add thickness
350-
t[idx] += rdat[i][6]
351-
a[idx] += 1
352-
394+
# Attempt to add thickness
395+
try:
396+
t[idx] += rdat[i][6]
397+
a[idx] += 1
398+
399+
except:
400+
logging.warning('Unable to load thickness from RLBLOCK '
401+
'constant %d. Likely an empty item.'% rnum[i])
402+
353403
# normalize thickness by number of entires
354404
a[a == 0] = 1 # avoid divide by zero
355405
t /= a

0 commit comments

Comments
 (0)