introduced functionality to get output results by point from the HDF5 file

This commit is contained in:
Martin Diehl 2014-01-15 22:17:32 +00:00
parent 649b8b91fe
commit 278f854e41
3 changed files with 29 additions and 9 deletions

View File

@ -464,14 +464,13 @@ endif
%.o : %.f90
$(PREFIX) $(COMPILERNAME) $(COMPILE) -c $< $(SUFFIX)
tidy:
.PHONY : tidy
@rm -rf *.o
@rm -rf *.mod
@rm -rf src*
clean:
.PHONY : clean
@rm -rf *.o
@rm -rf *.mod
@rm -rf *.exe
@rm -rf src*

View File

@ -78,7 +78,8 @@ except OSError:
print ('f2py not found')
try:
os.rename(os.path.join(codeDir,'core.so'), os.path.join(damaskEnv.relPath('lib/damask'),'core.so'))
os.rename(os.path.join(codeDir,'core.so'),\
os.path.join(damaskEnv.relPath('lib/damask'),'core.so'))
except:
pass

View File

@ -14,9 +14,29 @@ class Result():
'''
def __init__(self,resultsFile):
outFile=h5py.File(resultsFile,"a")
print("Opened "+resultsFile+" with %i points"%outFile.attrs['Number of Materialpoints'])
self.data=h5py.File(resultsFile,"r")
self.Npoints=self.data.attrs['Number of Materialpoints']
print("Opened "+resultsFile+" with %i points"%self.Npoints)
def getCrystallite(self,labels,inc,constituent=1,points=None):
if points is None: points = np.array(np.array(xrange(self.Npoints)))
results = {}
mapping=self.data['mapping/crystallite']
for instance in self.data['increments/%s/crystallite/'%inc]:
dsets = self.data['increments/%s/crystallite/%s'%(inc,instance)].keys()
for label in labels:
if label in dsets and label not in results:
shape = np.shape(self.data['increments/%s/crystallite/%s/%s'%(inc,instance,label)])[1:]
results[label] = np.nan*np.ones(np.array((self.Npoints,)+shape))
for myPoint in xrange(len(points)):
matPoint = points[myPoint]
pos = mapping[matPoint,constituent-1]
if pos[0] != 0:
try:
for label in labels:
results[label][matPoint,...] = self.data['increments/%s/crystallite/%s/%s'%(inc,pos[0],label)][pos[1],...]
except:
pass
return results