From 278f854e41b191750168f339b6acf7f7d8695f1d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 15 Jan 2014 22:17:32 +0000 Subject: [PATCH] introduced functionality to get output results by point from the HDF5 file --- code/Makefile | 7 +++---- installation/compile_CoreModule.py | 3 ++- lib/damask/result.py | 28 ++++++++++++++++++++++++---- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/code/Makefile b/code/Makefile index ca23e4010..6c3ea8450 100644 --- a/code/Makefile +++ b/code/Makefile @@ -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* + diff --git a/installation/compile_CoreModule.py b/installation/compile_CoreModule.py index 5db53c66c..e17bdc3cc 100755 --- a/installation/compile_CoreModule.py +++ b/installation/compile_CoreModule.py @@ -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 diff --git a/lib/damask/result.py b/lib/damask/result.py index 28e0fb33d..05236c978 100644 --- a/lib/damask/result.py +++ b/lib/damask/result.py @@ -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