message in case of unstructured grids and more constituents

This commit is contained in:
Vitesh Shah 2023-11-24 07:45:54 +01:00
parent fb823c81e7
commit 30b546f2dd
2 changed files with 7 additions and 3 deletions

View File

@ -13,6 +13,7 @@ from collections import defaultdict
from collections.abc import Iterable from collections.abc import Iterable
from typing import Optional, Union, Callable, Any, Sequence, Literal, Dict, List, Tuple from typing import Optional, Union, Callable, Any, Sequence, Literal, Dict, List, Tuple
import h5py
import numpy as np import numpy as np
from numpy import ma from numpy import ma
@ -1975,6 +1976,9 @@ class Result:
Directory to save DREAM3D files. Will be created if non-existent. Directory to save DREAM3D files. Will be created if non-existent.
""" """
if self.N_constituents != 1 or not self.structured:
raise TypeError('DREAM3D output requires structured grid with single constituent.')
N_digits = int(np.floor(np.log10(max(1,self.incs[-1]))))+1 N_digits = int(np.floor(np.log10(max(1,self.incs[-1]))))+1
Crystal_structure_types = {'Hexagonal': 0, 'Cubic': 1, 'Triclinic': 4, 'Monoclinic': 5, 'Orthorhombic': 6, 'Tetrogonal': 8} Crystal_structure_types = {'Hexagonal': 0, 'Cubic': 1, 'Triclinic': 4, 'Monoclinic': 5, 'Orthorhombic': 6, 'Tetrogonal': 8}
@ -2007,7 +2011,7 @@ class Result:
# Dream3D handles euler angles better # Dream3D handles euler angles better
except ValueError: except ValueError:
print("Orientation data is not present") print("Orientation data is not present")
exit() # need to check if such a statement would really work. exit()
phase_ID_array[at_cell_ph[c][label]] = count + 1 phase_ID_array[at_cell_ph[c][label]] = count + 1
@ -2084,7 +2088,7 @@ class Result:
o[ensemble_label].attrs['TupleDimensions'] = np.array([len(self.phases) + 1], np.uint64) o[ensemble_label].attrs['TupleDimensions'] = np.array([len(self.phases) + 1], np.uint64)
# Attributes for data in Ensemble matrix # Attributes for data in Ensemble matrix
for group in ['CrystalStructures','PhaseTypes']: for group in ['CrystalStructures','PhaseTypes']:
o[ensemble_label+'/'+group].attrs['ComponentDimensions'] = np.array([1],np.uint64) o[ensemble_label+'/'+group].attrs['ComponentDimensions'] = np.array([1],np.uint64)
o[ensemble_label+'/'+group].attrs['Tuple Axis Dimensions'] = f'x={len(self.phases)+1}' o[ensemble_label+'/'+group].attrs['Tuple Axis Dimensions'] = f'x={len(self.phases)+1}'
o[ensemble_label+'/'+group].attrs['DataArrayVersion'] = np.array([2],np.int32) o[ensemble_label+'/'+group].attrs['DataArrayVersion'] = np.array([2],np.int32)

View File

@ -493,7 +493,7 @@ class TestResult:
if not np.allclose(results_crystal_structure, ref_crystal_structure): if not np.allclose(results_crystal_structure, ref_crystal_structure):
error_messages.append('Crystal structure does not match') error_messages.append('Crystal structure does not match')
# check PhaseName array # check PhaseName array
results_phase_name = np.array(results_file[ensemble_label + '/PhaseNames']) results_phase_name = np.array(results_file[ensemble_label + '/PhaseNames'])
ref_phase_name = ['Unknown Phase Type'] ref_phase_name = ['Unknown Phase Type']
ref_phase_name.extend(i for i in result.visible['phases']) ref_phase_name.extend(i for i in result.visible['phases'])