grid type 10 error
Opened this issue · 4 comments
Hello,
I was trying to use pyNastran to read my OptiStruct results. Everything went well until I tried it on model with contact. This error has been caused by nodes that have been in contact as I found out. I actually do not understand this issue much, since I was not really aware of different grid types.
Error:
def recast_gridtype_as_string(self, grid_type):
"""
converts a grid_type integer to a string
Point type (per NX 10; OUG table; p.5-663):
-1, Harmonic Point (my choice) -> ' ' = 538976288 (as an integer)
=1, GRID Point
=2, Scalar Point
=3, Extra Point
=4, Modal
=5, p-elements, 0-DOF
-6, p-elements, number of DOF
"""
try:
grid_type_str = GRID_TYPE_INT_TO_STR[grid_type]
except KeyError:
if grid_type in NULL_GRIDTYPE: # 32/64 bit error...
warnings.warn(''.join(self.get_stats()))
raise RuntimeError(f'grid_type={grid_type!r}')
return grid_type_str
RuntimeError: grid_type=10
I actually do not need contact forces here. Only stress values at shell elements are of interest to me.
- Are there any ways of avoiding this error?
- As I would specify for bdf file to read certain keywords, can I specify this for op2? How? (I couldn't find it in documentation)
If there is not workaround I wouldn't mind helping with this if you would provide some clarification. But it also depends on the scale of such task :).
If implementation/solution would be not possible at the moment, would it be possible to at least implement some custom error that could be caught?
Hello, I am sorry. Here is a full trace:
File c:\Users\vybjan\py_projects\fatigue_evaluation2\fatigue_evaluation2\model\read_op2.py:37, in ResultsReader._read_op2_file(self, debug)
35 self.logger.info("Reading op2 file: %s", self._file_path.name)
36 logger = logging.getLogger("pyNastranOP2")
---> 37 self._op2 = read_op2(self._file_path, log=logger, skip_undefined_matrices=True, mode="optistruct") # type: ignore
39 self.logger.debug("Getting subcases")
40 self._subcases = {key: " ".join(value[3].split()) for key, value in self._op2.isubcase_name_map.items()}
File c:\Users\vybjan\py_projects\fatigue_evaluation2\.venv\Lib\site-packages\pyNastran\op2\op2.py:1424, in read_op2(op2_filename, load_geometry, combine, subcases, exclude_results, include_results, log, debug, build_dataframe, skip_undefined_matrices, mode, encoding)
1420 model.set_subcases(subcases)
1421 model.include_exclude_results(exclude_results=exclude_results,
1422 include_results=include_results)
-> 1424 model.read_op2(op2_filename=op2_filename, build_dataframe=build_dataframe,
1425 skip_undefined_matrices=skip_undefined_matrices, combine=combine,
1426 encoding=encoding)
1428 ## TODO: this will go away when OP2 is refactored
1429 ## TODO: many methods will be missing, but it's a start...
1430 ## doesn't support F06 writer
ref='c:\Users\vybjan\py_projects\fatigue_evaluation2\.venv\Lib\site-packages\pyNastran\op2\op2.py:1'>1</a>;32m (...)
1435 #setattr(obj, attr_name, attr)
1436 #obj.get_op2_stats()
1437 return model
File c:\Users\vybjan\py_projects\fatigue_evaluation2\.venv\Lib\site-packages\pyNastran\op2\op2.py:618, in OP2.read_op2(self, op2_filename, combine, build_dataframe, skip_undefined_matrices, encoding)
616 OP2_Scalar.close_op2(self, force=True)
617 raise
--> 618 self._finalize()
619 op2_reader._create_objects_from_matrices()
620 if build_dataframe:
File c:\Users\vybjan\py_projects\fatigue_evaluation2\.venv\Lib\site-packages\pyNastran\op2\op2.py:651, in OP2._finalize(self)
649 for obj in values:
650 if hasattr(obj, 'finalize'):
--> 651 obj.finalize()
652 elif hasattr(obj, 'tCode') and not obj.is_sort1:
653 raise RuntimeError('object has not implemented finalize\n%s' % (
654 ''.join(obj.get_stats())))
File c:\Users\vybjan\py_projects\fatigue_evaluation2\.venv\Lib\site-packages\pyNastran\op2\result_objects\table_object.py:657, in TableArray.finalize(self)
655 for ugridtype in ugridtypes:
656 i = np.where(gridtypes == ugridtype)
--> 657 self.gridtype_str[i] = self.recast_gridtype_as_string(ugridtype)
File c:\Users\vybjan\py_projects\fatigue_evaluation2\.venv\Lib\site-packages\pyNastran\op2\result_objects\op2_objects.py:591, in ScalarObject.recast_gridtype_as_string(self, grid_type)
589 if grid_type in NULL_GRIDTYPE: # 32/64 bit error...
590 warnings.warn(''.join(self.get_stats()))
--> 591 raise RuntimeError(f'grid_type={grid_type!r}')
592 return grid_type_str
RuntimeError: grid_type=10
Try turning off pandas (build_dataframe=False). I don't know why Optistruct uses that gridtype, but contact has never been tested with it.
Hello, I did run read_op2()
function with its default for argument build_dataframe. So this did not solve anything.
Actually I found out, that building dataframe using pyNastran turned out to be very slow for me, so I am not utilizing this option. I am actually not sure why. DataFrame itself looks very nice though. I am not sure if that is just nature of things with pandas when multiindexing, or if there is something else slowing up the process. So I am building a bit simper Df myself from np.ndarrays.