sharpened error detection and reporting

This commit is contained in:
Philip Eisenlohr 2017-08-16 15:18:29 -04:00
parent e18c2fd74c
commit 255a465e8b
1 changed files with 10 additions and 7 deletions

View File

@ -52,7 +52,7 @@ parser.set_defaults(data = [],
(options, filenames) = parser.parse_args()
if not options.vtk: parser.error('No VTK file specified.')
if not options.vtk: parser.error('no VTK file specified.')
if not os.path.exists(options.vtk): parser.error('VTK file does not exist.')
if os.path.splitext(options.vtk)[1] == '.vtp':
@ -66,16 +66,16 @@ elif os.path.splitext(options.vtk)[1] == '.vtk':
reader.Update()
Polydata = reader.GetPolyDataOutput()
else:
parser.error('Unsupported VTK file type extension.')
parser.error('unsupported VTK file type extension.')
Npoints = Polydata.GetNumberOfPoints()
Ncells = Polydata.GetNumberOfCells()
Nvertices = Polydata.GetNumberOfVerts()
if Npoints != Ncells or Npoints != Nvertices:
parser.error('Number of points, cells, and vertices in VTK differ from each other.')
parser.error('number of points, cells, and vertices in VTK differ from each other.')
damask.util.croak('{}: {} points, {} vertices, and {} cells...'.format(options.vtk,Npoints,Nvertices,Ncells))
damask.util.croak('{}: {} points/vertices/cells...'.format(options.vtk,Npoints))
# --- loop over input files -------------------------------------------------------------------------
@ -97,16 +97,19 @@ for name in filenames:
VTKarray = {}
active = defaultdict(list)
for datatype,dimension,label in [['data',99,options.data],
for datatype,dimension,label in [['data',0,options.data],
['tensor',9,options.tensor],
['color' ,3,options.color],
]:
for i,dim in enumerate(table.label_dimension(label)):
me = label[i]
if dim == -1: remarks.append('{} "{}" not found...'.format(datatype,me))
elif dim > dimension: remarks.append('"{}" not of dimension {}...'.format(me,dimension))
elif dimension > 0 \
and dim != dimension: remarks.append('"{}" not of dimension {}...'.format(me,dimension))
else:
remarks.append('adding {} "{}"...'.format(datatype,me))
remarks.append('adding {}{} "{}"...'.format(datatype if dim > 1 else 'scalar',
'' if dimension > 0 or dim == 1 else '[{}]'.format(dim),
me))
active[datatype].append(me)
if remarks != []: damask.util.croak(remarks)